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

試著忘記壹切 提交于 2019-12-07 04:24:55

问题


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:


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)




回答2:


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.




回答3:


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).



来源:https://stackoverflow.com/questions/760155/time-to-develop-an-option-in-eclipse-to-modify-a-java-file-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!