[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Re: Changing Java source in a builder; which mechanism?

Walter, what you say makes sense.  The method I was trying to add is 
required by our current API implementation and is similar to a copy method, 
in which the body of the method called each of the setters in the class and 
filled them with values.  In that scenario, I wanted the method to be 
dynamically recontructed each time a new getter/setter were added to the 
class.

However it seems what I could do would be to have an action to modify the 
source code, and still have a builder exist but change it to validate only. 
If the builder finds the method missing or ill-formed (missing setter 
invocation), it will log a problem in the problems view telling the user to 
run the action again.  I suspect this is what you're suggesting.

With this resdesigned, I'll ask my questions again since they're still 
applicable :-).  With a few ways to get things done, I'm unsure which is 
preferred/most efficient/best...

1 - Is ASTRewrite okay to use, or should I just modify the AST directly 
without creating TextEdits?
2 - The article indicated that TextFileBuffer should be used; is that the 
case for MyAction?  Is it required (such as if someone has the source open 
in an editor)?  The article seemed to be assuming the AST changes are in an 
editor, not an action.
3 - Should I be using a Working Copy instead?

Thanks!
Brad