Ruby 中的 Java 源代码解析器

发布于 2024-12-23 08:05:06 字数 344 浏览 0 评论 0原文

使用代码生成工具来帮助为我们的项目创建锅炉代码。

生成器是用 erb 模板用 ruby​​ 编写的,项目本身是用 Java 编写的。

现在我正在寻找一个用于解析java源文件的ruby gem/library,给定.java文件中的字符串,获取导入、方法、字段、类名等,这将使我能够导航到某个方法并向其附加代码等(有点像 jQuery 选择器)。

我想知道是否已经有可以使用的解决方案,有点像 javaclass-rb 库,但那是用于从 .class 文件解析字节码。

我知道我可以使用 ANTLR 和 ruby​​ 适配器,但我希望有现有的解决方案。

谢谢!

Working on a code generation tool to help creating boiler code for our project.

The generator is written in ruby with erb templates, the project itself is in Java.

Now I am looking for a ruby gem/library for parsing java source files, given a string from a .java files, get the imports, methods, fields, class name etc etc, that would enable me to navigate to a certain method and appending code to it etc (kinda like jQuery selector).

I am wondering if there are already solutions that I can use, kinda like the javaclass-rb library, but that is for parsing bytecodes from .class files.

I know I could use ANTLR and a ruby adapter, but I hope there are existing solutions.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木槿暧夏七纪年 2024-12-30 08:05:06

JRuby 是 JVM 之上的 Ruby 实现,它使 Ruby 和 Java 对象之间的交互变得简单。如果您决定使用它,则可以使用任何 Java 库来解决该任务,例如 javaparser

JRuby is a Ruby implementation on top of the JVM that make interaction between Ruby and Java objects trivial. If you decide to use this, you can use any Java library to solve the task, like javaparser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文