# Generator

> ## GWT Generator \#
>
> 環境：GWT 2.6、Maven、SDM

## 前置準備

`pom.xml` 要多加上（一般的 GWT 開發不需要這個 dependency）：

com.google.gwtgwt-devprovided

假設 interface 叫做 `FooBinder`（GWT 官方似乎喜歡用 binder 結尾）， 則需要一個 extends `Generator` 的 class，假設叫做 `FooBinderGenerator`， 然後 `gwt.xml` 要加上：

```
<generate-with class="PKG_NAME.FooBinderGenerator">
    <when-type-assignable class="PKG_NAME.FooBinder"/>
</generate-with>
```

## 撰寫 tip

* 修改 generator 必須重新啟動 code server 才會執行新的版本。
* 可以使用 `System.out.println()`，也可以用 `generate()` 傳入的 `TreeLogger` 參數，

  &#x20; 都會出現在 console 中。

## Reference

* <http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsDeferred.html>
* <http://christiangoudreau.wordpress.com/2013/05/06/how-to-efficiently-write-gwt-generators/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gwt.dontcareabout.us/gwt/generator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
