Terms
Parser:
PMD uses JavaCC and JJTree to generate source code parser.
When parsing java source file with the generated parser, it produces an AST tree with ASTCompilationUnit as root node.
See https://javacc.github.io/javacc/documentation/jjtree.html.
Node
The AST(Abstract Syntax Tree) node.
Rule
A PMD rule defines a visitor which traverses the AST in preorder and scan for violations.
Scope
A scope is a region within variables and other declarations are visible.
Scopes can be nested and form a tree.
There are SourceFileScope, ClassScope, LocalScope and MethodScope.
ScopeAndDeclarationFinder class traverses the AST and generates the scope tree.
Symbol Table
Before the rulesets travers the AST, ScopeAndDeclarationFinder traverse the AST first, it sets the scope of every node it visits.