How to access comments from the java compiler tree api generated ast?

前端 未结 5 2215
清歌不尽
清歌不尽 2020-12-30 17:37

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.

So far, i\'ve been

5条回答
  •  长发绾君心
    2020-12-30 18:14

    You might to use a different tool, like ANTLR's Java grammar. javac has no use for comments, and is likely to discard them completely. The parsers upon which tools like IDEs are built are more likely to retain comments in their AST.

提交回复
热议问题