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,600
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java
Menubar.addFile
public void addFile(String url) { int count = windowMenu.getItemCount(); JMenuItem item; if (count == 4) { windowMenu.addSeparator(); count++; } JMenuItem lastItem = windowMenu.getItem(count -1); boolean hasMoreWin = false; int maxWin = 5; ...
java
public void addFile(String url) { int count = windowMenu.getItemCount(); JMenuItem item; if (count == 4) { windowMenu.addSeparator(); count++; } JMenuItem lastItem = windowMenu.getItem(count -1); boolean hasMoreWin = false; int maxWin = 5; ...
[ "public", "void", "addFile", "(", "String", "url", ")", "{", "int", "count", "=", "windowMenu", ".", "getItemCount", "(", ")", ";", "JMenuItem", "item", ";", "if", "(", "count", "==", "4", ")", "{", "windowMenu", ".", "addSeparator", "(", ")", ";", "...
Adds a file to the window menu.
[ "Adds", "a", "file", "to", "the", "window", "menu", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java#L3551-L3587
21,601
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java
Menubar.updateEnabled
public void updateEnabled(boolean interrupted) { for (int i = 0; i != interruptOnlyItems.size(); ++i) { JMenuItem item = interruptOnlyItems.get(i); item.setEnabled(interrupted); } for (int i = 0; i != runOnlyItems.size(); ++i) { JMenuItem item = runOnlyItems....
java
public void updateEnabled(boolean interrupted) { for (int i = 0; i != interruptOnlyItems.size(); ++i) { JMenuItem item = interruptOnlyItems.get(i); item.setEnabled(interrupted); } for (int i = 0; i != runOnlyItems.size(); ++i) { JMenuItem item = runOnlyItems....
[ "public", "void", "updateEnabled", "(", "boolean", "interrupted", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "interruptOnlyItems", ".", "size", "(", ")", ";", "++", "i", ")", "{", "JMenuItem", "item", "=", "interruptOnlyItems", ".", "g...
Updates the enabledness of menu items.
[ "Updates", "the", "enabledness", "of", "menu", "items", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java#L3592-L3602
21,602
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java
RunProxy.run
@Override public void run() { switch (type) { case OPEN_FILE: try { debugGui.dim.compileScript(fileName, text); } catch (RuntimeException ex) { MessageDialogWrapper.showMessageDialog( debugGui, ex.getMessage(), "Error Comp...
java
@Override public void run() { switch (type) { case OPEN_FILE: try { debugGui.dim.compileScript(fileName, text); } catch (RuntimeException ex) { MessageDialogWrapper.showMessageDialog( debugGui, ex.getMessage(), "Error Comp...
[ "@", "Override", "public", "void", "run", "(", ")", "{", "switch", "(", "type", ")", "{", "case", "OPEN_FILE", ":", "try", "{", "debugGui", ".", "dim", ".", "compileScript", "(", "fileName", ",", "text", ")", ";", "}", "catch", "(", "RuntimeException",...
Runs this Runnable.
[ "Runs", "this", "Runnable", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java#L3670-L3711
21,603
mozilla/rhino
src/org/mozilla/javascript/NativeArray.java
NativeArray.toArrayIndex
private static long toArrayIndex(String id) { long index = toArrayIndex(ScriptRuntime.toNumber(id)); // Assume that ScriptRuntime.toString(index) is the same // as java.lang.Long.toString(index) for long if (Long.toString(index).equals(id)) { return index; } ...
java
private static long toArrayIndex(String id) { long index = toArrayIndex(ScriptRuntime.toNumber(id)); // Assume that ScriptRuntime.toString(index) is the same // as java.lang.Long.toString(index) for long if (Long.toString(index).equals(id)) { return index; } ...
[ "private", "static", "long", "toArrayIndex", "(", "String", "id", ")", "{", "long", "index", "=", "toArrayIndex", "(", "ScriptRuntime", ".", "toNumber", "(", "id", ")", ")", ";", "// Assume that ScriptRuntime.toString(index) is the same", "// as java.lang.Long.toString(...
otherwise return -1L
[ "otherwise", "return", "-", "1L" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeArray.java#L406-L415
21,604
mozilla/rhino
src/org/mozilla/javascript/NativeArray.java
NativeArray.jsConstructor
private static Object jsConstructor(Context cx, Scriptable scope, Object[] args) { if (args.length == 0) return new NativeArray(0); // Only use 1 arg as first element for version 1.2; for // any other version (including 1.3) follow ECMA an...
java
private static Object jsConstructor(Context cx, Scriptable scope, Object[] args) { if (args.length == 0) return new NativeArray(0); // Only use 1 arg as first element for version 1.2; for // any other version (including 1.3) follow ECMA an...
[ "private", "static", "Object", "jsConstructor", "(", "Context", "cx", ",", "Scriptable", "scope", ",", "Object", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "==", "0", ")", "return", "new", "NativeArray", "(", "0", ")", ";", "// Only ...
See ECMA 15.4.1,2
[ "See", "ECMA", "15", ".", "4", ".", "1", "2" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeArray.java#L620-L642
21,605
mozilla/rhino
src/org/mozilla/javascript/NativeArray.java
NativeArray.getRawElem
private static Object getRawElem(Scriptable target, long index) { if (index > Integer.MAX_VALUE) { return ScriptableObject.getProperty(target, Long.toString(index)); } return ScriptableObject.getProperty(target, (int)index); }
java
private static Object getRawElem(Scriptable target, long index) { if (index > Integer.MAX_VALUE) { return ScriptableObject.getProperty(target, Long.toString(index)); } return ScriptableObject.getProperty(target, (int)index); }
[ "private", "static", "Object", "getRawElem", "(", "Scriptable", "target", ",", "long", "index", ")", "{", "if", "(", "index", ">", "Integer", ".", "MAX_VALUE", ")", "{", "return", "ScriptableObject", ".", "getProperty", "(", "target", ",", "Long", ".", "to...
same as getElem, but without converting NOT_FOUND to undefined
[ "same", "as", "getElem", "but", "without", "converting", "NOT_FOUND", "to", "undefined" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeArray.java#L793-L798
21,606
mozilla/rhino
src/org/mozilla/javascript/NativeArray.java
NativeArray.js_join
private static String js_join(Context cx, Scriptable thisObj, Object[] args) { long llength = getLengthProperty(cx, thisObj, false); int length = (int)llength; if (llength != length) { throw Context.reportRuntimeError1( "msg.array...
java
private static String js_join(Context cx, Scriptable thisObj, Object[] args) { long llength = getLengthProperty(cx, thisObj, false); int length = (int)llength; if (llength != length) { throw Context.reportRuntimeError1( "msg.array...
[ "private", "static", "String", "js_join", "(", "Context", "cx", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ")", "{", "long", "llength", "=", "getLengthProperty", "(", "cx", ",", "thisObj", ",", "false", ")", ";", "int", "length", "=",...
See ECMA 15.4.4.3
[ "See", "ECMA", "15", ".", "4", ".", "4", ".", "3" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeArray.java#L931-L990
21,607
mozilla/rhino
src/org/mozilla/javascript/NativeArray.java
NativeArray.js_reverse
private static Scriptable js_reverse(Context cx, Scriptable thisObj, Object[] args) { if (thisObj instanceof NativeArray) { NativeArray na = (NativeArray) thisObj; if (na.denseOnly) { for (int i=0, j=((int)na.length)-1; i < j; i++,j--) { Object tem...
java
private static Scriptable js_reverse(Context cx, Scriptable thisObj, Object[] args) { if (thisObj instanceof NativeArray) { NativeArray na = (NativeArray) thisObj; if (na.denseOnly) { for (int i=0, j=((int)na.length)-1; i < j; i++,j--) { Object tem...
[ "private", "static", "Scriptable", "js_reverse", "(", "Context", "cx", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ")", "{", "if", "(", "thisObj", "instanceof", "NativeArray", ")", "{", "NativeArray", "na", "=", "(", "NativeArray", ")", ...
See ECMA 15.4.4.4
[ "See", "ECMA", "15", ".", "4", ".", "4", ".", "4" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeArray.java#L995-L1019
21,608
mozilla/rhino
src/org/mozilla/javascript/NativeArray.java
NativeArray.js_sort
private static Scriptable js_sort(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { final Comparator<Object> comparator; if (args.length > 0 && Undefined.instance != args[0]) { final Callable jsCompareFunction = ScriptRuntime ...
java
private static Scriptable js_sort(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { final Comparator<Object> comparator; if (args.length > 0 && Undefined.instance != args[0]) { final Callable jsCompareFunction = ScriptRuntime ...
[ "private", "static", "Scriptable", "js_sort", "(", "final", "Context", "cx", ",", "final", "Scriptable", "scope", ",", "final", "Scriptable", "thisObj", ",", "final", "Object", "[", "]", "args", ")", "{", "final", "Comparator", "<", "Object", ">", "comparato...
See ECMA 15.4.4.5
[ "See", "ECMA", "15", ".", "4", ".", "4", ".", "5" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeArray.java#L1024-L1076
21,609
mozilla/rhino
src/org/mozilla/javascript/NativeArray.java
NativeArray.reduceMethod
private static Object reduceMethod(Context cx, int id, Scriptable scope, Scriptable thisObj, Object[] args) { Scriptable o = ScriptRuntime.toObject(cx, scope, thisObj); long length = getLengthProperty(cx, o, false); Object callbackArg = args.length > 0...
java
private static Object reduceMethod(Context cx, int id, Scriptable scope, Scriptable thisObj, Object[] args) { Scriptable o = ScriptRuntime.toObject(cx, scope, thisObj); long length = getLengthProperty(cx, o, false); Object callbackArg = args.length > 0...
[ "private", "static", "Object", "reduceMethod", "(", "Context", "cx", ",", "int", "id", ",", "Scriptable", "scope", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ")", "{", "Scriptable", "o", "=", "ScriptRuntime", ".", "toObject", "(", "cx",...
Implements the methods "reduce" and "reduceRight".
[ "Implements", "the", "methods", "reduce", "and", "reduceRight", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeArray.java#L1745-L1779
21,610
mozilla/rhino
src/org/mozilla/javascript/NativeGlobal.java
NativeGlobal.js_parseInt
static Object js_parseInt(Object[] args) { String s = ScriptRuntime.toString(args, 0); int radix = ScriptRuntime.toInt32(args, 1); int len = s.length(); if (len == 0) return ScriptRuntime.NaNobj; boolean negative = false; int start = 0; char c; ...
java
static Object js_parseInt(Object[] args) { String s = ScriptRuntime.toString(args, 0); int radix = ScriptRuntime.toInt32(args, 1); int len = s.length(); if (len == 0) return ScriptRuntime.NaNobj; boolean negative = false; int start = 0; char c; ...
[ "static", "Object", "js_parseInt", "(", "Object", "[", "]", "args", ")", "{", "String", "s", "=", "ScriptRuntime", ".", "toString", "(", "args", ",", "0", ")", ";", "int", "radix", "=", "ScriptRuntime", ".", "toInt32", "(", "args", ",", "1", ")", ";"...
The global method parseInt, as per ECMA-262 15.1.2.2.
[ "The", "global", "method", "parseInt", "as", "per", "ECMA", "-", "262", "15", ".", "1", ".", "2", ".", "2", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeGlobal.java#L208-L256
21,611
mozilla/rhino
src/org/mozilla/javascript/NativeGlobal.java
NativeGlobal.js_parseFloat
static Object js_parseFloat(Object[] args) { if (args.length < 1) return ScriptRuntime.NaNobj; String s = ScriptRuntime.toString(args[0]); int len = s.length(); int start = 0; // Scan forward to skip whitespace char c; for (;;) { if (s...
java
static Object js_parseFloat(Object[] args) { if (args.length < 1) return ScriptRuntime.NaNobj; String s = ScriptRuntime.toString(args[0]); int len = s.length(); int start = 0; // Scan forward to skip whitespace char c; for (;;) { if (s...
[ "static", "Object", "js_parseFloat", "(", "Object", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "<", "1", ")", "return", "ScriptRuntime", ".", "NaNobj", ";", "String", "s", "=", "ScriptRuntime", ".", "toString", "(", "args", "[", "0",...
The global method parseFloat, as per ECMA-262 15.1.2.3. @param args the arguments to parseFloat, ignoring args[>=1]
[ "The", "global", "method", "parseFloat", "as", "per", "ECMA", "-", "262", "15", ".", "1", ".", "2", ".", "3", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeGlobal.java#L263-L362
21,612
mozilla/rhino
src/org/mozilla/javascript/NativeGlobal.java
NativeGlobal.js_escape
private Object js_escape(Object[] args) { final int URL_XALPHAS = 1, URL_XPALPHAS = 2, URL_PATH = 4; String s = ScriptRuntime.toString(args, 0); int mask = URL_XALPHAS | URL_XPALPHAS | URL_PATH; if (args.length > 1) { // the 'mask' argument. Non-ECM...
java
private Object js_escape(Object[] args) { final int URL_XALPHAS = 1, URL_XPALPHAS = 2, URL_PATH = 4; String s = ScriptRuntime.toString(args, 0); int mask = URL_XALPHAS | URL_XPALPHAS | URL_PATH; if (args.length > 1) { // the 'mask' argument. Non-ECM...
[ "private", "Object", "js_escape", "(", "Object", "[", "]", "args", ")", "{", "final", "int", "URL_XALPHAS", "=", "1", ",", "URL_XPALPHAS", "=", "2", ",", "URL_PATH", "=", "4", ";", "String", "s", "=", "ScriptRuntime", ".", "toString", "(", "args", ",",...
The global method escape, as per ECMA-262 15.1.2.4. Includes code for the 'mask' argument supported by the C escape method, which used to be part of the browser imbedding. Blame for the strange constant names should be directed there.
[ "The", "global", "method", "escape", "as", "per", "ECMA", "-", "262", "15", ".", "1", ".", "2", ".", "4", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeGlobal.java#L372-L433
21,613
mozilla/rhino
src/org/mozilla/javascript/NativeGlobal.java
NativeGlobal.js_unescape
private Object js_unescape(Object[] args) { String s = ScriptRuntime.toString(args, 0); int firstEscapePos = s.indexOf('%'); if (firstEscapePos >= 0) { int L = s.length(); char[] buf = s.toCharArray(); int destination = firstEscapePos; for (int...
java
private Object js_unescape(Object[] args) { String s = ScriptRuntime.toString(args, 0); int firstEscapePos = s.indexOf('%'); if (firstEscapePos >= 0) { int L = s.length(); char[] buf = s.toCharArray(); int destination = firstEscapePos; for (int...
[ "private", "Object", "js_unescape", "(", "Object", "[", "]", "args", ")", "{", "String", "s", "=", "ScriptRuntime", ".", "toString", "(", "args", ",", "0", ")", ";", "int", "firstEscapePos", "=", "s", ".", "indexOf", "(", "'", "'", ")", ";", "if", ...
The global unescape method, as per ECMA-262 15.1.2.5.
[ "The", "global", "unescape", "method", "as", "per", "ECMA", "-", "262", "15", ".", "1", ".", "2", ".", "5", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeGlobal.java#L439-L476
21,614
mozilla/rhino
src/org/mozilla/javascript/ast/TryStatement.java
TryStatement.addCatchClause
public void addCatchClause(CatchClause clause) { assertNotNull(clause); if (catchClauses == null) { catchClauses = new ArrayList<CatchClause>(); } catchClauses.add(clause); clause.setParent(this); }
java
public void addCatchClause(CatchClause clause) { assertNotNull(clause); if (catchClauses == null) { catchClauses = new ArrayList<CatchClause>(); } catchClauses.add(clause); clause.setParent(this); }
[ "public", "void", "addCatchClause", "(", "CatchClause", "clause", ")", "{", "assertNotNull", "(", "clause", ")", ";", "if", "(", "catchClauses", "==", "null", ")", "{", "catchClauses", "=", "new", "ArrayList", "<", "CatchClause", ">", "(", ")", ";", "}", ...
Add a catch-clause to the end of the list, and sets its parent to this node. @throws IllegalArgumentException} if {@code clause} is {@code null}
[ "Add", "a", "catch", "-", "clause", "to", "the", "end", "of", "the", "list", "and", "sets", "its", "parent", "to", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/TryStatement.java#L96-L103
21,615
mozilla/rhino
src/org/mozilla/javascript/ast/TryStatement.java
TryStatement.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { tryBlock.visit(v); for (CatchClause cc : getCatchClauses()) { cc.visit(v); } if (finallyBlock != null) { finallyBlock.visit(v); } } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { tryBlock.visit(v); for (CatchClause cc : getCatchClauses()) { cc.visit(v); } if (finallyBlock != null) { finallyBlock.visit(v); } } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "tryBlock", ".", "visit", "(", "v", ")", ";", "for", "(", "CatchClause", "cc", ":", "getCatchClauses", "(", ")"...
Visits this node, then the try-block, then any catch clauses, and then any finally block.
[ "Visits", "this", "node", "then", "the", "try", "-", "block", "then", "any", "catch", "clauses", "and", "then", "any", "finally", "block", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/TryStatement.java#L159-L170
21,616
mozilla/rhino
src/org/mozilla/javascript/ast/Name.java
Name.setIdentifier
public void setIdentifier(String identifier) { assertNotNull(identifier); this.identifier = identifier; setLength(identifier.length()); }
java
public void setIdentifier(String identifier) { assertNotNull(identifier); this.identifier = identifier; setLength(identifier.length()); }
[ "public", "void", "setIdentifier", "(", "String", "identifier", ")", "{", "assertNotNull", "(", "identifier", ")", ";", "this", ".", "identifier", "=", "identifier", ";", "setLength", "(", "identifier", ".", "length", "(", ")", ")", ";", "}" ]
Sets the node's identifier @throws IllegalArgumentException if identifier is null
[ "Sets", "the", "node", "s", "identifier" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Name.java#L68-L72
21,617
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/CompoundAssignment.java
CompoundAssignment.validateOperators
private static Set<Kind> validateOperators(Set<Kind> kinds) { for (Kind kind : kinds) { if (!COMPOUND_ASSIGNMENT_OPERATORS.contains(kind)) { throw new IllegalArgumentException(kind.name() + " is not a compound-assignment operator."); } } return kinds; }
java
private static Set<Kind> validateOperators(Set<Kind> kinds) { for (Kind kind : kinds) { if (!COMPOUND_ASSIGNMENT_OPERATORS.contains(kind)) { throw new IllegalArgumentException(kind.name() + " is not a compound-assignment operator."); } } return kinds; }
[ "private", "static", "Set", "<", "Kind", ">", "validateOperators", "(", "Set", "<", "Kind", ">", "kinds", ")", "{", "for", "(", "Kind", "kind", ":", "kinds", ")", "{", "if", "(", "!", "COMPOUND_ASSIGNMENT_OPERATORS", ".", "contains", "(", "kind", ")", ...
Returns the provided set of operators if they are all compound-assignment operators. Otherwise, throws an IllegalArgumentException.
[ "Returns", "the", "provided", "set", "of", "operators", "if", "they", "are", "all", "compound", "-", "assignment", "operators", ".", "Otherwise", "throws", "an", "IllegalArgumentException", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/CompoundAssignment.java#L88-L95
21,618
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/ThreadLocalUsage.java
ThreadLocalUsage.wellKnownTypeArgument
private boolean wellKnownTypeArgument(NewClassTree tree, VisitorState state) { Type type = getType(tree); if (type == null) { return false; } type = state.getTypes().asSuper(type, state.getSymbolFromString("java.lang.ThreadLocal")); if (type == null) { return false; } if (type.ge...
java
private boolean wellKnownTypeArgument(NewClassTree tree, VisitorState state) { Type type = getType(tree); if (type == null) { return false; } type = state.getTypes().asSuper(type, state.getSymbolFromString("java.lang.ThreadLocal")); if (type == null) { return false; } if (type.ge...
[ "private", "boolean", "wellKnownTypeArgument", "(", "NewClassTree", "tree", ",", "VisitorState", "state", ")", "{", "Type", "type", "=", "getType", "(", "tree", ")", ";", "if", "(", "type", "==", "null", ")", "{", "return", "false", ";", "}", "type", "="...
Ignore some common ThreadLocal type arguments that are fine to have per-instance copies of.
[ "Ignore", "some", "common", "ThreadLocal", "type", "arguments", "that", "are", "fine", "to", "have", "per", "-", "instance", "copies", "of", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ThreadLocalUsage.java#L106-L126
21,619
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/TypeNameShadowing.java
TypeNameShadowing.findShadowedTypes
private Description findShadowedTypes( Tree tree, List<? extends TypeParameterTree> typeParameters, VisitorState state) { Env<AttrContext> env = Enter.instance(state.context) .getEnv(ASTHelpers.getSymbol(state.findEnclosing(ClassTree.class))); Symtab symtab = state.getSymtab(); P...
java
private Description findShadowedTypes( Tree tree, List<? extends TypeParameterTree> typeParameters, VisitorState state) { Env<AttrContext> env = Enter.instance(state.context) .getEnv(ASTHelpers.getSymbol(state.findEnclosing(ClassTree.class))); Symtab symtab = state.getSymtab(); P...
[ "private", "Description", "findShadowedTypes", "(", "Tree", "tree", ",", "List", "<", "?", "extends", "TypeParameterTree", ">", "typeParameters", ",", "VisitorState", "state", ")", "{", "Env", "<", "AttrContext", ">", "env", "=", "Enter", ".", "instance", "(",...
Iterate through a list of type parameters, looking for type names shadowed by any of them.
[ "Iterate", "through", "a", "list", "of", "type", "parameters", "looking", "for", "type", "names", "shadowed", "by", "any", "of", "them", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/TypeNameShadowing.java#L118-L171
21,620
google/error-prone
check_api/src/main/java/com/google/errorprone/util/Comments.java
Comments.getTextFromComment
public static String getTextFromComment(Comment comment) { switch (comment.getStyle()) { case BLOCK: return comment.getText().replaceAll("^\\s*/\\*\\s*(.*?)\\s*\\*/\\s*", "$1"); case LINE: return comment.getText().replaceAll("^\\s*//\\s*", ""); default: return comment.getTe...
java
public static String getTextFromComment(Comment comment) { switch (comment.getStyle()) { case BLOCK: return comment.getText().replaceAll("^\\s*/\\*\\s*(.*?)\\s*\\*/\\s*", "$1"); case LINE: return comment.getText().replaceAll("^\\s*//\\s*", ""); default: return comment.getTe...
[ "public", "static", "String", "getTextFromComment", "(", "Comment", "comment", ")", "{", "switch", "(", "comment", ".", "getStyle", "(", ")", ")", "{", "case", "BLOCK", ":", "return", "comment", ".", "getText", "(", ")", ".", "replaceAll", "(", "\"^\\\\s*/...
Extract the text body from a comment. <p>This currently includes asterisks that start lines in the body of block comments. Do not rely on this behaviour. <p>TODO(andrewrice) Update this method to handle block comments properly if we find the need
[ "Extract", "the", "text", "body", "from", "a", "comment", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/Comments.java#L94-L103
21,621
google/error-prone
check_api/src/main/java/com/google/errorprone/util/Comments.java
Comments.computeEndPosition
@VisibleForTesting static Optional<Integer> computeEndPosition( Tree methodInvocationTree, CharSequence sourceCode, VisitorState state) { int invocationEnd = state.getEndPosition(methodInvocationTree); if (invocationEnd == -1) { return Optional.empty(); } // Finding a good end position is...
java
@VisibleForTesting static Optional<Integer> computeEndPosition( Tree methodInvocationTree, CharSequence sourceCode, VisitorState state) { int invocationEnd = state.getEndPosition(methodInvocationTree); if (invocationEnd == -1) { return Optional.empty(); } // Finding a good end position is...
[ "@", "VisibleForTesting", "static", "Optional", "<", "Integer", ">", "computeEndPosition", "(", "Tree", "methodInvocationTree", ",", "CharSequence", "sourceCode", ",", "VisitorState", "state", ")", "{", "int", "invocationEnd", "=", "state", ".", "getEndPosition", "(...
Finds the end position of this MethodInvocationTree. This is complicated by the fact that sometimes a comment will fall outside of the bounds of the tree. <p>For example: <pre> test(arg1, // comment1 arg2); // comment2 int i; </pre> In this case {@code comment2} lies beyond the end of the invocation tree. In order ...
[ "Finds", "the", "end", "position", "of", "this", "MethodInvocationTree", ".", "This", "is", "complicated", "by", "the", "fact", "that", "sometimes", "a", "comment", "will", "fall", "outside", "of", "the", "bounds", "of", "the", "tree", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/Comments.java#L235-L260
21,622
google/error-prone
check_api/src/main/java/com/google/errorprone/util/Comments.java
Comments.after
private static <T> T after(T target, Iterable<? extends T> iterable, T defaultValue) { Iterator<? extends T> iterator = iterable.iterator(); while (iterator.hasNext()) { if (iterator.next().equals(target)) { break; } } if (iterator.hasNext()) { return iterator.next(); } ...
java
private static <T> T after(T target, Iterable<? extends T> iterable, T defaultValue) { Iterator<? extends T> iterator = iterable.iterator(); while (iterator.hasNext()) { if (iterator.next().equals(target)) { break; } } if (iterator.hasNext()) { return iterator.next(); } ...
[ "private", "static", "<", "T", ">", "T", "after", "(", "T", "target", ",", "Iterable", "<", "?", "extends", "T", ">", "iterable", ",", "T", "defaultValue", ")", "{", "Iterator", "<", "?", "extends", "T", ">", "iterator", "=", "iterable", ".", "iterat...
Find the element in the iterable following the target @param target is the element to search for @param iterable is the iterable to search @param defaultValue will be returned if there is no item following the searched for item @return the item following {@code target} or {@code defaultValue} if not found
[ "Find", "the", "element", "in", "the", "iterable", "following", "the", "target" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/Comments.java#L300-L313
21,623
google/error-prone
check_api/src/main/java/com/google/errorprone/scanner/ErrorProneScanner.java
ErrorProneScanner.visitParameterizedType
@Override public Void visitParameterizedType(ParameterizedTypeTree tree, VisitorState visitorState) { VisitorState state = processMatchers( parameterizedTypeMatchers, tree, ParameterizedTypeTreeMatcher::matchParameterizedType, visitorState); return super...
java
@Override public Void visitParameterizedType(ParameterizedTypeTree tree, VisitorState visitorState) { VisitorState state = processMatchers( parameterizedTypeMatchers, tree, ParameterizedTypeTreeMatcher::matchParameterizedType, visitorState); return super...
[ "@", "Override", "public", "Void", "visitParameterizedType", "(", "ParameterizedTypeTree", "tree", ",", "VisitorState", "visitorState", ")", "{", "VisitorState", "state", "=", "processMatchers", "(", "parameterizedTypeMatchers", ",", "tree", ",", "ParameterizedTypeTreeMat...
generated by javac to implement autoboxing. We are only interested in source-level constructs.
[ "generated", "by", "javac", "to", "implement", "autoboxing", ".", "We", "are", "only", "interested", "in", "source", "-", "level", "constructs", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/scanner/ErrorProneScanner.java#L766-L775
21,624
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/LowInformationNameHeuristic.java
LowInformationNameHeuristic.isAcceptableChange
@Override public boolean isAcceptableChange( Changes changes, Tree node, MethodSymbol symbol, VisitorState state) { return changes.changedPairs().stream().allMatch(p -> findMatch(p.formal()) == null); }
java
@Override public boolean isAcceptableChange( Changes changes, Tree node, MethodSymbol symbol, VisitorState state) { return changes.changedPairs().stream().allMatch(p -> findMatch(p.formal()) == null); }
[ "@", "Override", "public", "boolean", "isAcceptableChange", "(", "Changes", "changes", ",", "Tree", "node", ",", "MethodSymbol", "symbol", ",", "VisitorState", "state", ")", "{", "return", "changes", ".", "changedPairs", "(", ")", ".", "stream", "(", ")", "....
Return true if this parameter does not match any of the regular expressions in the list of overloaded words.
[ "Return", "true", "if", "this", "parameter", "does", "not", "match", "any", "of", "the", "regular", "expressions", "in", "the", "list", "of", "overloaded", "words", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/LowInformationNameHeuristic.java#L51-L55
21,625
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/LowInformationNameHeuristic.java
LowInformationNameHeuristic.findMatch
protected String findMatch(Parameter parameter) { for (String regex : overloadedNamesRegexs) { if (parameter.name().matches(regex)) { return regex; } } return null; }
java
protected String findMatch(Parameter parameter) { for (String regex : overloadedNamesRegexs) { if (parameter.name().matches(regex)) { return regex; } } return null; }
[ "protected", "String", "findMatch", "(", "Parameter", "parameter", ")", "{", "for", "(", "String", "regex", ":", "overloadedNamesRegexs", ")", "{", "if", "(", "parameter", ".", "name", "(", ")", ".", "matches", "(", "regex", ")", ")", "{", "return", "reg...
Return the first regular expression from the list of overloaded words which matches the parameter name.
[ "Return", "the", "first", "regular", "expression", "from", "the", "list", "of", "overloaded", "words", "which", "matches", "the", "parameter", "name", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/LowInformationNameHeuristic.java#L61-L68
21,626
google/error-prone
check_api/src/main/java/com/google/errorprone/names/NamingConventions.java
NamingConventions.splitToLowercaseTerms
public static ImmutableList<String> splitToLowercaseTerms(String identifierName) { if (ONLY_UNDERSCORES.matcher(identifierName).matches()) { // Degenerate case of names which contain only underscore return ImmutableList.of(identifierName); } return Arrays.stream(TERM_SPLITTER.split(identifierNam...
java
public static ImmutableList<String> splitToLowercaseTerms(String identifierName) { if (ONLY_UNDERSCORES.matcher(identifierName).matches()) { // Degenerate case of names which contain only underscore return ImmutableList.of(identifierName); } return Arrays.stream(TERM_SPLITTER.split(identifierNam...
[ "public", "static", "ImmutableList", "<", "String", ">", "splitToLowercaseTerms", "(", "String", "identifierName", ")", "{", "if", "(", "ONLY_UNDERSCORES", ".", "matcher", "(", "identifierName", ")", ".", "matches", "(", ")", ")", "{", "// Degenerate case of names...
Split a Java name into terms based on either Camel Case or Underscores. We also split digits at the end of the name into a separate term so as to treat PERSON1 and PERSON_1 as the same thing. @param identifierName to split @return a list of the terms in the name, in order and converted to lowercase
[ "Split", "a", "Java", "name", "into", "terms", "based", "on", "either", "Camel", "Case", "or", "Underscores", ".", "We", "also", "split", "digits", "at", "the", "end", "of", "the", "name", "into", "a", "separate", "term", "so", "as", "to", "treat", "PE...
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/names/NamingConventions.java#L45-L53
21,627
google/error-prone
check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java
FindIdentifiers.findIdent
public static Symbol findIdent(String name, VisitorState state) { return findIdent(name, state, KindSelector.VAR); }
java
public static Symbol findIdent(String name, VisitorState state) { return findIdent(name, state, KindSelector.VAR); }
[ "public", "static", "Symbol", "findIdent", "(", "String", "name", ",", "VisitorState", "state", ")", "{", "return", "findIdent", "(", "name", ",", "state", ",", "KindSelector", ".", "VAR", ")", ";", "}" ]
Finds a variable declaration with the given name that is in scope at the current location.
[ "Finds", "a", "variable", "declaration", "with", "the", "given", "name", "that", "is", "in", "scope", "at", "the", "current", "location", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java#L80-L82
21,628
google/error-prone
check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java
FindIdentifiers.findIdent
@Nullable public static Symbol findIdent(String name, VisitorState state, KindSelector kind) { ClassType enclosingClass = ASTHelpers.getType(state.findEnclosing(ClassTree.class)); if (enclosingClass == null || enclosingClass.tsym == null) { return null; } Env<AttrContext> env = Enter.instance(st...
java
@Nullable public static Symbol findIdent(String name, VisitorState state, KindSelector kind) { ClassType enclosingClass = ASTHelpers.getType(state.findEnclosing(ClassTree.class)); if (enclosingClass == null || enclosingClass.tsym == null) { return null; } Env<AttrContext> env = Enter.instance(st...
[ "@", "Nullable", "public", "static", "Symbol", "findIdent", "(", "String", "name", ",", "VisitorState", "state", ",", "KindSelector", "kind", ")", "{", "ClassType", "enclosingClass", "=", "ASTHelpers", ".", "getType", "(", "state", ".", "findEnclosing", "(", "...
Finds a declaration with the given name and type that is in scope at the current location.
[ "Finds", "a", "declaration", "with", "the", "given", "name", "and", "type", "that", "is", "in", "scope", "at", "the", "current", "location", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java#L85-L106
21,629
google/error-prone
check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java
FindIdentifiers.findReferencedIdentifiers
public static ImmutableSet<Symbol> findReferencedIdentifiers(Tree tree) { ImmutableSet.Builder<Symbol> builder = ImmutableSet.builder(); createFindIdentifiersScanner(builder, null).scan(tree, null); return builder.build(); }
java
public static ImmutableSet<Symbol> findReferencedIdentifiers(Tree tree) { ImmutableSet.Builder<Symbol> builder = ImmutableSet.builder(); createFindIdentifiersScanner(builder, null).scan(tree, null); return builder.build(); }
[ "public", "static", "ImmutableSet", "<", "Symbol", ">", "findReferencedIdentifiers", "(", "Tree", "tree", ")", "{", "ImmutableSet", ".", "Builder", "<", "Symbol", ">", "builder", "=", "ImmutableSet", ".", "builder", "(", ")", ";", "createFindIdentifiersScanner", ...
Find the set of all identifiers referenced within this Tree
[ "Find", "the", "set", "of", "all", "identifiers", "referenced", "within", "this", "Tree" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java#L272-L276
21,630
google/error-prone
check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java
FindIdentifiers.findAllFields
public static List<VarSymbol> findAllFields(Type classType, VisitorState state) { // TODO(andrewrice): Switch collector to ImmutableList.toImmutableList() when released return state.getTypes().closure(classType).stream() .flatMap( type -> { TypeSymbol tsym = type.tsym; ...
java
public static List<VarSymbol> findAllFields(Type classType, VisitorState state) { // TODO(andrewrice): Switch collector to ImmutableList.toImmutableList() when released return state.getTypes().closure(classType).stream() .flatMap( type -> { TypeSymbol tsym = type.tsym; ...
[ "public", "static", "List", "<", "VarSymbol", ">", "findAllFields", "(", "Type", "classType", ",", "VisitorState", "state", ")", "{", "// TODO(andrewrice): Switch collector to ImmutableList.toImmutableList() when released", "return", "state", ".", "getTypes", "(", ")", "....
Finds all the visible fields declared or inherited in the target class
[ "Finds", "all", "the", "visible", "fields", "declared", "or", "inherited", "in", "the", "target", "class" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/FindIdentifiers.java#L279-L298
21,631
google/error-prone
core/src/main/java/com/google/errorprone/refaster/ExpressionTemplate.java
ExpressionTemplate.match
@Override public Iterable<ExpressionTemplateMatch> match(JCTree target, Context context) { if (target instanceof JCExpression) { JCExpression targetExpr = (JCExpression) target; Optional<Unifier> unifier = unify(targetExpr, new Unifier(context)).first(); if (unifier.isPresent()) { return...
java
@Override public Iterable<ExpressionTemplateMatch> match(JCTree target, Context context) { if (target instanceof JCExpression) { JCExpression targetExpr = (JCExpression) target; Optional<Unifier> unifier = unify(targetExpr, new Unifier(context)).first(); if (unifier.isPresent()) { return...
[ "@", "Override", "public", "Iterable", "<", "ExpressionTemplateMatch", ">", "match", "(", "JCTree", "target", ",", "Context", "context", ")", "{", "if", "(", "target", "instanceof", "JCExpression", ")", "{", "JCExpression", "targetExpr", "=", "(", "JCExpression"...
Returns the matches of this template against the specified target AST.
[ "Returns", "the", "matches", "of", "this", "template", "against", "the", "specified", "target", "AST", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/ExpressionTemplate.java#L124-L134
21,632
google/error-prone
core/src/main/java/com/google/errorprone/refaster/ExpressionTemplate.java
ExpressionTemplate.getPrecedence
private static int getPrecedence(JCTree leaf, Context context) { JCCompilationUnit comp = context.get(JCCompilationUnit.class); JCTree parent = TreeInfo.pathFor(leaf, comp).get(1); // In general, this should match the logic in com.sun.tools.javac.tree.Pretty. // // TODO(mdempsky): There are probabl...
java
private static int getPrecedence(JCTree leaf, Context context) { JCCompilationUnit comp = context.get(JCCompilationUnit.class); JCTree parent = TreeInfo.pathFor(leaf, comp).get(1); // In general, this should match the logic in com.sun.tools.javac.tree.Pretty. // // TODO(mdempsky): There are probabl...
[ "private", "static", "int", "getPrecedence", "(", "JCTree", "leaf", ",", "Context", "context", ")", "{", "JCCompilationUnit", "comp", "=", "context", ".", "get", "(", "JCCompilationUnit", ".", "class", ")", ";", "JCTree", "parent", "=", "TreeInfo", ".", "pat...
Returns the precedence level appropriate for unambiguously printing leaf as a subexpression of its parent.
[ "Returns", "the", "precedence", "level", "appropriate", "for", "unambiguously", "printing", "leaf", "as", "a", "subexpression", "of", "its", "parent", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/ExpressionTemplate.java#L249-L295
21,633
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.getSymbol
@Nullable public static MethodSymbol getSymbol(NewClassTree tree) { Symbol sym = ((JCNewClass) tree).constructor; return sym instanceof MethodSymbol ? (MethodSymbol) sym : null; }
java
@Nullable public static MethodSymbol getSymbol(NewClassTree tree) { Symbol sym = ((JCNewClass) tree).constructor; return sym instanceof MethodSymbol ? (MethodSymbol) sym : null; }
[ "@", "Nullable", "public", "static", "MethodSymbol", "getSymbol", "(", "NewClassTree", "tree", ")", "{", "Symbol", "sym", "=", "(", "(", "JCNewClass", ")", "tree", ")", ".", "constructor", ";", "return", "sym", "instanceof", "MethodSymbol", "?", "(", "Method...
Gets the method symbol for a new class.
[ "Gets", "the", "method", "symbol", "for", "a", "new", "class", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L263-L267
21,634
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.getSymbol
@Nullable public static MethodSymbol getSymbol(MethodInvocationTree tree) { Symbol sym = ASTHelpers.getSymbol(tree.getMethodSelect()); if (!(sym instanceof MethodSymbol)) { // Defensive. Would only occur if there are errors in the AST. return null; } return (MethodSymbol) sym; }
java
@Nullable public static MethodSymbol getSymbol(MethodInvocationTree tree) { Symbol sym = ASTHelpers.getSymbol(tree.getMethodSelect()); if (!(sym instanceof MethodSymbol)) { // Defensive. Would only occur if there are errors in the AST. return null; } return (MethodSymbol) sym; }
[ "@", "Nullable", "public", "static", "MethodSymbol", "getSymbol", "(", "MethodInvocationTree", "tree", ")", "{", "Symbol", "sym", "=", "ASTHelpers", ".", "getSymbol", "(", "tree", ".", "getMethodSelect", "(", ")", ")", ";", "if", "(", "!", "(", "sym", "ins...
Gets the symbol for a method invocation.
[ "Gets", "the", "symbol", "for", "a", "method", "invocation", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L275-L283
21,635
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.getSymbol
@Nullable public static MethodSymbol getSymbol(MemberReferenceTree tree) { Symbol sym = ((JCMemberReference) tree).sym; return sym instanceof MethodSymbol ? (MethodSymbol) sym : null; }
java
@Nullable public static MethodSymbol getSymbol(MemberReferenceTree tree) { Symbol sym = ((JCMemberReference) tree).sym; return sym instanceof MethodSymbol ? (MethodSymbol) sym : null; }
[ "@", "Nullable", "public", "static", "MethodSymbol", "getSymbol", "(", "MemberReferenceTree", "tree", ")", "{", "Symbol", "sym", "=", "(", "(", "JCMemberReference", ")", "tree", ")", ".", "sym", ";", "return", "sym", "instanceof", "MethodSymbol", "?", "(", "...
Gets the symbol for a member reference.
[ "Gets", "the", "symbol", "for", "a", "member", "reference", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L286-L290
21,636
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.stripParentheses
public static Tree stripParentheses(Tree tree) { while (tree instanceof ParenthesizedTree) { tree = ((ParenthesizedTree) tree).getExpression(); } return tree; }
java
public static Tree stripParentheses(Tree tree) { while (tree instanceof ParenthesizedTree) { tree = ((ParenthesizedTree) tree).getExpression(); } return tree; }
[ "public", "static", "Tree", "stripParentheses", "(", "Tree", "tree", ")", "{", "while", "(", "tree", "instanceof", "ParenthesizedTree", ")", "{", "tree", "=", "(", "(", "ParenthesizedTree", ")", "tree", ")", ".", "getExpression", "(", ")", ";", "}", "retur...
Removes any enclosing parentheses from the tree.
[ "Removes", "any", "enclosing", "parentheses", "from", "the", "tree", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L321-L326
21,637
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.stripParentheses
public static ExpressionTree stripParentheses(ExpressionTree tree) { while (tree instanceof ParenthesizedTree) { tree = ((ParenthesizedTree) tree).getExpression(); } return tree; }
java
public static ExpressionTree stripParentheses(ExpressionTree tree) { while (tree instanceof ParenthesizedTree) { tree = ((ParenthesizedTree) tree).getExpression(); } return tree; }
[ "public", "static", "ExpressionTree", "stripParentheses", "(", "ExpressionTree", "tree", ")", "{", "while", "(", "tree", "instanceof", "ParenthesizedTree", ")", "{", "tree", "=", "(", "(", "ParenthesizedTree", ")", "tree", ")", ".", "getExpression", "(", ")", ...
Given an ExpressionTree, removes any enclosing parentheses.
[ "Given", "an", "ExpressionTree", "removes", "any", "enclosing", "parentheses", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L329-L334
21,638
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.findEnclosingNode
@Nullable public static <T> T findEnclosingNode(TreePath path, Class<T> klass) { path = findPathFromEnclosingNodeToTopLevel(path, klass); return (path == null) ? null : klass.cast(path.getLeaf()); }
java
@Nullable public static <T> T findEnclosingNode(TreePath path, Class<T> klass) { path = findPathFromEnclosingNodeToTopLevel(path, klass); return (path == null) ? null : klass.cast(path.getLeaf()); }
[ "@", "Nullable", "public", "static", "<", "T", ">", "T", "findEnclosingNode", "(", "TreePath", "path", ",", "Class", "<", "T", ">", "klass", ")", "{", "path", "=", "findPathFromEnclosingNodeToTopLevel", "(", "path", ",", "klass", ")", ";", "return", "(", ...
Given a TreePath, walks up the tree until it finds a node of the given type. Returns null if no such node is found.
[ "Given", "a", "TreePath", "walks", "up", "the", "tree", "until", "it", "finds", "a", "node", "of", "the", "given", "type", ".", "Returns", "null", "if", "no", "such", "node", "is", "found", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L353-L357
21,639
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.getReturnType
public static Type getReturnType(ExpressionTree expressionTree) { if (expressionTree instanceof JCFieldAccess) { JCFieldAccess methodCall = (JCFieldAccess) expressionTree; return methodCall.type.getReturnType(); } else if (expressionTree instanceof JCIdent) { JCIdent methodCall = (JCIdent) exp...
java
public static Type getReturnType(ExpressionTree expressionTree) { if (expressionTree instanceof JCFieldAccess) { JCFieldAccess methodCall = (JCFieldAccess) expressionTree; return methodCall.type.getReturnType(); } else if (expressionTree instanceof JCIdent) { JCIdent methodCall = (JCIdent) exp...
[ "public", "static", "Type", "getReturnType", "(", "ExpressionTree", "expressionTree", ")", "{", "if", "(", "expressionTree", "instanceof", "JCFieldAccess", ")", "{", "JCFieldAccess", "methodCall", "=", "(", "JCFieldAccess", ")", "expressionTree", ";", "return", "met...
Gives the return type of an ExpressionTree that represents a method select. <p>TODO(eaftan): Are there other places this could be used?
[ "Gives", "the", "return", "type", "of", "an", "ExpressionTree", "that", "represents", "a", "method", "select", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L409-L422
21,640
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.getReceiver
@Nullable public static ExpressionTree getReceiver(ExpressionTree expressionTree) { if (expressionTree instanceof MethodInvocationTree) { ExpressionTree methodSelect = ((MethodInvocationTree) expressionTree).getMethodSelect(); if (methodSelect instanceof IdentifierTree) { return null; } ...
java
@Nullable public static ExpressionTree getReceiver(ExpressionTree expressionTree) { if (expressionTree instanceof MethodInvocationTree) { ExpressionTree methodSelect = ((MethodInvocationTree) expressionTree).getMethodSelect(); if (methodSelect instanceof IdentifierTree) { return null; } ...
[ "@", "Nullable", "public", "static", "ExpressionTree", "getReceiver", "(", "ExpressionTree", "expressionTree", ")", "{", "if", "(", "expressionTree", "instanceof", "MethodInvocationTree", ")", "{", "ExpressionTree", "methodSelect", "=", "(", "(", "MethodInvocationTree",...
Returns the receiver of an expression. <p>Examples: <pre>{@code a.foo() ==> a a.b.foo() ==> a.b a.bar().foo() ==> a.bar() a.b.c ==> a.b a.b().c ==> a.b() this.foo() ==> this foo() ==> null TheClass.aStaticMethod() ==> TheClass aStaticMethod() ==> null aStaticallyImportedMethod() ==> null }</pre>
[ "Returns", "the", "receiver", "of", "an", "expression", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L490-L508
21,641
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.matchBinaryTree
@Nullable public static List<ExpressionTree> matchBinaryTree( BinaryTree tree, List<Matcher<ExpressionTree>> matchers, VisitorState state) { ExpressionTree leftOperand = tree.getLeftOperand(); ExpressionTree rightOperand = tree.getRightOperand(); if (matchers.get(0).matches(leftOperand, state) ...
java
@Nullable public static List<ExpressionTree> matchBinaryTree( BinaryTree tree, List<Matcher<ExpressionTree>> matchers, VisitorState state) { ExpressionTree leftOperand = tree.getLeftOperand(); ExpressionTree rightOperand = tree.getRightOperand(); if (matchers.get(0).matches(leftOperand, state) ...
[ "@", "Nullable", "public", "static", "List", "<", "ExpressionTree", ">", "matchBinaryTree", "(", "BinaryTree", "tree", ",", "List", "<", "Matcher", "<", "ExpressionTree", ">", ">", "matchers", ",", "VisitorState", "state", ")", "{", "ExpressionTree", "leftOperan...
Given a BinaryTree to match against and a list of two matchers, applies the matchers to the operands in both orders. If both matchers match, returns a list with the operand that matched each matcher in the corresponding position. @param tree a BinaryTree AST node @param matchers a list of matchers @param state the Vis...
[ "Given", "a", "BinaryTree", "to", "match", "against", "and", "a", "list", "of", "two", "matchers", "applies", "the", "matchers", "to", "the", "operands", "in", "both", "orders", ".", "If", "both", "matchers", "match", "returns", "a", "list", "with", "the",...
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L520-L533
21,642
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.findMethod
@Nullable public static MethodTree findMethod(MethodSymbol symbol, VisitorState state) { return JavacTrees.instance(state.context).getTree(symbol); }
java
@Nullable public static MethodTree findMethod(MethodSymbol symbol, VisitorState state) { return JavacTrees.instance(state.context).getTree(symbol); }
[ "@", "Nullable", "public", "static", "MethodTree", "findMethod", "(", "MethodSymbol", "symbol", ",", "VisitorState", "state", ")", "{", "return", "JavacTrees", ".", "instance", "(", "state", ".", "context", ")", ".", "getTree", "(", "symbol", ")", ";", "}" ]
Returns the method tree that matches the given symbol within the compilation unit, or null if none was found.
[ "Returns", "the", "method", "tree", "that", "matches", "the", "given", "symbol", "within", "the", "compilation", "unit", "or", "null", "if", "none", "was", "found", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L539-L542
21,643
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.findClass
@Nullable public static ClassTree findClass(ClassSymbol symbol, VisitorState state) { return JavacTrees.instance(state.context).getTree(symbol); }
java
@Nullable public static ClassTree findClass(ClassSymbol symbol, VisitorState state) { return JavacTrees.instance(state.context).getTree(symbol); }
[ "@", "Nullable", "public", "static", "ClassTree", "findClass", "(", "ClassSymbol", "symbol", ",", "VisitorState", "state", ")", "{", "return", "JavacTrees", ".", "instance", "(", "state", ".", "context", ")", ".", "getTree", "(", "symbol", ")", ";", "}" ]
Returns the class tree that matches the given symbol within the compilation unit, or null if none was found.
[ "Returns", "the", "class", "tree", "that", "matches", "the", "given", "symbol", "within", "the", "compilation", "unit", "or", "null", "if", "none", "was", "found", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L548-L551
21,644
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.methodCanBeOverridden
public static boolean methodCanBeOverridden(MethodSymbol methodSymbol) { if (methodSymbol.getModifiers().contains(Modifier.ABSTRACT)) { return true; } if (methodSymbol.isStatic() || methodSymbol.isPrivate() || isFinal(methodSymbol) || methodSymbol.isConstructor()) { retu...
java
public static boolean methodCanBeOverridden(MethodSymbol methodSymbol) { if (methodSymbol.getModifiers().contains(Modifier.ABSTRACT)) { return true; } if (methodSymbol.isStatic() || methodSymbol.isPrivate() || isFinal(methodSymbol) || methodSymbol.isConstructor()) { retu...
[ "public", "static", "boolean", "methodCanBeOverridden", "(", "MethodSymbol", "methodSymbol", ")", "{", "if", "(", "methodSymbol", ".", "getModifiers", "(", ")", ".", "contains", "(", "Modifier", ".", "ABSTRACT", ")", ")", "{", "return", "true", ";", "}", "if...
Determines whether a method can be overridden. @return true if the method can be overridden.
[ "Determines", "whether", "a", "method", "can", "be", "overridden", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L631-L645
21,645
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.inSamePackage
public static boolean inSamePackage(Symbol targetSymbol, VisitorState state) { JCCompilationUnit compilationUnit = (JCCompilationUnit) state.getPath().getCompilationUnit(); PackageSymbol usePackage = compilationUnit.packge; PackageSymbol targetPackage = targetSymbol.packge(); return targetPackage != nu...
java
public static boolean inSamePackage(Symbol targetSymbol, VisitorState state) { JCCompilationUnit compilationUnit = (JCCompilationUnit) state.getPath().getCompilationUnit(); PackageSymbol usePackage = compilationUnit.packge; PackageSymbol targetPackage = targetSymbol.packge(); return targetPackage != nu...
[ "public", "static", "boolean", "inSamePackage", "(", "Symbol", "targetSymbol", ",", "VisitorState", "state", ")", "{", "JCCompilationUnit", "compilationUnit", "=", "(", "JCCompilationUnit", ")", "state", ".", "getPath", "(", ")", ".", "getCompilationUnit", "(", ")...
Return true if the given symbol is defined in the current package.
[ "Return", "true", "if", "the", "given", "symbol", "is", "defined", "in", "the", "current", "package", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L889-L897
21,646
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.isVoidType
public static boolean isVoidType(Type type, VisitorState state) { if (type == null) { return false; } return type.getKind() == TypeKind.VOID || state.getTypes().isSameType(Suppliers.JAVA_LANG_VOID_TYPE.get(state), type); }
java
public static boolean isVoidType(Type type, VisitorState state) { if (type == null) { return false; } return type.getKind() == TypeKind.VOID || state.getTypes().isSameType(Suppliers.JAVA_LANG_VOID_TYPE.get(state), type); }
[ "public", "static", "boolean", "isVoidType", "(", "Type", "type", ",", "VisitorState", "state", ")", "{", "if", "(", "type", "==", "null", ")", "{", "return", "false", ";", "}", "return", "type", ".", "getKind", "(", ")", "==", "TypeKind", ".", "VOID",...
Return true if the given type is 'void' or 'Void'.
[ "Return", "true", "if", "the", "given", "type", "is", "void", "or", "Void", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L938-L944
21,647
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.getModifiers
@Nullable public static ModifiersTree getModifiers(Tree tree) { if (tree instanceof ClassTree) { return ((ClassTree) tree).getModifiers(); } else if (tree instanceof MethodTree) { return ((MethodTree) tree).getModifiers(); } else if (tree instanceof VariableTree) { return ((VariableTree)...
java
@Nullable public static ModifiersTree getModifiers(Tree tree) { if (tree instanceof ClassTree) { return ((ClassTree) tree).getModifiers(); } else if (tree instanceof MethodTree) { return ((MethodTree) tree).getModifiers(); } else if (tree instanceof VariableTree) { return ((VariableTree)...
[ "@", "Nullable", "public", "static", "ModifiersTree", "getModifiers", "(", "Tree", "tree", ")", "{", "if", "(", "tree", "instanceof", "ClassTree", ")", "{", "return", "(", "(", "ClassTree", ")", "tree", ")", ".", "getModifiers", "(", ")", ";", "}", "else...
Returns the modifiers tree of the given class, method, or variable declaration.
[ "Returns", "the", "modifiers", "tree", "of", "the", "given", "class", "method", "or", "variable", "declaration", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L987-L998
21,648
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.getUpperBound
public static Type getUpperBound(Type type, Types types) { if (type.hasTag(TypeTag.WILDCARD)) { return types.wildUpperBound(type); } if (type.hasTag(TypeTag.TYPEVAR) && ((TypeVar) type).isCaptured()) { return types.cvarUpperBound(type); } if (type.getUpperBound() != null) { retur...
java
public static Type getUpperBound(Type type, Types types) { if (type.hasTag(TypeTag.WILDCARD)) { return types.wildUpperBound(type); } if (type.hasTag(TypeTag.TYPEVAR) && ((TypeVar) type).isCaptured()) { return types.cvarUpperBound(type); } if (type.getUpperBound() != null) { retur...
[ "public", "static", "Type", "getUpperBound", "(", "Type", "type", ",", "Types", "types", ")", "{", "if", "(", "type", ".", "hasTag", "(", "TypeTag", ".", "WILDCARD", ")", ")", "{", "return", "types", ".", "wildUpperBound", "(", "type", ")", ";", "}", ...
Returns the upper bound of a type if it has one, or the type itself if not. Correctly handles wildcards and capture variables.
[ "Returns", "the", "upper", "bound", "of", "a", "type", "if", "it", "has", "one", "or", "the", "type", "itself", "if", "not", ".", "Correctly", "handles", "wildcards", "and", "capture", "variables", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L1004-L1019
21,649
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.unaryNumericPromotion
@Nullable private static Type unaryNumericPromotion(Type type, VisitorState state) { Type unboxed = unboxAndEnsureNumeric(type, state); switch (unboxed.getTag()) { case BYTE: case SHORT: case CHAR: return state.getSymtab().intType; case INT: case LONG: case FLOAT: ...
java
@Nullable private static Type unaryNumericPromotion(Type type, VisitorState state) { Type unboxed = unboxAndEnsureNumeric(type, state); switch (unboxed.getTag()) { case BYTE: case SHORT: case CHAR: return state.getSymtab().intType; case INT: case LONG: case FLOAT: ...
[ "@", "Nullable", "private", "static", "Type", "unaryNumericPromotion", "(", "Type", "type", ",", "VisitorState", "state", ")", "{", "Type", "unboxed", "=", "unboxAndEnsureNumeric", "(", "type", ",", "state", ")", ";", "switch", "(", "unboxed", ".", "getTag", ...
Implementation of unary numeric promotion rules. <p><a href="https://docs.oracle.com/javase/specs/jls/se9/html/jls-5.html#jls-5.6.1">JLS §5.6.1</a>
[ "Implementation", "of", "unary", "numeric", "promotion", "rules", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L1248-L1264
21,650
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.binaryNumericPromotion
@Nullable private static Type binaryNumericPromotion(Type leftType, Type rightType, VisitorState state) { Type unboxedLeft = unboxAndEnsureNumeric(leftType, state); Type unboxedRight = unboxAndEnsureNumeric(rightType, state); Set<TypeTag> tags = EnumSet.of(unboxedLeft.getTag(), unboxedRight.getTag()); ...
java
@Nullable private static Type binaryNumericPromotion(Type leftType, Type rightType, VisitorState state) { Type unboxedLeft = unboxAndEnsureNumeric(leftType, state); Type unboxedRight = unboxAndEnsureNumeric(rightType, state); Set<TypeTag> tags = EnumSet.of(unboxedLeft.getTag(), unboxedRight.getTag()); ...
[ "@", "Nullable", "private", "static", "Type", "binaryNumericPromotion", "(", "Type", "leftType", ",", "Type", "rightType", ",", "VisitorState", "state", ")", "{", "Type", "unboxedLeft", "=", "unboxAndEnsureNumeric", "(", "leftType", ",", "state", ")", ";", "Type...
Implementation of binary numeric promotion rules. <p><a href="https://docs.oracle.com/javase/specs/jls/se9/html/jls-5.html#jls-5.6.2">JLS §5.6.2</a>
[ "Implementation", "of", "binary", "numeric", "promotion", "rules", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L1272-L1286
21,651
google/error-prone
check_api/src/main/java/com/google/errorprone/names/NeedlemanWunschEditDistance.java
NeedlemanWunschEditDistance.getWorstCaseEditDistance
public static int getWorstCaseEditDistance( int sourceLength, int targetLength, int changeCost, int openGapCost, int continueGapCost) { int maxLen = Math.max(sourceLength, targetLength); int minLen = Math.min(sourceLength, targetLength); // Compute maximum cost of changing one string into another. ...
java
public static int getWorstCaseEditDistance( int sourceLength, int targetLength, int changeCost, int openGapCost, int continueGapCost) { int maxLen = Math.max(sourceLength, targetLength); int minLen = Math.min(sourceLength, targetLength); // Compute maximum cost of changing one string into another. ...
[ "public", "static", "int", "getWorstCaseEditDistance", "(", "int", "sourceLength", ",", "int", "targetLength", ",", "int", "changeCost", ",", "int", "openGapCost", ",", "int", "continueGapCost", ")", "{", "int", "maxLen", "=", "Math", ".", "max", "(", "sourceL...
Return the worst case edit distance between strings of this length
[ "Return", "the", "worst", "case", "edit", "distance", "between", "strings", "of", "this", "length" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/names/NeedlemanWunschEditDistance.java#L161-L179
21,652
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/LambdaFunctionalInterface.java
LambdaFunctionalInterface.matchMethod
@Override public Description matchMethod(MethodTree tree, VisitorState state) { MethodSymbol methodSym = ASTHelpers.getSymbol(tree); // precondition (1) if (!methodSym.getModifiers().contains(Modifier.PRIVATE)) { return Description.NO_MATCH; } ImmutableList<Tree> params = tree.get...
java
@Override public Description matchMethod(MethodTree tree, VisitorState state) { MethodSymbol methodSym = ASTHelpers.getSymbol(tree); // precondition (1) if (!methodSym.getModifiers().contains(Modifier.PRIVATE)) { return Description.NO_MATCH; } ImmutableList<Tree> params = tree.get...
[ "@", "Override", "public", "Description", "matchMethod", "(", "MethodTree", "tree", ",", "VisitorState", "state", ")", "{", "MethodSymbol", "methodSym", "=", "ASTHelpers", ".", "getSymbol", "(", "tree", ")", ";", "// precondition (1)", "if", "(", "!", "methodSym...
Identifies methods with parameters that have a generic argument with Int, Long, or Double. If pre-conditions are met, it refactors them to the primitive specializations. <pre>PreConditions: (1): The method declaration has to be private (to do a safe refactoring) (2): Its parameters have to meet the following condition...
[ "Identifies", "methods", "with", "parameters", "that", "have", "a", "generic", "argument", "with", "Int", "Long", "or", "Double", ".", "If", "pre", "-", "conditions", "are", "met", "it", "refactors", "them", "to", "the", "primitive", "specializations", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/LambdaFunctionalInterface.java#L145-L185
21,653
google/error-prone
check_api/src/main/java/com/google/errorprone/scanner/ErrorProneScannerTransformer.java
ErrorProneScannerTransformer.createVisitorState
private VisitorState createVisitorState(Context context, DescriptionListener listener) { ErrorProneOptions options = requireNonNull(context.get(ErrorProneOptions.class)); return VisitorState.createConfiguredForCompilation( context, listener, scanner().severityMap(), options); }
java
private VisitorState createVisitorState(Context context, DescriptionListener listener) { ErrorProneOptions options = requireNonNull(context.get(ErrorProneOptions.class)); return VisitorState.createConfiguredForCompilation( context, listener, scanner().severityMap(), options); }
[ "private", "VisitorState", "createVisitorState", "(", "Context", "context", ",", "DescriptionListener", "listener", ")", "{", "ErrorProneOptions", "options", "=", "requireNonNull", "(", "context", ".", "get", "(", "ErrorProneOptions", ".", "class", ")", ")", ";", ...
Create a VisitorState object from a compilation unit.
[ "Create", "a", "VisitorState", "object", "from", "a", "compilation", "unit", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/scanner/ErrorProneScannerTransformer.java#L52-L56
21,654
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/OrphanedFormatString.java
OrphanedFormatString.missingFormatArgs
private static boolean missingFormatArgs(String value) { try { Formatter.check(value); } catch (MissingFormatArgumentException e) { return true; } catch (Exception ignored) { // we don't care about other errors (it isn't supposed to be a format string) } return false; }
java
private static boolean missingFormatArgs(String value) { try { Formatter.check(value); } catch (MissingFormatArgumentException e) { return true; } catch (Exception ignored) { // we don't care about other errors (it isn't supposed to be a format string) } return false; }
[ "private", "static", "boolean", "missingFormatArgs", "(", "String", "value", ")", "{", "try", "{", "Formatter", ".", "check", "(", "value", ")", ";", "}", "catch", "(", "MissingFormatArgumentException", "e", ")", "{", "return", "true", ";", "}", "catch", "...
Returns true for strings that contain format specifiers.
[ "Returns", "true", "for", "strings", "that", "contain", "format", "specifiers", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/OrphanedFormatString.java#L139-L148
21,655
google/error-prone
check_api/src/main/java/com/google/errorprone/JavacErrorDescriptionListener.java
JavacErrorDescriptionListener.shouldSkipImportTreeFix
private static boolean shouldSkipImportTreeFix(DiagnosticPosition position, Fix f) { if (position.getTree() != null && position.getTree().getKind() != Kind.IMPORT) { return false; } return !f.getImportsToAdd().isEmpty() || !f.getImportsToRemove().isEmpty(); }
java
private static boolean shouldSkipImportTreeFix(DiagnosticPosition position, Fix f) { if (position.getTree() != null && position.getTree().getKind() != Kind.IMPORT) { return false; } return !f.getImportsToAdd().isEmpty() || !f.getImportsToRemove().isEmpty(); }
[ "private", "static", "boolean", "shouldSkipImportTreeFix", "(", "DiagnosticPosition", "position", ",", "Fix", "f", ")", "{", "if", "(", "position", ".", "getTree", "(", ")", "!=", "null", "&&", "position", ".", "getTree", "(", ")", ".", "getKind", "(", ")"...
be fixed if they were specified via SuggestedFix.replace, for example.
[ "be", "fixed", "if", "they", "were", "specified", "via", "SuggestedFix", ".", "replace", "for", "example", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/JavacErrorDescriptionListener.java#L119-L125
21,656
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/android/MislabeledAndroidString.java
MislabeledAndroidString.matchMemberSelect
@Override public Description matchMemberSelect(MemberSelectTree tree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(tree); // Match symbol's owner to android.R.string separately because couldn't get fully qualified // "android.R.string.yes" out of symbol, just "yes" if (symbol == null ...
java
@Override public Description matchMemberSelect(MemberSelectTree tree, VisitorState state) { Symbol symbol = ASTHelpers.getSymbol(tree); // Match symbol's owner to android.R.string separately because couldn't get fully qualified // "android.R.string.yes" out of symbol, just "yes" if (symbol == null ...
[ "@", "Override", "public", "Description", "matchMemberSelect", "(", "MemberSelectTree", "tree", ",", "VisitorState", "state", ")", "{", "Symbol", "symbol", "=", "ASTHelpers", ".", "getSymbol", "(", "tree", ")", ";", "// Match symbol's owner to android.R.string separatel...
assumed and actual meaning
[ "assumed", "and", "actual", "meaning" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/android/MislabeledAndroidString.java#L65-L97
21,657
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java
ThreadSafety.isTypeParameterThreadSafe
private boolean isTypeParameterThreadSafe( TypeVariableSymbol symbol, Set<String> containerTypeParameters) { if (!recursiveThreadSafeTypeParameter.add(symbol)) { return true; } // TODO(b/77695285): Prevent type variables that are immutable because of an immutable upper // bound to be marked ...
java
private boolean isTypeParameterThreadSafe( TypeVariableSymbol symbol, Set<String> containerTypeParameters) { if (!recursiveThreadSafeTypeParameter.add(symbol)) { return true; } // TODO(b/77695285): Prevent type variables that are immutable because of an immutable upper // bound to be marked ...
[ "private", "boolean", "isTypeParameterThreadSafe", "(", "TypeVariableSymbol", "symbol", ",", "Set", "<", "String", ">", "containerTypeParameters", ")", "{", "if", "(", "!", "recursiveThreadSafeTypeParameter", ".", "add", "(", "symbol", ")", ")", "{", "return", "tr...
Returns whether a type parameter is thread-safe. <p>This is true if either the type parameter's declaration is annotated with {@link #typeParameterAnnotation} (indicating it can only be instantiated with thread-safe types), or the type parameter has a thread-safe upper bound (sub-classes of thread-safe types are also ...
[ "Returns", "whether", "a", "type", "parameter", "is", "thread", "-", "safe", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java#L627-L645
21,658
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java
ThreadSafety.mutableEnclosingInstance
public Type mutableEnclosingInstance(Optional<ClassTree> tree, ClassType type) { if (tree.isPresent() && !CanBeStaticAnalyzer.referencesOuter( tree.get(), ASTHelpers.getSymbol(tree.get()), state)) { return null; } Type enclosing = type.getEnclosingType(); while (!Type.noType.eq...
java
public Type mutableEnclosingInstance(Optional<ClassTree> tree, ClassType type) { if (tree.isPresent() && !CanBeStaticAnalyzer.referencesOuter( tree.get(), ASTHelpers.getSymbol(tree.get()), state)) { return null; } Type enclosing = type.getEnclosingType(); while (!Type.noType.eq...
[ "public", "Type", "mutableEnclosingInstance", "(", "Optional", "<", "ClassTree", ">", "tree", ",", "ClassType", "type", ")", "{", "if", "(", "tree", ".", "isPresent", "(", ")", "&&", "!", "CanBeStaticAnalyzer", ".", "referencesOuter", "(", "tree", ".", "get"...
Returns an enclosing instance for the specified type if it is thread-safe.
[ "Returns", "an", "enclosing", "instance", "for", "the", "specified", "type", "if", "it", "is", "thread", "-", "safe", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java#L662-L681
21,659
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java
ThreadSafety.threadSafeTypeParametersInScope
public Set<String> threadSafeTypeParametersInScope(Symbol sym) { if (sym == null) { return ImmutableSet.of(); } ImmutableSet.Builder<String> result = ImmutableSet.builder(); OUTER: for (Symbol s = sym; s.owner != null; s = s.owner) { switch (s.getKind()) { case INSTANCE_INIT: ...
java
public Set<String> threadSafeTypeParametersInScope(Symbol sym) { if (sym == null) { return ImmutableSet.of(); } ImmutableSet.Builder<String> result = ImmutableSet.builder(); OUTER: for (Symbol s = sym; s.owner != null; s = s.owner) { switch (s.getKind()) { case INSTANCE_INIT: ...
[ "public", "Set", "<", "String", ">", "threadSafeTypeParametersInScope", "(", "Symbol", "sym", ")", "{", "if", "(", "sym", "==", "null", ")", "{", "return", "ImmutableSet", ".", "of", "(", ")", ";", "}", "ImmutableSet", ".", "Builder", "<", "String", ">",...
Gets the set of in-scope threadsafe type parameters from the containerOf specs on annotations. <p>Usually only the immediately enclosing declaration is searched, but it's possible to have cases like: <pre> {@literal @}MarkerAnnotation(containerOf="T") class C&lt;T&gt; { class Inner extends ThreadSafeCollection&lt;T&g...
[ "Gets", "the", "set", "of", "in", "-", "scope", "threadsafe", "type", "parameters", "from", "the", "containerOf", "specs", "on", "annotations", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java#L695-L725
21,660
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java
ThreadSafety.getInheritedAnnotation
public AnnotationInfo getInheritedAnnotation(Symbol sym, VisitorState state) { return getAnnotation(sym, markerAnnotations, state); }
java
public AnnotationInfo getInheritedAnnotation(Symbol sym, VisitorState state) { return getAnnotation(sym, markerAnnotations, state); }
[ "public", "AnnotationInfo", "getInheritedAnnotation", "(", "Symbol", "sym", ",", "VisitorState", "state", ")", "{", "return", "getAnnotation", "(", "sym", ",", "markerAnnotations", ",", "state", ")", ";", "}" ]
Gets the possibly inherited marker annotation on the given symbol, and reverse-propagates containerOf spec's from super-classes.
[ "Gets", "the", "possibly", "inherited", "marker", "annotation", "on", "the", "given", "symbol", "and", "reverse", "-", "propagates", "containerOf", "spec", "s", "from", "super", "-", "classes", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java#L796-L798
21,661
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java
ThreadSafety.checkInstantiation
public Violation checkInstantiation( Collection<TypeVariableSymbol> typeParameters, Collection<Type> typeArguments) { return Streams.zip( typeParameters.stream(), typeArguments.stream(), (sym, type) -> { if (!hasThreadSafeTypeParameterAnnotation(sym)) { ...
java
public Violation checkInstantiation( Collection<TypeVariableSymbol> typeParameters, Collection<Type> typeArguments) { return Streams.zip( typeParameters.stream(), typeArguments.stream(), (sym, type) -> { if (!hasThreadSafeTypeParameterAnnotation(sym)) { ...
[ "public", "Violation", "checkInstantiation", "(", "Collection", "<", "TypeVariableSymbol", ">", "typeParameters", ",", "Collection", "<", "Type", ">", "typeArguments", ")", "{", "return", "Streams", ".", "zip", "(", "typeParameters", ".", "stream", "(", ")", ","...
Checks that any thread-safe type parameters are instantiated with thread-safe types.
[ "Checks", "that", "any", "thread", "-", "safe", "type", "parameters", "are", "instantiated", "with", "thread", "-", "safe", "types", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java#L846-L870
21,662
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java
ThreadSafety.checkInvocation
public Violation checkInvocation(Type methodType, Symbol symbol) { if (methodType == null) { return Violation.absent(); } List<TypeVariableSymbol> typeParameters = symbol.getTypeParameters(); if (typeParameters.stream().noneMatch(this::hasThreadSafeTypeParameterAnnotation)) { // fast path ...
java
public Violation checkInvocation(Type methodType, Symbol symbol) { if (methodType == null) { return Violation.absent(); } List<TypeVariableSymbol> typeParameters = symbol.getTypeParameters(); if (typeParameters.stream().noneMatch(this::hasThreadSafeTypeParameterAnnotation)) { // fast path ...
[ "public", "Violation", "checkInvocation", "(", "Type", "methodType", ",", "Symbol", "symbol", ")", "{", "if", "(", "methodType", "==", "null", ")", "{", "return", "Violation", ".", "absent", "(", ")", ";", "}", "List", "<", "TypeVariableSymbol", ">", "type...
Checks the instantiation of any thread-safe type parameters in the current invocation.
[ "Checks", "the", "instantiation", "of", "any", "thread", "-", "safe", "type", "parameters", "in", "the", "current", "invocation", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ThreadSafety.java#L873-L892
21,663
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/DoubleCheckedLocking.java
DoubleCheckedLocking.isImmutable
private static boolean isImmutable(Type type, VisitorState state) { switch (type.getKind()) { case BOOLEAN: case BYTE: case SHORT: case INT: case CHAR: case FLOAT: return true; case LONG: case DOUBLE: // double-width primitives aren't written atomicall...
java
private static boolean isImmutable(Type type, VisitorState state) { switch (type.getKind()) { case BOOLEAN: case BYTE: case SHORT: case INT: case CHAR: case FLOAT: return true; case LONG: case DOUBLE: // double-width primitives aren't written atomicall...
[ "private", "static", "boolean", "isImmutable", "(", "Type", "type", ",", "VisitorState", "state", ")", "{", "switch", "(", "type", ".", "getKind", "(", ")", ")", "{", "case", "BOOLEAN", ":", "case", "BYTE", ":", "case", "SHORT", ":", "case", "INT", ":"...
Recognize a small set of known-immutable types that are safe for DCL even without a volatile field.
[ "Recognize", "a", "small", "set", "of", "known", "-", "immutable", "types", "that", "are", "safe", "for", "DCL", "even", "without", "a", "volatile", "field", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/DoubleCheckedLocking.java#L116-L134
21,664
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/DoubleCheckedLocking.java
DoubleCheckedLocking.handleLocal
private Description handleLocal(DCLInfo info, VisitorState state) { JCExpressionStatement expr = getChild(info.synchTree().getBlock(), JCExpressionStatement.class); if (expr == null) { return Description.NO_MATCH; } if (expr.getStartPosition() > ((JCTree) info.innerIf()).getStartPosition()) { ...
java
private Description handleLocal(DCLInfo info, VisitorState state) { JCExpressionStatement expr = getChild(info.synchTree().getBlock(), JCExpressionStatement.class); if (expr == null) { return Description.NO_MATCH; } if (expr.getStartPosition() > ((JCTree) info.innerIf()).getStartPosition()) { ...
[ "private", "Description", "handleLocal", "(", "DCLInfo", "info", ",", "VisitorState", "state", ")", "{", "JCExpressionStatement", "expr", "=", "getChild", "(", "info", ".", "synchTree", "(", ")", ".", "getBlock", "(", ")", ",", "JCExpressionStatement", ".", "c...
Report a diagnostic for an instance of DCL on a local variable. A match is only reported if a non-volatile field is written to the variable after acquiring the lock and before the second null-check on the local. <p>e.g. <pre>{@code if ($X == null) { synchronized (...) { $X = myNonVolatileField; if ($X == null) { ... ...
[ "Report", "a", "diagnostic", "for", "an", "instance", "of", "DCL", "on", "a", "local", "variable", ".", "A", "match", "is", "only", "reported", "if", "a", "non", "-", "volatile", "field", "is", "written", "to", "the", "variable", "after", "acquiring", "t...
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/DoubleCheckedLocking.java#L155-L179
21,665
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/DoubleCheckedLocking.java
DoubleCheckedLocking.findFieldDeclaration
@Nullable private static JCTree findFieldDeclaration(TreePath path, VarSymbol var) { for (TreePath curr = path; curr != null; curr = curr.getParentPath()) { Tree leaf = curr.getLeaf(); if (!(leaf instanceof JCClassDecl)) { continue; } for (JCTree tree : ((JCClassDecl) leaf).getMemb...
java
@Nullable private static JCTree findFieldDeclaration(TreePath path, VarSymbol var) { for (TreePath curr = path; curr != null; curr = curr.getParentPath()) { Tree leaf = curr.getLeaf(); if (!(leaf instanceof JCClassDecl)) { continue; } for (JCTree tree : ((JCClassDecl) leaf).getMemb...
[ "@", "Nullable", "private", "static", "JCTree", "findFieldDeclaration", "(", "TreePath", "path", ",", "VarSymbol", "var", ")", "{", "for", "(", "TreePath", "curr", "=", "path", ";", "curr", "!=", "null", ";", "curr", "=", "curr", ".", "getParentPath", "(",...
Performs a best-effort search for the AST node of a field declaration. <p>It will only find fields declared in a lexically enclosing scope of the current location. Since double-checked locking should always be used on a private field, this should be reasonably effective.
[ "Performs", "a", "best", "-", "effort", "search", "for", "the", "AST", "node", "of", "a", "field", "declaration", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/DoubleCheckedLocking.java#L309-L323
21,666
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/BadComparable.java
BadComparable.matches
private boolean matches(TypeCastTree tree, VisitorState state) { Type treeType = ASTHelpers.getType(tree.getType()); // If the cast isn't narrowing to an int then don't implicate it in the bug pattern. if (treeType.getTag() != TypeTag.INT) { return false; } // The expression should be a subt...
java
private boolean matches(TypeCastTree tree, VisitorState state) { Type treeType = ASTHelpers.getType(tree.getType()); // If the cast isn't narrowing to an int then don't implicate it in the bug pattern. if (treeType.getTag() != TypeTag.INT) { return false; } // The expression should be a subt...
[ "private", "boolean", "matches", "(", "TypeCastTree", "tree", ",", "VisitorState", "state", ")", "{", "Type", "treeType", "=", "ASTHelpers", ".", "getType", "(", "tree", ".", "getType", "(", ")", ")", ";", "// If the cast isn't narrowing to an int then don't implica...
Matches if this is a narrowing integral cast between signed types where the expression is a subtract.
[ "Matches", "if", "this", "is", "a", "narrowing", "integral", "cast", "between", "signed", "types", "where", "the", "expression", "is", "a", "subtract", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/BadComparable.java#L96-L115
21,667
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/apidiff/ApiDiff.java
ApiDiff.isMemberUnsupported
boolean isMemberUnsupported(String className, ClassMemberKey memberKey) { return unsupportedMembersByClass().containsEntry(className, memberKey) || unsupportedMembersByClass() .containsEntry(className, ClassMemberKey.create(memberKey.identifier(), "")); }
java
boolean isMemberUnsupported(String className, ClassMemberKey memberKey) { return unsupportedMembersByClass().containsEntry(className, memberKey) || unsupportedMembersByClass() .containsEntry(className, ClassMemberKey.create(memberKey.identifier(), "")); }
[ "boolean", "isMemberUnsupported", "(", "String", "className", ",", "ClassMemberKey", "memberKey", ")", "{", "return", "unsupportedMembersByClass", "(", ")", ".", "containsEntry", "(", "className", ",", "memberKey", ")", "||", "unsupportedMembersByClass", "(", ")", "...
Returns true if the member with the given declaring class is unsupported.
[ "Returns", "true", "if", "the", "member", "with", "the", "given", "declaring", "class", "is", "unsupported", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/apidiff/ApiDiff.java#L62-L66
21,668
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/ReturnValueIgnored.java
ReturnValueIgnored.methodReturnsSameTypeAsReceiver
private static Matcher<ExpressionTree> methodReturnsSameTypeAsReceiver() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { return isSameType( ASTHelpers.getReceiverType(expressionTree), ASTHelper...
java
private static Matcher<ExpressionTree> methodReturnsSameTypeAsReceiver() { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { return isSameType( ASTHelpers.getReceiverType(expressionTree), ASTHelper...
[ "private", "static", "Matcher", "<", "ExpressionTree", ">", "methodReturnsSameTypeAsReceiver", "(", ")", "{", "return", "new", "Matcher", "<", "ExpressionTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "ExpressionTree", "expression...
Matches method invocations that return the same type as the receiver object.
[ "Matches", "method", "invocations", "that", "return", "the", "same", "type", "as", "the", "receiver", "object", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ReturnValueIgnored.java#L161-L171
21,669
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/ReturnValueIgnored.java
ReturnValueIgnored.methodReceiverHasType
private static Matcher<ExpressionTree> methodReceiverHasType(final Set<String> typeSet) { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { Type receiverType = ASTHelpers.getReceiverType(expressionTree); return ty...
java
private static Matcher<ExpressionTree> methodReceiverHasType(final Set<String> typeSet) { return new Matcher<ExpressionTree>() { @Override public boolean matches(ExpressionTree expressionTree, VisitorState state) { Type receiverType = ASTHelpers.getReceiverType(expressionTree); return ty...
[ "private", "static", "Matcher", "<", "ExpressionTree", ">", "methodReceiverHasType", "(", "final", "Set", "<", "String", ">", "typeSet", ")", "{", "return", "new", "Matcher", "<", "ExpressionTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "m...
Matches method calls whose receiver objects are of a type included in the set.
[ "Matches", "method", "calls", "whose", "receiver", "objects", "are", "of", "a", "type", "included", "in", "the", "set", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ReturnValueIgnored.java#L174-L182
21,670
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JdkObsolete.java
JdkObsolete.stringBufferFix
private static Optional<Fix> stringBufferFix(VisitorState state) { Tree tree = state.getPath().getLeaf(); // expect `new StringBuffer()` if (!(tree instanceof NewClassTree)) { return Optional.empty(); } // expect e.g. `StringBuffer sb = new StringBuffer();` NewClassTree newClassTree = (New...
java
private static Optional<Fix> stringBufferFix(VisitorState state) { Tree tree = state.getPath().getLeaf(); // expect `new StringBuffer()` if (!(tree instanceof NewClassTree)) { return Optional.empty(); } // expect e.g. `StringBuffer sb = new StringBuffer();` NewClassTree newClassTree = (New...
[ "private", "static", "Optional", "<", "Fix", ">", "stringBufferFix", "(", "VisitorState", "state", ")", "{", "Tree", "tree", "=", "state", ".", "getPath", "(", ")", ".", "getLeaf", "(", ")", ";", "// expect `new StringBuffer()`", "if", "(", "!", "(", "tree...
current method.
[ "current", "method", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JdkObsolete.java#L307-L355
21,671
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JdkObsolete.java
JdkObsolete.mockingObsoleteMethod
private boolean mockingObsoleteMethod(MethodTree enclosingMethod, VisitorState state, Type type) { // mutable boolean to return result from visitor boolean[] found = {false}; enclosingMethod.accept( new TreeScanner<Void, Void>() { @Override public Void visitMethodInvocation(Metho...
java
private boolean mockingObsoleteMethod(MethodTree enclosingMethod, VisitorState state, Type type) { // mutable boolean to return result from visitor boolean[] found = {false}; enclosingMethod.accept( new TreeScanner<Void, Void>() { @Override public Void visitMethodInvocation(Metho...
[ "private", "boolean", "mockingObsoleteMethod", "(", "MethodTree", "enclosingMethod", ",", "VisitorState", "state", ",", "Type", "type", ")", "{", "// mutable boolean to return result from visitor", "boolean", "[", "]", "found", "=", "{", "false", "}", ";", "enclosingM...
Allow mocking APIs that return obsolete types.
[ "Allow", "mocking", "APIs", "that", "return", "obsolete", "types", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JdkObsolete.java#L390-L413
21,672
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/JdkObsolete.java
JdkObsolete.implementingObsoleteMethod
private static boolean implementingObsoleteMethod( MethodTree enclosingMethod, VisitorState state, Type type) { MethodSymbol method = ASTHelpers.getSymbol(enclosingMethod); if (method == null) { return false; } if (ASTHelpers.findSuperMethods(method, state.getTypes()).isEmpty()) { // n...
java
private static boolean implementingObsoleteMethod( MethodTree enclosingMethod, VisitorState state, Type type) { MethodSymbol method = ASTHelpers.getSymbol(enclosingMethod); if (method == null) { return false; } if (ASTHelpers.findSuperMethods(method, state.getTypes()).isEmpty()) { // n...
[ "private", "static", "boolean", "implementingObsoleteMethod", "(", "MethodTree", "enclosingMethod", ",", "VisitorState", "state", ",", "Type", "type", ")", "{", "MethodSymbol", "method", "=", "ASTHelpers", ".", "getSymbol", "(", "enclosingMethod", ")", ";", "if", ...
Allow creating obsolete types when overriding a method with an obsolete return type.
[ "Allow", "creating", "obsolete", "types", "when", "overriding", "a", "method", "with", "an", "obsolete", "return", "type", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/JdkObsolete.java#L416-L430
21,673
google/error-prone
check_api/src/main/java/com/google/errorprone/scanner/Scanner.java
Scanner.isSuppressed
protected SuppressedState isSuppressed( Suppressible suppressible, ErrorProneOptions errorProneOptions) { boolean suppressedInGeneratedCode = errorProneOptions.disableWarningsInGeneratedCode() && severityMap().get(suppressible.canonicalName()) != SeverityLevel.ERROR; return currentSu...
java
protected SuppressedState isSuppressed( Suppressible suppressible, ErrorProneOptions errorProneOptions) { boolean suppressedInGeneratedCode = errorProneOptions.disableWarningsInGeneratedCode() && severityMap().get(suppressible.canonicalName()) != SeverityLevel.ERROR; return currentSu...
[ "protected", "SuppressedState", "isSuppressed", "(", "Suppressible", "suppressible", ",", "ErrorProneOptions", "errorProneOptions", ")", "{", "boolean", "suppressedInGeneratedCode", "=", "errorProneOptions", ".", "disableWarningsInGeneratedCode", "(", ")", "&&", "severityMap"...
Returns if this checker should be suppressed on the current tree path. @param suppressible holds information about the suppressibility of a checker @param errorProneOptions Options object configuring whether or not to suppress non-errors in generated code.
[ "Returns", "if", "this", "checker", "should", "be", "suppressed", "on", "the", "current", "tree", "path", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/scanner/Scanner.java#L105-L113
21,674
google/error-prone
core/src/main/java/com/google/errorprone/refaster/URepeated.java
URepeated.getUnderlyingBinding
public JCExpression getUnderlyingBinding(Unifier unifier) { return (unifier == null) ? null : unifier.getBinding(new UFreeIdent.Key(identifier())); }
java
public JCExpression getUnderlyingBinding(Unifier unifier) { return (unifier == null) ? null : unifier.getBinding(new UFreeIdent.Key(identifier())); }
[ "public", "JCExpression", "getUnderlyingBinding", "(", "Unifier", "unifier", ")", "{", "return", "(", "unifier", "==", "null", ")", "?", "null", ":", "unifier", ".", "getBinding", "(", "new", "UFreeIdent", ".", "Key", "(", "identifier", "(", ")", ")", ")",...
Gets the binding of the underlying identifier in the unifier.
[ "Gets", "the", "binding", "of", "the", "underlying", "identifier", "in", "the", "unifier", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/URepeated.java#L60-L62
21,675
google/error-prone
check_api/src/main/java/com/google/errorprone/ErrorProneVersion.java
ErrorProneVersion.loadVersionFromPom
public static Optional<String> loadVersionFromPom() { try (InputStream stream = ErrorProneVersion.class.getResourceAsStream(PROPERTIES_RESOURCE)) { if (stream == null) { return Optional.absent(); } Properties mavenProperties = new Properties(); mavenProperties.load(stream); ret...
java
public static Optional<String> loadVersionFromPom() { try (InputStream stream = ErrorProneVersion.class.getResourceAsStream(PROPERTIES_RESOURCE)) { if (stream == null) { return Optional.absent(); } Properties mavenProperties = new Properties(); mavenProperties.load(stream); ret...
[ "public", "static", "Optional", "<", "String", ">", "loadVersionFromPom", "(", ")", "{", "try", "(", "InputStream", "stream", "=", "ErrorProneVersion", ".", "class", ".", "getResourceAsStream", "(", "PROPERTIES_RESOURCE", ")", ")", "{", "if", "(", "stream", "=...
Loads the Error Prone version. <p>This depends on the Maven build, and will always return {@code Optional.absent()} with other build systems.
[ "Loads", "the", "Error", "Prone", "version", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/ErrorProneVersion.java#L36-L47
21,676
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/HeldLockAnalyzer.java
HeldLockAnalyzer.analyze
public static void analyze( VisitorState state, LockEventListener listener, Predicate<Tree> isSuppressed) { HeldLockSet locks = HeldLockSet.empty(); locks = handleMonitorGuards(state, locks); new LockScanner(state, listener, isSuppressed).scan(state.getPath(), locks); }
java
public static void analyze( VisitorState state, LockEventListener listener, Predicate<Tree> isSuppressed) { HeldLockSet locks = HeldLockSet.empty(); locks = handleMonitorGuards(state, locks); new LockScanner(state, listener, isSuppressed).scan(state.getPath(), locks); }
[ "public", "static", "void", "analyze", "(", "VisitorState", "state", ",", "LockEventListener", "listener", ",", "Predicate", "<", "Tree", ">", "isSuppressed", ")", "{", "HeldLockSet", "locks", "=", "HeldLockSet", ".", "empty", "(", ")", ";", "locks", "=", "h...
Analyzes a method body, tracking the set of held locks and checking accesses to guarded members.
[ "Analyzes", "a", "method", "body", "tracking", "the", "set", "of", "held", "locks", "and", "checking", "accesses", "to", "guarded", "members", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/HeldLockAnalyzer.java#L83-L88
21,677
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java
NonAtomicVolatileUpdate.expressionFromUnaryTree
private static Matcher<UnaryTree> expressionFromUnaryTree( final Matcher<ExpressionTree> exprMatcher) { return new Matcher<UnaryTree>() { @Override public boolean matches(UnaryTree tree, VisitorState state) { return exprMatcher.matches(tree.getExpression(), state); } }; }
java
private static Matcher<UnaryTree> expressionFromUnaryTree( final Matcher<ExpressionTree> exprMatcher) { return new Matcher<UnaryTree>() { @Override public boolean matches(UnaryTree tree, VisitorState state) { return exprMatcher.matches(tree.getExpression(), state); } }; }
[ "private", "static", "Matcher", "<", "UnaryTree", ">", "expressionFromUnaryTree", "(", "final", "Matcher", "<", "ExpressionTree", ">", "exprMatcher", ")", "{", "return", "new", "Matcher", "<", "UnaryTree", ">", "(", ")", "{", "@", "Override", "public", "boolea...
Extracts the expression from a UnaryTree and applies a matcher to it.
[ "Extracts", "the", "expression", "from", "a", "UnaryTree", "and", "applies", "a", "matcher", "to", "it", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java#L57-L65
21,678
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java
NonAtomicVolatileUpdate.variableFromCompoundAssignmentTree
private static Matcher<CompoundAssignmentTree> variableFromCompoundAssignmentTree( final Matcher<ExpressionTree> exprMatcher) { return new Matcher<CompoundAssignmentTree>() { @Override public boolean matches(CompoundAssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree...
java
private static Matcher<CompoundAssignmentTree> variableFromCompoundAssignmentTree( final Matcher<ExpressionTree> exprMatcher) { return new Matcher<CompoundAssignmentTree>() { @Override public boolean matches(CompoundAssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree...
[ "private", "static", "Matcher", "<", "CompoundAssignmentTree", ">", "variableFromCompoundAssignmentTree", "(", "final", "Matcher", "<", "ExpressionTree", ">", "exprMatcher", ")", "{", "return", "new", "Matcher", "<", "CompoundAssignmentTree", ">", "(", ")", "{", "@"...
Extracts the variable from a CompoundAssignmentTree and applies a matcher to it.
[ "Extracts", "the", "variable", "from", "a", "CompoundAssignmentTree", "and", "applies", "a", "matcher", "to", "it", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java#L68-L76
21,679
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java
NonAtomicVolatileUpdate.variableFromAssignmentTree
private static Matcher<AssignmentTree> variableFromAssignmentTree( final Matcher<ExpressionTree> exprMatcher) { return new Matcher<AssignmentTree>() { @Override public boolean matches(AssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree.getVariable(), state); } ...
java
private static Matcher<AssignmentTree> variableFromAssignmentTree( final Matcher<ExpressionTree> exprMatcher) { return new Matcher<AssignmentTree>() { @Override public boolean matches(AssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree.getVariable(), state); } ...
[ "private", "static", "Matcher", "<", "AssignmentTree", ">", "variableFromAssignmentTree", "(", "final", "Matcher", "<", "ExpressionTree", ">", "exprMatcher", ")", "{", "return", "new", "Matcher", "<", "AssignmentTree", ">", "(", ")", "{", "@", "Override", "publi...
Extracts the variable from an AssignmentTree and applies a matcher to it.
[ "Extracts", "the", "variable", "from", "an", "AssignmentTree", "and", "applies", "a", "matcher", "to", "it", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java#L79-L87
21,680
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java
NonAtomicVolatileUpdate.assignmentIncrementDecrementMatcher
private static Matcher<AssignmentTree> assignmentIncrementDecrementMatcher( ExpressionTree variable) { return allOf( variableFromAssignmentTree(Matchers.<ExpressionTree>hasModifier(Modifier.VOLATILE)), not(inSynchronized()), assignment( Matchers.<ExpressionTree>anything(), ...
java
private static Matcher<AssignmentTree> assignmentIncrementDecrementMatcher( ExpressionTree variable) { return allOf( variableFromAssignmentTree(Matchers.<ExpressionTree>hasModifier(Modifier.VOLATILE)), not(inSynchronized()), assignment( Matchers.<ExpressionTree>anything(), ...
[ "private", "static", "Matcher", "<", "AssignmentTree", ">", "assignmentIncrementDecrementMatcher", "(", "ExpressionTree", "variable", ")", "{", "return", "allOf", "(", "variableFromAssignmentTree", "(", "Matchers", ".", "<", "ExpressionTree", ">", "hasModifier", "(", ...
Matches patterns like i = i + 1 and i = i - 1 in which i is volatile, and the pattern is not enclosed by a synchronized block.
[ "Matches", "patterns", "like", "i", "=", "i", "+", "1", "and", "i", "=", "i", "-", "1", "in", "which", "i", "is", "volatile", "and", "the", "pattern", "is", "not", "enclosed", "by", "a", "synchronized", "block", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/NonAtomicVolatileUpdate.java#L134-L146
21,681
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/CanBeStaticAnalyzer.java
CanBeStaticAnalyzer.referencesOuter
public static boolean referencesOuter(Tree tree, Symbol owner, VisitorState state) { CanBeStaticAnalyzer scanner = new CanBeStaticAnalyzer(owner, state); ((JCTree) tree).accept(scanner); return !scanner.canPossiblyBeStatic || !scanner.outerReferences.isEmpty(); }
java
public static boolean referencesOuter(Tree tree, Symbol owner, VisitorState state) { CanBeStaticAnalyzer scanner = new CanBeStaticAnalyzer(owner, state); ((JCTree) tree).accept(scanner); return !scanner.canPossiblyBeStatic || !scanner.outerReferences.isEmpty(); }
[ "public", "static", "boolean", "referencesOuter", "(", "Tree", "tree", ",", "Symbol", "owner", ",", "VisitorState", "state", ")", "{", "CanBeStaticAnalyzer", "scanner", "=", "new", "CanBeStaticAnalyzer", "(", "owner", ",", "state", ")", ";", "(", "(", "JCTree"...
Returns true if the tree references its enclosing class.
[ "Returns", "true", "if", "the", "tree", "references", "its", "enclosing", "class", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/CanBeStaticAnalyzer.java#L43-L47
21,682
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/CanBeStaticAnalyzer.java
CanBeStaticAnalyzer.memberOfEnclosing
private static boolean memberOfEnclosing(Symbol owner, VisitorState state, Symbol sym) { if (sym == null || !sym.hasOuterInstance()) { return false; } for (ClassSymbol encl = owner.owner.enclClass(); encl != null; encl = encl.owner != null ? encl.owner.enclClass() : null) { if (s...
java
private static boolean memberOfEnclosing(Symbol owner, VisitorState state, Symbol sym) { if (sym == null || !sym.hasOuterInstance()) { return false; } for (ClassSymbol encl = owner.owner.enclClass(); encl != null; encl = encl.owner != null ? encl.owner.enclClass() : null) { if (s...
[ "private", "static", "boolean", "memberOfEnclosing", "(", "Symbol", "owner", ",", "VisitorState", "state", ",", "Symbol", "sym", ")", "{", "if", "(", "sym", "==", "null", "||", "!", "sym", ".", "hasOuterInstance", "(", ")", ")", "{", "return", "false", "...
Is sym a non-static member of an enclosing class of currentClass?
[ "Is", "sym", "a", "non", "-", "static", "member", "of", "an", "enclosing", "class", "of", "currentClass?" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/CanBeStaticAnalyzer.java#L180-L192
21,683
google/error-prone
check_api/src/main/java/com/google/errorprone/names/TermEditDistance.java
TermEditDistance.computeCost
private static double computeCost( int[] assignments, double[][] costMatrix, double[] sourceTermDeletionCosts, double[] targetTermDeletionCosts) { // We need to sum the costs of each assigned pair, each unassigned source term, and each // unassigned target term. // Start with the t...
java
private static double computeCost( int[] assignments, double[][] costMatrix, double[] sourceTermDeletionCosts, double[] targetTermDeletionCosts) { // We need to sum the costs of each assigned pair, each unassigned source term, and each // unassigned target term. // Start with the t...
[ "private", "static", "double", "computeCost", "(", "int", "[", "]", "assignments", ",", "double", "[", "]", "[", "]", "costMatrix", ",", "double", "[", "]", "sourceTermDeletionCosts", ",", "double", "[", "]", "targetTermDeletionCosts", ")", "{", "// We need to...
Compute the total cost of this assignment including the costs of unassigned source and target terms.
[ "Compute", "the", "total", "cost", "of", "this", "assignment", "including", "the", "costs", "of", "unassigned", "source", "and", "target", "terms", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/names/TermEditDistance.java#L102-L128
21,684
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/BigDecimalLiteralDouble.java
BigDecimalLiteralDouble.floatingPointArgument
private static boolean floatingPointArgument(ExpressionTree tree) { if (tree.getKind() == Kind.UNARY_PLUS || tree.getKind() == Kind.UNARY_MINUS) { tree = ((UnaryTree) tree).getExpression(); } return tree.getKind() == Kind.DOUBLE_LITERAL || tree.getKind() == Kind.FLOAT_LITERAL; }
java
private static boolean floatingPointArgument(ExpressionTree tree) { if (tree.getKind() == Kind.UNARY_PLUS || tree.getKind() == Kind.UNARY_MINUS) { tree = ((UnaryTree) tree).getExpression(); } return tree.getKind() == Kind.DOUBLE_LITERAL || tree.getKind() == Kind.FLOAT_LITERAL; }
[ "private", "static", "boolean", "floatingPointArgument", "(", "ExpressionTree", "tree", ")", "{", "if", "(", "tree", ".", "getKind", "(", ")", "==", "Kind", ".", "UNARY_PLUS", "||", "tree", ".", "getKind", "(", ")", "==", "Kind", ".", "UNARY_MINUS", ")", ...
accept multiple unary prefixes.
[ "accept", "multiple", "unary", "prefixes", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/BigDecimalLiteralDouble.java#L64-L69
21,685
google/error-prone
core/src/main/java/com/google/errorprone/refaster/PlaceholderUnificationVisitor.java
PlaceholderUnificationVisitor.chooseSubtrees
private static <T, R> Choice<State<R>> chooseSubtrees( State<?> state, Function<State<?>, Choice<? extends State<? extends T>>> choice1, Function<T, R> finalizer) { return choice1.apply(state).transform(s -> s.withResult(finalizer.apply(s.result()))); }
java
private static <T, R> Choice<State<R>> chooseSubtrees( State<?> state, Function<State<?>, Choice<? extends State<? extends T>>> choice1, Function<T, R> finalizer) { return choice1.apply(state).transform(s -> s.withResult(finalizer.apply(s.result()))); }
[ "private", "static", "<", "T", ",", "R", ">", "Choice", "<", "State", "<", "R", ">", ">", "chooseSubtrees", "(", "State", "<", "?", ">", "state", ",", "Function", "<", "State", "<", "?", ">", ",", "Choice", "<", "?", "extends", "State", "<", "?",...
This method, and its overloads, take <ol> <li>an initial state <li>functions that, given one state, return a branch choosing a subtree <li>a function that takes pieces of a tree type and recomposes them </ol>
[ "This", "method", "and", "its", "overloads", "take" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/PlaceholderUnificationVisitor.java#L311-L316
21,686
google/error-prone
check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java
MoreAnnotations.getValue
public static Optional<Attribute> getValue(Attribute.Compound attribute, String name) { return attribute.getElementValues().entrySet().stream() .filter(e -> e.getKey().getSimpleName().contentEquals(name)) .map(Map.Entry::getValue) .findFirst(); }
java
public static Optional<Attribute> getValue(Attribute.Compound attribute, String name) { return attribute.getElementValues().entrySet().stream() .filter(e -> e.getKey().getSimpleName().contentEquals(name)) .map(Map.Entry::getValue) .findFirst(); }
[ "public", "static", "Optional", "<", "Attribute", ">", "getValue", "(", "Attribute", ".", "Compound", "attribute", ",", "String", "name", ")", "{", "return", "attribute", ".", "getElementValues", "(", ")", ".", "entrySet", "(", ")", ".", "stream", "(", ")"...
Returns the value of the annotation element-value pair with the given name if it is not explicitly set.
[ "Returns", "the", "value", "of", "the", "annotation", "element", "-", "value", "pair", "with", "the", "given", "name", "if", "it", "is", "not", "explicitly", "set", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java#L109-L114
21,687
google/error-prone
check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java
MoreAnnotations.asIntegerValue
public static Optional<Integer> asIntegerValue(Attribute a) { class Visitor extends SimpleAnnotationValueVisitor8<Integer, Void> { @Override public Integer visitInt(int i, Void unused) { return i; } } return Optional.ofNullable(a.accept(new Visitor(), null)); }
java
public static Optional<Integer> asIntegerValue(Attribute a) { class Visitor extends SimpleAnnotationValueVisitor8<Integer, Void> { @Override public Integer visitInt(int i, Void unused) { return i; } } return Optional.ofNullable(a.accept(new Visitor(), null)); }
[ "public", "static", "Optional", "<", "Integer", ">", "asIntegerValue", "(", "Attribute", "a", ")", "{", "class", "Visitor", "extends", "SimpleAnnotationValueVisitor8", "<", "Integer", ",", "Void", ">", "{", "@", "Override", "public", "Integer", "visitInt", "(", ...
Converts the given attribute to an integer value.
[ "Converts", "the", "given", "attribute", "to", "an", "integer", "value", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java#L117-L125
21,688
google/error-prone
check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java
MoreAnnotations.asStringValue
public static Optional<String> asStringValue(Attribute a) { class Visitor extends SimpleAnnotationValueVisitor8<String, Void> { @Override public String visitString(String s, Void unused) { return s; } } return Optional.ofNullable(a.accept(new Visitor(), null)); }
java
public static Optional<String> asStringValue(Attribute a) { class Visitor extends SimpleAnnotationValueVisitor8<String, Void> { @Override public String visitString(String s, Void unused) { return s; } } return Optional.ofNullable(a.accept(new Visitor(), null)); }
[ "public", "static", "Optional", "<", "String", ">", "asStringValue", "(", "Attribute", "a", ")", "{", "class", "Visitor", "extends", "SimpleAnnotationValueVisitor8", "<", "String", ",", "Void", ">", "{", "@", "Override", "public", "String", "visitString", "(", ...
Converts the given attribute to an string value.
[ "Converts", "the", "given", "attribute", "to", "an", "string", "value", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java#L128-L136
21,689
google/error-prone
check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java
MoreAnnotations.asEnumValue
public static <T extends Enum<T>> Optional<T> asEnumValue(Class<T> clazz, Attribute a) { class Visitor extends SimpleAnnotationValueVisitor8<T, Void> { @Override public T visitEnumConstant(VariableElement c, Void unused) { return Enum.valueOf(clazz, c.getSimpleName().toString()); } } ...
java
public static <T extends Enum<T>> Optional<T> asEnumValue(Class<T> clazz, Attribute a) { class Visitor extends SimpleAnnotationValueVisitor8<T, Void> { @Override public T visitEnumConstant(VariableElement c, Void unused) { return Enum.valueOf(clazz, c.getSimpleName().toString()); } } ...
[ "public", "static", "<", "T", "extends", "Enum", "<", "T", ">", ">", "Optional", "<", "T", ">", "asEnumValue", "(", "Class", "<", "T", ">", "clazz", ",", "Attribute", "a", ")", "{", "class", "Visitor", "extends", "SimpleAnnotationValueVisitor8", "<", "T"...
Converts the given attribute to an enum value.
[ "Converts", "the", "given", "attribute", "to", "an", "enum", "value", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/MoreAnnotations.java#L139-L147
21,690
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/inject/InvalidTargetingOnScopingAnnotation.java
InvalidTargetingOnScopingAnnotation.replaceTargetAnnotation
private static Fix replaceTargetAnnotation( Target annotation, AnnotationTree targetAnnotationTree) { Set<ElementType> types = EnumSet.copyOf(REQUIRED_ELEMENT_TYPES); types.addAll(Arrays.asList(annotation.value())); return replaceTargetAnnotation(targetAnnotationTree, types); }
java
private static Fix replaceTargetAnnotation( Target annotation, AnnotationTree targetAnnotationTree) { Set<ElementType> types = EnumSet.copyOf(REQUIRED_ELEMENT_TYPES); types.addAll(Arrays.asList(annotation.value())); return replaceTargetAnnotation(targetAnnotationTree, types); }
[ "private", "static", "Fix", "replaceTargetAnnotation", "(", "Target", "annotation", ",", "AnnotationTree", "targetAnnotationTree", ")", "{", "Set", "<", "ElementType", ">", "types", "=", "EnumSet", ".", "copyOf", "(", "REQUIRED_ELEMENT_TYPES", ")", ";", "types", "...
Rewrite the annotation with static imports, adding TYPE and METHOD to the @Target annotation value (and reordering them to their declaration order in ElementType).
[ "Rewrite", "the", "annotation", "with", "static", "imports", "adding", "TYPE", "and", "METHOD", "to", "the" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/inject/InvalidTargetingOnScopingAnnotation.java#L98-L104
21,691
google/error-prone
check_api/src/main/java/com/google/errorprone/ErrorProneAnalyzer.java
ErrorProneAnalyzer.shouldExcludeSourceFile
private boolean shouldExcludeSourceFile(CompilationUnitTree tree) { Pattern excludedPattern = errorProneOptions.getExcludedPattern(); return excludedPattern != null && excludedPattern.matcher(ASTHelpers.getFileName(tree)).matches(); }
java
private boolean shouldExcludeSourceFile(CompilationUnitTree tree) { Pattern excludedPattern = errorProneOptions.getExcludedPattern(); return excludedPattern != null && excludedPattern.matcher(ASTHelpers.getFileName(tree)).matches(); }
[ "private", "boolean", "shouldExcludeSourceFile", "(", "CompilationUnitTree", "tree", ")", "{", "Pattern", "excludedPattern", "=", "errorProneOptions", ".", "getExcludedPattern", "(", ")", ";", "return", "excludedPattern", "!=", "null", "&&", "excludedPattern", ".", "m...
Returns true if the given source file should be excluded from analysis.
[ "Returns", "true", "if", "the", "given", "source", "file", "should", "be", "excluded", "from", "analysis", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/ErrorProneAnalyzer.java#L177-L181
21,692
google/error-prone
check_api/src/main/java/com/google/errorprone/ErrorProneAnalyzer.java
ErrorProneAnalyzer.finishedCompilation
private boolean finishedCompilation(CompilationUnitTree tree) { OUTER: for (Tree decl : tree.getTypeDecls()) { switch (decl.getKind()) { case EMPTY_STATEMENT: // ignore ";" at the top level, which counts as an empty type decl continue OUTER; case IMPORT: // Th...
java
private boolean finishedCompilation(CompilationUnitTree tree) { OUTER: for (Tree decl : tree.getTypeDecls()) { switch (decl.getKind()) { case EMPTY_STATEMENT: // ignore ";" at the top level, which counts as an empty type decl continue OUTER; case IMPORT: // Th...
[ "private", "boolean", "finishedCompilation", "(", "CompilationUnitTree", "tree", ")", "{", "OUTER", ":", "for", "(", "Tree", "decl", ":", "tree", ".", "getTypeDecls", "(", ")", ")", "{", "switch", "(", "decl", ".", "getKind", "(", ")", ")", "{", "case", ...
Returns true if all declarations inside the given compilation unit have been visited.
[ "Returns", "true", "if", "all", "declarations", "inside", "the", "given", "compilation", "unit", "have", "been", "visited", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/ErrorProneAnalyzer.java#L184-L207
21,693
google/error-prone
core/src/main/java/com/google/errorprone/refaster/PlaceholderMethod.java
PlaceholderMethod.requiredParameters
Set<UVariableDecl> requiredParameters() { return Maps.filterValues( annotatedParameters(), (ImmutableClassToInstanceMap<Annotation> annotations) -> !annotations.containsKey(MayOptionallyUse.class)) .keySet(); }
java
Set<UVariableDecl> requiredParameters() { return Maps.filterValues( annotatedParameters(), (ImmutableClassToInstanceMap<Annotation> annotations) -> !annotations.containsKey(MayOptionallyUse.class)) .keySet(); }
[ "Set", "<", "UVariableDecl", ">", "requiredParameters", "(", ")", "{", "return", "Maps", ".", "filterValues", "(", "annotatedParameters", "(", ")", ",", "(", "ImmutableClassToInstanceMap", "<", "Annotation", ">", "annotations", ")", "->", "!", "annotations", "."...
Parameters which must be referenced in any tree matched to this placeholder.
[ "Parameters", "which", "must", "be", "referenced", "in", "any", "tree", "matched", "to", "this", "placeholder", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/PlaceholderMethod.java#L107-L113
21,694
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/JUnitMatchers.java
JUnitMatchers.hasJUnitAnnotation
public static boolean hasJUnitAnnotation(MethodTree tree, VisitorState state) { MethodSymbol methodSym = getSymbol(tree); if (methodSym == null) { return false; } if (hasJUnitAttr(methodSym)) { return true; } return findSuperMethods(methodSym, state.getTypes()).stream() .anyM...
java
public static boolean hasJUnitAnnotation(MethodTree tree, VisitorState state) { MethodSymbol methodSym = getSymbol(tree); if (methodSym == null) { return false; } if (hasJUnitAttr(methodSym)) { return true; } return findSuperMethods(methodSym, state.getTypes()).stream() .anyM...
[ "public", "static", "boolean", "hasJUnitAnnotation", "(", "MethodTree", "tree", ",", "VisitorState", "state", ")", "{", "MethodSymbol", "methodSym", "=", "getSymbol", "(", "tree", ")", ";", "if", "(", "methodSym", "==", "null", ")", "{", "return", "false", "...
Checks if a method, or any overridden method, is annotated with any annotation from the org.junit package.
[ "Checks", "if", "a", "method", "or", "any", "overridden", "method", "is", "annotated", "with", "any", "annotation", "from", "the", "org", ".", "junit", "package", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/JUnitMatchers.java#L81-L91
21,695
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/JUnitMatchers.java
JUnitMatchers.hasJUnitAttr
private static boolean hasJUnitAttr(MethodSymbol methodSym) { return methodSym.getRawAttributes().stream() .anyMatch(attr -> attr.type.tsym.getQualifiedName().toString().startsWith("org.junit.")); }
java
private static boolean hasJUnitAttr(MethodSymbol methodSym) { return methodSym.getRawAttributes().stream() .anyMatch(attr -> attr.type.tsym.getQualifiedName().toString().startsWith("org.junit.")); }
[ "private", "static", "boolean", "hasJUnitAttr", "(", "MethodSymbol", "methodSym", ")", "{", "return", "methodSym", ".", "getRawAttributes", "(", ")", ".", "stream", "(", ")", ".", "anyMatch", "(", "attr", "->", "attr", ".", "type", ".", "tsym", ".", "getQu...
Checks if a method symbol has any attribute from the org.junit package.
[ "Checks", "if", "a", "method", "symbol", "has", "any", "attribute", "from", "the", "org", ".", "junit", "package", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/JUnitMatchers.java#L94-L97
21,696
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/GuardedBySymbolResolver.java
GuardedBySymbolResolver.resolveType
private Symbol resolveType(String name, SearchSuperTypes searchSuperTypes) { Symbol type = null; if (searchSuperTypes == SearchSuperTypes.YES) { type = getSuperType(enclosingClass, name); } if (enclosingClass.getSimpleName().contentEquals(name)) { type = enclosingClass; } if (type ==...
java
private Symbol resolveType(String name, SearchSuperTypes searchSuperTypes) { Symbol type = null; if (searchSuperTypes == SearchSuperTypes.YES) { type = getSuperType(enclosingClass, name); } if (enclosingClass.getSimpleName().contentEquals(name)) { type = enclosingClass; } if (type ==...
[ "private", "Symbol", "resolveType", "(", "String", "name", ",", "SearchSuperTypes", "searchSuperTypes", ")", "{", "Symbol", "type", "=", "null", ";", "if", "(", "searchSuperTypes", "==", "SearchSuperTypes", ".", "YES", ")", "{", "type", "=", "getSuperType", "(...
Resolves a simple name as a type. Considers super classes, lexically enclosing classes, and then arbitrary types available in the current environment.
[ "Resolves", "a", "simple", "name", "as", "a", "type", ".", "Considers", "super", "classes", "lexically", "enclosing", "classes", "and", "then", "arbitrary", "types", "available", "in", "the", "current", "environment", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/GuardedBySymbolResolver.java#L197-L216
21,697
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/AssertEqualsArgumentOrderChecker.java
AssertEqualsArgumentOrderChecker.isEnumIdentifier
private static boolean isEnumIdentifier(Parameter parameter) { switch (parameter.kind()) { case IDENTIFIER: case MEMBER_SELECT: break; default: return false; } TypeSymbol typeSymbol = parameter.type().tsym; if (typeSymbol != null) { return typeSymbol.getKind() == ...
java
private static boolean isEnumIdentifier(Parameter parameter) { switch (parameter.kind()) { case IDENTIFIER: case MEMBER_SELECT: break; default: return false; } TypeSymbol typeSymbol = parameter.type().tsym; if (typeSymbol != null) { return typeSymbol.getKind() == ...
[ "private", "static", "boolean", "isEnumIdentifier", "(", "Parameter", "parameter", ")", "{", "switch", "(", "parameter", ".", "kind", "(", ")", ")", "{", "case", "IDENTIFIER", ":", "case", "MEMBER_SELECT", ":", "break", ";", "default", ":", "return", "false"...
Returns true if this parameter is an enum identifier
[ "Returns", "true", "if", "this", "parameter", "is", "an", "enum", "identifier" ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/AssertEqualsArgumentOrderChecker.java#L130-L143
21,698
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/AbstractMustBeClosedChecker.java
AbstractMustBeClosedChecker.enclosingMethod
@Nullable private static MethodTree enclosingMethod(VisitorState state) { for (Tree node : state.getPath().getParentPath()) { switch (node.getKind()) { case LAMBDA_EXPRESSION: case NEW_CLASS: return null; case METHOD: return (MethodTree) node; default: ...
java
@Nullable private static MethodTree enclosingMethod(VisitorState state) { for (Tree node : state.getPath().getParentPath()) { switch (node.getKind()) { case LAMBDA_EXPRESSION: case NEW_CLASS: return null; case METHOD: return (MethodTree) node; default: ...
[ "@", "Nullable", "private", "static", "MethodTree", "enclosingMethod", "(", "VisitorState", "state", ")", "{", "for", "(", "Tree", "node", ":", "state", ".", "getPath", "(", ")", ".", "getParentPath", "(", ")", ")", "{", "switch", "(", "node", ".", "getK...
Returns the enclosing method of the given visitor state. Returns null if the state is within a lambda expression or anonymous class.
[ "Returns", "the", "enclosing", "method", "of", "the", "given", "visitor", "state", ".", "Returns", "null", "if", "the", "state", "is", "within", "a", "lambda", "expression", "or", "anonymous", "class", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AbstractMustBeClosedChecker.java#L162-L176
21,699
google/error-prone
core/src/main/java/com/google/errorprone/bugpatterns/MissingCasesInEnumSwitch.java
MissingCasesInEnumSwitch.buildMessage
private String buildMessage(Set<String> unhandled) { StringBuilder message = new StringBuilder( "Non-exhaustive switch; either add a default or handle the remaining cases: "); int numberToShow = unhandled.size() > MAX_CASES_TO_PRINT ? 3 // if there are too many to print, ...
java
private String buildMessage(Set<String> unhandled) { StringBuilder message = new StringBuilder( "Non-exhaustive switch; either add a default or handle the remaining cases: "); int numberToShow = unhandled.size() > MAX_CASES_TO_PRINT ? 3 // if there are too many to print, ...
[ "private", "String", "buildMessage", "(", "Set", "<", "String", ">", "unhandled", ")", "{", "StringBuilder", "message", "=", "new", "StringBuilder", "(", "\"Non-exhaustive switch; either add a default or handle the remaining cases: \"", ")", ";", "int", "numberToShow", "=...
Build the diagnostic message. <p>Examples: <ul> <li>Non-exhaustive switch, expected cases for: FOO <li>Non-exhaustive switch, expected cases for: FOO, BAR, BAZ, and 42 others. </ul>
[ "Build", "the", "diagnostic", "message", "." ]
fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/MissingCasesInEnumSwitch.java#L79-L92