如何从java编译器树api生成的ast访问注释? [英] How to access comments from the java compiler tree api generated ast?

查看:21
本文介绍了如何从java编译器树api生成的ast访问注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 java 编译器树 api 来为 java 源文件生成 ast.但是,我无法访问源文件中的注释.

I've used the java compiler tree api to generate the ast for java source files. However, i'm unable to access th comments in the source files.

到目前为止,我一直无法找到从源文件中提取注释的方法.. 有没有办法使用编译器 api 或其他一些工具?

So far, i've been unable to find a way to extract comments from source file .. is there a way using the compiler api or some other tool ?

推荐答案

通过使用 getsourceposition() 和一些字符串操作(不需要正则表达式)设法解决了问题

Managed to solve the problem by using the getsourceposition() and some string manipulation (no regex was needed)

这篇关于如何从java编译器树api生成的ast访问注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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