Class Matchers
java.lang.Object
com.google.javascript.refactoring.Matchers
Class that contains common Matchers that are useful to everyone.
-
Method Summary
Modifier and TypeMethodDescriptionstatic MatcherReturns a Matcher that returns true only if all of the provided matchers match.static MatcherReturns a Matcher that returns true if any of the provided matchers match.static Matcheranything()Returns a Matcher that matches every node.static MatcherassignmentWithRhs(Matcher rhsMatcher) Returns a Matcher that matches an ASSIGN node where the RHS of the assignment matches the given rhsMatcher.static MatcherReturns a matcher that matches any constructor definitions.static Matcherconstructor(@Nullable String name) Returns a matcher that matches constructor definitions of the specified name.static MatcherReturns a Matcher that matches against properties that are declared in the constructor.static MatcherReturns a Matcher that matches definitions of any enum.static MatcherenumDefinitionOfType(String type) Returns a Matcher that matches definitions of an enum of the given type.static MatcherReturns a Matcher that matches any function call.static MatcherfunctionCall(@Nullable String name) Returns a Matcher that matches all nodes that are function calls that match the provided name.static MatcherfunctionCallWithNumArgs(int numArgs) Returns a Matcher that matches any function call that has the given number of arguments.static MatcherfunctionCallWithNumArgs(String name, int numArgs) Returns a Matcher that matches any function call that has the given number of arguments and the given name.static Matcherstatic Matcherstatic Matcherstatic Matcherstatic Matcherstatic MatchergoogRequirelike(String namespace) static Matcherstatic MatcherReturns a Matcher that matches against nodes that are declared@private.static MatcherReturns a Matcher that matches nodes that contain JS Doc that specify the@typeannotation equivalent to the provided type.static MatchernewClass()Returns a Matcher that matches constructing new objects.static MatcherReturns a Matcher that matches constructing objects of the provided class name.static MatcherReturns a Matcher that matches the opposite of the provided matcher.static MatcherReturns a Matcher that matches any property access.static MatcherpropertyAccess(@Nullable String name) Returns a Matcher that matches nodes representing a GETPROP access of an object property.static MatcherReturns a Matcher that matches a declaration of a method on the prototype of a class.static MatcherReturns a Matcher that matches a declaration of a variable on the prototype of a class.
-
Method Details
-
anything
Returns a Matcher that matches every node. -
allOf
Returns a Matcher that returns true only if all of the provided matchers match. -
anyOf
Returns a Matcher that returns true if any of the provided matchers match. -
not
Returns a Matcher that matches the opposite of the provided matcher. -
constructor
Returns a matcher that matches any constructor definitions. -
constructor
Returns a matcher that matches constructor definitions of the specified name.- Parameters:
name- The name of the class constructor to match.
-
newClass
Returns a Matcher that matches constructing new objects. This will match the NEW node of the JS Compiler AST. -
newClass
Returns a Matcher that matches constructing objects of the provided class name. This will match the NEW node of the JS Compiler AST.- Parameters:
className- The name of the class to return matching NEW nodes.
-
functionCall
Returns a Matcher that matches any function call. -
functionCall
Returns a Matcher that matches all nodes that are function calls that match the provided name.- Parameters:
name- The name of the function to match. For non-static functions, this must be the fully qualified name that includes the type of the object. For instance:ns.AppContext.prototype.getwill matchappContext.getandthis.getwhen called from the AppContext class.
-
functionCallWithNumArgs
Returns a Matcher that matches any function call that has the given number of arguments. -
functionCallWithNumArgs
Returns a Matcher that matches any function call that has the given number of arguments and the given name.- Parameters:
name- The name of the function to match. For non-static functions, this must be the fully qualified name that includes the type of the object. For instance:ns.AppContext.prototype.getwill matchappContext.getandthis.getwhen called from the AppContext class.
-
googRequirelike
-
googRequirelike
-
googRequire
-
googRequireType
-
googForwardDeclare
-
googModule
-
googModuleOrProvide
-
propertyAccess
Returns a Matcher that matches any property access. -
propertyAccess
Returns a Matcher that matches nodes representing a GETPROP access of an object property.- Parameters:
name- The name of the property to match. For non-static properties, this must be the fully qualified name that includes the type of the object. For instance:ns.AppContext.prototype.rootwill matchappContext.rootandthis.rootwhen accessed from the AppContext.
-
enumDefinition
Returns a Matcher that matches definitions of any enum. -
enumDefinitionOfType
Returns a Matcher that matches definitions of an enum of the given type. -
assignmentWithRhs
Returns a Matcher that matches an ASSIGN node where the RHS of the assignment matches the given rhsMatcher. -
prototypeVariableDeclaration
Returns a Matcher that matches a declaration of a variable on the prototype of a class. -
prototypeMethodDeclaration
Returns a Matcher that matches a declaration of a method on the prototype of a class. -
jsDocType
Returns a Matcher that matches nodes that contain JS Doc that specify the@typeannotation equivalent to the provided type. -
constructorPropertyDeclaration
Returns a Matcher that matches against properties that are declared in the constructor. -
isPrivate
Returns a Matcher that matches against nodes that are declared@private.
-