Package com.google.javascript.jscomp
Class TemplateAstMatcher
java.lang.Object
com.google.javascript.jscomp.TemplateAstMatcher
A matcher that can take an arbitrary AST and use it as a template to find
matches in another. As this matcher potentially matches against every node
in the AST it is tuned to avoid generating GC garbage. It first checks the
AST shape without types and then successful checks the associated types.
-
Constructor Summary
ConstructorsConstructorDescriptionTemplateAstMatcher
(AbstractCompiler compiler, Node templateFunctionNode, TypeMatchingStrategy typeMatchingStrategy) Constructs this matcher with a Function node that serves as the template to match all other nodes against. -
Method Summary
Modifier and TypeMethodDescriptionReturns a map from named template Nodes (such as parameters or local variables) to Nodes that were matches from the last matched template.boolean
boolean
-
Constructor Details
-
TemplateAstMatcher
public TemplateAstMatcher(AbstractCompiler compiler, Node templateFunctionNode, TypeMatchingStrategy typeMatchingStrategy) Constructs this matcher with a Function node that serves as the template to match all other nodes against. The body of the function will be used to match against.
-
-
Method Details
-
matches
- Parameters:
n
- The node to check.- Returns:
- Whether the node is matches the template.
-
isLooseMatch
public boolean isLooseMatch()- Returns:
- Whether the last match succeeded due to loose type information.
-
getTemplateNodeToMatchMap
Returns a map from named template Nodes (such as parameters or local variables) to Nodes that were matches from the last matched template.
-