Class Matchers
- java.lang.Object
-
- com.google.javascript.refactoring.Matchers
-
public final class Matchers extends java.lang.ObjectClass that contains common Matchers that are useful to everyone.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MatcherallOf(Matcher... matchers)Returns a Matcher that returns true only if all of the provided matchers match.static MatcheranyOf(Matcher... matchers)Returns 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 Matcherconstructor()Returns a matcher that matches any constructor definitions.static Matcherconstructor(java.lang.String name)Returns a matcher that matches constructor definitions of the specified name.static MatcherconstructorPropertyDeclaration()Returns a Matcher that matches against properties that are declared in the constructor.static MatcherenumDefinition()Returns a Matcher that matches definitions of any enum.static MatcherenumDefinitionOfType(java.lang.String type)Returns a Matcher that matches definitions of an enum of the given type.static MatcherfunctionCall()Returns a Matcher that matches any function call.static MatcherfunctionCall(java.lang.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(java.lang.String name, int numArgs)Returns a Matcher that matches any function call that has the given number of arguments and the given name.static MatchergoogForwardDeclare()static MatchergoogModule()static MatchergoogModuleOrProvide()static MatchergoogRequire()static MatchergoogRequirelike()static MatchergoogRequirelike(java.lang.String namespace)static MatchergoogRequireType()static MatcherisPrivate()Returns a Matcher that matches against nodes that are declared@private.static MatcherjsDocType(java.lang.String type)Returns 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 MatchernewClass(java.lang.String className)Returns a Matcher that matches constructing objects of the provided class name.static Matchernot(Matcher matcher)Returns a Matcher that matches the opposite of the provided matcher.static MatcherpropertyAccess()Returns a Matcher that matches any property access.static MatcherpropertyAccess(java.lang.String name)Returns a Matcher that matches nodes representing a GETPROP access of an object property.static MatcherprototypeMethodDeclaration()Returns a Matcher that matches a declaration of a method on the prototype of a class.static MatcherprototypeVariableDeclaration()Returns a Matcher that matches a declaration of a variable on the prototype of a class.
-
-
-
Method Detail
-
anything
public static Matcher anything()
Returns a Matcher that matches every node.
-
allOf
public static Matcher allOf(Matcher... matchers)
Returns a Matcher that returns true only if all of the provided matchers match.
-
anyOf
public static Matcher anyOf(Matcher... matchers)
Returns a Matcher that returns true if any of the provided matchers match.
-
not
public static Matcher not(Matcher matcher)
Returns a Matcher that matches the opposite of the provided matcher.
-
constructor
public static Matcher constructor()
Returns a matcher that matches any constructor definitions.
-
constructor
public static Matcher constructor(java.lang.String name)
Returns a matcher that matches constructor definitions of the specified name.- Parameters:
name- The name of the class constructor to match.
-
newClass
public static Matcher newClass()
Returns a Matcher that matches constructing new objects. This will match the NEW node of the JS Compiler AST.
-
newClass
public static Matcher newClass(java.lang.String className)
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
public static Matcher functionCall()
Returns a Matcher that matches any function call.
-
functionCall
public static Matcher functionCall(java.lang.String name)
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
public static Matcher functionCallWithNumArgs(int numArgs)
Returns a Matcher that matches any function call that has the given number of arguments.
-
functionCallWithNumArgs
public static Matcher functionCallWithNumArgs(java.lang.String name, int numArgs)
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
public static Matcher googRequirelike(java.lang.String namespace)
-
googRequirelike
public static Matcher googRequirelike()
-
googRequire
public static Matcher googRequire()
-
googRequireType
public static Matcher googRequireType()
-
googForwardDeclare
public static Matcher googForwardDeclare()
-
googModule
public static Matcher googModule()
-
googModuleOrProvide
public static Matcher googModuleOrProvide()
-
propertyAccess
public static Matcher propertyAccess()
Returns a Matcher that matches any property access.
-
propertyAccess
public static Matcher propertyAccess(java.lang.String name)
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
public static Matcher enumDefinition()
Returns a Matcher that matches definitions of any enum.
-
enumDefinitionOfType
public static Matcher enumDefinitionOfType(java.lang.String type)
Returns a Matcher that matches definitions of an enum of the given type.
-
assignmentWithRhs
public static Matcher assignmentWithRhs(Matcher rhsMatcher)
Returns a Matcher that matches an ASSIGN node where the RHS of the assignment matches the given rhsMatcher.
-
prototypeVariableDeclaration
public static Matcher prototypeVariableDeclaration()
Returns a Matcher that matches a declaration of a variable on the prototype of a class.
-
prototypeMethodDeclaration
public static Matcher prototypeMethodDeclaration()
Returns a Matcher that matches a declaration of a method on the prototype of a class.
-
jsDocType
public static Matcher jsDocType(java.lang.String type)
Returns a Matcher that matches nodes that contain JS Doc that specify the@typeannotation equivalent to the provided type.
-
constructorPropertyDeclaration
public static Matcher constructorPropertyDeclaration()
Returns a Matcher that matches against properties that are declared in the constructor.
-
isPrivate
public static Matcher isPrivate()
Returns a Matcher that matches against nodes that are declared@private.
-
-