Parsing Java Source Code

前端 未结 9 1780
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 07:20

I am asked to develop a software which should be able to create Flow chart/ Control Flow of the input Java source code. So I started researching on it and arrived at followi

相关标签:
9条回答
  • 2021-01-12 08:14

    Eclipse has a library for parsing the source code and creating Abstract Syntax Tree from it which would let you extract what you want.

    See here for a tutorial http://www.vogella.de/articles/EclipseJDT/article.html

    See here for api http://help.eclipse.org/indigo/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/package-summary.html#package_description

    0 讨论(0)
  • 2021-01-12 08:14

    Or even more easy: Use reflection. You should be able to compile the sources, load the classes with java classloader and analyse them from there. I think this is far more easy than any parsing.

    0 讨论(0)
  • 2021-01-12 08:15

    Your input files are written in Java, and the software should be written in Java, but this is your first project in Java? First of all, I'd suggest learning the language with smaller projects. Also you need to learn how to use graphics in Java (there are various libraries). Then, you should focus on what you want to show on your graphs. Or is text sufficient?

    0 讨论(0)
提交回复
热议问题