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 Matcher
Returns a Matcher that returns true only if all of the provided matchers match.static Matcher
Returns a Matcher that returns true if any of the provided matchers match.static Matcher
anything()
Returns a Matcher that matches every node.static Matcher
assignmentWithRhs
(Matcher rhsMatcher) Returns a Matcher that matches an ASSIGN node where the RHS of the assignment matches the given rhsMatcher.static Matcher
Returns a matcher that matches any constructor definitions.static Matcher
constructor
(@Nullable String name) Returns a matcher that matches constructor definitions of the specified name.static Matcher
Returns a Matcher that matches against properties that are declared in the constructor.static Matcher
Returns a Matcher that matches definitions of any enum.static Matcher
enumDefinitionOfType
(String type) Returns a Matcher that matches definitions of an enum of the given type.static Matcher
Returns a Matcher that matches any function call.static Matcher
functionCall
(@Nullable String name) Returns a Matcher that matches all nodes that are function calls that match the provided name.static Matcher
functionCallWithNumArgs
(int numArgs) Returns a Matcher that matches any function call that has the given number of arguments.static Matcher
functionCallWithNumArgs
(String name, int numArgs) Returns a Matcher that matches any function call that has the given number of arguments and the given name.static Matcher
static Matcher
static Matcher
static Matcher
static Matcher
static Matcher
googRequirelike
(String namespace) static Matcher
static Matcher
Returns a Matcher that matches against nodes that are declared@private
.static Matcher
Returns a Matcher that matches nodes that contain JS Doc that specify the@type
annotation equivalent to the provided type.static Matcher
newClass()
Returns a Matcher that matches constructing new objects.static Matcher
Returns a Matcher that matches constructing objects of the provided class name.static Matcher
Returns a Matcher that matches the opposite of the provided matcher.static Matcher
Returns a Matcher that matches any property access.static Matcher
propertyAccess
(@Nullable String name) Returns a Matcher that matches nodes representing a GETPROP access of an object property.static Matcher
Returns a Matcher that matches a declaration of a method on the prototype of a class.static Matcher
Returns 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.get
will matchappContext.get
andthis.get
when 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.get
will matchappContext.get
andthis.get
when 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.root
will matchappContext.root
andthis.root
when 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@type
annotation 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
.
-