Matches a type cast AST node if both of the given matchers match.

@param typeMatcher The matcher to apply to the type.
@param expressionMatcher The matcher to apply to the expression.
198274
public static Matcher<TypeCastTree> typeCast(
      final Matcher<Tree> typeMatcher, final Matcher<ExpressionTree> expressionMatcher) {
    return new Matcher<TypeCastTree>() {
      @Override
      public boolean matches(TypeCastTree t, VisitorState state) {
        return typeMatcher.matches(t.getType(), state)
            && expressionMatcher.matches(t.getExpression(), state);
      }
    };
  }
139411
public static MultiMatcher<ClassTree, MethodTree> constructor(
      MatchType matchType, Matcher<MethodTree> constructorMatcher) {
    return new ConstructorOfClass(matchType, constructorMatcher);
  }
224201
public static <T> TypeSafeMatcher<Optional<T>> presentAnd(final Matcher<? super T> innerMatcher) {
        return IsPresentOptionalAnd.presentAnd(innerMatcher);
    }
1137950
public static boolean matches(PrecedencedSelfDescribing self, Matcher<?> matcher, Object item, Description mismatch) {
        boolean paren = useParen(self, matcher);
        if (paren) {
            return QuickDiagnose.matches(matcher, item, mismatch, "($1)");
        } else {
            return QuickDiagnose.matches(matcher, item, mismatch);
        }
    }
357018
function match(node, type) {
            let innerStatementNode = node;

            while (innerStatementNode.type === "LabeledStatement") {
                innerStatementNode = innerStatementNode.body;
            }
            if (Array.isArray(type)) {
                return type.some(match.bind(null, innerStatementNode));
            }
            return StatementTypes[type].test(innerStatementNode, sourceCode);
        }
1132303
public static Matcher<ExpressionTree> sameVariable(final ExpressionTree expr) {
    return new Matcher<ExpressionTree>() {
      @Override
      public boolean matches(ExpressionTree tree, VisitorState state) {
        return ASTHelpers.sameVariable(tree, expr);
      }
    };
  }
1119539
public static <T extends Tree> Matcher<T> isSameType(Supplier<Type> type) {
    return new IsSameType<>(type);
  }
425070
public static Matcher<AssignmentTree> assignment(
      final Matcher<ExpressionTree> variableMatcher,
      final Matcher<? super ExpressionTree> expressionMatcher) {
    return new Matcher<AssignmentTree>() {
      @Override
      public boolean matches(AssignmentTree t, VisitorState state) {
        return variableMatcher.matches(t.getVariable(), state)
            && expressionMatcher.matches(t.getExpression(), state);
      }
    };
  }
1174597
private static <T extends Node> ImmutableList<T> getAllMatchingNodesOfType(
      Node rootSoyNode, final Class<T> classObject, final Predicate<T> filter) {
    final ImmutableList.Builder<T> matchedNodesBuilder = ImmutableList.builder();
    // optimization to avoid navigating into expr trees if we can't possibly match anything
    final boolean exploreExpressions = ExprNode.class.isAssignableFrom(classObject);
    visitAllNodes(
        rootSoyNode,
        new NodeVisitor<Node, VisitDirective>() {
          @Override
          public VisitDirective exec(Node node) {
            if (classObject.isInstance(node)) {
              T typedNode = classObject.cast(node);
              if (filter.test(typedNode)) {
                matchedNodesBuilder.add(typedNode);
              }
            }
            if (!exploreExpressions && node instanceof ExprNode) {
              return VisitDirective.SKIP_CHILDREN;
            }
            return VisitDirective.CONTINUE;
          }
        });
    return matchedNodesBuilder.build();
  }
959889
public static boolean isValidStringMatchingRegex(final String value, final String expression) {

		Pattern pattern = patterns.get(expression);

		if (pattern == null) {

			pattern = Pattern.compile(expression);
			patterns.put(expression, pattern);
		}

		return (value != null && pattern.matcher(value).matches());
	}
627177
public static Matcher assignmentWithRhs(final Matcher rhsMatcher) {
    return new Matcher() {
      @Override public boolean matches(Node node, NodeMetadata metadata) {
        return node.isAssign() && rhsMatcher.matches(node.getLastChild(), metadata);
      }
    };
  }
478431
public static <T extends ParameterDescription> ElementMatcher.Junction<T> definedParameter(ElementMatcher<? super ParameterDescription.InDefinedShape> matcher) {
        return new DefinedShapeMatcher<T, ParameterDescription.InDefinedShape>(matcher);
    }
104957
public static boolean matches(Pattern patternMatcher, Object... elements)
    {
        if (patternMatcher == null) {
            return true;
        }

        for (Object element : elements) {
            if (matches(patternMatcher, element)) {
                return true;
            }
        }

        return false;
    }
1031354
public static boolean matchesTypeName(Class<?> clazz, String typeName) {
        return (typeName != null &&
                (typeName.equals(clazz.getTypeName()) || typeName.equals(clazz.getSimpleName())));
    }
292287
public static Matcher<VariableTree> variableInitializer(
      final Matcher<ExpressionTree> expressionTreeMatcher) {
    return new Matcher<VariableTree>() {
      @Override
      public boolean matches(VariableTree variableTree, VisitorState state) {
        ExpressionTree initializer = variableTree.getInitializer();
        return initializer == null ? false : expressionTreeMatcher.matches(initializer, state);
      }
    };
  }
188710
public static MultiMatcher<MethodInvocationTree, ExpressionTree> hasArguments(
      MatchType matchType, Matcher<ExpressionTree> argumentMatcher) {
    return new HasArguments(matchType, argumentMatcher);
  }
57794
public static <T> MatcherDecoratorsBuilder<T> should(final Matcher<? super T> matcher) {
        return MatcherDecoratorsBuilder.should(matcher);
    }