Parsing Java source code to find classes, attributes and methods -


this question has answer here:

i'm doing experiment , have map classes , attributes , methods respective code in java. i'd know what's best approach parse .java file , find classes there in files, attributes , methods. i've seen in other topics building own lexical analyser not idea, there're libraries hard work. found it's possible files included in project calling methods in java, not external .java files.

can light me up? in advance

you can use source code scan tool pmd, pmd checks source code against rules , produces report. this:

  • something passes file name , ruleset pmd
  • pmd hands inputstream file off javacc-generated parser
  • pmd gets reference abstract syntax tree parser
  • pmd hands ast off symbol table layer builds scopes, finds declarations, , find usages.
  • if rules need data flow analysis, pmd hands ast on dfa layer building control flow graphs , data flow nodes.
  • each rule in ruleset gets traverse ast , check problems. rules can poke around symbol table , dfa nodes.
  • the report filled ruleviolations, , printed out in xml or html or whatever

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -