1

I am working on a project to generate some code in Eclipse. I found that CodeModel can generate Java Code for me, but how do I integrate this as a plug-in?

How does Eclipse generate Code? Like getters and setters?

My overall goal would be to generate my own code in Eclipse. Is there any API out there what I could use?

Gábor Csikós
  • 2,787
  • 7
  • 31
  • 57
  • you would have to create a plugin for eclipse if you intend to use the IDE to generate things for you. You could start from http://www.eclipse.org/articles/Article-Your%20First%20Plug-in/YourFirstPlugin.html – Mohammad Najar Oct 14 '14 at 14:51
  • I don't have problem with making a plugin, I found a lot of tutorial. My problem is with generating code. For example If I generate a code with CodeModel, how can I save them to the current place where the developer generates it. – Gábor Csikós Oct 14 '14 at 14:58

2 Answers2

1

You can use the eclipse JDT libraries for doing code parsing and modifications.

If you are trying to use the same in an eclipse plugin project, you will have to add org.eclipse.jdt.core to the plugin dependencies (in the plugin.xml file).

Check the below posts for more information on parsing the java code and saving the changes back to the code.

Community
  • 1
  • 1
Unni Kris
  • 3,081
  • 4
  • 35
  • 57
1

You can use generated AspectJ files. To generate this files you can use reflection or some framework like write-it-once.

Atmega
  • 131
  • 4