简体   繁体   English

Eclipse如何生成代码? 像getter和setter一样

[英]How does Eclipse generate code? Like Getters and Setters

I am working on a project to generate some code in Eclipse. 我正在研究一个在Eclipse中生成一些代码的项目。 I found that CodeModel can generate Java Code for me, but how do I integrate this as a plug-in? 我发现CodeModel可以为我生成Java代码,但是如何将其集成为插件?

How does Eclipse generate Code? Eclipse如何生成代码? Like getters and setters? 喜欢吸气剂和二传手?

My overall goal would be to generate my own code in Eclipse. 我的总体目标是在Eclipse中生成自己的代码。 Is there any API out there what I could use? 我可以使用什么API?

You can use the eclipse JDT libraries for doing code parsing and modifications. 您可以使用eclipse JDT库进行代码解析和修改。

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). 如果您想在eclipse插件项目中使用相同的插件,则必须将org.eclipse.jdt.core添加到插件依赖项中(在plugin.xml文件中)。

Check the below posts for more information on parsing the java code and saving the changes back to the code. 检查以下帖子,以获取有关解析Java代码并将更改保存回代码的更多信息。

You can use generated AspectJ files. 您可以使用生成的AspectJ文件。 To generate this files you can use reflection or some framework like write-it-once . 要生成此文件,可以使用反射或诸如write-it-once之类的框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM