Search code examples
javacompiler-constructionabstract-syntax-tree

How to access comments from the java compiler tree api generated 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.

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 ?


Solution

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