用于代码分析的 Java 库 [英] Java library for code analysis

查看:34
本文介绍了用于代码分析的 Java 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何 Java 库可以帮助从指定的 Java 源文件构建 AST反之亦然(从 ASTree 对象生成代码)?我需要像 this 之类的东西,但是有一个 API,允许访问以编程方式生成树.

Is there any Java library, that can help in building AST from the specified java source file and vice versa (generate code from the ASTree object)? I need something like this, but with an API, allowing to access the generated tree programmatically.

推荐答案

Eclipse 核心中已经提供了一切.这里有一个页面,其中包含一个小示例,说明如何使用 org.eclipse.jdt.core.dom.ASTParser 创建所需的 AST 数据结构.

Everything's already available within the Eclipse core. Here's a page with a small example of how to use org.eclipse.jdt.core.dom.ASTParser to create your desired AST datastructure.

这篇关于用于代码分析的 Java 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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