How do I parse a Java file to retrieve its function names? -
this question has answer here:
i working on small program compare 2 java files. goal compare 2 files can see functions added , deleted 1 file (like simple version control program). running issues on how should handling these files. current approach use scanner , use:
while(scanner.hasnext()) { string function = scanner.next("((public|private|protected|static|final|native|synchronized|abstract|threadsafe|transient)+\\s)+[\\$_\\w\\<\\>\\[\\]]*\\s+[\\$_\\w]+\\([^\\)]*\\)?\\s*\\{?[^\\}]*\\}?"); system.out.println(function); } however not getting me results file know has functions in it. tips or ideas on how approach this?
you use antlr java grammar https://github.com/antlr/grammars-v4/blob/master/java8/java8.g4 full-blown java parser , use extract information need java files.
Comments
Post a Comment