简体   繁体   English

用于自动代码编辑的C ++或Java库?

[英]C++ or Java Library for automated code editing?

I am writing/planning to write a program that takes in a java file (or multiple java files), and edits and adds functions/classes/variables and then outputs a new java file (or multiple files). 我正在编写/计划编写一个接收java文件(或多个java文件)的程序,编辑并添加函数/类/变量,然后输出一个新的java文件(或多个文件)。

Is there a C++ or Java library that 是否有C ++或Java库

  1. Can recognize and output names of classes/functions within a text file 可以在文本文件中识别和输出类/函数的名称
  2. Can recognize and output the names of the input arguments for said classes/functions 可以识别并输出所述类/函数的输入参数的名称
  3. Can allow me to insert code at specific lines or within specific functions 可以允许我在特定行或特定函数中插入代码
  4. Can search for a given variable name/value 可以搜索给定的变量名称/值
  5. Maintains original file formatting 保持原始文件格式

I would prefer not having to manually code something to do the above, so any help would be appreciated. 我宁愿不必手动编写代码来执行上述操作,因此任何帮助都将不胜感激。

Thank you in advance! 先感谢您!

EDIT: I currently use Eclipse, and am unsure of how to proceed. 编辑:我目前使用Eclipse,并不确定如何继续。 So to further explain my question: 所以进一步解释我的问题:

In eclipse, if I write a program that opens another .java file, How would I go about 'asking' eclipse to output, say, all the class names of the .java file I just opened? 在eclipse中,如果我编写一个打开另一个.java文件的程序,我将如何“询问”eclipse输出,比如说,我刚刚打开的.java文件的所有类名?

Also I will explain the 'purpose' of this project to further clarify. 此外,我将解释该项目的“目的”,以进一步澄清。 I want to write a program that can take in any java file, and turn it into a class that can implemented remotely via RMI. 我想编写一个可以接收任何java文件的程序,并将其转换为可以通过RMI远程实现的类。 To do this I will need to add an execute() function, have the file implement Task and Serializable and add a few variables, etc... Based on my knowledge, doing this in Eclipse would require manual editing of the program, but I would like to completely automate this process. 为此,我需要添加一个execute()函数,让文件实现Task和Serializable并添加一些变量等等......根据我的知识,在Eclipse中执行此操作需要手动编辑程序,但是我我想完全自动化这个过程。

Thank you, again. 再次感谢你。

Much of what you need can be found in a modern IDE; 您需要的大部分内容都可以在现代IDE中找到; and some very good IDEs are open source (eclipse and Intellij IDEA Community Edition for Java). 一些非常好的IDE是开源的(eclipse和Intellij IDEA社区版for Java)。 You might look there to see if there are modules that suite your needs. 您可以在那里查看是否有适合您需求的模块。

Looks like you are talking of a tool like eclipse. 看起来你在谈论像eclipse这样的工具。 You might not be looking for a full fledged IDE, but the requirements that you have mentioned are fulfilled by any basic IDE. 您可能不会寻找完整的IDE,但您提到的要求是由任何基本IDE实现的。

If you wish to make one of your own, you can do that using eclipse rich client platform. 如果你想自己做一个,你可以使用eclipse富客户端平台做到这一点。 All that you would need from Java is the reflection API. 您需要的所有Java都是反射API。

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

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