Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time to develop an option in Eclipse to modify a Java file source

Tags:

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.

like image 414
Daniel Fanjul Avatar asked Apr 17 '09 12:04

Daniel Fanjul


2 Answers

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.

like image 43
Michael Borgwardt Avatar answered Oct 03 '22 14:10

Michael Borgwardt


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)

like image 169
Scott Stanchfield Avatar answered Oct 03 '22 14:10

Scott Stanchfield