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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -