22

Is there any good documentation on implementing new refactorings in Eclipse? Specifically, I'd like to access the AST for a Java class, make some non-trivial changes, and save the result back to the source file.

So far, the only documentation I've found is (1) the source code for the existing refactorings and (2) a few articles on the LTK and Java AST:

Are there any other articles or tutorials that I should read?

Kenan Banks
  • 207,056
  • 34
  • 155
  • 173
emk
  • 60,150
  • 6
  • 45
  • 50

2 Answers2

18

I found the eclipse.org article the most helpful to get me started. To be honest you're probably best off debugging some of the Eclipse refactorings to get a real feel for how they work.

A good place to get started debugging the code is to set breakpoints on org.eclipse.jdt.core.dom.rewrite.ASTRewrite, particularly the rewriteAST() method, then trigger some refactorings.

Here are a few you might find useful. Are you looking for anything in particular or a general sense of how to process the AST?

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
  • Ah, thank you! Those are also very useful articles. I think the time has arrived for me to start digging through the source code for the built-in refactorings. – emk Aug 23 '09 at 20:24
  • These are great refrences. I used second and third links and also the ast view: http://www.eclipse.org/jdt/ui/update-site – oshai Nov 08 '10 at 11:10
  • 1
    The first link is dead. – Aaron Digulla May 07 '14 at 08:42
1

You can take a look at Lombok Project. It seems they have Eclipse plugin.

It does some AST manipulations - e.q. getters/setters. Could be helpful for you too.

daoway
  • 779
  • 7
  • 8
  • Here is a great article about writing custom AST transformations with Lombok: http://www.ibm.com/developerworks/library/j-lombok/ – Aaron Digulla May 07 '14 at 08:41