使用 javax.lang.model 或 ANTLR JavaParser 获取 Java 源代码信息的示例/教程 [英] Examples / tutorials for usage of javax.lang.model or ANTLR JavaParser to get information on Java Source Code

查看:29
本文介绍了使用 javax.lang.model 或 ANTLR JavaParser 获取 Java 源代码信息的示例/教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为简单的Java逻辑创建一个类似流程图的自动可视化,为此我需要解析Java源代码,我有2个候选,ANTLRjavax.lang.model 的 Java 6.两者都不容易.

I would like to create an automatic Flowchart-like visualization to simple Java Logic, for this I need to parse Java Source code, I have 2 candidates, ANTLR and javax.lang.model of Java 6. Neither are easy.

我还没有找到一个可以与我想要实现的目标相去甚远的可行示例.

I have yet to find a single working example that will be even remotely close to what I want to achieve.

我想找到简单的变量声明、赋值和流程(if、for、switch、布尔条件等)

I want to find simple variable declarations, assignments, and flows (if, for, switch, boolean conditions etc)

是否有针对其中任何一个的简单示例或教程?我发现很少有 ANTLR 示例(没有一个是开箱即用的,没有重要的作业"),对于 javax.lang.model 绝对没有

Is there a simple example or tutorial for either of these? I found very few ANTLR examples (non of them are working out of the box without significant "homework") and absolutely none for javax.lang.model

推荐答案

我会尝试使用 Eclipse Xtext,它在幕后使用 ANTLR,它也(相对)易于与 Eclipse GMF 一起使用以进行可视化.

I would try that with Eclipse Xtext, it uses ANTLR under the hood, it is also (relative) easy to use it together with Eclipse GMF for visualization.

这篇关于使用 javax.lang.model 或 ANTLR JavaParser 获取 Java 源代码信息的示例/教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆