Create typebinding in eclipse jdt AST

I'm generating source code from a java object with eclipse JDT. While creating a Type, for example a SimpleType representing a class, how would I add typebindings?

PS: I still have trouble understanding typebinding.

Upvotes: 2

Views: 144

Answers (1)

Stephan Herrmann
Stephan Herrmann

Reputation: 8178

Type bindings are not created nor assigned by clients of JDT. Binding are created by the compiler as a result of parsing and resolving a Java file.

So, if you implement a tool that in step 1 generates a class and in step 2 needs a binding of that class: save the class from step 1, and re-read it using the ASTParser after setting setResolveBindings(true).

Otherwise, if you are just creating this one class, don't worry about the binding, it's only the AST that will determine the resulting source file.

Upvotes: 1

Related Questions