Using the Java 7 grammar https://github.com/antlr/grammars-v4/blob/master/java7/Java7.g4 I want to find methods with a specific name and then just print out that method. I see that I can use the methodDeclaration
rule when I match. So I subclass Java7BaseListener
and override this listener method:
@Override public void enterMethodDeclaration(Java7Parser.MethodDeclarationContext ctx) { }
How do I get the original text out? ctx.getText()
gives me a string with all the whitespace stripped out. I want the comments and original formatting.