开发者

Code generation in Eclipse plug-in

开发者 https://www.devze.com 2022-12-23 10:11 出处:网络
I\'m developing an Eclipse plug-in and I\'d like to insert c开发者_JAVA技巧ode automatically... sort of create a sample application automatically when the user presses a button. How can I go about it

I'm developing an Eclipse plug-in and I'd like to insert c开发者_JAVA技巧ode automatically... sort of create a sample application automatically when the user presses a button. How can I go about it please?

Thanks and regards, Krt_Malta


This did the trick: http://wiki.eclipse.org/FAQ_How_do_I_insert_text_in_the_active_text_editor%3F


If you want to create a project/files, then you have to use the Resource API of Eclipse. For some initial ideas look at http://www.phurnace.com/blog/the-eclipse-resources-plug-in-2.html.

In a similar fashion you could look for existing files and read them.


A pretty straightforward approach to code generation in Eclipse are Java Emitter Templates. If your use case involves EMF, you could consider Xpand. And there are other options in the Eclipse M2T project.


This helped me out a lot:

http://sdqweb.ipd.kit.edu/wiki/JDT_Tutorial:_Creating_Eclipse_Java_Projects_Programmatically

Using it you can create projects, packages and classes programatically. With some additional code, you could import libraries into the project files programmatically.

0

精彩评论

暂无评论...
验证码 换一张
取 消