Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Code insertion: AST vs. document view
Code insertion: AST vs. document view [message #242977] Thu, 19 April 2007 14:17 Go to next message
Eclipse UserFriend
Originally posted by: myawn.ebay.com

I'm hoping someone can give me some advice here, or (better yet) point
me to code that might serve as a model for what I'm trying to do.

I need to generate Java classes that are based on a template. So far,
my efforts have been based on having an AST parse of the template file,
and adding in new nodes, then saving the modified AST to a target location.

I'm wondering if this is really the best approach. For one thing, it
seems that I won't be able to insert (non-Javadoc) comments into the
generated code this way. (And even if I have the comments already in
the template, it doesn't seem like I can insert nodes so that they fall
in the right place relative to the existing comments) For another
thing, there are places where I need to insert chunks of code that are
constant, and the amount of code needed to reproduce the lines via AST
is far greater than just printf-like output to a text document.

So I'm wondering about a combination of using AST for some things, and
some sort of document/text view for others. I'm not sure from what I
have now how best to obtain a view of my code as just a stream of bytes,
and what steps I need to take to synchronize changes made to the AST
with changes made to the text view. Or if I'd be better off just
abandoning the AST approach and treat the entire file as just text.

I guess a broader question might be, what is AST really well-suited for,
and what is it not intended to be used for?

Mike
Re: Code insertion: AST vs. document view [message #243023 is a reply to message #242977] Thu, 19 April 2007 20:50 Go to previous message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Mike Yawn" <myawn@ebay.com> wrote in message
news:f07tmc$5f3$1@build.eclipse.org...
> [...]
> I guess a broader question might be, what is AST really well-suited for,
> and what is it not intended to be used for?

Try writing a refactoring operation based on text alone, and you might get
your own answer :-)
Previous Topic:Re-using retargetable actions "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.workspa
Next Topic:Include external directory
Goto Forum:
  


Current Time: Mon Dec 30 18:04:21 GMT 2024

Powered by FUDForum. Page generated in 0.05096 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top