deep-code-search
deep-code-search copied to clipboard
How to parse the Java code?
I tried some methods but the results are a little different. For example, when I get method o.m(), I do not know how to get the Class of o and add O.m to the API Sequence.
you can use eclipse JDT to parse the AST. The AST contains class names of each method invocation. You can find JDT through maven. There are also python libraries for parsing Java code such as https://github.com/c2nes/javalang
@guxd I am working on the data pre-processing of extracting method, description, API sequence, tokens using python library - https://github.com/c2nes/javalang. Regarding extracting token, I need to transform AST to java code at first, then transform the code to tokens. Do you have any idea of transforming AST nodes to java code, currently I haven't find suitable solutions. I want to ask if you have any idea, because you are experts in such fields.
Thanks a lot
https://github.com/mast-group/codemining-core/blob/master/src/main/java/codemining/java/tokenizers/JavaTokenizer.java