com.google.errorprone.matchers.Matcher Java Examples
The following examples show how to use
com.google.errorprone.matchers.Matcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BannedMethod.java From besu with Apache License 2.0 | 5 votes |
@Override public Description matchMethodInvocation( final MethodInvocationTree tree, final VisitorState state) { for (final Map.Entry<Matcher<ExpressionTree>, String> entry : BANNED_METHOD_LIST.entrySet()) { if (entry.getKey().matches(tree, state)) { return buildDescription(tree).setMessage(entry.getValue()).build(); } } return NO_MATCH; }
Example #2
Source File: NullAway.java From NullAway with MIT License | 5 votes |
/** * A safe init method is an instance method that is either private or final (so no overriding is * possible) * * @param stmt the statement * @param enclosingClassSymbol symbol for enclosing constructor / initializer * @param state visitor state * @return element of safe init function if stmt invokes that function; null otherwise */ @Nullable private Element getInvokeOfSafeInitMethod( StatementTree stmt, final Symbol.ClassSymbol enclosingClassSymbol, VisitorState state) { Matcher<ExpressionTree> invokeMatcher = (expressionTree, s) -> { if (!(expressionTree instanceof MethodInvocationTree)) { return false; } MethodInvocationTree methodInvocationTree = (MethodInvocationTree) expressionTree; Symbol.MethodSymbol symbol = ASTHelpers.getSymbol(methodInvocationTree); Set<Modifier> modifiers = symbol.getModifiers(); Set<Modifier> classModifiers = enclosingClassSymbol.getModifiers(); if ((symbol.isPrivate() || modifiers.contains(Modifier.FINAL) || classModifiers.contains(Modifier.FINAL)) && !symbol.isStatic() && !modifiers.contains(Modifier.NATIVE)) { // check it's the same class (could be an issue with inner classes) if (ASTHelpers.enclosingClass(symbol).equals(enclosingClassSymbol)) { // make sure the receiver is 'this' ExpressionTree receiver = ASTHelpers.getReceiver(expressionTree); return receiver == null || isThisIdentifier(receiver); } } return false; }; if (stmt.getKind().equals(EXPRESSION_STATEMENT)) { ExpressionTree expression = ((ExpressionStatementTree) stmt).getExpression(); if (invokeMatcher.matches(expression, state)) { return ASTHelpers.getSymbol(expression); } } return null; }
Example #3
Source File: UMatches.java From Refaster with Apache License 2.0 | 5 votes |
public static UMatches create(Class<? extends Matcher<? super ExpressionTree>> matcherClass, boolean positive, UExpression expression) { // Verify that we can instantiate the Matcher makeMatcher(matcherClass); return new AutoValue_UMatches(positive, matcherClass, expression); }
Example #4
Source File: ComponentsAppGetCheck.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
private static <T extends Tree> Matcher<T> isSupertypeOf(Supplier<Type> type) { return new IsSupertypeOf<T>(type); }
Example #5
Source File: UMatches.java From Refaster with Apache License 2.0 | votes |
abstract Class<? extends Matcher<? super ExpressionTree>> matcherClass();