views:

230

answers:

3

I'm evaluating the possibility of developing an Eclipse plugin to modify the source code of some Java files.

The Eclipse plugin should:

  1. add one menu option or context menu option to launch the modification process.
  2. add a key binding
  3. only alter the UI in that way when an editor has been open on a Java file.
  4. the modification process would not open a dialog, or maybe, a very simple one.
  5. the modification process would traverse the AST of the Java file and would modify it.

Considering that we have no experience with Eclipse plugins and we need spend time in reading docs, how much time do you estimate in developing that plugin?

Thanks in advance.

+1  A: 

You'll probably spend quite some time cursing the complexity of the eclipse plugin system. There are some example plugin development projects that can be very helpful if they cover the area you're working in.

I'd say you're looking at 2-4 days of work, spent mainly getting familiar with the platform - someone with a lot of experience writing eclipse plugins would probably take no more than an hour.

However, your step 5 could be tricky. I don't know how easy it is to access and change the Java AST; my experience is based on developing an editor plugin for an exotic file format rather than Java code.

Michael Borgwardt
A: 

Well, the four first points are easy to achieve, even by monkey coders that look at the eclipse PDE documentation shipped with Eclipse. These can be achieve in 1 day of work, maybe 2.

The hardest point is really the fifth one and the kind of modification you expect to do. Acting directly on the editor content is simple, accessing the editor internal AST and modifying it is really a bigger challenge and I doubt that it could be achieve in less than a week by unexperimented people (it can take longer, depending of what kind of modification you want to apply).

gizmo
+3  A: 

It's really not that difficult at all... I had students in my design patterns class doing it for an assignment (adding/removing javabean getters and setters)

See http://help.eclipse.org/ganymede/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_manip.htm

[EDIT: added the following article reference]

And a great article on it at http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation_AST/index.html (from 2006 -- there may be a few API changes since)

Yes, writing plugins takes a little getting used to, but so does any API.

And you can modify the AST -- see the page I reference above.

(I should note that the above link is from the eclipse help, which can also be accessed via Help->Help Contents inside Eclipse -- there's a lot of good info in there, but it's just a starting point)

Scott Stanchfield