id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
21,700
google/error-prone
check_api/src/main/java/com/google/errorprone/fixes/SuggestedFix.java
SuggestedFix.replace
public static SuggestedFix replace(int startPos, int endPos, String replaceWith) { return builder().replace(startPos, endPos, replaceWith).build(); }
java
public static SuggestedFix replace(int startPos, int endPos, String replaceWith) { return builder().replace(startPos, endPos, replaceWith).build(); }
[ "public", "static", "SuggestedFix", "replace", "(", "int", "startPos", ",", "int", "endPos", ",", "String", "replaceWith", ")", "{", "return", "builder", "(", ")", ".", "replace", "(", "startPos", ",", "endPos", ",", "replaceWith", ")", ".", "build", "(", ...
Replace the characters from startPos, inclusive, until endPos, exclusive, with the given string. @param startPos The position from which to start replacing, inclusive @param endPos The position at which to end replacing, exclusive @param replaceWith The string to replace with
[ "Replace", "the", "characters", "from", "startPos", "inclusive", "until", "endPos", "exclusive", "with", "the", "given", "string", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFix.java#L109-L111
21,701
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/NameInCommentHeuristic.java
NameInCommentHeuristic.isAcceptableChange
@Override public boolean isAcceptableChange( Changes changes, Tree node, MethodSymbol symbol, VisitorState state) { // Now check to see if there is a comment in the position of any actual parameter we want to // change which matches the formal parameter ImmutableList<Commented<ExpressionTree>> comme...
java
@Override public boolean isAcceptableChange( Changes changes, Tree node, MethodSymbol symbol, VisitorState state) { // Now check to see if there is a comment in the position of any actual parameter we want to // change which matches the formal parameter ImmutableList<Commented<ExpressionTree>> comme...
[ "@", "Override", "public", "boolean", "isAcceptableChange", "(", "Changes", "changes", ",", "Tree", "node", ",", "MethodSymbol", "symbol", ",", "VisitorState", "state", ")", "{", "// Now check to see if there is a comment in the position of any actual parameter we want to", "...
Return true if there are no comments on the original actual parameter of a change which match the name of the formal parameter.
[ "Return", "true", "if", "there", "are", "no", "comments", "on", "the", "original", "actual", "parameter", "of", "a", "change", "which", "match", "the", "name", "of", "the", "formal", "parameter", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/NameInCommentHeuristic.java#L42-L57
21,702
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/ModifyingCollectionWithItself.java
ModifyingCollectionWithItself.matchMethodInvocation
@Override public Description matchMethodInvocation(MethodInvocationTree t, VisitorState state) { if (IS_COLLECTION_MODIFIED_WITH_ITSELF.matches(t, state)) { return describe(t, state); } return Description.NO_MATCH; }
java
@Override public Description matchMethodInvocation(MethodInvocationTree t, VisitorState state) { if (IS_COLLECTION_MODIFIED_WITH_ITSELF.matches(t, state)) { return describe(t, state); } return Description.NO_MATCH; }
[ "@", "Override", "public", "Description", "matchMethodInvocation", "(", "MethodInvocationTree", "t", ",", "VisitorState", "state", ")", "{", "if", "(", "IS_COLLECTION_MODIFIED_WITH_ITSELF", ".", "matches", "(", "t", ",", "state", ")", ")", "{", "return", "describe...
Matches calls to addAll, containsAll, removeAll, and retainAll on itself
[ "Matches", "calls", "to", "addAll", "containsAll", "removeAll", "and", "retainAll", "on", "itself" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ModifyingCollectionWithItself.java#L78-L84
21,703
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.getArgumentTypesWithoutMessage
private List<Type> getArgumentTypesWithoutMessage( MethodInvocationTree methodInvocationTree, VisitorState state) { List<Type> argumentTypes = new ArrayList<>(); for (ExpressionTree argument : methodInvocationTree.getArguments()) { JCTree tree = (JCTree) argument; argumentTypes.add(tree.type);...
java
private List<Type> getArgumentTypesWithoutMessage( MethodInvocationTree methodInvocationTree, VisitorState state) { List<Type> argumentTypes = new ArrayList<>(); for (ExpressionTree argument : methodInvocationTree.getArguments()) { JCTree tree = (JCTree) argument; argumentTypes.add(tree.type);...
[ "private", "List", "<", "Type", ">", "getArgumentTypesWithoutMessage", "(", "MethodInvocationTree", "methodInvocationTree", ",", "VisitorState", "state", ")", "{", "List", "<", "Type", ">", "argumentTypes", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(...
Gets the argument types, excluding the message argument if present.
[ "Gets", "the", "argument", "types", "excluding", "the", "message", "argument", "if", "present", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L76-L85
21,704
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.removeMessageArgumentIfPresent
private void removeMessageArgumentIfPresent(VisitorState state, List<Type> argumentTypes) { if (argumentTypes.size() == 2) { return; } Types types = state.getTypes(); Type firstType = argumentTypes.get(0); if (types.isSameType(firstType, state.getSymtab().stringType)) { argumentTypes.rem...
java
private void removeMessageArgumentIfPresent(VisitorState state, List<Type> argumentTypes) { if (argumentTypes.size() == 2) { return; } Types types = state.getTypes(); Type firstType = argumentTypes.get(0); if (types.isSameType(firstType, state.getSymtab().stringType)) { argumentTypes.rem...
[ "private", "void", "removeMessageArgumentIfPresent", "(", "VisitorState", "state", ",", "List", "<", "Type", ">", "argumentTypes", ")", "{", "if", "(", "argumentTypes", ".", "size", "(", ")", "==", "2", ")", "{", "return", ";", "}", "Types", "types", "=", ...
Removes the message argument if it is present.
[ "Removes", "the", "message", "argument", "if", "it", "is", "present", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L88-L97
21,705
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.canBeConvertedToJUnit4
private boolean canBeConvertedToJUnit4(VisitorState state, List<Type> argumentTypes) { // Delta argument is used. if (argumentTypes.size() > 2) { return true; } Type firstType = argumentTypes.get(0); Type secondType = argumentTypes.get(1); // Neither argument is floating-point. if (!is...
java
private boolean canBeConvertedToJUnit4(VisitorState state, List<Type> argumentTypes) { // Delta argument is used. if (argumentTypes.size() > 2) { return true; } Type firstType = argumentTypes.get(0); Type secondType = argumentTypes.get(1); // Neither argument is floating-point. if (!is...
[ "private", "boolean", "canBeConvertedToJUnit4", "(", "VisitorState", "state", ",", "List", "<", "Type", ">", "argumentTypes", ")", "{", "// Delta argument is used.", "if", "(", "argumentTypes", ".", "size", "(", ")", ">", "2", ")", "{", "return", "true", ";", ...
Determines if the invocation can be safely converted to JUnit 4 based on its argument types.
[ "Determines", "if", "the", "invocation", "can", "be", "safely", "converted", "to", "JUnit", "4", "based", "on", "its", "argument", "types", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L102-L122
21,706
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.isFloatingPoint
private boolean isFloatingPoint(VisitorState state, Type type) { Type trueType = unboxedTypeOrType(state, type); return (trueType.getKind() == TypeKind.DOUBLE) || (trueType.getKind() == TypeKind.FLOAT); }
java
private boolean isFloatingPoint(VisitorState state, Type type) { Type trueType = unboxedTypeOrType(state, type); return (trueType.getKind() == TypeKind.DOUBLE) || (trueType.getKind() == TypeKind.FLOAT); }
[ "private", "boolean", "isFloatingPoint", "(", "VisitorState", "state", ",", "Type", "type", ")", "{", "Type", "trueType", "=", "unboxedTypeOrType", "(", "state", ",", "type", ")", ";", "return", "(", "trueType", ".", "getKind", "(", ")", "==", "TypeKind", ...
Determines if the type is a floating-point type, including reference types.
[ "Determines", "if", "the", "type", "is", "a", "floating", "-", "point", "type", "including", "reference", "types", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L125-L128
21,707
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.isNumeric
private boolean isNumeric(VisitorState state, Type type) { Type trueType = unboxedTypeOrType(state, type); return trueType.isNumeric(); }
java
private boolean isNumeric(VisitorState state, Type type) { Type trueType = unboxedTypeOrType(state, type); return trueType.isNumeric(); }
[ "private", "boolean", "isNumeric", "(", "VisitorState", "state", ",", "Type", "type", ")", "{", "Type", "trueType", "=", "unboxedTypeOrType", "(", "state", ",", "type", ")", ";", "return", "trueType", ".", "isNumeric", "(", ")", ";", "}" ]
Determines if the type is a numeric type, including reference types. <p>Type.isNumeric() does not handle reference types properly.
[ "Determines", "if", "the", "type", "is", "a", "numeric", "type", "including", "reference", "types", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L135-L138
21,708
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.unboxedTypeOrType
private Type unboxedTypeOrType(VisitorState state, Type type) { Types types = state.getTypes(); return types.unboxedTypeOrType(type); }
java
private Type unboxedTypeOrType(VisitorState state, Type type) { Types types = state.getTypes(); return types.unboxedTypeOrType(type); }
[ "private", "Type", "unboxedTypeOrType", "(", "VisitorState", "state", ",", "Type", "type", ")", "{", "Types", "types", "=", "state", ".", "getTypes", "(", ")", ";", "return", "types", ".", "unboxedTypeOrType", "(", "type", ")", ";", "}" ]
Gets the unboxed type, or the original type if it is not unboxable.
[ "Gets", "the", "unboxed", "type", "or", "the", "original", "type", "if", "it", "is", "not", "unboxable", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L141-L144
21,709
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.addDeltaArgument
private Fix addDeltaArgument( MethodInvocationTree methodInvocationTree, VisitorState state, List<Type> argumentTypes) { int insertionIndex = getDeltaInsertionIndex(methodInvocationTree, state); String deltaArgument = getDeltaArgument(state, argumentTypes); return SuggestedFix.replace(insertionIndex, ...
java
private Fix addDeltaArgument( MethodInvocationTree methodInvocationTree, VisitorState state, List<Type> argumentTypes) { int insertionIndex = getDeltaInsertionIndex(methodInvocationTree, state); String deltaArgument = getDeltaArgument(state, argumentTypes); return SuggestedFix.replace(insertionIndex, ...
[ "private", "Fix", "addDeltaArgument", "(", "MethodInvocationTree", "methodInvocationTree", ",", "VisitorState", "state", ",", "List", "<", "Type", ">", "argumentTypes", ")", "{", "int", "insertionIndex", "=", "getDeltaInsertionIndex", "(", "methodInvocationTree", ",", ...
Creates the fix to add a delta argument.
[ "Creates", "the", "fix", "to", "add", "a", "delta", "argument", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L147-L152
21,710
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.getDeltaInsertionIndex
private int getDeltaInsertionIndex( MethodInvocationTree methodInvocationTree, VisitorState state) { JCTree lastArgument = (JCTree) Iterables.getLast(methodInvocationTree.getArguments()); return state.getEndPosition(lastArgument); }
java
private int getDeltaInsertionIndex( MethodInvocationTree methodInvocationTree, VisitorState state) { JCTree lastArgument = (JCTree) Iterables.getLast(methodInvocationTree.getArguments()); return state.getEndPosition(lastArgument); }
[ "private", "int", "getDeltaInsertionIndex", "(", "MethodInvocationTree", "methodInvocationTree", ",", "VisitorState", "state", ")", "{", "JCTree", "lastArgument", "=", "(", "JCTree", ")", "Iterables", ".", "getLast", "(", "methodInvocationTree", ".", "getArguments", "...
Gets the index of where to insert the delta argument.
[ "Gets", "the", "index", "of", "where", "to", "insert", "the", "delta", "argument", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L155-L159
21,711
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.getDeltaArgument
private String getDeltaArgument(VisitorState state, List<Type> argumentTypes) { Type firstType = argumentTypes.get(0); Type secondType = argumentTypes.get(1); boolean doublePrecisionUsed = isDouble(state, firstType) || isDouble(state, secondType); return doublePrecisionUsed ? ", 0.0" : ", 0.0f"; }
java
private String getDeltaArgument(VisitorState state, List<Type> argumentTypes) { Type firstType = argumentTypes.get(0); Type secondType = argumentTypes.get(1); boolean doublePrecisionUsed = isDouble(state, firstType) || isDouble(state, secondType); return doublePrecisionUsed ? ", 0.0" : ", 0.0f"; }
[ "private", "String", "getDeltaArgument", "(", "VisitorState", "state", ",", "List", "<", "Type", ">", "argumentTypes", ")", "{", "Type", "firstType", "=", "argumentTypes", ".", "get", "(", "0", ")", ";", "Type", "secondType", "=", "argumentTypes", ".", "get"...
Gets the text for the delta argument to be added.
[ "Gets", "the", "text", "for", "the", "delta", "argument", "to", "be", "added", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L162-L167
21,712
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java
JUnit3FloatingPointComparisonWithoutDelta.isDouble
private boolean isDouble(VisitorState state, Type type) { Type trueType = unboxedTypeOrType(state, type); return trueType.getKind() == TypeKind.DOUBLE; }
java
private boolean isDouble(VisitorState state, Type type) { Type trueType = unboxedTypeOrType(state, type); return trueType.getKind() == TypeKind.DOUBLE; }
[ "private", "boolean", "isDouble", "(", "VisitorState", "state", ",", "Type", "type", ")", "{", "Type", "trueType", "=", "unboxedTypeOrType", "(", "state", ",", "type", ")", ";", "return", "trueType", ".", "getKind", "(", ")", "==", "TypeKind", ".", "DOUBLE...
Determines if the type is a double, including reference types.
[ "Determines", "if", "the", "type", "is", "a", "double", "including", "reference", "types", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JUnit3FloatingPointComparisonWithoutDelta.java#L170-L173
21,713
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/ThreeLetterTimeZoneID.java
ThreeLetterTimeZoneID.handleNonDaylightSavingsZone
static Replacement handleNonDaylightSavingsZone( boolean inJodaTimeContext, String daylightSavingsZone, String fixedOffset) { if (inJodaTimeContext) { String newDescription = SUMMARY + "\n\n" + observesDaylightSavingsMessage("DateTimeZone", daylightSavingsZone, fixe...
java
static Replacement handleNonDaylightSavingsZone( boolean inJodaTimeContext, String daylightSavingsZone, String fixedOffset) { if (inJodaTimeContext) { String newDescription = SUMMARY + "\n\n" + observesDaylightSavingsMessage("DateTimeZone", daylightSavingsZone, fixe...
[ "static", "Replacement", "handleNonDaylightSavingsZone", "(", "boolean", "inJodaTimeContext", ",", "String", "daylightSavingsZone", ",", "String", "fixedOffset", ")", "{", "if", "(", "inJodaTimeContext", ")", "{", "String", "newDescription", "=", "SUMMARY", "+", "\"\\...
How we handle it depends upon whether we are in a JodaTime context or not.
[ "How", "we", "handle", "it", "depends", "upon", "whether", "we", "are", "in", "a", "JodaTime", "context", "or", "not", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ThreeLetterTimeZoneID.java#L127-L147
21,714
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/ConstantOverflow.java
ConstantOverflow.longFix
private Fix longFix(ExpressionTree expr, VisitorState state) { BinaryTree binExpr = null; while (expr instanceof BinaryTree) { binExpr = (BinaryTree) expr; expr = binExpr.getLeftOperand(); } if (!(expr instanceof LiteralTree) || expr.getKind() != Kind.INT_LITERAL) { return null; } ...
java
private Fix longFix(ExpressionTree expr, VisitorState state) { BinaryTree binExpr = null; while (expr instanceof BinaryTree) { binExpr = (BinaryTree) expr; expr = binExpr.getLeftOperand(); } if (!(expr instanceof LiteralTree) || expr.getKind() != Kind.INT_LITERAL) { return null; } ...
[ "private", "Fix", "longFix", "(", "ExpressionTree", "expr", ",", "VisitorState", "state", ")", "{", "BinaryTree", "binExpr", "=", "null", ";", "while", "(", "expr", "instanceof", "BinaryTree", ")", "{", "binExpr", "=", "(", "BinaryTree", ")", "expr", ";", ...
If the left operand of an int binary expression is an int literal, suggest making it a long.
[ "If", "the", "left", "operand", "of", "an", "int", "binary", "expression", "is", "an", "int", "literal", "suggest", "making", "it", "a", "long", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ConstantOverflow.java#L86-L105
21,715
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.anything
public static <T extends Tree> Matcher<T> anything() { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return true; } }; }
java
public static <T extends Tree> Matcher<T> anything() { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return true; } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "anything", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "T", "t", ",", "VisitorState", ...
A matcher that matches any AST node.
[ "A", "matcher", "that", "matches", "any", "AST", "node", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L98-L105
21,716
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.nothing
public static <T extends Tree> Matcher<T> nothing() { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return false; } }; }
java
public static <T extends Tree> Matcher<T> nothing() { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return false; } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "nothing", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "T", "t", ",", "VisitorState", ...
A matcher that matches no AST node.
[ "A", "matcher", "that", "matches", "no", "AST", "node", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L108-L115
21,717
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.not
public static <T extends Tree> Matcher<T> not(final Matcher<T> matcher) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return !matcher.matches(t, state); } }; }
java
public static <T extends Tree> Matcher<T> not(final Matcher<T> matcher) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return !matcher.matches(t, state); } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "not", "(", "final", "Matcher", "<", "T", ">", "matcher", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "mat...
Matches an AST node iff it does not match the given matcher.
[ "Matches", "an", "AST", "node", "iff", "it", "does", "not", "match", "the", "given", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L118-L125
21,718
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.allOf
@SafeVarargs public static <T extends Tree> Matcher<T> allOf(final Matcher<? super T>... matchers) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { for (Matcher<? super T> matcher : matchers) { if (!matcher.matches(t, state)) { retur...
java
@SafeVarargs public static <T extends Tree> Matcher<T> allOf(final Matcher<? super T>... matchers) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { for (Matcher<? super T> matcher : matchers) { if (!matcher.matches(t, state)) { retur...
[ "@", "SafeVarargs", "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "allOf", "(", "final", "Matcher", "<", "?", "super", "T", ">", "...", "matchers", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{"...
Compose several matchers together, such that the composite matches an AST node iff all the given matchers do.
[ "Compose", "several", "matchers", "together", "such", "that", "the", "composite", "matches", "an", "AST", "node", "iff", "all", "the", "given", "matchers", "do", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L131-L144
21,719
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.anyOf
public static <T extends Tree> Matcher<T> anyOf( final Iterable<? extends Matcher<? super T>> matchers) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { for (Matcher<? super T> matcher : matchers) { if (matcher.matches(t, state)) { ...
java
public static <T extends Tree> Matcher<T> anyOf( final Iterable<? extends Matcher<? super T>> matchers) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { for (Matcher<? super T> matcher : matchers) { if (matcher.matches(t, state)) { ...
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "anyOf", "(", "final", "Iterable", "<", "?", "extends", "Matcher", "<", "?", "super", "T", ">", ">", "matchers", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(...
Compose several matchers together, such that the composite matches an AST node if any of the given matchers do.
[ "Compose", "several", "matchers", "together", "such", "that", "the", "composite", "matches", "an", "AST", "node", "if", "any", "of", "the", "given", "matchers", "do", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L150-L163
21,720
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isInstance
public static <T extends Tree> Matcher<T> isInstance(final java.lang.Class<?> klass) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return klass.isInstance(t); } }; }
java
public static <T extends Tree> Matcher<T> isInstance(final java.lang.Class<?> klass) { return new Matcher<T>() { @Override public boolean matches(T t, VisitorState state) { return klass.isInstance(t); } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isInstance", "(", "final", "java", ".", "lang", ".", "Class", "<", "?", ">", "klass", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Overr...
Matches if an AST node is an instance of the given class.
[ "Matches", "if", "an", "AST", "node", "is", "an", "instance", "of", "the", "given", "class", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L171-L178
21,721
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.kindIs
public static <T extends Tree> Matcher<T> kindIs(final Kind kind) { return new Matcher<T>() { @Override public boolean matches(T tree, VisitorState state) { return tree.getKind() == kind; } }; }
java
public static <T extends Tree> Matcher<T> kindIs(final Kind kind) { return new Matcher<T>() { @Override public boolean matches(T tree, VisitorState state) { return tree.getKind() == kind; } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "kindIs", "(", "final", "Kind", "kind", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "T", "...
Matches an AST node of a given kind, for example, an Annotation or a switch block.
[ "Matches", "an", "AST", "node", "of", "a", "given", "kind", "for", "example", "an", "Annotation", "or", "a", "switch", "block", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L181-L188
21,722
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isSame
public static <T extends Tree> Matcher<T> isSame(final Tree t) { return new Matcher<T>() { @Override public boolean matches(T tree, VisitorState state) { return tree == t; } }; }
java
public static <T extends Tree> Matcher<T> isSame(final Tree t) { return new Matcher<T>() { @Override public boolean matches(T tree, VisitorState state) { return tree == t; } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isSame", "(", "final", "Tree", "t", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "T", "tre...
Matches an AST node which is the same object reference as the given node.
[ "Matches", "an", "AST", "node", "which", "is", "the", "same", "object", "reference", "as", "the", "given", "node", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L191-L198
21,723
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isInstanceField
public static Matcher<ExpressionTree> isInstanceField() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(expressionTree); return symbol != null && symbol.getKind() == Elemen...
java
public static Matcher<ExpressionTree> isInstanceField() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(expressionTree); return symbol != null && symbol.getKind() == Elemen...
[ "public", "static", "Matcher", "<", "ExpressionTree", ">", "isInstanceField", "(", ")", "{", "return", "new", "Matcher", "<", "ExpressionTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "ExpressionTree", "expressionTree", ",", "...
Matches an AST node that represents a non-static field.
[ "Matches", "an", "AST", "node", "that", "represents", "a", "non", "-", "static", "field", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L221-L229
21,724
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isVariable
public static Matcher<ExpressionTree> isVariable() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(expressionTree); if (symbol == null) { return false; } ...
java
public static Matcher<ExpressionTree> isVariable() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(expressionTree); if (symbol == null) { return false; } ...
[ "public", "static", "Matcher", "<", "ExpressionTree", ">", "isVariable", "(", ")", "{", "return", "new", "Matcher", "<", "ExpressionTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "ExpressionTree", "expressionTree", ",", "Visit...
Matches an AST node that represents a local variable or parameter.
[ "Matches", "an", "AST", "node", "that", "represents", "a", "local", "variable", "or", "parameter", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L232-L244
21,725
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.compoundAssignment
public static CompoundAssignment compoundAssignment( Kind operator, Matcher<ExpressionTree> leftOperandMatcher, Matcher<ExpressionTree> rightOperandMatcher) { Set<Kind> operators = new HashSet<>(1); operators.add(operator); return new CompoundAssignment(operators, leftOperandMatcher, right...
java
public static CompoundAssignment compoundAssignment( Kind operator, Matcher<ExpressionTree> leftOperandMatcher, Matcher<ExpressionTree> rightOperandMatcher) { Set<Kind> operators = new HashSet<>(1); operators.add(operator); return new CompoundAssignment(operators, leftOperandMatcher, right...
[ "public", "static", "CompoundAssignment", "compoundAssignment", "(", "Kind", "operator", ",", "Matcher", "<", "ExpressionTree", ">", "leftOperandMatcher", ",", "Matcher", "<", "ExpressionTree", ">", "rightOperandMatcher", ")", "{", "Set", "<", "Kind", ">", "operator...
Matches a compound assignment operator AST node which matches a given left-operand matcher, a given right-operand matcher, and a specific compound assignment operator. @param operator Which compound assignment operator to match against. @param leftOperandMatcher The matcher to apply to the left operand. @param rightOp...
[ "Matches", "a", "compound", "assignment", "operator", "AST", "node", "which", "matches", "a", "given", "left", "-", "operand", "matcher", "a", "given", "right", "-", "operand", "matcher", "and", "a", "specific", "compound", "assignment", "operator", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L254-L261
21,726
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.compoundAssignment
public static CompoundAssignment compoundAssignment( Set<Kind> operators, Matcher<ExpressionTree> receiverMatcher, Matcher<ExpressionTree> expressionMatcher) { return new CompoundAssignment(operators, receiverMatcher, expressionMatcher); }
java
public static CompoundAssignment compoundAssignment( Set<Kind> operators, Matcher<ExpressionTree> receiverMatcher, Matcher<ExpressionTree> expressionMatcher) { return new CompoundAssignment(operators, receiverMatcher, expressionMatcher); }
[ "public", "static", "CompoundAssignment", "compoundAssignment", "(", "Set", "<", "Kind", ">", "operators", ",", "Matcher", "<", "ExpressionTree", ">", "receiverMatcher", ",", "Matcher", "<", "ExpressionTree", ">", "expressionMatcher", ")", "{", "return", "new", "C...
Matches a compound assignment operator AST node which matches a given left-operand matcher, a given right-operand matcher, and is one of a set of compound assignment operators. Does not match compound assignment operators. @param operators Which compound assignment operators to match against. @param receiverMatcher Th...
[ "Matches", "a", "compound", "assignment", "operator", "AST", "node", "which", "matches", "a", "given", "left", "-", "operand", "matcher", "a", "given", "right", "-", "operand", "matcher", "and", "is", "one", "of", "a", "set", "of", "compound", "assignment", ...
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L272-L277
21,727
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.annotations
public static <T extends Tree> MultiMatcher<T, AnnotationTree> annotations( MatchType matchType, Matcher<AnnotationTree> annotationMatcher) { return new AnnotationMatcher<>(matchType, annotationMatcher); }
java
public static <T extends Tree> MultiMatcher<T, AnnotationTree> annotations( MatchType matchType, Matcher<AnnotationTree> annotationMatcher) { return new AnnotationMatcher<>(matchType, annotationMatcher); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "MultiMatcher", "<", "T", ",", "AnnotationTree", ">", "annotations", "(", "MatchType", "matchType", ",", "Matcher", "<", "AnnotationTree", ">", "annotationMatcher", ")", "{", "return", "new", "AnnotationMatch...
Matches if the given annotation matcher matches all of or any of the annotations on this tree node. @param matchType Whether to match if the matchers match any of or all of the annotations on this tree. @param annotationMatcher The annotation matcher to use.
[ "Matches", "if", "the", "given", "annotation", "matcher", "matches", "all", "of", "or", "any", "of", "the", "annotations", "on", "this", "tree", "node", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L328-L331
21,728
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.methodInvocation
public static Matcher<ExpressionTree> methodInvocation( Matcher<ExpressionTree> methodSelectMatcher, MatchType matchType, Matcher<ExpressionTree> methodArgumentMatcher) { return new MethodInvocation(methodSelectMatcher, matchType, methodArgumentMatcher); }
java
public static Matcher<ExpressionTree> methodInvocation( Matcher<ExpressionTree> methodSelectMatcher, MatchType matchType, Matcher<ExpressionTree> methodArgumentMatcher) { return new MethodInvocation(methodSelectMatcher, matchType, methodArgumentMatcher); }
[ "public", "static", "Matcher", "<", "ExpressionTree", ">", "methodInvocation", "(", "Matcher", "<", "ExpressionTree", ">", "methodSelectMatcher", ",", "MatchType", "matchType", ",", "Matcher", "<", "ExpressionTree", ">", "methodArgumentMatcher", ")", "{", "return", ...
Matches an AST node if it is a method invocation and the given matchers match. @param methodSelectMatcher matcher identifying the method being called @param matchType how to match method arguments with {@code methodArgumentMatcher} @param methodArgumentMatcher matcher applied to each method argument
[ "Matches", "an", "AST", "node", "if", "it", "is", "a", "method", "invocation", "and", "the", "given", "matchers", "match", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L363-L368
21,729
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isSameType
public static <T extends Tree> Matcher<T> isSameType(Supplier<Type> type) { return new IsSameType<>(type); }
java
public static <T extends Tree> Matcher<T> isSameType(Supplier<Type> type) { return new IsSameType<>(type); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isSameType", "(", "Supplier", "<", "Type", ">", "type", ")", "{", "return", "new", "IsSameType", "<>", "(", "type", ")", ";", "}" ]
Matches an AST node if it has the same erased type as the given type.
[ "Matches", "an", "AST", "node", "if", "it", "has", "the", "same", "erased", "type", "as", "the", "given", "type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L436-L438
21,730
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isSameType
public static <T extends Tree> Matcher<T> isSameType(Class<?> clazz) { return new IsSameType<>(typeFromClass(clazz)); }
java
public static <T extends Tree> Matcher<T> isSameType(Class<?> clazz) { return new IsSameType<>(typeFromClass(clazz)); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isSameType", "(", "Class", "<", "?", ">", "clazz", ")", "{", "return", "new", "IsSameType", "<>", "(", "typeFromClass", "(", "clazz", ")", ")", ";", "}" ]
Matches an AST node if it has the same erased type as the given class.
[ "Matches", "an", "AST", "node", "if", "it", "has", "the", "same", "erased", "type", "as", "the", "given", "class", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L446-L448
21,731
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isArrayType
public static <T extends Tree> Matcher<T> isArrayType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && state.getTypes().isArray(type); } }; }
java
public static <T extends Tree> Matcher<T> isArrayType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && state.getTypes().isArray(type); } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isArrayType", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Tree", "t", ",", "VisitorSt...
Matches an AST node if its type is an array type.
[ "Matches", "an", "AST", "node", "if", "its", "type", "is", "an", "array", "type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L451-L459
21,732
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isPrimitiveArrayType
public static <T extends Tree> Matcher<T> isPrimitiveArrayType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && state.getTypes().isArray(type) && state.getTypes().elemtype(t...
java
public static <T extends Tree> Matcher<T> isPrimitiveArrayType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && state.getTypes().isArray(type) && state.getTypes().elemtype(t...
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isPrimitiveArrayType", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Tree", "t", ",", "...
Matches an AST node if its type is a primitive array type.
[ "Matches", "an", "AST", "node", "if", "its", "type", "is", "a", "primitive", "array", "type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L462-L472
21,733
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isPrimitiveType
public static <T extends Tree> Matcher<T> isPrimitiveType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && type.isPrimitive(); } }; }
java
public static <T extends Tree> Matcher<T> isPrimitiveType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && type.isPrimitive(); } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isPrimitiveType", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Tree", "t", ",", "Visit...
Matches an AST node if its type is a primitive type.
[ "Matches", "an", "AST", "node", "if", "its", "type", "is", "a", "primitive", "type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L475-L483
21,734
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isPrimitiveOrBoxedPrimitiveType
public static <T extends Tree> Matcher<T> isPrimitiveOrBoxedPrimitiveType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && state.getTypes().unboxedTypeOrType(type).isPrimitive(); } }; }
java
public static <T extends Tree> Matcher<T> isPrimitiveOrBoxedPrimitiveType() { return new Matcher<T>() { @Override public boolean matches(Tree t, VisitorState state) { Type type = getType(t); return type != null && state.getTypes().unboxedTypeOrType(type).isPrimitive(); } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isPrimitiveOrBoxedPrimitiveType", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Tree", "t",...
Matches an AST node if its type is a primitive type, or a boxed version of a primitive type.
[ "Matches", "an", "AST", "node", "if", "its", "type", "is", "a", "primitive", "type", "or", "a", "boxed", "version", "of", "a", "primitive", "type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L510-L518
21,735
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.enclosingBlock
public static <T extends Tree> Enclosing.Block<T> enclosingBlock(Matcher<BlockTree> matcher) { return new Enclosing.Block<>(matcher); }
java
public static <T extends Tree> Enclosing.Block<T> enclosingBlock(Matcher<BlockTree> matcher) { return new Enclosing.Block<>(matcher); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Enclosing", ".", "Block", "<", "T", ">", "enclosingBlock", "(", "Matcher", "<", "BlockTree", ">", "matcher", ")", "{", "return", "new", "Enclosing", ".", "Block", "<>", "(", "matcher", ")", ";", "}...
Matches an AST node which is enclosed by a block node that matches the given matcher.
[ "Matches", "an", "AST", "node", "which", "is", "enclosed", "by", "a", "block", "node", "that", "matches", "the", "given", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L521-L523
21,736
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.enclosingClass
public static <T extends Tree> Enclosing.Class<T> enclosingClass(Matcher<ClassTree> matcher) { return new Enclosing.Class<>(matcher); }
java
public static <T extends Tree> Enclosing.Class<T> enclosingClass(Matcher<ClassTree> matcher) { return new Enclosing.Class<>(matcher); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Enclosing", ".", "Class", "<", "T", ">", "enclosingClass", "(", "Matcher", "<", "ClassTree", ">", "matcher", ")", "{", "return", "new", "Enclosing", ".", "Class", "<>", "(", "matcher", ")", ";", "}...
Matches an AST node which is enclosed by a class node that matches the given matcher.
[ "Matches", "an", "AST", "node", "which", "is", "enclosed", "by", "a", "class", "node", "that", "matches", "the", "given", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L526-L528
21,737
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.enclosingMethod
public static <T extends Tree> Enclosing.Method<T> enclosingMethod(Matcher<MethodTree> matcher) { return new Enclosing.Method<>(matcher); }
java
public static <T extends Tree> Enclosing.Method<T> enclosingMethod(Matcher<MethodTree> matcher) { return new Enclosing.Method<>(matcher); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Enclosing", ".", "Method", "<", "T", ">", "enclosingMethod", "(", "Matcher", "<", "MethodTree", ">", "matcher", ")", "{", "return", "new", "Enclosing", ".", "Method", "<>", "(", "matcher", ")", ";", ...
Matches an AST node which is enclosed by a method node that matches the given matcher.
[ "Matches", "an", "AST", "node", "which", "is", "enclosed", "by", "a", "method", "node", "that", "matches", "the", "given", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L531-L533
21,738
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.enclosingNode
public static <T extends Tree> Matcher<Tree> enclosingNode(final Matcher<T> matcher) { return new Matcher<Tree>() { @SuppressWarnings("unchecked") // TODO(cushon): this should take a Class<T> @Override public boolean matches(Tree t, VisitorState state) { TreePath path = state.getPath().get...
java
public static <T extends Tree> Matcher<Tree> enclosingNode(final Matcher<T> matcher) { return new Matcher<Tree>() { @SuppressWarnings("unchecked") // TODO(cushon): this should take a Class<T> @Override public boolean matches(Tree t, VisitorState state) { TreePath path = state.getPath().get...
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "Tree", ">", "enclosingNode", "(", "final", "Matcher", "<", "T", ">", "matcher", ")", "{", "return", "new", "Matcher", "<", "Tree", ">", "(", ")", "{", "@", "SuppressWarnings", "(", ...
Matches an AST node that is enclosed by some node that matches the given matcher. <p>TODO(eaftan): This could be used instead of enclosingBlock and enclosingClass.
[ "Matches", "an", "AST", "node", "that", "is", "enclosed", "by", "some", "node", "that", "matches", "the", "given", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L540-L557
21,739
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.nextStatement
public static <T extends StatementTree> NextStatement<T> nextStatement( Matcher<StatementTree> matcher) { return new NextStatement<>(matcher); }
java
public static <T extends StatementTree> NextStatement<T> nextStatement( Matcher<StatementTree> matcher) { return new NextStatement<>(matcher); }
[ "public", "static", "<", "T", "extends", "StatementTree", ">", "NextStatement", "<", "T", ">", "nextStatement", "(", "Matcher", "<", "StatementTree", ">", "matcher", ")", "{", "return", "new", "NextStatement", "<>", "(", "matcher", ")", ";", "}" ]
Matches a statement AST node if the following statement in the enclosing block matches the given matcher.
[ "Matches", "a", "statement", "AST", "node", "if", "the", "following", "statement", "in", "the", "enclosing", "block", "matches", "the", "given", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L563-L566
21,740
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.previousStatement
public static <T extends StatementTree> Matcher<T> previousStatement( Matcher<StatementTree> matcher) { return (T statement, VisitorState state) -> { BlockTree block = state.findEnclosing(BlockTree.class); if (block == null) { return false; } List<? extends StatementTree> state...
java
public static <T extends StatementTree> Matcher<T> previousStatement( Matcher<StatementTree> matcher) { return (T statement, VisitorState state) -> { BlockTree block = state.findEnclosing(BlockTree.class); if (block == null) { return false; } List<? extends StatementTree> state...
[ "public", "static", "<", "T", "extends", "StatementTree", ">", "Matcher", "<", "T", ">", "previousStatement", "(", "Matcher", "<", "StatementTree", ">", "matcher", ")", "{", "return", "(", "T", "statement", ",", "VisitorState", "state", ")", "->", "{", "Bl...
Matches a statement AST node if the previous statement in the enclosing block matches the given matcher.
[ "Matches", "a", "statement", "AST", "node", "if", "the", "previous", "statement", "in", "the", "enclosing", "block", "matches", "the", "given", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L572-L588
21,741
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.nonNullLiteral
public static Matcher<ExpressionTree> nonNullLiteral() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree tree, VisitorState state) { switch (tree.getKind()) { case MEMBER_SELECT: return ((MemberSelectTree) tree).getIdentifier().content...
java
public static Matcher<ExpressionTree> nonNullLiteral() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree tree, VisitorState state) { switch (tree.getKind()) { case MEMBER_SELECT: return ((MemberSelectTree) tree).getIdentifier().content...
[ "public", "static", "Matcher", "<", "ExpressionTree", ">", "nonNullLiteral", "(", ")", "{", "return", "new", "Matcher", "<", "ExpressionTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "ExpressionTree", "tree", ",", "VisitorStat...
Matches an AST node if it is a literal other than null.
[ "Matches", "an", "AST", "node", "if", "it", "is", "a", "literal", "other", "than", "null", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L596-L617
21,742
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.methodReturnsNonNull
public static Matcher<ExpressionTree> methodReturnsNonNull() { return anyOf( instanceMethod().onDescendantOf("java.lang.Object").named("toString"), instanceMethod().onExactClass("java.lang.String"), staticMethod().onClass("java.lang.String"), instanceMethod().onExactClass("java.util....
java
public static Matcher<ExpressionTree> methodReturnsNonNull() { return anyOf( instanceMethod().onDescendantOf("java.lang.Object").named("toString"), instanceMethod().onExactClass("java.lang.String"), staticMethod().onClass("java.lang.String"), instanceMethod().onExactClass("java.util....
[ "public", "static", "Matcher", "<", "ExpressionTree", ">", "methodReturnsNonNull", "(", ")", "{", "return", "anyOf", "(", "instanceMethod", "(", ")", ".", "onDescendantOf", "(", "\"java.lang.Object\"", ")", ".", "named", "(", "\"toString\"", ")", ",", "instanceM...
Matches a whitelisted method invocation that is known to never return null
[ "Matches", "a", "whitelisted", "method", "invocation", "that", "is", "known", "to", "never", "return", "null" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L882-L888
21,743
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.methodIsNamed
public static Matcher<MethodTree> methodIsNamed(final String methodName) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return methodTree.getName().contentEquals(methodName); } }; }
java
public static Matcher<MethodTree> methodIsNamed(final String methodName) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return methodTree.getName().contentEquals(methodName); } }; }
[ "public", "static", "Matcher", "<", "MethodTree", ">", "methodIsNamed", "(", "final", "String", "methodName", ")", "{", "return", "new", "Matcher", "<", "MethodTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "MethodTree", "me...
Match a method declaration with a specific name. @param methodName The name of the method to match, e.g., "equals"
[ "Match", "a", "method", "declaration", "with", "a", "specific", "name", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L918-L925
21,744
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.methodNameStartsWith
public static Matcher<MethodTree> methodNameStartsWith(final String prefix) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return methodTree.getName().toString().startsWith(prefix); } }; }
java
public static Matcher<MethodTree> methodNameStartsWith(final String prefix) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return methodTree.getName().toString().startsWith(prefix); } }; }
[ "public", "static", "Matcher", "<", "MethodTree", ">", "methodNameStartsWith", "(", "final", "String", "prefix", ")", "{", "return", "new", "Matcher", "<", "MethodTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "MethodTree", ...
Match a method declaration that starts with a given string. @param prefix The prefix.
[ "Match", "a", "method", "declaration", "that", "starts", "with", "a", "given", "string", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L932-L939
21,745
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.methodWithClassAndName
public static Matcher<MethodTree> methodWithClassAndName( final String className, final String methodName) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return ASTHelpers.getSymbol(methodTree) .getEnclosin...
java
public static Matcher<MethodTree> methodWithClassAndName( final String className, final String methodName) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return ASTHelpers.getSymbol(methodTree) .getEnclosin...
[ "public", "static", "Matcher", "<", "MethodTree", ">", "methodWithClassAndName", "(", "final", "String", "className", ",", "final", "String", "methodName", ")", "{", "return", "new", "Matcher", "<", "MethodTree", ">", "(", ")", "{", "@", "Override", "public", ...
Match a method declaration with a specific enclosing class and method name. @param className The fully-qualified name of the enclosing class, e.g. "com.google.common.base.Preconditions" @param methodName The name of the method to match, e.g., "checkNotNull"
[ "Match", "a", "method", "declaration", "with", "a", "specific", "enclosing", "class", "and", "method", "name", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L948-L960
21,746
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.constructorOfClass
public static Matcher<MethodTree> constructorOfClass(final String className) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(methodTree); return symbol.getEnclosingElement().getQualifi...
java
public static Matcher<MethodTree> constructorOfClass(final String className) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(methodTree); return symbol.getEnclosingElement().getQualifi...
[ "public", "static", "Matcher", "<", "MethodTree", ">", "constructorOfClass", "(", "final", "String", "className", ")", "{", "return", "new", "Matcher", "<", "MethodTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "MethodTree", ...
Matches a constructor declaration in a specific enclosing class. @param className The fully-qualified name of the enclosing class, e.g. "com.google.common.base.Preconditions"
[ "Matches", "a", "constructor", "declaration", "in", "a", "specific", "enclosing", "class", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1032-L1041
21,747
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.hasMethod
public static Matcher<ClassTree> hasMethod(final Matcher<MethodTree> methodMatcher) { return new Matcher<ClassTree>() { @Override public boolean matches(ClassTree t, VisitorState state) { for (Tree member : t.getMembers()) { if (member instanceof MethodTree) { if (methodMat...
java
public static Matcher<ClassTree> hasMethod(final Matcher<MethodTree> methodMatcher) { return new Matcher<ClassTree>() { @Override public boolean matches(ClassTree t, VisitorState state) { for (Tree member : t.getMembers()) { if (member instanceof MethodTree) { if (methodMat...
[ "public", "static", "Matcher", "<", "ClassTree", ">", "hasMethod", "(", "final", "Matcher", "<", "MethodTree", ">", "methodMatcher", ")", "{", "return", "new", "Matcher", "<", "ClassTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", ...
Matches a class in which at least one method matches the given methodMatcher. @param methodMatcher A matcher on MethodTrees to run against all methods in this class. @return True if some method in the class matches the given methodMatcher.
[ "Matches", "a", "class", "in", "which", "at", "least", "one", "method", "matches", "the", "given", "methodMatcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1049-L1063
21,748
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.variableType
public static Matcher<VariableTree> variableType(final Matcher<Tree> treeMatcher) { return new Matcher<VariableTree>() { @Override public boolean matches(VariableTree variableTree, VisitorState state) { return treeMatcher.matches(variableTree.getType(), state); } }; }
java
public static Matcher<VariableTree> variableType(final Matcher<Tree> treeMatcher) { return new Matcher<VariableTree>() { @Override public boolean matches(VariableTree variableTree, VisitorState state) { return treeMatcher.matches(variableTree.getType(), state); } }; }
[ "public", "static", "Matcher", "<", "VariableTree", ">", "variableType", "(", "final", "Matcher", "<", "Tree", ">", "treeMatcher", ")", "{", "return", "new", "Matcher", "<", "VariableTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches",...
Matches on the type of a VariableTree AST node. @param treeMatcher A matcher on the type of the variable.
[ "Matches", "on", "the", "type", "of", "a", "VariableTree", "AST", "node", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1070-L1077
21,749
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.variableInitializer
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();...
java
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();...
[ "public", "static", "Matcher", "<", "VariableTree", ">", "variableInitializer", "(", "final", "Matcher", "<", "ExpressionTree", ">", "expressionTreeMatcher", ")", "{", "return", "new", "Matcher", "<", "VariableTree", ">", "(", ")", "{", "@", "Override", "public"...
Matches on the initializer of a VariableTree AST node. @param expressionTreeMatcher A matcher on the initializer of the variable.
[ "Matches", "on", "the", "initializer", "of", "a", "VariableTree", "AST", "node", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1084-L1093
21,750
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.nestingKind
public static Matcher<ClassTree> nestingKind(final NestingKind kind) { return new Matcher<ClassTree>() { @Override public boolean matches(ClassTree classTree, VisitorState state) { ClassSymbol sym = ASTHelpers.getSymbol(classTree); return sym.getNestingKind() == kind; } }; }
java
public static Matcher<ClassTree> nestingKind(final NestingKind kind) { return new Matcher<ClassTree>() { @Override public boolean matches(ClassTree classTree, VisitorState state) { ClassSymbol sym = ASTHelpers.getSymbol(classTree); return sym.getNestingKind() == kind; } }; }
[ "public", "static", "Matcher", "<", "ClassTree", ">", "nestingKind", "(", "final", "NestingKind", "kind", ")", "{", "return", "new", "Matcher", "<", "ClassTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "ClassTree", "classTre...
Matches an class based on whether it is nested in another class or method. @param kind The kind of nesting to match, eg ANONYMOUS, LOCAL, MEMBER, TOP_LEVEL
[ "Matches", "an", "class", "based", "on", "whether", "it", "is", "nested", "in", "another", "class", "or", "method", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1114-L1122
21,751
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isStatic
public static <T extends Tree> Matcher<T> isStatic() { return new Matcher<T>() { @Override public boolean matches(Tree tree, VisitorState state) { Symbol sym = ASTHelpers.getSymbol(tree); return sym != null && sym.isStatic(); } }; }
java
public static <T extends Tree> Matcher<T> isStatic() { return new Matcher<T>() { @Override public boolean matches(Tree tree, VisitorState state) { Symbol sym = ASTHelpers.getSymbol(tree); return sym != null && sym.isStatic(); } }; }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isStatic", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Tree", "tree", ",", "VisitorSt...
Matches an AST node that is static.
[ "Matches", "an", "AST", "node", "that", "is", "static", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1167-L1175
21,752
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isTransient
public static <T extends Tree> Matcher<T> isTransient() { return new Matcher<T>() { @Override public boolean matches(Tree tree, VisitorState state) { Symbol sym = ASTHelpers.getSymbol(tree); // NOTE(yorick): there is no isTransient() on Symbol. This is what it would be. return sy...
java
public static <T extends Tree> Matcher<T> isTransient() { return new Matcher<T>() { @Override public boolean matches(Tree tree, VisitorState state) { Symbol sym = ASTHelpers.getSymbol(tree); // NOTE(yorick): there is no isTransient() on Symbol. This is what it would be. return sy...
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "isTransient", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Tree", "tree", ",", "Visito...
Matches an AST node that is transient.
[ "Matches", "an", "AST", "node", "that", "is", "transient", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1178-L1187
21,753
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.inSynchronized
public static final <T extends Tree> Matcher<T> inSynchronized() { return new Matcher<T>() { @Override public boolean matches(T tree, VisitorState state) { SynchronizedTree synchronizedTree = ASTHelpers.findEnclosingNode(state.getPath(), SynchronizedTree.class); if (synchroni...
java
public static final <T extends Tree> Matcher<T> inSynchronized() { return new Matcher<T>() { @Override public boolean matches(T tree, VisitorState state) { SynchronizedTree synchronizedTree = ASTHelpers.findEnclosingNode(state.getPath(), SynchronizedTree.class); if (synchroni...
[ "public", "static", "final", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "inSynchronized", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "T", "tree", ","...
Matches if this Tree is enclosed by either a synchronized block or a synchronized method.
[ "Matches", "if", "this", "Tree", "is", "enclosed", "by", "either", "a", "synchronized", "block", "or", "a", "synchronized", "method", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1255-L1270
21,754
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.sameVariable
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); } }; }
java
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); } }; }
[ "public", "static", "Matcher", "<", "ExpressionTree", ">", "sameVariable", "(", "final", "ExpressionTree", "expr", ")", "{", "return", "new", "Matcher", "<", "ExpressionTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Expressio...
Matches if this ExpressionTree refers to the same variable as the one passed into the matcher.
[ "Matches", "if", "this", "ExpressionTree", "refers", "to", "the", "same", "variable", "as", "the", "one", "passed", "into", "the", "matcher", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1275-L1282
21,755
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.enhancedForLoop
public static Matcher<EnhancedForLoopTree> enhancedForLoop( final Matcher<VariableTree> variableMatcher, final Matcher<ExpressionTree> expressionMatcher, final Matcher<StatementTree> statementMatcher) { return new Matcher<EnhancedForLoopTree>() { @Override public boolean matches(Enhanc...
java
public static Matcher<EnhancedForLoopTree> enhancedForLoop( final Matcher<VariableTree> variableMatcher, final Matcher<ExpressionTree> expressionMatcher, final Matcher<StatementTree> statementMatcher) { return new Matcher<EnhancedForLoopTree>() { @Override public boolean matches(Enhanc...
[ "public", "static", "Matcher", "<", "EnhancedForLoopTree", ">", "enhancedForLoop", "(", "final", "Matcher", "<", "VariableTree", ">", "variableMatcher", ",", "final", "Matcher", "<", "ExpressionTree", ">", "expressionMatcher", ",", "final", "Matcher", "<", "Statemen...
Matches an enhanced for loop if all the given matchers match. @param variableMatcher The matcher to apply to the variable. @param expressionMatcher The matcher to apply to the expression. @param statementMatcher The matcher to apply to the statement.
[ "Matches", "an", "enhanced", "for", "loop", "if", "all", "the", "given", "matchers", "match", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1301-L1313
21,756
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.inLoop
public static <T extends Tree> Matcher<T> inLoop() { return new Matcher<T>() { @Override public boolean matches(Tree tree, VisitorState state) { TreePath path = state.getPath().getParentPath(); Tree node = path.getLeaf(); while (path != null) { switch (node.getKind()) {...
java
public static <T extends Tree> Matcher<T> inLoop() { return new Matcher<T>() { @Override public boolean matches(Tree tree, VisitorState state) { TreePath path = state.getPath().getParentPath(); Tree node = path.getLeaf(); while (path != null) { switch (node.getKind()) {...
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "inLoop", "(", ")", "{", "return", "new", "Matcher", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "Tree", "tree", ",", "VisitorStat...
Matches if the given tree is inside a loop.
[ "Matches", "if", "the", "given", "tree", "is", "inside", "a", "loop", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1316-L1341
21,757
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.assignment
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 variableM...
java
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 variableM...
[ "public", "static", "Matcher", "<", "AssignmentTree", ">", "assignment", "(", "final", "Matcher", "<", "ExpressionTree", ">", "variableMatcher", ",", "final", "Matcher", "<", "?", "super", "ExpressionTree", ">", "expressionMatcher", ")", "{", "return", "new", "M...
Matches an assignment operator AST node if both of the given matchers match. @param variableMatcher The matcher to apply to the variable. @param expressionMatcher The matcher to apply to the expression.
[ "Matches", "an", "assignment", "operator", "AST", "node", "if", "both", "of", "the", "given", "matchers", "match", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1349-L1359
21,758
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.typeCast
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) ...
java
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) ...
[ "public", "static", "Matcher", "<", "TypeCastTree", ">", "typeCast", "(", "final", "Matcher", "<", "Tree", ">", "typeMatcher", ",", "final", "Matcher", "<", "ExpressionTree", ">", "expressionMatcher", ")", "{", "return", "new", "Matcher", "<", "TypeCastTree", ...
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.
[ "Matches", "a", "type", "cast", "AST", "node", "if", "both", "of", "the", "given", "matchers", "match", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1367-L1376
21,759
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.assertionWithCondition
public static Matcher<AssertTree> assertionWithCondition( final Matcher<ExpressionTree> conditionMatcher) { return new Matcher<AssertTree>() { @Override public boolean matches(AssertTree tree, VisitorState state) { return conditionMatcher.matches(tree.getCondition(), state); } };...
java
public static Matcher<AssertTree> assertionWithCondition( final Matcher<ExpressionTree> conditionMatcher) { return new Matcher<AssertTree>() { @Override public boolean matches(AssertTree tree, VisitorState state) { return conditionMatcher.matches(tree.getCondition(), state); } };...
[ "public", "static", "Matcher", "<", "AssertTree", ">", "assertionWithCondition", "(", "final", "Matcher", "<", "ExpressionTree", ">", "conditionMatcher", ")", "{", "return", "new", "Matcher", "<", "AssertTree", ">", "(", ")", "{", "@", "Override", "public", "b...
Matches an assertion AST node if the given matcher matches its condition. @param conditionMatcher The matcher to apply to the condition in the assertion, e.g. in "assert false", the "false" part of the statement
[ "Matches", "an", "assertion", "AST", "node", "if", "the", "given", "matcher", "matches", "its", "condition", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1384-L1392
21,760
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.contains
public static <T extends Tree, V extends Tree> Matcher<T> contains( Class<V> clazz, Matcher<V> treeMatcher) { final Matcher<Tree> contains = new Contains(toType(clazz, treeMatcher)); return contains::matches; }
java
public static <T extends Tree, V extends Tree> Matcher<T> contains( Class<V> clazz, Matcher<V> treeMatcher) { final Matcher<Tree> contains = new Contains(toType(clazz, treeMatcher)); return contains::matches; }
[ "public", "static", "<", "T", "extends", "Tree", ",", "V", "extends", "Tree", ">", "Matcher", "<", "T", ">", "contains", "(", "Class", "<", "V", ">", "clazz", ",", "Matcher", "<", "V", ">", "treeMatcher", ")", "{", "final", "Matcher", "<", "Tree", ...
Applies the given matcher recursively to all descendants of an AST node, and matches if any matching descendant node is found. @param clazz The type of node to be matched. @param treeMatcher The matcher to apply recursively to the tree.
[ "Applies", "the", "given", "matcher", "recursively", "to", "all", "descendants", "of", "an", "AST", "node", "and", "matches", "if", "any", "matching", "descendant", "node", "is", "found", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1411-L1415
21,761
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.methodHasArity
public static Matcher<MethodTree> methodHasArity(final int arity) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return methodTree.getParameters().size() == arity; } }; }
java
public static Matcher<MethodTree> methodHasArity(final int arity) { return new Matcher<MethodTree>() { @Override public boolean matches(MethodTree methodTree, VisitorState state) { return methodTree.getParameters().size() == arity; } }; }
[ "public", "static", "Matcher", "<", "MethodTree", ">", "methodHasArity", "(", "final", "int", "arity", ")", "{", "return", "new", "Matcher", "<", "MethodTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "MethodTree", "methodTre...
Matches if the method accepts the given number of arguments. @param arity the number of arguments the method should accept
[ "Matches", "if", "the", "method", "accepts", "the", "given", "number", "of", "arguments", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1422-L1429
21,762
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.isDirectImplementationOf
public static Matcher<ClassTree> isDirectImplementationOf(String clazz) { Matcher<Tree> isProvidedType = isSameType(clazz); return new IsDirectImplementationOf(isProvidedType); }
java
public static Matcher<ClassTree> isDirectImplementationOf(String clazz) { Matcher<Tree> isProvidedType = isSameType(clazz); return new IsDirectImplementationOf(isProvidedType); }
[ "public", "static", "Matcher", "<", "ClassTree", ">", "isDirectImplementationOf", "(", "String", "clazz", ")", "{", "Matcher", "<", "Tree", ">", "isProvidedType", "=", "isSameType", "(", "clazz", ")", ";", "return", "new", "IsDirectImplementationOf", "(", "isPro...
Matches any node that is directly an implementation, but not extension, of the given Class. <p>E.x. {@code class C implements I} will match, but {@code class C extends A} will not. <p>Additionally, this will only match <i>direct</i> implementations of interfaces. E.g. the following will not match: <p>{@code interfac...
[ "Matches", "any", "node", "that", "is", "directly", "an", "implementation", "but", "not", "extension", "of", "the", "given", "Class", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1442-L1445
21,763
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.packageMatches
public static <T extends Tree> Matcher<T> packageMatches(Pattern pattern) { return (tree, state) -> pattern.matcher(getPackageFullName(state)).matches(); }
java
public static <T extends Tree> Matcher<T> packageMatches(Pattern pattern) { return (tree, state) -> pattern.matcher(getPackageFullName(state)).matches(); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "packageMatches", "(", "Pattern", "pattern", ")", "{", "return", "(", "tree", ",", "state", ")", "->", "pattern", ".", "matcher", "(", "getPackageFullName", "(", "state", ")"...
Matches an AST node whose compilation unit's package name matches the given pattern.
[ "Matches", "an", "AST", "node", "whose", "compilation", "unit", "s", "package", "name", "matches", "the", "given", "pattern", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1476-L1478
21,764
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.packageStartsWith
public static <T extends Tree> Matcher<T> packageStartsWith(String prefix) { return (tree, state) -> getPackageFullName(state).startsWith(prefix); }
java
public static <T extends Tree> Matcher<T> packageStartsWith(String prefix) { return (tree, state) -> getPackageFullName(state).startsWith(prefix); }
[ "public", "static", "<", "T", "extends", "Tree", ">", "Matcher", "<", "T", ">", "packageStartsWith", "(", "String", "prefix", ")", "{", "return", "(", "tree", ",", "state", ")", "->", "getPackageFullName", "(", "state", ")", ".", "startsWith", "(", "pref...
Matches an AST node whose compilation unit starts with this prefix.
[ "Matches", "an", "AST", "node", "whose", "compilation", "unit", "starts", "with", "this", "prefix", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1481-L1483
21,765
google/error-prone
core/src/main/java/com/google/errorprone/refaster/UTry.java
UTry.inlineFinallyBlock
@Nullable private JCBlock inlineFinallyBlock(Inliner inliner) throws CouldNotResolveImportException { if (getFinallyBlock() != null) { JCBlock block = getFinallyBlock().inline(inliner); if (!block.getStatements().isEmpty()) { return block; } } return null; }
java
@Nullable private JCBlock inlineFinallyBlock(Inliner inliner) throws CouldNotResolveImportException { if (getFinallyBlock() != null) { JCBlock block = getFinallyBlock().inline(inliner); if (!block.getStatements().isEmpty()) { return block; } } return null; }
[ "@", "Nullable", "private", "JCBlock", "inlineFinallyBlock", "(", "Inliner", "inliner", ")", "throws", "CouldNotResolveImportException", "{", "if", "(", "getFinallyBlock", "(", ")", "!=", "null", ")", "{", "JCBlock", "block", "=", "getFinallyBlock", "(", ")", "....
Skips the finally block if the result would be empty.
[ "Skips", "the", "finally", "block", "if", "the", "result", "would", "be", "empty", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/UTry.java#L81-L90
21,766
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/inject/dagger/RefersToDaggerCodegen.java
RefersToDaggerCodegen.isGeneratedFactoryType
private static boolean isGeneratedFactoryType(ClassSymbol symbol, VisitorState state) { // TODO(ronshapiro): check annotation creators, inaccessible map key proxies, or inaccessible // module constructor proxies? return GENERATED_BASE_TYPES.stream() .anyMatch(baseType -> isGeneratedBaseType(symbol, ...
java
private static boolean isGeneratedFactoryType(ClassSymbol symbol, VisitorState state) { // TODO(ronshapiro): check annotation creators, inaccessible map key proxies, or inaccessible // module constructor proxies? return GENERATED_BASE_TYPES.stream() .anyMatch(baseType -> isGeneratedBaseType(symbol, ...
[ "private", "static", "boolean", "isGeneratedFactoryType", "(", "ClassSymbol", "symbol", ",", "VisitorState", "state", ")", "{", "// TODO(ronshapiro): check annotation creators, inaccessible map key proxies, or inaccessible", "// module constructor proxies?", "return", "GENERATED_BASE_T...
instead of checking for subtypes of generated code
[ "instead", "of", "checking", "for", "subtypes", "of", "generated", "code" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/inject/dagger/RefersToDaggerCodegen.java#L93-L98
21,767
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableAnalysis.java
ImmutableAnalysis.areFieldsImmutable
Violation areFieldsImmutable( Optional<ClassTree> tree, ImmutableSet<String> immutableTyParams, ClassType classType, ViolationReporter reporter) { ClassSymbol classSym = (ClassSymbol) classType.tsym; if (classSym.members() == null) { return Violation.absent(); } Filter<Symb...
java
Violation areFieldsImmutable( Optional<ClassTree> tree, ImmutableSet<String> immutableTyParams, ClassType classType, ViolationReporter reporter) { ClassSymbol classSym = (ClassSymbol) classType.tsym; if (classSym.members() == null) { return Violation.absent(); } Filter<Symb...
[ "Violation", "areFieldsImmutable", "(", "Optional", "<", "ClassTree", ">", "tree", ",", "ImmutableSet", "<", "String", ">", "immutableTyParams", ",", "ClassType", "classType", ",", "ViolationReporter", "reporter", ")", "{", "ClassSymbol", "classSym", "=", "(", "Cl...
Check a single class' fields for immutability. @param immutableTyParams the in-scope immutable type parameters @param classType the type to check the fields of
[ "Check", "a", "single", "class", "fields", "for", "immutability", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableAnalysis.java#L222-L261
21,768
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableAnalysis.java
ImmutableAnalysis.isFieldImmutable
private Violation isFieldImmutable( Optional<Tree> tree, ImmutableSet<String> immutableTyParams, ClassSymbol classSym, ClassType classType, VarSymbol var, ViolationReporter reporter) { if (bugChecker.isSuppressed(var)) { return Violation.absent(); } if (!var.getModi...
java
private Violation isFieldImmutable( Optional<Tree> tree, ImmutableSet<String> immutableTyParams, ClassSymbol classSym, ClassType classType, VarSymbol var, ViolationReporter reporter) { if (bugChecker.isSuppressed(var)) { return Violation.absent(); } if (!var.getModi...
[ "private", "Violation", "isFieldImmutable", "(", "Optional", "<", "Tree", ">", "tree", ",", "ImmutableSet", "<", "String", ">", "immutableTyParams", ",", "ClassSymbol", "classSym", ",", "ClassType", "classType", ",", "VarSymbol", "var", ",", "ViolationReporter", "...
Check a single field for immutability.
[ "Check", "a", "single", "field", "for", "immutability", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableAnalysis.java#L264-L311
21,769
google/error-prone
core/src/main/java/com/google/errorprone/ErrorProneCompiler.java
ErrorProneCompiler.compile
public static Result compile(DiagnosticListener<JavaFileObject> listener, String[] args) { return ErrorProneCompiler.builder().listenToDiagnostics(listener).build().run(args); }
java
public static Result compile(DiagnosticListener<JavaFileObject> listener, String[] args) { return ErrorProneCompiler.builder().listenToDiagnostics(listener).build().run(args); }
[ "public", "static", "Result", "compile", "(", "DiagnosticListener", "<", "JavaFileObject", ">", "listener", ",", "String", "[", "]", "args", ")", "{", "return", "ErrorProneCompiler", ".", "builder", "(", ")", ".", "listenToDiagnostics", "(", "listener", ")", "...
Compiles in-process. @param listener listens to the diagnostics produced by error-prone @param args the same args which would be passed to javac on the command line @return result from the compiler invocation
[ "Compiles", "in", "-", "process", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/ErrorProneCompiler.java#L57-L59
21,770
google/error-prone
core/src/main/java/com/google/errorprone/ErrorProneCompiler.java
ErrorProneCompiler.compile
public static Result compile(String[] args, PrintWriter out) { return ErrorProneCompiler.builder().redirectOutputTo(out).build().run(args); }
java
public static Result compile(String[] args, PrintWriter out) { return ErrorProneCompiler.builder().redirectOutputTo(out).build().run(args); }
[ "public", "static", "Result", "compile", "(", "String", "[", "]", "args", ",", "PrintWriter", "out", ")", "{", "return", "ErrorProneCompiler", ".", "builder", "(", ")", ".", "redirectOutputTo", "(", "out", ")", ".", "build", "(", ")", ".", "run", "(", ...
Programmatic interface to the error-prone Java compiler. @param args the same args which would be passed to javac on the command line @param out a {@link PrintWriter} to which to send diagnostic output @return result from the compiler invocation
[ "Programmatic", "interface", "to", "the", "error", "-", "prone", "Java", "compiler", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/ErrorProneCompiler.java#L78-L80
21,771
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/AbstractReturnValueIgnored.java
AbstractReturnValueIgnored.functionalInterfaceReturnsExactlyVoid
private static boolean functionalInterfaceReturnsExactlyVoid( Type interfaceType, VisitorState state) { return state.getTypes().findDescriptorType(interfaceType).getReturnType().getKind() == TypeKind.VOID; }
java
private static boolean functionalInterfaceReturnsExactlyVoid( Type interfaceType, VisitorState state) { return state.getTypes().findDescriptorType(interfaceType).getReturnType().getKind() == TypeKind.VOID; }
[ "private", "static", "boolean", "functionalInterfaceReturnsExactlyVoid", "(", "Type", "interfaceType", ",", "VisitorState", "state", ")", "{", "return", "state", ".", "getTypes", "(", ")", ".", "findDescriptorType", "(", "interfaceType", ")", ".", "getReturnType", "...
Checks that the return value of a functional interface is void. Note, we do not use ASTHelpers.isVoidType here, return values of Void are actually type-checked. Only void-returning functions silently ignore return values of any type.
[ "Checks", "that", "the", "return", "value", "of", "a", "functional", "interface", "is", "void", ".", "Note", "we", "do", "not", "use", "ASTHelpers", ".", "isVoidType", "here", "return", "values", "of", "Void", "are", "actually", "type", "-", "checked", "."...
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AbstractReturnValueIgnored.java#L124-L128
21,772
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/formatstring/FormatStringAnnotationChecker.java
FormatStringAnnotationChecker.matchInvocation
private Description matchInvocation( ExpressionTree tree, MethodSymbol symbol, List<? extends ExpressionTree> args, VisitorState state) { if (!ASTHelpers.hasAnnotation(symbol, FormatMethod.class, state)) { return Description.NO_MATCH; } Type stringType = state.getSymtab().stri...
java
private Description matchInvocation( ExpressionTree tree, MethodSymbol symbol, List<? extends ExpressionTree> args, VisitorState state) { if (!ASTHelpers.hasAnnotation(symbol, FormatMethod.class, state)) { return Description.NO_MATCH; } Type stringType = state.getSymtab().stri...
[ "private", "Description", "matchInvocation", "(", "ExpressionTree", "tree", ",", "MethodSymbol", "symbol", ",", "List", "<", "?", "extends", "ExpressionTree", ">", "args", ",", "VisitorState", "state", ")", "{", "if", "(", "!", "ASTHelpers", ".", "hasAnnotation"...
Matches a method or constructor invocation. The input symbol should match the invoked method or contructor and the args should be the parameters in the invocation.
[ "Matches", "a", "method", "or", "constructor", "invocation", ".", "The", "input", "symbol", "should", "match", "the", "invoked", "method", "or", "contructor", "and", "the", "args", "should", "be", "the", "parameters", "in", "the", "invocation", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/formatstring/FormatStringAnnotationChecker.java#L54-L92
21,773
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/StaticImports.java
StaticImports.lookup
private static ImmutableSet<Symbol> lookup( Symbol.TypeSymbol typeSym, Symbol.TypeSymbol start, Name identifier, Types types, Symbol.PackageSymbol pkg) { if (typeSym == null) { return ImmutableSet.of(); } ImmutableSet.Builder<Symbol> members = ImmutableSet.builder(); ...
java
private static ImmutableSet<Symbol> lookup( Symbol.TypeSymbol typeSym, Symbol.TypeSymbol start, Name identifier, Types types, Symbol.PackageSymbol pkg) { if (typeSym == null) { return ImmutableSet.of(); } ImmutableSet.Builder<Symbol> members = ImmutableSet.builder(); ...
[ "private", "static", "ImmutableSet", "<", "Symbol", ">", "lookup", "(", "Symbol", ".", "TypeSymbol", "typeSym", ",", "Symbol", ".", "TypeSymbol", "start", ",", "Name", "identifier", ",", "Types", "types", ",", "Symbol", ".", "PackageSymbol", "pkg", ")", "{",...
to filter on method signature.
[ "to", "filter", "on", "method", "signature", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/StaticImports.java#L166-L208
21,774
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Costs.java
Costs.invalidateAllAlternatives
void invalidateAllAlternatives(Parameter formal) { for (int actualIndex = 0; actualIndex < costMatrix[formal.index()].length; actualIndex++) { if (actualIndex != formal.index()) { costMatrix[formal.index()][actualIndex] = Double.POSITIVE_INFINITY; } } }
java
void invalidateAllAlternatives(Parameter formal) { for (int actualIndex = 0; actualIndex < costMatrix[formal.index()].length; actualIndex++) { if (actualIndex != formal.index()) { costMatrix[formal.index()][actualIndex] = Double.POSITIVE_INFINITY; } } }
[ "void", "invalidateAllAlternatives", "(", "Parameter", "formal", ")", "{", "for", "(", "int", "actualIndex", "=", "0", ";", "actualIndex", "<", "costMatrix", "[", "formal", ".", "index", "(", ")", "]", ".", "length", ";", "actualIndex", "++", ")", "{", "...
Set the cost of all the alternatives for this formal parameter to be Inf.
[ "Set", "the", "cost", "of", "all", "the", "alternatives", "for", "this", "formal", "parameter", "to", "be", "Inf", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Costs.java#L98-L104
21,775
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Costs.java
Costs.updatePair
void updatePair(ParameterPair p, double cost) { costMatrix[p.formal().index()][p.actual().index()] = cost; }
java
void updatePair(ParameterPair p, double cost) { costMatrix[p.formal().index()][p.actual().index()] = cost; }
[ "void", "updatePair", "(", "ParameterPair", "p", ",", "double", "cost", ")", "{", "costMatrix", "[", "p", ".", "formal", "(", ")", ".", "index", "(", ")", "]", "[", "p", ".", "actual", "(", ")", ".", "index", "(", ")", "]", "=", "cost", ";", "}...
Update the cost of the given pairing.
[ "Update", "the", "cost", "of", "the", "given", "pairing", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Costs.java#L107-L109
21,776
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.createForUtilityPurposes
public static VisitorState createForUtilityPurposes(Context context) { return new VisitorState( context, VisitorState::nullListener, ImmutableMap.of(), ErrorProneOptions.empty(), // Can't use this VisitorState to report results, so no-op collector. StatisticsCollector...
java
public static VisitorState createForUtilityPurposes(Context context) { return new VisitorState( context, VisitorState::nullListener, ImmutableMap.of(), ErrorProneOptions.empty(), // Can't use this VisitorState to report results, so no-op collector. StatisticsCollector...
[ "public", "static", "VisitorState", "createForUtilityPurposes", "(", "Context", "context", ")", "{", "return", "new", "VisitorState", "(", "context", ",", "VisitorState", "::", "nullListener", ",", "ImmutableMap", ".", "of", "(", ")", ",", "ErrorProneOptions", "."...
Return a VisitorState that has no Error Prone configuration, and can't report results. <p>If using this method, consider moving to using utility methods not needing VisitorSate
[ "Return", "a", "VisitorState", "that", "has", "no", "Error", "Prone", "configuration", "and", "can", "t", "report", "results", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L82-L93
21,777
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.createConfiguredForCompilation
public static VisitorState createConfiguredForCompilation( Context context, DescriptionListener listener, Map<String, SeverityLevel> severityMap, ErrorProneOptions errorProneOptions) { return new VisitorState( context, listener, severityMap, errorProneOptions,...
java
public static VisitorState createConfiguredForCompilation( Context context, DescriptionListener listener, Map<String, SeverityLevel> severityMap, ErrorProneOptions errorProneOptions) { return new VisitorState( context, listener, severityMap, errorProneOptions,...
[ "public", "static", "VisitorState", "createConfiguredForCompilation", "(", "Context", "context", ",", "DescriptionListener", "listener", ",", "Map", "<", "String", ",", "SeverityLevel", ">", "severityMap", ",", "ErrorProneOptions", "errorProneOptions", ")", "{", "return...
Return a VisitorState configured for a new compilation, including Error Prone configuration.
[ "Return", "a", "VisitorState", "configured", "for", "a", "new", "compilation", "including", "Error", "Prone", "configuration", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L115-L129
21,778
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.inferBinaryName
private static String inferBinaryName(String classname) { StringBuilder sb = new StringBuilder(); boolean first = true; char sep = '.'; for (String bit : Splitter.on('.').split(classname)) { if (!first) { sb.append(sep); } sb.append(bit); if (Character.isUpperCase(bit.cha...
java
private static String inferBinaryName(String classname) { StringBuilder sb = new StringBuilder(); boolean first = true; char sep = '.'; for (String bit : Splitter.on('.').split(classname)) { if (!first) { sb.append(sep); } sb.append(bit); if (Character.isUpperCase(bit.cha...
[ "private", "static", "String", "inferBinaryName", "(", "String", "classname", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "first", "=", "true", ";", "char", "sep", "=", "'", "'", ";", "for", "(", "String", "bit...
so it may not end up being a performance win.)
[ "so", "it", "may", "not", "end", "up", "being", "a", "performance", "win", ".", ")" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L406-L421
21,779
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.getType
public Type getType(Type baseType, boolean isArray, List<Type> typeParams) { boolean isGeneric = typeParams != null && !typeParams.isEmpty(); if (!isArray && !isGeneric) { // Simple type. return baseType; } else if (isArray && !isGeneric) { // Array type, not generic. ClassSymbol arr...
java
public Type getType(Type baseType, boolean isArray, List<Type> typeParams) { boolean isGeneric = typeParams != null && !typeParams.isEmpty(); if (!isArray && !isGeneric) { // Simple type. return baseType; } else if (isArray && !isGeneric) { // Array type, not generic. ClassSymbol arr...
[ "public", "Type", "getType", "(", "Type", "baseType", ",", "boolean", "isArray", ",", "List", "<", "Type", ">", "typeParams", ")", "{", "boolean", "isGeneric", "=", "typeParams", "!=", "null", "&&", "!", "typeParams", ".", "isEmpty", "(", ")", ";", "if",...
Build an instance of a Type.
[ "Build", "an", "instance", "of", "a", "Type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L424-L441
21,780
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.findEnclosing
@Nullable @SuppressWarnings("unchecked") // findPathToEnclosing guarantees that the type is from |classes| @SafeVarargs public final <T extends Tree> T findEnclosing(Class<? extends T>... classes) { TreePath pathToEnclosing = findPathToEnclosing(classes); return (pathToEnclosing == null) ? null : (T) path...
java
@Nullable @SuppressWarnings("unchecked") // findPathToEnclosing guarantees that the type is from |classes| @SafeVarargs public final <T extends Tree> T findEnclosing(Class<? extends T>... classes) { TreePath pathToEnclosing = findPathToEnclosing(classes); return (pathToEnclosing == null) ? null : (T) path...
[ "@", "Nullable", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "// findPathToEnclosing guarantees that the type is from |classes|", "@", "SafeVarargs", "public", "final", "<", "T", "extends", "Tree", ">", "T", "findEnclosing", "(", "Class", "<", "?", "extends", ...
Find the first enclosing tree node of one of the given types. @return the node, or {@code null} if there is no match
[ "Find", "the", "first", "enclosing", "tree", "node", "of", "one", "of", "the", "given", "types", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L474-L480
21,781
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.getSourceCode
@Nullable public CharSequence getSourceCode() { try { return getPath().getCompilationUnit().getSourceFile().getCharContent(false); } catch (IOException e) { return null; } }
java
@Nullable public CharSequence getSourceCode() { try { return getPath().getCompilationUnit().getSourceFile().getCharContent(false); } catch (IOException e) { return null; } }
[ "@", "Nullable", "public", "CharSequence", "getSourceCode", "(", ")", "{", "try", "{", "return", "getPath", "(", ")", ".", "getCompilationUnit", "(", ")", ".", "getSourceFile", "(", ")", ".", "getCharContent", "(", "false", ")", ";", "}", "catch", "(", "...
Gets the current source file. @return the source file as a sequence of characters, or null if it is not available
[ "Gets", "the", "current", "source", "file", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L487-L494
21,782
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.getSourceForNode
@Nullable public String getSourceForNode(Tree tree) { JCTree node = (JCTree) tree; int start = node.getStartPosition(); int end = getEndPosition(node); if (end < 0) { return null; } return getSourceCode().subSequence(start, end).toString(); }
java
@Nullable public String getSourceForNode(Tree tree) { JCTree node = (JCTree) tree; int start = node.getStartPosition(); int end = getEndPosition(node); if (end < 0) { return null; } return getSourceCode().subSequence(start, end).toString(); }
[ "@", "Nullable", "public", "String", "getSourceForNode", "(", "Tree", "tree", ")", "{", "JCTree", "node", "=", "(", "JCTree", ")", "tree", ";", "int", "start", "=", "node", ".", "getStartPosition", "(", ")", ";", "int", "end", "=", "getEndPosition", "(",...
Gets the original source code that represents the given node. <p>Note that this may be different from what is returned by calling .toString() on the node. This returns exactly what is in the source code, whereas .toString() pretty-prints the node from its AST representation. @return the source code that represents th...
[ "Gets", "the", "original", "source", "code", "that", "represents", "the", "given", "node", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L505-L514
21,783
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.getEndPosition
public int getEndPosition(Tree node) { JCCompilationUnit compilationUnit = (JCCompilationUnit) getPath().getCompilationUnit(); if (compilationUnit.endPositions == null) { return -1; } return ((JCTree) node).getEndPosition(compilationUnit.endPositions); }
java
public int getEndPosition(Tree node) { JCCompilationUnit compilationUnit = (JCCompilationUnit) getPath().getCompilationUnit(); if (compilationUnit.endPositions == null) { return -1; } return ((JCTree) node).getEndPosition(compilationUnit.endPositions); }
[ "public", "int", "getEndPosition", "(", "Tree", "node", ")", "{", "JCCompilationUnit", "compilationUnit", "=", "(", "JCCompilationUnit", ")", "getPath", "(", ")", ".", "getCompilationUnit", "(", ")", ";", "if", "(", "compilationUnit", ".", "endPositions", "==", ...
Returns the end position of the node, or -1 if it is not available.
[ "Returns", "the", "end", "position", "of", "the", "node", "or", "-", "1", "if", "it", "is", "not", "available", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L527-L533
21,784
google/error-prone
check_api/src/main/java/com/google/errorprone/VisitorState.java
VisitorState.validateTypeStr
private static void validateTypeStr(String typeStr) { if (typeStr.contains("[") || typeStr.contains("]")) { throw new IllegalArgumentException( String.format( "Cannot convert array types (%s), please build them using getType()", typeStr)); } if (typeStr.contains("<") || typeStr...
java
private static void validateTypeStr(String typeStr) { if (typeStr.contains("[") || typeStr.contains("]")) { throw new IllegalArgumentException( String.format( "Cannot convert array types (%s), please build them using getType()", typeStr)); } if (typeStr.contains("<") || typeStr...
[ "private", "static", "void", "validateTypeStr", "(", "String", "typeStr", ")", "{", "if", "(", "typeStr", ".", "contains", "(", "\"[\"", ")", "||", "typeStr", ".", "contains", "(", "\"]\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "S...
Validates a type string, ensuring it is not generic and not an array type.
[ "Validates", "a", "type", "string", "ensuring", "it", "is", "not", "generic", "and", "not", "an", "array", "type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/VisitorState.java#L536-L547
21,785
google/error-prone
check_api/src/main/java/com/google/errorprone/util/Reachability.java
Reachability.canCompleteNormally
public static boolean canCompleteNormally(CaseTree caseTree) { List<? extends StatementTree> statements = caseTree.getStatements(); if (statements.isEmpty()) { return true; } // We only care whether the last statement completes; javac would have already // reported an error if that statement w...
java
public static boolean canCompleteNormally(CaseTree caseTree) { List<? extends StatementTree> statements = caseTree.getStatements(); if (statements.isEmpty()) { return true; } // We only care whether the last statement completes; javac would have already // reported an error if that statement w...
[ "public", "static", "boolean", "canCompleteNormally", "(", "CaseTree", "caseTree", ")", "{", "List", "<", "?", "extends", "StatementTree", ">", "statements", "=", "caseTree", ".", "getStatements", "(", ")", ";", "if", "(", "statements", ".", "isEmpty", "(", ...
Returns true if the given case tree can complete normally, as defined by JLS 14.21. <p>An exception is made for {@code System.exit}, which cannot complete normally in practice.
[ "Returns", "true", "if", "the", "given", "case", "tree", "can", "complete", "normally", "as", "defined", "by", "JLS", "14", ".", "21", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/Reachability.java#L74-L84
21,786
google/error-prone
check_api/src/main/java/com/google/errorprone/BaseErrorProneJavaCompiler.java
BaseErrorProneJavaCompiler.setupMessageBundle
public static void setupMessageBundle(Context context) { ResourceBundle bundle = ResourceBundle.getBundle("com.google.errorprone.errors"); JavacMessages.instance(context).add(l -> bundle); }
java
public static void setupMessageBundle(Context context) { ResourceBundle bundle = ResourceBundle.getBundle("com.google.errorprone.errors"); JavacMessages.instance(context).add(l -> bundle); }
[ "public", "static", "void", "setupMessageBundle", "(", "Context", "context", ")", "{", "ResourceBundle", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "\"com.google.errorprone.errors\"", ")", ";", "JavacMessages", ".", "instance", "(", "context", ")", ".",...
Registers our message bundle.
[ "Registers", "our", "message", "bundle", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/BaseErrorProneJavaCompiler.java#L200-L203
21,787
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/NamedParameterComment.java
NamedParameterComment.match
static MatchedComment match(Commented<ExpressionTree> actual, String formal) { Optional<Comment> lastBlockComment = Streams.findLast( actual.beforeComments().stream().filter(c -> c.getStyle() == CommentStyle.BLOCK)); if (lastBlockComment.isPresent()) { Matcher m = PARAMETER_...
java
static MatchedComment match(Commented<ExpressionTree> actual, String formal) { Optional<Comment> lastBlockComment = Streams.findLast( actual.beforeComments().stream().filter(c -> c.getStyle() == CommentStyle.BLOCK)); if (lastBlockComment.isPresent()) { Matcher m = PARAMETER_...
[ "static", "MatchedComment", "match", "(", "Commented", "<", "ExpressionTree", ">", "actual", ",", "String", "formal", ")", "{", "Optional", "<", "Comment", ">", "lastBlockComment", "=", "Streams", ".", "findLast", "(", "actual", ".", "beforeComments", "(", ")"...
Determine the kind of match we have between the comments on this argument and the formal parameter name.
[ "Determine", "the", "kind", "of", "match", "we", "have", "between", "the", "comments", "on", "this", "argument", "and", "the", "formal", "parameter", "name", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/NamedParameterComment.java#L131-L165
21,788
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/NamedParameterComment.java
NamedParameterComment.containsSyntheticParameterName
public static boolean containsSyntheticParameterName(MethodSymbol sym) { return sym.getParameters().stream() .anyMatch(p -> SYNTHETIC_PARAMETER_NAME.matcher(p.getSimpleName()).matches()); }
java
public static boolean containsSyntheticParameterName(MethodSymbol sym) { return sym.getParameters().stream() .anyMatch(p -> SYNTHETIC_PARAMETER_NAME.matcher(p.getSimpleName()).matches()); }
[ "public", "static", "boolean", "containsSyntheticParameterName", "(", "MethodSymbol", "sym", ")", "{", "return", "sym", ".", "getParameters", "(", ")", ".", "stream", "(", ")", ".", "anyMatch", "(", "p", "->", "SYNTHETIC_PARAMETER_NAME", ".", "matcher", "(", "...
Returns true if the method has synthetic parameter names, indicating the real names are not available.
[ "Returns", "true", "if", "the", "method", "has", "synthetic", "parameter", "names", "indicating", "the", "real", "names", "are", "not", "available", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/NamedParameterComment.java#L185-L188
21,789
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/AnnotationPosition.java
AnnotationPosition.checkAnnotations
private Description checkAnnotations( Tree tree, int treePos, List<? extends AnnotationTree> annotations, Comment danglingJavadoc, int firstModifierPos, int lastModifierPos, VisitorState state) { SuggestedFix.Builder builder = SuggestedFix.builder(); List<AnnotationTree...
java
private Description checkAnnotations( Tree tree, int treePos, List<? extends AnnotationTree> annotations, Comment danglingJavadoc, int firstModifierPos, int lastModifierPos, VisitorState state) { SuggestedFix.Builder builder = SuggestedFix.builder(); List<AnnotationTree...
[ "private", "Description", "checkAnnotations", "(", "Tree", "tree", ",", "int", "treePos", ",", "List", "<", "?", "extends", "AnnotationTree", ">", "annotations", ",", "Comment", "danglingJavadoc", ",", "int", "firstModifierPos", ",", "int", "lastModifierPos", ",",...
Checks that annotations are on the right side of the modifiers.
[ "Checks", "that", "annotations", "are", "on", "the", "right", "side", "of", "the", "modifiers", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AnnotationPosition.java#L178-L245
21,790
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/AnnotationMatcherUtils.java
AnnotationMatcherUtils.getArgument
@Nullable public static ExpressionTree getArgument(AnnotationTree annotationTree, String name) { for (ExpressionTree argumentTree : annotationTree.getArguments()) { if (argumentTree.getKind() != Tree.Kind.ASSIGNMENT) { continue; } AssignmentTree assignmentTree = (AssignmentTree) argument...
java
@Nullable public static ExpressionTree getArgument(AnnotationTree annotationTree, String name) { for (ExpressionTree argumentTree : annotationTree.getArguments()) { if (argumentTree.getKind() != Tree.Kind.ASSIGNMENT) { continue; } AssignmentTree assignmentTree = (AssignmentTree) argument...
[ "@", "Nullable", "public", "static", "ExpressionTree", "getArgument", "(", "AnnotationTree", "annotationTree", ",", "String", "name", ")", "{", "for", "(", "ExpressionTree", "argumentTree", ":", "annotationTree", ".", "getArguments", "(", ")", ")", "{", "if", "(...
Gets the value for an argument, or null if the argument does not exist. @param annotationTree the AST node for the annotation @param name the name of the argument whose value to get @return the value of the argument, or null if the argument does not exist
[ "Gets", "the", "value", "for", "an", "argument", "or", "null", "if", "the", "argument", "does", "not", "exist", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/AnnotationMatcherUtils.java#L39-L53
21,791
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/EnclosedByReverseHeuristic.java
EnclosedByReverseHeuristic.isAcceptableChange
@Override public boolean isAcceptableChange( Changes changes, Tree node, MethodSymbol symbol, VisitorState state) { return findReverseWordsMatchInParentNodes(state) == null; }
java
@Override public boolean isAcceptableChange( Changes changes, Tree node, MethodSymbol symbol, VisitorState state) { return findReverseWordsMatchInParentNodes(state) == null; }
[ "@", "Override", "public", "boolean", "isAcceptableChange", "(", "Changes", "changes", ",", "Tree", "node", ",", "MethodSymbol", "symbol", ",", "VisitorState", "state", ")", "{", "return", "findReverseWordsMatchInParentNodes", "(", "state", ")", "==", "null", ";",...
Return true if this call is not enclosed in a method call about reversing things
[ "Return", "true", "if", "this", "call", "is", "not", "enclosed", "in", "a", "method", "call", "about", "reversing", "things" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/EnclosedByReverseHeuristic.java#L71-L75
21,792
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/UnsynchronizedOverridesSynchronized.java
UnsynchronizedOverridesSynchronized.ignore
private static boolean ignore(MethodTree method, VisitorState state) { return firstNonNull( new TreeScanner<Boolean, Void>() { @Override public Boolean visitBlock(BlockTree tree, Void unused) { switch (tree.getStatements().size()) { case 0: retur...
java
private static boolean ignore(MethodTree method, VisitorState state) { return firstNonNull( new TreeScanner<Boolean, Void>() { @Override public Boolean visitBlock(BlockTree tree, Void unused) { switch (tree.getStatements().size()) { case 0: retur...
[ "private", "static", "boolean", "ignore", "(", "MethodTree", "method", ",", "VisitorState", "state", ")", "{", "return", "firstNonNull", "(", "new", "TreeScanner", "<", "Boolean", ",", "Void", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "visitB...
Don't flag methods that are empty or trivially delegate to a super-implementation.
[ "Don", "t", "flag", "methods", "that", "are", "empty", "or", "trivially", "delegate", "to", "a", "super", "-", "implementation", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/UnsynchronizedOverridesSynchronized.java#L88-L136
21,793
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/UnnecessaryTypeArgument.java
UnnecessaryTypeArgument.buildFix
private Fix buildFix(Tree tree, List<? extends Tree> arguments, VisitorState state) { JCTree node = (JCTree) tree; int startAbsolute = node.getStartPosition(); int lower = ((JCTree) arguments.get(0)).getStartPosition() - startAbsolute; int upper = state.getEndPosition(arguments.get(arguments.size() - 1...
java
private Fix buildFix(Tree tree, List<? extends Tree> arguments, VisitorState state) { JCTree node = (JCTree) tree; int startAbsolute = node.getStartPosition(); int lower = ((JCTree) arguments.get(0)).getStartPosition() - startAbsolute; int upper = state.getEndPosition(arguments.get(arguments.size() - 1...
[ "private", "Fix", "buildFix", "(", "Tree", "tree", ",", "List", "<", "?", "extends", "Tree", ">", "arguments", ",", "VisitorState", "state", ")", "{", "JCTree", "node", "=", "(", "JCTree", ")", "tree", ";", "int", "startAbsolute", "=", "node", ".", "ge...
Constructor a fix that deletes the set of type arguments.
[ "Constructor", "a", "fix", "that", "deletes", "the", "set", "of", "type", "arguments", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/UnnecessaryTypeArgument.java#L84-L107
21,794
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/collectionincompatibletype/CompatibleWithMisuse.java
CompatibleWithMisuse.valueArgumentFromCompatibleWithAnnotation
private String valueArgumentFromCompatibleWithAnnotation(AnnotationTree tree) { ExpressionTree argumentValue = Iterables.getOnlyElement(tree.getArguments()); if (argumentValue.getKind() != Kind.ASSIGNMENT) { // :-| Annotation symbol broken. Punt? return null; } return ASTHelpers.constValue(...
java
private String valueArgumentFromCompatibleWithAnnotation(AnnotationTree tree) { ExpressionTree argumentValue = Iterables.getOnlyElement(tree.getArguments()); if (argumentValue.getKind() != Kind.ASSIGNMENT) { // :-| Annotation symbol broken. Punt? return null; } return ASTHelpers.constValue(...
[ "private", "String", "valueArgumentFromCompatibleWithAnnotation", "(", "AnnotationTree", "tree", ")", "{", "ExpressionTree", "argumentValue", "=", "Iterables", ".", "getOnlyElement", "(", "tree", ".", "getArguments", "(", ")", ")", ";", "if", "(", "argumentValue", "...
is required.
[ "is", "required", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/collectionincompatibletype/CompatibleWithMisuse.java#L127-L135
21,795
google/error-prone
core/src/main/java/com/google/errorprone/refaster/Choice.java
Choice.fromOptional
public static <T> Choice<T> fromOptional(Optional<T> optional) { return optional.isPresent() ? of(optional.get()) : Choice.<T>none(); }
java
public static <T> Choice<T> fromOptional(Optional<T> optional) { return optional.isPresent() ? of(optional.get()) : Choice.<T>none(); }
[ "public", "static", "<", "T", ">", "Choice", "<", "T", ">", "fromOptional", "(", "Optional", "<", "T", ">", "optional", ")", "{", "return", "optional", ".", "isPresent", "(", ")", "?", "of", "(", "optional", ".", "get", "(", ")", ")", ":", "Choice"...
Returns a choice of the optional value, if it is present, or the empty choice if it is absent.
[ "Returns", "a", "choice", "of", "the", "optional", "value", "if", "it", "is", "present", "or", "the", "empty", "choice", "if", "it", "is", "absent", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/Choice.java#L151-L153
21,796
google/error-prone
core/src/main/java/com/google/errorprone/refaster/Choice.java
Choice.any
public static <T> Choice<T> any(final Collection<Choice<T>> choices) { return from(choices).thenChoose(Functions.<Choice<T>>identity()); }
java
public static <T> Choice<T> any(final Collection<Choice<T>> choices) { return from(choices).thenChoose(Functions.<Choice<T>>identity()); }
[ "public", "static", "<", "T", ">", "Choice", "<", "T", ">", "any", "(", "final", "Collection", "<", "Choice", "<", "T", ">", ">", "choices", ")", "{", "return", "from", "(", "choices", ")", ".", "thenChoose", "(", "Functions", ".", "<", "Choice", "...
Returns a choice between any of the options from any of the specified choices.
[ "Returns", "a", "choice", "between", "any", "of", "the", "options", "from", "any", "of", "the", "specified", "choices", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/Choice.java#L177-L179
21,797
google/error-prone
core/src/main/java/com/google/errorprone/refaster/Choice.java
Choice.transform
public <R> Choice<R> transform(final Function<? super T, R> function) { checkNotNull(function); final Choice<T> thisChoice = this; return new Choice<R>() { @Override protected Iterator<R> iterator() { return Iterators.transform(thisChoice.iterator(), function); } }; }
java
public <R> Choice<R> transform(final Function<? super T, R> function) { checkNotNull(function); final Choice<T> thisChoice = this; return new Choice<R>() { @Override protected Iterator<R> iterator() { return Iterators.transform(thisChoice.iterator(), function); } }; }
[ "public", "<", "R", ">", "Choice", "<", "R", ">", "transform", "(", "final", "Function", "<", "?", "super", "T", ",", "R", ">", "function", ")", "{", "checkNotNull", "(", "function", ")", ";", "final", "Choice", "<", "T", ">", "thisChoice", "=", "t...
Maps the choices with the specified function.
[ "Maps", "the", "choices", "with", "the", "specified", "function", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/Choice.java#L248-L257
21,798
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ErrorProneTokens.java
ErrorProneTokens.getTokens
public static ImmutableList<ErrorProneToken> getTokens(String source, Context context) { return new ErrorProneTokens(source, context).getTokens(); }
java
public static ImmutableList<ErrorProneToken> getTokens(String source, Context context) { return new ErrorProneTokens(source, context).getTokens(); }
[ "public", "static", "ImmutableList", "<", "ErrorProneToken", ">", "getTokens", "(", "String", "source", ",", "Context", "context", ")", "{", "return", "new", "ErrorProneTokens", "(", "source", ",", "context", ")", ".", "getTokens", "(", ")", ";", "}" ]
Returns the tokens for the given source text, including comments.
[ "Returns", "the", "tokens", "for", "the", "given", "source", "text", "including", "comments", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ErrorProneTokens.java#L59-L61
21,799
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/inject/dagger/Util.java
Util.hasAnyParameter
private static Matcher<AnnotationTree> hasAnyParameter(String... parameters) { return anyOf( transform( asList(parameters), new Function<String, Matcher<AnnotationTree>>() { @Override public Matcher<AnnotationTree> apply(String parameter) { ...
java
private static Matcher<AnnotationTree> hasAnyParameter(String... parameters) { return anyOf( transform( asList(parameters), new Function<String, Matcher<AnnotationTree>>() { @Override public Matcher<AnnotationTree> apply(String parameter) { ...
[ "private", "static", "Matcher", "<", "AnnotationTree", ">", "hasAnyParameter", "(", "String", "...", "parameters", ")", "{", "return", "anyOf", "(", "transform", "(", "asList", "(", "parameters", ")", ",", "new", "Function", "<", "String", ",", "Matcher", "<...
Matches an annotation that has an argument for at least one of the given parameters.
[ "Matches", "an", "annotation", "that", "has", "an", "argument", "for", "at", "least", "one", "of", "the", "given", "parameters", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/inject/dagger/Util.java#L95-L105