Concrete superclass and default implementation of an AST subtree matcher.
For example, to compute whether two ASTs subtrees are structurally
isomorphic, use n1.subtreeMatch(new ASTMatcher(), n2) where
n1 and n2 are the AST root nodes of the subtrees.
For each different concrete AST node type T there is a
public boolean match(T node, Object other) method
that matches the given node against another object (typically another
AST node, although this is not essential). The default implementations
provided by this class tests whether the other object is a node of the
same type with structurally isomorphic child subtrees. For nodes with
list-valued properties, the child nodes within the list are compared in
order. For nodes with multiple properties, the child nodes are compared
in the order that most closely corresponds to the lexical reading order
of the source program. For instance, for a type declaration node, the
child ordering is: name, superclass, superinterfaces, and body
declarations.
Subclasses may override (extend or reimplement) some or all of the
match methods in order to define more specialized subtree
matchers.
For example, to compute whether two ASTs subtrees are structurally isomorphic, use
n1.subtreeMatch(new ASTMatcher(), n2)wheren1andn2are the AST root nodes of the subtrees.For each different concrete AST node typeT there is a
public boolean match(T node, Object other)method that matches the given node against another object (typically another AST node, although this is not essential). The default implementations provided by this class tests whether the other object is a node of the same type with structurally isomorphic child subtrees. For nodes with list-valued properties, the child nodes within the list are compared in order. For nodes with multiple properties, the child nodes are compared in the order that most closely corresponds to the lexical reading order of the source program. For instance, for a type declaration node, the child ordering is: name, superclass, superinterfaces, and body declarations.Subclasses may override (extend or reimplement) some or all of the
matchmethods in order to define more specialized subtree matchers.