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
partition
stringclasses
1 value
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindInconsistentSync2.java
FindInconsistentSync2.findLockedMethods
private static Set<Method> findLockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) { JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); CallGraph callGraph = selfCalls.getCallGraph(); // Initially, assume all methods are locked Set<Method> lockedMethodSet = new HashSet<>(); // Assume all public methods are unlocked for (Method method : methodList) { if (method.isSynchronized()) { lockedMethodSet.add(method); } } // Explore the self-call graph to find nonpublic methods // that can be called from an unlocked context. boolean change; do { change = false; for (Iterator<CallGraphEdge> i = callGraph.edgeIterator(); i.hasNext();) { CallGraphEdge edge = i.next(); CallSite callSite = edge.getCallSite(); if (obviouslyLockedSites.contains(callSite) || lockedMethodSet.contains(callSite.getMethod())) { // Calling method is locked, so the called method // is also locked. CallGraphNode target = edge.getTarget(); if (lockedMethodSet.add(target.getMethod())) { change = true; } } } } while (change); if (DEBUG) { System.out.println("Apparently locked methods:"); for (Method method : lockedMethodSet) { System.out.println("\t" + method.getName()); } } // We assume that any methods left in the locked set // are called only from a locked context. return lockedMethodSet; }
java
private static Set<Method> findLockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) { JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); CallGraph callGraph = selfCalls.getCallGraph(); // Initially, assume all methods are locked Set<Method> lockedMethodSet = new HashSet<>(); // Assume all public methods are unlocked for (Method method : methodList) { if (method.isSynchronized()) { lockedMethodSet.add(method); } } // Explore the self-call graph to find nonpublic methods // that can be called from an unlocked context. boolean change; do { change = false; for (Iterator<CallGraphEdge> i = callGraph.edgeIterator(); i.hasNext();) { CallGraphEdge edge = i.next(); CallSite callSite = edge.getCallSite(); if (obviouslyLockedSites.contains(callSite) || lockedMethodSet.contains(callSite.getMethod())) { // Calling method is locked, so the called method // is also locked. CallGraphNode target = edge.getTarget(); if (lockedMethodSet.add(target.getMethod())) { change = true; } } } } while (change); if (DEBUG) { System.out.println("Apparently locked methods:"); for (Method method : lockedMethodSet) { System.out.println("\t" + method.getName()); } } // We assume that any methods left in the locked set // are called only from a locked context. return lockedMethodSet; }
[ "private", "static", "Set", "<", "Method", ">", "findLockedMethods", "(", "ClassContext", "classContext", ",", "SelfCalls", "selfCalls", ",", "Set", "<", "CallSite", ">", "obviouslyLockedSites", ")", "{", "JavaClass", "javaClass", "=", "classContext", ".", "getJav...
Find methods that appear to always be called from a locked context. We assume that nonpublic methods will only be called from within the class, which is not really a valid assumption.
[ "Find", "methods", "that", "appear", "to", "always", "be", "called", "from", "a", "locked", "context", ".", "We", "assume", "that", "nonpublic", "methods", "will", "only", "be", "called", "from", "within", "the", "class", "which", "is", "not", "really", "a...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindInconsistentSync2.java#L951-L1000
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindInconsistentSync2.java
FindInconsistentSync2.findObviouslyLockedCallSites
private static Set<CallSite> findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls) throws CFGBuilderException, DataflowAnalysisException { ConstantPoolGen cpg = classContext.getConstantPoolGen(); // Find all obviously locked call sites Set<CallSite> obviouslyLockedSites = new HashSet<>(); for (Iterator<CallSite> i = selfCalls.callSiteIterator(); i.hasNext();) { CallSite callSite = i.next(); Method method = callSite.getMethod(); Location location = callSite.getLocation(); InstructionHandle handle = location.getHandle(); // Only instance method calls qualify as candidates for // "obviously locked" Instruction ins = handle.getInstruction(); if (ins.getOpcode() == Const.INVOKESTATIC) { continue; } // Get lock set for site LockChecker lockChecker = classContext.getLockChecker(method); LockSet lockSet = lockChecker.getFactAtLocation(location); // Get value number frame for site ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location); // NOTE: if the CFG on which the value number analysis was performed // was pruned, there may be unreachable instructions. Therefore, // we can't assume the frame is valid. if (!frame.isValid()) { continue; } // Find the ValueNumber of the receiver object int numConsumed = ins.consumeStack(cpg); MethodGen methodGen = classContext.getMethodGen(method); assert methodGen != null; if (numConsumed == Const.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption", methodGen, handle); } // if (DEBUG) System.out.println("Getting receiver for frame: " + // frame); ValueNumber instance = frame.getStackValue(numConsumed - 1); // Is the instance locked? int lockCount = lockSet.getLockCount(instance.getNumber()); if (lockCount > 0) { // This is a locked call site obviouslyLockedSites.add(callSite); } } return obviouslyLockedSites; }
java
private static Set<CallSite> findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls) throws CFGBuilderException, DataflowAnalysisException { ConstantPoolGen cpg = classContext.getConstantPoolGen(); // Find all obviously locked call sites Set<CallSite> obviouslyLockedSites = new HashSet<>(); for (Iterator<CallSite> i = selfCalls.callSiteIterator(); i.hasNext();) { CallSite callSite = i.next(); Method method = callSite.getMethod(); Location location = callSite.getLocation(); InstructionHandle handle = location.getHandle(); // Only instance method calls qualify as candidates for // "obviously locked" Instruction ins = handle.getInstruction(); if (ins.getOpcode() == Const.INVOKESTATIC) { continue; } // Get lock set for site LockChecker lockChecker = classContext.getLockChecker(method); LockSet lockSet = lockChecker.getFactAtLocation(location); // Get value number frame for site ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location); // NOTE: if the CFG on which the value number analysis was performed // was pruned, there may be unreachable instructions. Therefore, // we can't assume the frame is valid. if (!frame.isValid()) { continue; } // Find the ValueNumber of the receiver object int numConsumed = ins.consumeStack(cpg); MethodGen methodGen = classContext.getMethodGen(method); assert methodGen != null; if (numConsumed == Const.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption", methodGen, handle); } // if (DEBUG) System.out.println("Getting receiver for frame: " + // frame); ValueNumber instance = frame.getStackValue(numConsumed - 1); // Is the instance locked? int lockCount = lockSet.getLockCount(instance.getNumber()); if (lockCount > 0) { // This is a locked call site obviouslyLockedSites.add(callSite); } } return obviouslyLockedSites; }
[ "private", "static", "Set", "<", "CallSite", ">", "findObviouslyLockedCallSites", "(", "ClassContext", "classContext", ",", "SelfCalls", "selfCalls", ")", "throws", "CFGBuilderException", ",", "DataflowAnalysisException", "{", "ConstantPoolGen", "cpg", "=", "classContext"...
Find all self-call sites that are obviously locked.
[ "Find", "all", "self", "-", "call", "sites", "that", "are", "obviously", "locked", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindInconsistentSync2.java#L1048-L1102
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/WrongMapIterator.java
WrongMapIterator.implementsMap
private static boolean implementsMap(ClassDescriptor d) { while (d != null) { try { // Do not report this warning for EnumMap: EnumMap.keySet()/get() iteration is as fast as entrySet() iteration if ("java.util.EnumMap".equals(d.getDottedClassName())) { return false; } // True if variable is itself declared as a Map if ("java.util.Map".equals(d.getDottedClassName())) { return true; } XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, d); ClassDescriptor is[] = classNameAndInfo.getInterfaceDescriptorList(); d = classNameAndInfo.getSuperclassDescriptor(); for (ClassDescriptor i : is) { if ("java.util.Map".equals(i.getDottedClassName())) { return true; } } } catch (CheckedAnalysisException e) { d = null; } } return false; }
java
private static boolean implementsMap(ClassDescriptor d) { while (d != null) { try { // Do not report this warning for EnumMap: EnumMap.keySet()/get() iteration is as fast as entrySet() iteration if ("java.util.EnumMap".equals(d.getDottedClassName())) { return false; } // True if variable is itself declared as a Map if ("java.util.Map".equals(d.getDottedClassName())) { return true; } XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, d); ClassDescriptor is[] = classNameAndInfo.getInterfaceDescriptorList(); d = classNameAndInfo.getSuperclassDescriptor(); for (ClassDescriptor i : is) { if ("java.util.Map".equals(i.getDottedClassName())) { return true; } } } catch (CheckedAnalysisException e) { d = null; } } return false; }
[ "private", "static", "boolean", "implementsMap", "(", "ClassDescriptor", "d", ")", "{", "while", "(", "d", "!=", "null", ")", "{", "try", "{", "// Do not report this warning for EnumMap: EnumMap.keySet()/get() iteration is as fast as entrySet() iteration", "if", "(", "\"jav...
Determine from the class descriptor for a variable whether that variable implements java.util.Map. @param d class descriptor for variable we want to check implements Map @return true iff the descriptor corresponds to an implementor of Map
[ "Determine", "from", "the", "class", "descriptor", "for", "a", "variable", "whether", "that", "variable", "implements", "java", ".", "util", ".", "Map", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/WrongMapIterator.java#L163-L187
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/properties/FindbugsPropertyPage.java
FindbugsPropertyPage.restoreDefaultSettings
private void restoreDefaultSettings() { if (getProject() != null) { // By default, don't run FindBugs automatically chkEnableFindBugs.setSelection(false); chkRunAtFullBuild.setEnabled(false); FindBugsPreferenceInitializer.restoreDefaults(projectStore); } else { FindBugsPreferenceInitializer.restoreDefaults(workspaceStore); } currentUserPreferences = FindBugsPreferenceInitializer.createDefaultUserPreferences(); refreshUI(currentUserPreferences); }
java
private void restoreDefaultSettings() { if (getProject() != null) { // By default, don't run FindBugs automatically chkEnableFindBugs.setSelection(false); chkRunAtFullBuild.setEnabled(false); FindBugsPreferenceInitializer.restoreDefaults(projectStore); } else { FindBugsPreferenceInitializer.restoreDefaults(workspaceStore); } currentUserPreferences = FindBugsPreferenceInitializer.createDefaultUserPreferences(); refreshUI(currentUserPreferences); }
[ "private", "void", "restoreDefaultSettings", "(", ")", "{", "if", "(", "getProject", "(", ")", "!=", "null", ")", "{", "// By default, don't run FindBugs automatically", "chkEnableFindBugs", ".", "setSelection", "(", "false", ")", ";", "chkRunAtFullBuild", ".", "set...
Restore default settings. This just changes the dialog widgets - the user still needs to confirm by clicking the "OK" button.
[ "Restore", "default", "settings", ".", "This", "just", "changes", "the", "dialog", "widgets", "-", "the", "user", "still", "needs", "to", "confirm", "by", "clicking", "the", "OK", "button", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/properties/FindbugsPropertyPage.java#L426-L437
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/properties/FindbugsPropertyPage.java
FindbugsPropertyPage.performOk
@Override public boolean performOk() { reportConfigurationTab.performOk(); boolean analysisSettingsChanged = false; boolean reporterSettingsChanged = false; boolean needRedisplayMarkers = false; if (workspaceSettingsTab != null) { workspaceSettingsTab.performOK(); } boolean pluginsChanged = false; // Have user preferences for project changed? // If so, write them to the user preferences file & re-run builder if (!currentUserPreferences.equals(origUserPreferences)) { pluginsChanged = !currentUserPreferences.getCustomPlugins().equals(origUserPreferences.getCustomPlugins()); // save only if we in the workspace page OR in the project page with // enabled // project settings if (getProject() == null || enableProjectCheck.getSelection()) { try { FindbugsPlugin.saveUserPreferences(getProject(), currentUserPreferences); } catch (CoreException e) { FindbugsPlugin.getDefault().logException(e, "Could not store SpotBugs preferences for project"); } } if(pluginsChanged) { FindbugsPlugin.applyCustomDetectors(true); } } analysisSettingsChanged = pluginsChanged || areAnalysisPrefsChanged(currentUserPreferences, origUserPreferences); reporterSettingsChanged = !currentUserPreferences.getFilterSettings().equals(origUserPreferences.getFilterSettings()); boolean markerSeveritiesChanged = reportConfigurationTab.isMarkerSeveritiesChanged(); needRedisplayMarkers = pluginsChanged || markerSeveritiesChanged || reporterSettingsChanged; boolean builderEnabled = false; if (getProject() != null) { builderEnabled = chkEnableFindBugs.getSelection(); // Update whether or not FindBugs is run automatically. if (!natureEnabled && builderEnabled) { addNature(); } else if (natureEnabled && !builderEnabled) { removeNature(); } // update the flag to match the incremental/not property builderEnabled &= chkRunAtFullBuild.getSelection(); boolean newSelection = enableProjectCheck.getSelection(); if (projectPropsInitiallyEnabled != newSelection) { analysisSettingsChanged = true; FindbugsPlugin.setProjectSettingsEnabled(project, projectStore, newSelection); } } if (analysisSettingsChanged) { // trigger a Findbugs rebuild here if (builderEnabled) { runFindbugsBuilder(); needRedisplayMarkers = false; } else { if (!getPreferenceStore().getBoolean(FindBugsConstants.DONT_REMIND_ABOUT_FULL_BUILD)) { remindAboutFullBuild(); } } } if (needRedisplayMarkers) { redisplayMarkers(); } return true; }
java
@Override public boolean performOk() { reportConfigurationTab.performOk(); boolean analysisSettingsChanged = false; boolean reporterSettingsChanged = false; boolean needRedisplayMarkers = false; if (workspaceSettingsTab != null) { workspaceSettingsTab.performOK(); } boolean pluginsChanged = false; // Have user preferences for project changed? // If so, write them to the user preferences file & re-run builder if (!currentUserPreferences.equals(origUserPreferences)) { pluginsChanged = !currentUserPreferences.getCustomPlugins().equals(origUserPreferences.getCustomPlugins()); // save only if we in the workspace page OR in the project page with // enabled // project settings if (getProject() == null || enableProjectCheck.getSelection()) { try { FindbugsPlugin.saveUserPreferences(getProject(), currentUserPreferences); } catch (CoreException e) { FindbugsPlugin.getDefault().logException(e, "Could not store SpotBugs preferences for project"); } } if(pluginsChanged) { FindbugsPlugin.applyCustomDetectors(true); } } analysisSettingsChanged = pluginsChanged || areAnalysisPrefsChanged(currentUserPreferences, origUserPreferences); reporterSettingsChanged = !currentUserPreferences.getFilterSettings().equals(origUserPreferences.getFilterSettings()); boolean markerSeveritiesChanged = reportConfigurationTab.isMarkerSeveritiesChanged(); needRedisplayMarkers = pluginsChanged || markerSeveritiesChanged || reporterSettingsChanged; boolean builderEnabled = false; if (getProject() != null) { builderEnabled = chkEnableFindBugs.getSelection(); // Update whether or not FindBugs is run automatically. if (!natureEnabled && builderEnabled) { addNature(); } else if (natureEnabled && !builderEnabled) { removeNature(); } // update the flag to match the incremental/not property builderEnabled &= chkRunAtFullBuild.getSelection(); boolean newSelection = enableProjectCheck.getSelection(); if (projectPropsInitiallyEnabled != newSelection) { analysisSettingsChanged = true; FindbugsPlugin.setProjectSettingsEnabled(project, projectStore, newSelection); } } if (analysisSettingsChanged) { // trigger a Findbugs rebuild here if (builderEnabled) { runFindbugsBuilder(); needRedisplayMarkers = false; } else { if (!getPreferenceStore().getBoolean(FindBugsConstants.DONT_REMIND_ABOUT_FULL_BUILD)) { remindAboutFullBuild(); } } } if (needRedisplayMarkers) { redisplayMarkers(); } return true; }
[ "@", "Override", "public", "boolean", "performOk", "(", ")", "{", "reportConfigurationTab", ".", "performOk", "(", ")", ";", "boolean", "analysisSettingsChanged", "=", "false", ";", "boolean", "reporterSettingsChanged", "=", "false", ";", "boolean", "needRedisplayMa...
Will be called when the user presses the OK button. @see IPreferencePage#performOk()
[ "Will", "be", "called", "when", "the", "user", "presses", "the", "OK", "button", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/properties/FindbugsPropertyPage.java#L450-L525
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/Tokenizer.java
Tokenizer.next
public Token next() throws IOException { skipWhitespace(); int c = reader.read(); if (c < 0) { return new Token(Token.EOF); } else if (c == '\n') { return new Token(Token.EOL); } else if (c == '\'' || c == '"') { return munchString(c); } else if (c == '/') { return maybeComment(); } else if (single.get(c)) { return new Token(Token.SINGLE, String.valueOf((char) c)); } else { reader.unread(c); return parseWord(); } }
java
public Token next() throws IOException { skipWhitespace(); int c = reader.read(); if (c < 0) { return new Token(Token.EOF); } else if (c == '\n') { return new Token(Token.EOL); } else if (c == '\'' || c == '"') { return munchString(c); } else if (c == '/') { return maybeComment(); } else if (single.get(c)) { return new Token(Token.SINGLE, String.valueOf((char) c)); } else { reader.unread(c); return parseWord(); } }
[ "public", "Token", "next", "(", ")", "throws", "IOException", "{", "skipWhitespace", "(", ")", ";", "int", "c", "=", "reader", ".", "read", "(", ")", ";", "if", "(", "c", "<", "0", ")", "{", "return", "new", "Token", "(", "Token", ".", "EOF", ")"...
Get the next Token in the stream. @return the Token
[ "Get", "the", "next", "Token", "in", "the", "stream", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/Tokenizer.java#L89-L106
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/reporter/Reporter.java
Reporter.reportResultsToConsole
private void reportResultsToConsole() { if (!isStreamReportingEnabled()) { return; } printToStream("Finished, found: " + bugCount + " bugs"); ConfigurableXmlOutputStream xmlStream = new ConfigurableXmlOutputStream(stream, true); ProjectStats stats = bugCollection.getProjectStats(); printToStream("\nFootprint: " + new Footprint(stats.getBaseFootprint()).toString()); Profiler profiler = stats.getProfiler(); PrintStream printStream; try { printStream = new PrintStream(stream, false, "UTF-8"); } catch (UnsupportedEncodingException e1) { // can never happen with UTF-8 return; } printToStream("\nTotal time:"); profiler.report(new Profiler.TotalTimeComparator(profiler), new Profiler.FilterByTime(10000000), printStream); printToStream("\nTotal calls:"); int numClasses = stats.getNumClasses(); if(numClasses > 0) { profiler.report(new Profiler.TotalCallsComparator(profiler), new Profiler.FilterByCalls(numClasses), printStream); printToStream("\nTime per call:"); profiler.report(new Profiler.TimePerCallComparator(profiler), new Profiler.FilterByTimePerCall(10000000 / numClasses), printStream); } try { xmlStream.finish(); } catch (IOException e) { FindbugsPlugin.getDefault().logException(e, "Print to console failed"); } }
java
private void reportResultsToConsole() { if (!isStreamReportingEnabled()) { return; } printToStream("Finished, found: " + bugCount + " bugs"); ConfigurableXmlOutputStream xmlStream = new ConfigurableXmlOutputStream(stream, true); ProjectStats stats = bugCollection.getProjectStats(); printToStream("\nFootprint: " + new Footprint(stats.getBaseFootprint()).toString()); Profiler profiler = stats.getProfiler(); PrintStream printStream; try { printStream = new PrintStream(stream, false, "UTF-8"); } catch (UnsupportedEncodingException e1) { // can never happen with UTF-8 return; } printToStream("\nTotal time:"); profiler.report(new Profiler.TotalTimeComparator(profiler), new Profiler.FilterByTime(10000000), printStream); printToStream("\nTotal calls:"); int numClasses = stats.getNumClasses(); if(numClasses > 0) { profiler.report(new Profiler.TotalCallsComparator(profiler), new Profiler.FilterByCalls(numClasses), printStream); printToStream("\nTime per call:"); profiler.report(new Profiler.TimePerCallComparator(profiler), new Profiler.FilterByTimePerCall(10000000 / numClasses), printStream); } try { xmlStream.finish(); } catch (IOException e) { FindbugsPlugin.getDefault().logException(e, "Print to console failed"); } }
[ "private", "void", "reportResultsToConsole", "(", ")", "{", "if", "(", "!", "isStreamReportingEnabled", "(", ")", ")", "{", "return", ";", "}", "printToStream", "(", "\"Finished, found: \"", "+", "bugCount", "+", "\" bugs\"", ")", ";", "ConfigurableXmlOutputStream...
If there is a FB console opened, report results and statistics to it.
[ "If", "there", "is", "a", "FB", "console", "opened", "report", "results", "and", "statistics", "to", "it", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/reporter/Reporter.java#L184-L221
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/bcp/ByteCodePattern.java
ByteCodePattern.addWild
public ByteCodePattern addWild(int numWild) { Wild wild = isLastWild(); if (wild != null) { wild.setMinAndMax(0, numWild); } else { addElement(new Wild(numWild)); } return this; }
java
public ByteCodePattern addWild(int numWild) { Wild wild = isLastWild(); if (wild != null) { wild.setMinAndMax(0, numWild); } else { addElement(new Wild(numWild)); } return this; }
[ "public", "ByteCodePattern", "addWild", "(", "int", "numWild", ")", "{", "Wild", "wild", "=", "isLastWild", "(", ")", ";", "if", "(", "wild", "!=", "null", ")", "{", "wild", ".", "setMinAndMax", "(", "0", ",", "numWild", ")", ";", "}", "else", "{", ...
Add a wildcard to match between 0 and given number of instructions. If there is already a wildcard at the end of the current pattern, resets its max value to that given. @param numWild maximum number of instructions to be matched by the wildcard
[ "Add", "a", "wildcard", "to", "match", "between", "0", "and", "given", "number", "of", "instructions", ".", "If", "there", "is", "already", "a", "wildcard", "at", "the", "end", "of", "the", "current", "pattern", "resets", "its", "max", "value", "to", "th...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/bcp/ByteCodePattern.java#L61-L69
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.lookupEdgeById
public Edge lookupEdgeById(int id) { Iterator<Edge> i = edgeIterator(); while (i.hasNext()) { Edge edge = i.next(); if (edge.getId() == id) { return edge; } } return null; }
java
public Edge lookupEdgeById(int id) { Iterator<Edge> i = edgeIterator(); while (i.hasNext()) { Edge edge = i.next(); if (edge.getId() == id) { return edge; } } return null; }
[ "public", "Edge", "lookupEdgeById", "(", "int", "id", ")", "{", "Iterator", "<", "Edge", ">", "i", "=", "edgeIterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "Edge", "edge", "=", "i", ".", "next", "(", ")", ";", ...
Look up an Edge by its id. @param id the id of the edge to look up @return the Edge, or null if no matching Edge was found
[ "Look", "up", "an", "Edge", "by", "its", "id", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L271-L280
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.lookupBlockByLabel
public BasicBlock lookupBlockByLabel(int blockLabel) { for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next(); if (basicBlock.getLabel() == blockLabel) { return basicBlock; } } return null; }
java
public BasicBlock lookupBlockByLabel(int blockLabel) { for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next(); if (basicBlock.getLabel() == blockLabel) { return basicBlock; } } return null; }
[ "public", "BasicBlock", "lookupBlockByLabel", "(", "int", "blockLabel", ")", "{", "for", "(", "Iterator", "<", "BasicBlock", ">", "i", "=", "blockIterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "BasicBlock", "basicBlock", "=", "i"...
Look up a BasicBlock by its unique label. @param blockLabel the label of a BasicBlock @return the BasicBlock with the given label, or null if there is no such BasicBlock
[ "Look", "up", "a", "BasicBlock", "by", "its", "unique", "label", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L290-L298
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.orderedLocations
public Collection<Location> orderedLocations() { TreeSet<Location> tree = new TreeSet<>(); for (Iterator<Location> locs = locationIterator(); locs.hasNext();) { Location loc = locs.next(); tree.add(loc); } return tree; }
java
public Collection<Location> orderedLocations() { TreeSet<Location> tree = new TreeSet<>(); for (Iterator<Location> locs = locationIterator(); locs.hasNext();) { Location loc = locs.next(); tree.add(loc); } return tree; }
[ "public", "Collection", "<", "Location", ">", "orderedLocations", "(", ")", "{", "TreeSet", "<", "Location", ">", "tree", "=", "new", "TreeSet", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "Location", ">", "locs", "=", "locationIterator", "(", ")",...
Returns a collection of locations, ordered according to the compareTo ordering over locations. If you want to list all the locations in a CFG for debugging purposes, this is a good order to do so in. @return collection of locations
[ "Returns", "a", "collection", "of", "locations", "ordered", "according", "to", "the", "compareTo", "ordering", "over", "locations", ".", "If", "you", "want", "to", "list", "all", "the", "locations", "in", "a", "CFG", "for", "debugging", "purposes", "this", "...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L336-L343
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.getBlocks
public Collection<BasicBlock> getBlocks(BitSet labelSet) { LinkedList<BasicBlock> result = new LinkedList<>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock block = i.next(); if (labelSet.get(block.getLabel())) { result.add(block); } } return result; }
java
public Collection<BasicBlock> getBlocks(BitSet labelSet) { LinkedList<BasicBlock> result = new LinkedList<>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock block = i.next(); if (labelSet.get(block.getLabel())) { result.add(block); } } return result; }
[ "public", "Collection", "<", "BasicBlock", ">", "getBlocks", "(", "BitSet", "labelSet", ")", "{", "LinkedList", "<", "BasicBlock", ">", "result", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "BasicBlock", ">", "i", "=", "bl...
Get Collection of basic blocks whose IDs are specified by given BitSet. @param labelSet BitSet of block labels @return a Collection containing the blocks whose IDs are given
[ "Get", "Collection", "of", "basic", "blocks", "whose", "IDs", "are", "specified", "by", "given", "BitSet", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L352-L361
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.getBlocksContainingInstructionWithOffset
public Collection<BasicBlock> getBlocksContainingInstructionWithOffset(int offset) { LinkedList<BasicBlock> result = new LinkedList<>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock block = i.next(); if (block.containsInstructionWithOffset(offset)) { result.add(block); } } return result; }
java
public Collection<BasicBlock> getBlocksContainingInstructionWithOffset(int offset) { LinkedList<BasicBlock> result = new LinkedList<>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock block = i.next(); if (block.containsInstructionWithOffset(offset)) { result.add(block); } } return result; }
[ "public", "Collection", "<", "BasicBlock", ">", "getBlocksContainingInstructionWithOffset", "(", "int", "offset", ")", "{", "LinkedList", "<", "BasicBlock", ">", "result", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "BasicBlock", ...
Get a Collection of basic blocks which contain the bytecode instruction with given offset. @param offset the bytecode offset of an instruction @return Collection of BasicBlock objects which contain the instruction with that offset
[ "Get", "a", "Collection", "of", "basic", "blocks", "which", "contain", "the", "bytecode", "instruction", "with", "given", "offset", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L372-L381
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.getLocationsContainingInstructionWithOffset
public Collection<Location> getLocationsContainingInstructionWithOffset(int offset) { LinkedList<Location> result = new LinkedList<>(); for (Iterator<Location> i = locationIterator(); i.hasNext();) { Location location = i.next(); if (location.getHandle().getPosition() == offset) { result.add(location); } } return result; }
java
public Collection<Location> getLocationsContainingInstructionWithOffset(int offset) { LinkedList<Location> result = new LinkedList<>(); for (Iterator<Location> i = locationIterator(); i.hasNext();) { Location location = i.next(); if (location.getHandle().getPosition() == offset) { result.add(location); } } return result; }
[ "public", "Collection", "<", "Location", ">", "getLocationsContainingInstructionWithOffset", "(", "int", "offset", ")", "{", "LinkedList", "<", "Location", ">", "result", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "Location", "...
Get a Collection of Locations which specify the instruction at given bytecode offset. @param offset the bytecode offset @return all Locations referring to the instruction at that offset
[ "Get", "a", "Collection", "of", "Locations", "which", "specify", "the", "instruction", "at", "given", "bytecode", "offset", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L391-L400
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.getNumNonExceptionSucessors
public int getNumNonExceptionSucessors(BasicBlock block) { int numNonExceptionSuccessors = block.getNumNonExceptionSuccessors(); if (numNonExceptionSuccessors < 0) { numNonExceptionSuccessors = 0; for (Iterator<Edge> i = outgoingEdgeIterator(block); i.hasNext();) { Edge edge = i.next(); if (!edge.isExceptionEdge()) { numNonExceptionSuccessors++; } } block.setNumNonExceptionSuccessors(numNonExceptionSuccessors); } return numNonExceptionSuccessors; }
java
public int getNumNonExceptionSucessors(BasicBlock block) { int numNonExceptionSuccessors = block.getNumNonExceptionSuccessors(); if (numNonExceptionSuccessors < 0) { numNonExceptionSuccessors = 0; for (Iterator<Edge> i = outgoingEdgeIterator(block); i.hasNext();) { Edge edge = i.next(); if (!edge.isExceptionEdge()) { numNonExceptionSuccessors++; } } block.setNumNonExceptionSuccessors(numNonExceptionSuccessors); } return numNonExceptionSuccessors; }
[ "public", "int", "getNumNonExceptionSucessors", "(", "BasicBlock", "block", ")", "{", "int", "numNonExceptionSuccessors", "=", "block", ".", "getNumNonExceptionSuccessors", "(", ")", ";", "if", "(", "numNonExceptionSuccessors", "<", "0", ")", "{", "numNonExceptionSucc...
Get number of non-exception control successors of given basic block. @param block a BasicBlock @return number of non-exception control successors of the basic block
[ "Get", "number", "of", "non", "-", "exception", "control", "successors", "of", "given", "basic", "block", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L590-L603
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java
CFG.getLocationAtEntry
public Location getLocationAtEntry() { InstructionHandle handle = getEntry().getFirstInstruction(); assert handle != null; return new Location(handle, getEntry()); }
java
public Location getLocationAtEntry() { InstructionHandle handle = getEntry().getFirstInstruction(); assert handle != null; return new Location(handle, getEntry()); }
[ "public", "Location", "getLocationAtEntry", "(", ")", "{", "InstructionHandle", "handle", "=", "getEntry", "(", ")", ".", "getFirstInstruction", "(", ")", ";", "assert", "handle", "!=", "null", ";", "return", "new", "Location", "(", "handle", ",", "getEntry", ...
Get the Location representing the entry to the CFG. Note that this is a "fake" Location, and shouldn't be relied on to yield source line information. @return Location at entry to CFG
[ "Get", "the", "Location", "representing", "the", "entry", "to", "the", "CFG", ".", "Note", "that", "this", "is", "a", "fake", "Location", "and", "shouldn", "t", "be", "relied", "on", "to", "yield", "source", "line", "information", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/CFG.java#L612-L616
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/plan/ExecutionPlan.java
ExecutionPlan.addPlugin
public void addPlugin(Plugin plugin) throws OrderingConstraintException { if (DEBUG) { System.out.println("Adding plugin " + plugin.getPluginId() + " to execution plan"); } pluginList.add(plugin); // Add ordering constraints copyTo(plugin.interPassConstraintIterator(), interPassConstraintList); copyTo(plugin.intraPassConstraintIterator(), intraPassConstraintList); // Add detector factories for (DetectorFactory factory : plugin.getDetectorFactories()) { if (DEBUG) { System.out.println(" Detector factory " + factory.getShortName()); } if (factoryMap.put(factory.getFullName(), factory) != null) { throw new OrderingConstraintException("Detector " + factory.getFullName() + " is defined by more than one plugin"); } } }
java
public void addPlugin(Plugin plugin) throws OrderingConstraintException { if (DEBUG) { System.out.println("Adding plugin " + plugin.getPluginId() + " to execution plan"); } pluginList.add(plugin); // Add ordering constraints copyTo(plugin.interPassConstraintIterator(), interPassConstraintList); copyTo(plugin.intraPassConstraintIterator(), intraPassConstraintList); // Add detector factories for (DetectorFactory factory : plugin.getDetectorFactories()) { if (DEBUG) { System.out.println(" Detector factory " + factory.getShortName()); } if (factoryMap.put(factory.getFullName(), factory) != null) { throw new OrderingConstraintException("Detector " + factory.getFullName() + " is defined by more than one plugin"); } } }
[ "public", "void", "addPlugin", "(", "Plugin", "plugin", ")", "throws", "OrderingConstraintException", "{", "if", "(", "DEBUG", ")", "{", "System", ".", "out", ".", "println", "(", "\"Adding plugin \"", "+", "plugin", ".", "getPluginId", "(", ")", "+", "\" to...
Add a Plugin whose Detectors should be added to the execution plan.
[ "Add", "a", "Plugin", "whose", "Detectors", "should", "be", "added", "to", "the", "execution", "plan", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/plan/ExecutionPlan.java#L112-L132
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/plan/ExecutionPlan.java
ExecutionPlan.assignToPass
private void assignToPass(DetectorFactory factory, AnalysisPass pass) { pass.addToPass(factory); assignedToPassSet.add(factory); }
java
private void assignToPass(DetectorFactory factory, AnalysisPass pass) { pass.addToPass(factory); assignedToPassSet.add(factory); }
[ "private", "void", "assignToPass", "(", "DetectorFactory", "factory", ",", "AnalysisPass", "pass", ")", "{", "pass", ".", "addToPass", "(", "factory", ")", ";", "assignedToPassSet", ".", "add", "(", "factory", ")", ";", "}" ]
Make a DetectorFactory a member of an AnalysisPass.
[ "Make", "a", "DetectorFactory", "a", "member", "of", "an", "AnalysisPass", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/plan/ExecutionPlan.java#L466-L469
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/InstructionScannerDriver.java
InstructionScannerDriver.execute
public void execute(InstructionScannerGenerator generator) { // Pump the instructions in the path through the generator and all // generated scanners while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); BasicBlock source = edge.getSource(); if (DEBUG) { System.out.println("ISD: scanning instructions in block " + source.getLabel()); } // Traverse all instructions in the source block Iterator<InstructionHandle> i = source.instructionIterator(); int count = 0; while (i.hasNext()) { InstructionHandle handle = i.next(); // Check if the generator wants to create a new scanner if (generator.start(handle)) { scannerList.add(generator.createScanner()); } // Pump the instruction into all scanners for (InstructionScanner scanner : scannerList) { scanner.scanInstruction(handle); } ++count; } if (DEBUG) { System.out.println("ISD: scanned " + count + " instructions"); } // Now that we've finished the source block, pump the edge // into all scanners for (InstructionScanner scanner : scannerList) { scanner.traverseEdge(edge); } } }
java
public void execute(InstructionScannerGenerator generator) { // Pump the instructions in the path through the generator and all // generated scanners while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); BasicBlock source = edge.getSource(); if (DEBUG) { System.out.println("ISD: scanning instructions in block " + source.getLabel()); } // Traverse all instructions in the source block Iterator<InstructionHandle> i = source.instructionIterator(); int count = 0; while (i.hasNext()) { InstructionHandle handle = i.next(); // Check if the generator wants to create a new scanner if (generator.start(handle)) { scannerList.add(generator.createScanner()); } // Pump the instruction into all scanners for (InstructionScanner scanner : scannerList) { scanner.scanInstruction(handle); } ++count; } if (DEBUG) { System.out.println("ISD: scanned " + count + " instructions"); } // Now that we've finished the source block, pump the edge // into all scanners for (InstructionScanner scanner : scannerList) { scanner.traverseEdge(edge); } } }
[ "public", "void", "execute", "(", "InstructionScannerGenerator", "generator", ")", "{", "// Pump the instructions in the path through the generator and all", "// generated scanners", "while", "(", "edgeIter", ".", "hasNext", "(", ")", ")", "{", "Edge", "edge", "=", "edgeI...
Execute by driving the InstructionScannerGenerator over all instructions. Each generated InstructionScanner is driven over all instructions and edges. @param generator the InstructionScannerGenerator
[ "Execute", "by", "driving", "the", "InstructionScannerGenerator", "over", "all", "instructions", ".", "Each", "generated", "InstructionScanner", "is", "driven", "over", "all", "instructions", "and", "edges", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/InstructionScannerDriver.java#L61-L100
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsBuilder.java
FindBugsBuilder.build
@SuppressWarnings("rawtypes") @Override protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { monitor.subTask("Running SpotBugs..."); switch (kind) { case IncrementalProjectBuilder.FULL_BUILD: { FindBugs2Eclipse.cleanClassClache(getProject()); if (FindbugsPlugin.getUserPreferences(getProject()).isRunAtFullBuild()) { if (DEBUG) { System.out.println("FULL BUILD"); } doBuild(args, monitor, kind); } else { // TODO probably worth to cleanup? // MarkerUtil.removeMarkers(getProject()); } break; } case IncrementalProjectBuilder.INCREMENTAL_BUILD: { if (DEBUG) { System.out.println("INCREMENTAL BUILD"); } doBuild(args, monitor, kind); break; } case IncrementalProjectBuilder.AUTO_BUILD: { if (DEBUG) { System.out.println("AUTO BUILD"); } doBuild(args, monitor, kind); break; } default: { FindbugsPlugin.getDefault() .logWarning("UKNOWN BUILD kind" + kind); doBuild(args, monitor, kind); break; } } return null; }
java
@SuppressWarnings("rawtypes") @Override protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { monitor.subTask("Running SpotBugs..."); switch (kind) { case IncrementalProjectBuilder.FULL_BUILD: { FindBugs2Eclipse.cleanClassClache(getProject()); if (FindbugsPlugin.getUserPreferences(getProject()).isRunAtFullBuild()) { if (DEBUG) { System.out.println("FULL BUILD"); } doBuild(args, monitor, kind); } else { // TODO probably worth to cleanup? // MarkerUtil.removeMarkers(getProject()); } break; } case IncrementalProjectBuilder.INCREMENTAL_BUILD: { if (DEBUG) { System.out.println("INCREMENTAL BUILD"); } doBuild(args, monitor, kind); break; } case IncrementalProjectBuilder.AUTO_BUILD: { if (DEBUG) { System.out.println("AUTO BUILD"); } doBuild(args, monitor, kind); break; } default: { FindbugsPlugin.getDefault() .logWarning("UKNOWN BUILD kind" + kind); doBuild(args, monitor, kind); break; } } return null; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "@", "Override", "protected", "IProject", "[", "]", "build", "(", "int", "kind", ",", "Map", "args", ",", "IProgressMonitor", "monitor", ")", "throws", "CoreException", "{", "monitor", ".", "subTask", "(", "...
Run the builder. @see IncrementalProjectBuilder#build
[ "Run", "the", "builder", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsBuilder.java#L62-L103
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsBuilder.java
FindBugsBuilder.work
protected void work(final IResource resource, final List<WorkItem> resources, IProgressMonitor monitor) { IPreferenceStore store = FindbugsPlugin.getPluginPreferences(getProject()); boolean runAsJob = store.getBoolean(FindBugsConstants.KEY_RUN_ANALYSIS_AS_EXTRA_JOB); FindBugsJob fbJob = new StartedFromBuilderJob("Finding bugs in " + resource.getName() + "...", resource, resources); if(runAsJob) { // run asynchronously, so there might be more similar jobs waiting to run if (DEBUG) { FindbugsPlugin.log("cancelSimilarJobs"); } FindBugsJob.cancelSimilarJobs(fbJob); if (DEBUG) { FindbugsPlugin.log("scheduleAsSystem"); } fbJob.scheduleAsSystem(); if (DEBUG) { FindbugsPlugin.log("done scheduleAsSystem"); } } else { // run synchronously (in same thread) if (DEBUG) { FindbugsPlugin.log("running fbJob"); } fbJob.run(monitor); if (DEBUG) { FindbugsPlugin.log("done fbJob"); } } }
java
protected void work(final IResource resource, final List<WorkItem> resources, IProgressMonitor monitor) { IPreferenceStore store = FindbugsPlugin.getPluginPreferences(getProject()); boolean runAsJob = store.getBoolean(FindBugsConstants.KEY_RUN_ANALYSIS_AS_EXTRA_JOB); FindBugsJob fbJob = new StartedFromBuilderJob("Finding bugs in " + resource.getName() + "...", resource, resources); if(runAsJob) { // run asynchronously, so there might be more similar jobs waiting to run if (DEBUG) { FindbugsPlugin.log("cancelSimilarJobs"); } FindBugsJob.cancelSimilarJobs(fbJob); if (DEBUG) { FindbugsPlugin.log("scheduleAsSystem"); } fbJob.scheduleAsSystem(); if (DEBUG) { FindbugsPlugin.log("done scheduleAsSystem"); } } else { // run synchronously (in same thread) if (DEBUG) { FindbugsPlugin.log("running fbJob"); } fbJob.run(monitor); if (DEBUG) { FindbugsPlugin.log("done fbJob"); } } }
[ "protected", "void", "work", "(", "final", "IResource", "resource", ",", "final", "List", "<", "WorkItem", ">", "resources", ",", "IProgressMonitor", "monitor", ")", "{", "IPreferenceStore", "store", "=", "FindbugsPlugin", ".", "getPluginPreferences", "(", "getPro...
Run a FindBugs analysis on the given resource as build job BUT not delaying the current Java build @param resources The resource to run the analysis on. @param monitor
[ "Run", "a", "FindBugs", "analysis", "on", "the", "given", "resource", "as", "build", "job", "BUT", "not", "delaying", "the", "current", "Java", "build" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsBuilder.java#L167-L194
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ClassNotFoundExceptionParser.java
ClassNotFoundExceptionParser.getMissingClassName
public static @DottedClassName String getMissingClassName(ClassNotFoundException ex) { // If the exception has a ResourceNotFoundException as the cause, // then we have an easy answer. Throwable cause = ex.getCause(); if (cause instanceof ResourceNotFoundException) { String resourceName = ((ResourceNotFoundException) cause).getResourceName(); if (resourceName != null) { ClassDescriptor classDesc = DescriptorFactory.createClassDescriptorFromResourceName(resourceName); return classDesc.toDottedClassName(); } } if (ex.getMessage() == null) { return null; } // Try the regular expression patterns to parse the class name // from the exception message. for (Pattern pattern : patternList) { Matcher matcher = pattern.matcher(ex.getMessage()); if (matcher.matches()) { String className = matcher.group(1); ClassName.assertIsDotted(className); return className; } } return null; }
java
public static @DottedClassName String getMissingClassName(ClassNotFoundException ex) { // If the exception has a ResourceNotFoundException as the cause, // then we have an easy answer. Throwable cause = ex.getCause(); if (cause instanceof ResourceNotFoundException) { String resourceName = ((ResourceNotFoundException) cause).getResourceName(); if (resourceName != null) { ClassDescriptor classDesc = DescriptorFactory.createClassDescriptorFromResourceName(resourceName); return classDesc.toDottedClassName(); } } if (ex.getMessage() == null) { return null; } // Try the regular expression patterns to parse the class name // from the exception message. for (Pattern pattern : patternList) { Matcher matcher = pattern.matcher(ex.getMessage()); if (matcher.matches()) { String className = matcher.group(1); ClassName.assertIsDotted(className); return className; } } return null; }
[ "public", "static", "@", "DottedClassName", "String", "getMissingClassName", "(", "ClassNotFoundException", "ex", ")", "{", "// If the exception has a ResourceNotFoundException as the cause,", "// then we have an easy answer.", "Throwable", "cause", "=", "ex", ".", "getCause", ...
Get the name of the missing class from a ClassNotFoundException. @param ex the ClassNotFoundException @return the name of the missing class, or null if we couldn't figure out the class name
[ "Get", "the", "name", "of", "the", "missing", "class", "from", "a", "ClassNotFoundException", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ClassNotFoundExceptionParser.java#L66-L94
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java
SourceInfoMap.addFieldLine
public void addFieldLine(String className, String fieldName, SourceLineRange range) { fieldLineMap.put(new FieldDescriptor(className, fieldName), range); }
java
public void addFieldLine(String className, String fieldName, SourceLineRange range) { fieldLineMap.put(new FieldDescriptor(className, fieldName), range); }
[ "public", "void", "addFieldLine", "(", "String", "className", ",", "String", "fieldName", ",", "SourceLineRange", "range", ")", "{", "fieldLineMap", ".", "put", "(", "new", "FieldDescriptor", "(", "className", ",", "fieldName", ")", ",", "range", ")", ";", "...
Add a line number entry for a field. @param className name of class containing the field @param fieldName name of field @param range the line number(s) of the field
[ "Add", "a", "line", "number", "entry", "for", "a", "field", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java#L251-L253
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java
SourceInfoMap.addMethodLine
public void addMethodLine(String className, String methodName, String methodSignature, SourceLineRange range) { methodLineMap.put(new MethodDescriptor(className, methodName, methodSignature), range); }
java
public void addMethodLine(String className, String methodName, String methodSignature, SourceLineRange range) { methodLineMap.put(new MethodDescriptor(className, methodName, methodSignature), range); }
[ "public", "void", "addMethodLine", "(", "String", "className", ",", "String", "methodName", ",", "String", "methodSignature", ",", "SourceLineRange", "range", ")", "{", "methodLineMap", ".", "put", "(", "new", "MethodDescriptor", "(", "className", ",", "methodName...
Add a line number entry for a method. @param className name of class containing the method @param methodName name of method @param methodSignature signature of method @param range the line number of the method
[ "Add", "a", "line", "number", "entry", "for", "a", "method", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java#L267-L269
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java
SourceInfoMap.getFieldLine
public @CheckForNull SourceLineRange getFieldLine(String className, String fieldName) { return fieldLineMap.get(new FieldDescriptor(className, fieldName)); }
java
public @CheckForNull SourceLineRange getFieldLine(String className, String fieldName) { return fieldLineMap.get(new FieldDescriptor(className, fieldName)); }
[ "public", "@", "CheckForNull", "SourceLineRange", "getFieldLine", "(", "String", "className", ",", "String", "fieldName", ")", "{", "return", "fieldLineMap", ".", "get", "(", "new", "FieldDescriptor", "(", "className", ",", "fieldName", ")", ")", ";", "}" ]
Look up the line number range for a field. @param className name of class containing the field @param fieldName name of field @return the line number range, or null if no line number is known for the field
[ "Look", "up", "the", "line", "number", "range", "for", "a", "field", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java#L293-L296
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java
SourceInfoMap.getMethodLine
public @CheckForNull SourceLineRange getMethodLine(String className, String methodName, String methodSignature) { return methodLineMap.get(new MethodDescriptor(className, methodName, methodSignature)); }
java
public @CheckForNull SourceLineRange getMethodLine(String className, String methodName, String methodSignature) { return methodLineMap.get(new MethodDescriptor(className, methodName, methodSignature)); }
[ "public", "@", "CheckForNull", "SourceLineRange", "getMethodLine", "(", "String", "className", ",", "String", "methodName", ",", "String", "methodSignature", ")", "{", "return", "methodLineMap", ".", "get", "(", "new", "MethodDescriptor", "(", "className", ",", "m...
Look up the line number range for a method. @param className name of class containing the method @param methodName name of method @param methodSignature signature of method @return the line number range, or null if no line number is known for the method
[ "Look", "up", "the", "line", "number", "range", "for", "a", "method", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java#L310-L313
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java
SourceInfoMap.parseVersionNumber
private static String parseVersionNumber(String line) { StringTokenizer tokenizer = new StringTokenizer(line, " \t"); if (!expect(tokenizer, "sourceInfo") || !expect(tokenizer, "version") || !tokenizer.hasMoreTokens()) { return null; } return tokenizer.nextToken(); }
java
private static String parseVersionNumber(String line) { StringTokenizer tokenizer = new StringTokenizer(line, " \t"); if (!expect(tokenizer, "sourceInfo") || !expect(tokenizer, "version") || !tokenizer.hasMoreTokens()) { return null; } return tokenizer.nextToken(); }
[ "private", "static", "String", "parseVersionNumber", "(", "String", "line", ")", "{", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "line", ",", "\" \\t\"", ")", ";", "if", "(", "!", "expect", "(", "tokenizer", ",", "\"sourceInfo\"", ")",...
Parse the sourceInfo version string. @param line the first line of the sourceInfo file @return the version number constant, or null if the line does not appear to be a version string
[ "Parse", "the", "sourceInfo", "version", "string", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java#L433-L441
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java
SourceInfoMap.expect
private static boolean expect(StringTokenizer tokenizer, String token) { if (!tokenizer.hasMoreTokens()) { return false; } String s = tokenizer.nextToken(); if (DEBUG) { System.out.println("token=" + s); } return s.equals(token); }
java
private static boolean expect(StringTokenizer tokenizer, String token) { if (!tokenizer.hasMoreTokens()) { return false; } String s = tokenizer.nextToken(); if (DEBUG) { System.out.println("token=" + s); } return s.equals(token); }
[ "private", "static", "boolean", "expect", "(", "StringTokenizer", "tokenizer", ",", "String", "token", ")", "{", "if", "(", "!", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "return", "false", ";", "}", "String", "s", "=", "tokenizer", ".", "ne...
Expect a particular token string to be returned by the given StringTokenizer. @param tokenizer the StringTokenizer @param token the expectedToken @return true if the expected token was returned, false if not
[ "Expect", "a", "particular", "token", "string", "to", "be", "returned", "by", "the", "given", "StringTokenizer", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceInfoMap.java#L453-L462
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/SloppyBugComparator.java
SloppyBugComparator.compareClassesAllowingNull
private int compareClassesAllowingNull(ClassAnnotation lhs, ClassAnnotation rhs) { if (lhs == null || rhs == null) { return compareNullElements(lhs, rhs); } String lhsClassName = classNameRewriter.rewriteClassName(lhs.getClassName()); String rhsClassName = classNameRewriter.rewriteClassName(rhs.getClassName()); if (DEBUG) { System.err.println("Comparing " + lhsClassName + " and " + rhsClassName); } int cmp = lhsClassName.compareTo(rhsClassName); if (DEBUG) { System.err.println("\t==> " + cmp); } return cmp; }
java
private int compareClassesAllowingNull(ClassAnnotation lhs, ClassAnnotation rhs) { if (lhs == null || rhs == null) { return compareNullElements(lhs, rhs); } String lhsClassName = classNameRewriter.rewriteClassName(lhs.getClassName()); String rhsClassName = classNameRewriter.rewriteClassName(rhs.getClassName()); if (DEBUG) { System.err.println("Comparing " + lhsClassName + " and " + rhsClassName); } int cmp = lhsClassName.compareTo(rhsClassName); if (DEBUG) { System.err.println("\t==> " + cmp); } return cmp; }
[ "private", "int", "compareClassesAllowingNull", "(", "ClassAnnotation", "lhs", ",", "ClassAnnotation", "rhs", ")", "{", "if", "(", "lhs", "==", "null", "||", "rhs", "==", "null", ")", "{", "return", "compareNullElements", "(", "lhs", ",", "rhs", ")", ";", ...
Compare class annotations. @param lhs left hand class annotation @param rhs right hand class annotation @return comparison of the class annotations
[ "Compare", "class", "annotations", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SloppyBugComparator.java#L63-L80
train
spotbugs/spotbugs
spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/BugSet.java
BugSet.countFilteredBugs
static int countFilteredBugs() { int result = 0; for (BugLeafNode bug : getMainBugSet().mainList) { if (suppress(bug)) { result++; } } return result; }
java
static int countFilteredBugs() { int result = 0; for (BugLeafNode bug : getMainBugSet().mainList) { if (suppress(bug)) { result++; } } return result; }
[ "static", "int", "countFilteredBugs", "(", ")", "{", "int", "result", "=", "0", ";", "for", "(", "BugLeafNode", "bug", ":", "getMainBugSet", "(", ")", ".", "mainList", ")", "{", "if", "(", "suppress", "(", "bug", ")", ")", "{", "result", "++", ";", ...
used to update the status bar in mainframe with the number of bugs that are filtered out
[ "used", "to", "update", "the", "status", "bar", "in", "mainframe", "with", "the", "number", "of", "bugs", "that", "are", "filtered", "out" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/BugSet.java#L182-L191
train
spotbugs/spotbugs
spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/BugSet.java
BugSet.query
public BugSet query(BugAspects a) { BugSet result = this; for (SortableValue sp : a) { result = result.query(sp); } return result; }
java
public BugSet query(BugAspects a) { BugSet result = this; for (SortableValue sp : a) { result = result.query(sp); } return result; }
[ "public", "BugSet", "query", "(", "BugAspects", "a", ")", "{", "BugSet", "result", "=", "this", ";", "for", "(", "SortableValue", "sp", ":", "a", ")", "{", "result", "=", "result", ".", "query", "(", "sp", ")", ";", "}", "return", "result", ";", "}...
Gives you back the BugSet containing all bugs that match your query
[ "Gives", "you", "back", "the", "BugSet", "containing", "all", "bugs", "that", "match", "your", "query" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/BugSet.java#L341-L348
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/props/WarningPropertyUtil.java
WarningPropertyUtil.pcToLocation
private static Location pcToLocation(ClassContext classContext, Method method, int pc) throws CFGBuilderException { CFG cfg = classContext.getCFG(method); for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location location = i.next(); if (location.getHandle().getPosition() == pc) { return location; } } return null; }
java
private static Location pcToLocation(ClassContext classContext, Method method, int pc) throws CFGBuilderException { CFG cfg = classContext.getCFG(method); for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location location = i.next(); if (location.getHandle().getPosition() == pc) { return location; } } return null; }
[ "private", "static", "Location", "pcToLocation", "(", "ClassContext", "classContext", ",", "Method", "method", ",", "int", "pc", ")", "throws", "CFGBuilderException", "{", "CFG", "cfg", "=", "classContext", ".", "getCFG", "(", "method", ")", ";", "for", "(", ...
Get a Location matching the given PC value. Because of JSR subroutines, there may be multiple Locations referring to the given instruction. This method simply returns one of them arbitrarily. @param classContext the ClassContext containing the method @param method the method @param pc a PC value of an instruction in the method @return a Location corresponding to the PC value, or null if no such Location can be found @throws CFGBuilderException
[ "Get", "a", "Location", "matching", "the", "given", "PC", "value", ".", "Because", "of", "JSR", "subroutines", "there", "may", "be", "multiple", "Locations", "referring", "to", "the", "given", "instruction", ".", "This", "method", "simply", "returns", "one", ...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/props/WarningPropertyUtil.java#L75-L84
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/props/WarningPropertyUtil.java
WarningPropertyUtil.addReceiverObjectType
private static void addReceiverObjectType(WarningPropertySet<WarningProperty> propertySet, ClassContext classContext, Method method, Location location) { try { Instruction ins = location.getHandle().getInstruction(); if (!receiverObjectInstructionSet.get(ins.getOpcode())) { return; } TypeDataflow typeDataflow = classContext.getTypeDataflow(method); TypeFrame frame = typeDataflow.getFactAtLocation(location); if (frame.isValid()) { Type type = frame.getInstance(ins, classContext.getConstantPoolGen()); if (type instanceof ReferenceType) { propertySet.setProperty(GeneralWarningProperty.RECEIVER_OBJECT_TYPE, type.toString()); } } } catch (DataflowAnalysisException e) { // Ignore } catch (CFGBuilderException e) { // Ignore } }
java
private static void addReceiverObjectType(WarningPropertySet<WarningProperty> propertySet, ClassContext classContext, Method method, Location location) { try { Instruction ins = location.getHandle().getInstruction(); if (!receiverObjectInstructionSet.get(ins.getOpcode())) { return; } TypeDataflow typeDataflow = classContext.getTypeDataflow(method); TypeFrame frame = typeDataflow.getFactAtLocation(location); if (frame.isValid()) { Type type = frame.getInstance(ins, classContext.getConstantPoolGen()); if (type instanceof ReferenceType) { propertySet.setProperty(GeneralWarningProperty.RECEIVER_OBJECT_TYPE, type.toString()); } } } catch (DataflowAnalysisException e) { // Ignore } catch (CFGBuilderException e) { // Ignore } }
[ "private", "static", "void", "addReceiverObjectType", "(", "WarningPropertySet", "<", "WarningProperty", ">", "propertySet", ",", "ClassContext", "classContext", ",", "Method", "method", ",", "Location", "location", ")", "{", "try", "{", "Instruction", "ins", "=", ...
Add a RECEIVER_OBJECT_TYPE warning property for a particular location in a method to given warning property set. @param propertySet the property set @param classContext ClassContext of the class containing the method @param method the method @param location Location within the method
[ "Add", "a", "RECEIVER_OBJECT_TYPE", "warning", "property", "for", "a", "particular", "location", "in", "a", "method", "to", "given", "warning", "property", "set", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/props/WarningPropertyUtil.java#L99-L121
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/model/MovedClassMap.java
MovedClassMap.buildClassSet
private Set<String> buildClassSet(BugCollection bugCollection) { Set<String> classSet = new HashSet<>(); for (Iterator<BugInstance> i = bugCollection.iterator(); i.hasNext();) { BugInstance warning = i.next(); for (Iterator<BugAnnotation> j = warning.annotationIterator(); j.hasNext();) { BugAnnotation annotation = j.next(); if (!(annotation instanceof ClassAnnotation)) { continue; } classSet.add(((ClassAnnotation) annotation).getClassName()); } } return classSet; }
java
private Set<String> buildClassSet(BugCollection bugCollection) { Set<String> classSet = new HashSet<>(); for (Iterator<BugInstance> i = bugCollection.iterator(); i.hasNext();) { BugInstance warning = i.next(); for (Iterator<BugAnnotation> j = warning.annotationIterator(); j.hasNext();) { BugAnnotation annotation = j.next(); if (!(annotation instanceof ClassAnnotation)) { continue; } classSet.add(((ClassAnnotation) annotation).getClassName()); } } return classSet; }
[ "private", "Set", "<", "String", ">", "buildClassSet", "(", "BugCollection", "bugCollection", ")", "{", "Set", "<", "String", ">", "classSet", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "BugInstance", ">", "i", "=", "bugColl...
Find set of classes referenced in given BugCollection. @param bugCollection @return set of classes referenced in the BugCollection
[ "Find", "set", "of", "classes", "referenced", "in", "given", "BugCollection", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/model/MovedClassMap.java#L109-L124
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java
FindDeadLocalStores.suppressWarningsIfOneLiveStoreOnLine
private void suppressWarningsIfOneLiveStoreOnLine(BugAccumulator accumulator, BitSet liveStoreSourceLineSet) { if (!SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE) { return; } // Eliminate any accumulated warnings for instructions // that (due to inlining) *can* be live stores. entryLoop: for (Iterator<? extends BugInstance> i = accumulator.uniqueBugs().iterator(); i.hasNext();) { for (SourceLineAnnotation annotation : accumulator.locations(i.next())) { if (liveStoreSourceLineSet.get(annotation.getStartLine())) { // This instruction can be a live store; don't report // it as a warning. i.remove(); continue entryLoop; } } } }
java
private void suppressWarningsIfOneLiveStoreOnLine(BugAccumulator accumulator, BitSet liveStoreSourceLineSet) { if (!SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE) { return; } // Eliminate any accumulated warnings for instructions // that (due to inlining) *can* be live stores. entryLoop: for (Iterator<? extends BugInstance> i = accumulator.uniqueBugs().iterator(); i.hasNext();) { for (SourceLineAnnotation annotation : accumulator.locations(i.next())) { if (liveStoreSourceLineSet.get(annotation.getStartLine())) { // This instruction can be a live store; don't report // it as a warning. i.remove(); continue entryLoop; } } } }
[ "private", "void", "suppressWarningsIfOneLiveStoreOnLine", "(", "BugAccumulator", "accumulator", ",", "BitSet", "liveStoreSourceLineSet", ")", "{", "if", "(", "!", "SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE", ")", "{", "return", ";", "}", "// Eliminate any accumulated warni...
If feature is enabled, suppress warnings where there is at least one live store on the line where the warning would be reported. @param accumulator BugAccumulator containing warnings for method @param liveStoreSourceLineSet bitset of lines where at least one live store was seen
[ "If", "feature", "is", "enabled", "suppress", "warnings", "where", "there", "is", "at", "least", "one", "live", "store", "on", "the", "line", "where", "the", "warning", "would", "be", "reported", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java#L624-L642
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java
FindDeadLocalStores.countLocalStoresLoadsAndIncrements
private void countLocalStoresLoadsAndIncrements(int[] localStoreCount, int[] localLoadCount, int[] localIncrementCount, CFG cfg) { for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location location = i.next(); if (location.getBasicBlock().isExceptionHandler()) { continue; } boolean isStore = isStore(location); boolean isLoad = isLoad(location); if (!isStore && !isLoad) { continue; } IndexedInstruction ins = (IndexedInstruction) location.getHandle().getInstruction(); int local = ins.getIndex(); if (ins instanceof IINC) { localStoreCount[local]++; localLoadCount[local]++; localIncrementCount[local]++; } else if (isStore) { localStoreCount[local]++; } else { localLoadCount[local]++; } } }
java
private void countLocalStoresLoadsAndIncrements(int[] localStoreCount, int[] localLoadCount, int[] localIncrementCount, CFG cfg) { for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location location = i.next(); if (location.getBasicBlock().isExceptionHandler()) { continue; } boolean isStore = isStore(location); boolean isLoad = isLoad(location); if (!isStore && !isLoad) { continue; } IndexedInstruction ins = (IndexedInstruction) location.getHandle().getInstruction(); int local = ins.getIndex(); if (ins instanceof IINC) { localStoreCount[local]++; localLoadCount[local]++; localIncrementCount[local]++; } else if (isStore) { localStoreCount[local]++; } else { localLoadCount[local]++; } } }
[ "private", "void", "countLocalStoresLoadsAndIncrements", "(", "int", "[", "]", "localStoreCount", ",", "int", "[", "]", "localLoadCount", ",", "int", "[", "]", "localIncrementCount", ",", "CFG", "cfg", ")", "{", "for", "(", "Iterator", "<", "Location", ">", ...
Count stores, loads, and increments of local variables in method whose CFG is given. @param localStoreCount counts of local stores (indexed by local) @param localLoadCount counts of local loads (indexed by local) @param localIncrementCount counts of local increments (indexed by local) @param cfg control flow graph (CFG) of method
[ "Count", "stores", "loads", "and", "increments", "of", "local", "variables", "in", "method", "whose", "CFG", "is", "given", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java#L657-L684
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java
FindDeadLocalStores.isStore
private boolean isStore(Location location) { Instruction ins = location.getHandle().getInstruction(); return (ins instanceof StoreInstruction) || (ins instanceof IINC); }
java
private boolean isStore(Location location) { Instruction ins = location.getHandle().getInstruction(); return (ins instanceof StoreInstruction) || (ins instanceof IINC); }
[ "private", "boolean", "isStore", "(", "Location", "location", ")", "{", "Instruction", "ins", "=", "location", ".", "getHandle", "(", ")", ".", "getInstruction", "(", ")", ";", "return", "(", "ins", "instanceof", "StoreInstruction", ")", "||", "(", "ins", ...
Is instruction at given location a store? @param location the location @return true if instruction at given location is a store, false if not
[ "Is", "instruction", "at", "given", "location", "a", "store?" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java#L716-L719
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java
FindDeadLocalStores.isLoad
private boolean isLoad(Location location) { Instruction ins = location.getHandle().getInstruction(); return (ins instanceof LoadInstruction) || (ins instanceof IINC); }
java
private boolean isLoad(Location location) { Instruction ins = location.getHandle().getInstruction(); return (ins instanceof LoadInstruction) || (ins instanceof IINC); }
[ "private", "boolean", "isLoad", "(", "Location", "location", ")", "{", "Instruction", "ins", "=", "location", ".", "getHandle", "(", ")", ".", "getInstruction", "(", ")", ";", "return", "(", "ins", "instanceof", "LoadInstruction", ")", "||", "(", "ins", "i...
Is instruction at given location a load? @param location the location @return true if instruction at given location is a load, false if not
[ "Is", "instruction", "at", "given", "location", "a", "load?" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindDeadLocalStores.java#L728-L731
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/analysis/AnnotationValue.java
AnnotationValue.getAnnotationVisitor
public AnnotationVisitor getAnnotationVisitor() { return new AnnotationVisitor(FindBugsASM.ASM_VERSION) { @Override public void visit(String name, Object value) { name = canonicalString(name); valueMap.put(name, value); } /* * (non-Javadoc) * * @see * org.objectweb.asm.AnnotationVisitor#visitAnnotation(java.lang * .String, java.lang.String) */ @Override public AnnotationVisitor visitAnnotation(String name, String desc) { name = canonicalString(name); AnnotationValue newValue = new AnnotationValue(desc); valueMap.put(name, newValue); typeMap.put(name, desc); return newValue.getAnnotationVisitor(); } /* * (non-Javadoc) * * @see * org.objectweb.asm.AnnotationVisitor#visitArray(java.lang.String) */ @Override public AnnotationVisitor visitArray(String name) { name = canonicalString(name); return new AnnotationArrayVisitor(name); } /* * (non-Javadoc) * * @see org.objectweb.asm.AnnotationVisitor#visitEnd() */ @Override public void visitEnd() { } /* * (non-Javadoc) * * @see * org.objectweb.asm.AnnotationVisitor#visitEnum(java.lang.String, * java.lang.String, java.lang.String) */ @Override public void visitEnum(String name, String desc, String value) { name = canonicalString(name); valueMap.put(name, new EnumValue(desc, value)); typeMap.put(name, desc); } }; }
java
public AnnotationVisitor getAnnotationVisitor() { return new AnnotationVisitor(FindBugsASM.ASM_VERSION) { @Override public void visit(String name, Object value) { name = canonicalString(name); valueMap.put(name, value); } /* * (non-Javadoc) * * @see * org.objectweb.asm.AnnotationVisitor#visitAnnotation(java.lang * .String, java.lang.String) */ @Override public AnnotationVisitor visitAnnotation(String name, String desc) { name = canonicalString(name); AnnotationValue newValue = new AnnotationValue(desc); valueMap.put(name, newValue); typeMap.put(name, desc); return newValue.getAnnotationVisitor(); } /* * (non-Javadoc) * * @see * org.objectweb.asm.AnnotationVisitor#visitArray(java.lang.String) */ @Override public AnnotationVisitor visitArray(String name) { name = canonicalString(name); return new AnnotationArrayVisitor(name); } /* * (non-Javadoc) * * @see org.objectweb.asm.AnnotationVisitor#visitEnd() */ @Override public void visitEnd() { } /* * (non-Javadoc) * * @see * org.objectweb.asm.AnnotationVisitor#visitEnum(java.lang.String, * java.lang.String, java.lang.String) */ @Override public void visitEnum(String name, String desc, String value) { name = canonicalString(name); valueMap.put(name, new EnumValue(desc, value)); typeMap.put(name, desc); } }; }
[ "public", "AnnotationVisitor", "getAnnotationVisitor", "(", ")", "{", "return", "new", "AnnotationVisitor", "(", "FindBugsASM", ".", "ASM_VERSION", ")", "{", "@", "Override", "public", "void", "visit", "(", "String", "name", ",", "Object", "value", ")", "{", "...
Get an AnnotationVisitor which can populate this AnnotationValue object.
[ "Get", "an", "AnnotationVisitor", "which", "can", "populate", "this", "AnnotationValue", "object", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/analysis/AnnotationValue.java#L113-L174
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java
ClassParser.readConstant
private Constant readConstant() throws InvalidClassFileFormatException, IOException { int tag = in.readUnsignedByte(); if (tag < 0 || tag >= CONSTANT_FORMAT_MAP.length) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } String format = CONSTANT_FORMAT_MAP[tag]; if (format == null) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } Object[] data = new Object[format.length()]; for (int i = 0; i < format.length(); i++) { char spec = format.charAt(i); switch (spec) { case '8': data[i] = in.readUTF(); break; case 'I': data[i] = in.readInt(); break; case 'F': data[i] = Float.valueOf(in.readFloat()); break; case 'L': data[i] = in.readLong(); break; case 'D': data[i] = Double.valueOf(in.readDouble()); break; case 'i': data[i] = in.readUnsignedShort(); break; case 'b': data[i] = in.readUnsignedByte(); break; default: throw new IllegalStateException(); } } return new Constant(tag, data); }
java
private Constant readConstant() throws InvalidClassFileFormatException, IOException { int tag = in.readUnsignedByte(); if (tag < 0 || tag >= CONSTANT_FORMAT_MAP.length) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } String format = CONSTANT_FORMAT_MAP[tag]; if (format == null) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } Object[] data = new Object[format.length()]; for (int i = 0; i < format.length(); i++) { char spec = format.charAt(i); switch (spec) { case '8': data[i] = in.readUTF(); break; case 'I': data[i] = in.readInt(); break; case 'F': data[i] = Float.valueOf(in.readFloat()); break; case 'L': data[i] = in.readLong(); break; case 'D': data[i] = Double.valueOf(in.readDouble()); break; case 'i': data[i] = in.readUnsignedShort(); break; case 'b': data[i] = in.readUnsignedByte(); break; default: throw new IllegalStateException(); } } return new Constant(tag, data); }
[ "private", "Constant", "readConstant", "(", ")", "throws", "InvalidClassFileFormatException", ",", "IOException", "{", "int", "tag", "=", "in", ".", "readUnsignedByte", "(", ")", ";", "if", "(", "tag", "<", "0", "||", "tag", ">=", "CONSTANT_FORMAT_MAP", ".", ...
Read a constant from the constant pool. Return null for @return a StaticConstant @throws InvalidClassFileFormatException @throws IOException
[ "Read", "a", "constant", "from", "the", "constant", "pool", ".", "Return", "null", "for" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java#L243-L284
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java
ClassParser.getUtf8String
private String getUtf8String(int refIndex) throws InvalidClassFileFormatException { checkConstantPoolIndex(refIndex); Constant refConstant = constantPool[refIndex]; checkConstantTag(refConstant, IClassConstants.CONSTANT_Utf8); return (String) refConstant.data[0]; }
java
private String getUtf8String(int refIndex) throws InvalidClassFileFormatException { checkConstantPoolIndex(refIndex); Constant refConstant = constantPool[refIndex]; checkConstantTag(refConstant, IClassConstants.CONSTANT_Utf8); return (String) refConstant.data[0]; }
[ "private", "String", "getUtf8String", "(", "int", "refIndex", ")", "throws", "InvalidClassFileFormatException", "{", "checkConstantPoolIndex", "(", "refIndex", ")", ";", "Constant", "refConstant", "=", "constantPool", "[", "refIndex", "]", ";", "checkConstantTag", "("...
Get the UTF-8 string constant at given constant pool index. @param refIndex the constant pool index @return the String at that index @throws InvalidClassFileFormatException
[ "Get", "the", "UTF", "-", "8", "string", "constant", "at", "given", "constant", "pool", "index", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java#L333-L338
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java
ClassParser.checkConstantPoolIndex
private void checkConstantPoolIndex(int index) throws InvalidClassFileFormatException { if (index < 0 || index >= constantPool.length || constantPool[index] == null) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } }
java
private void checkConstantPoolIndex(int index) throws InvalidClassFileFormatException { if (index < 0 || index >= constantPool.length || constantPool[index] == null) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } }
[ "private", "void", "checkConstantPoolIndex", "(", "int", "index", ")", "throws", "InvalidClassFileFormatException", "{", "if", "(", "index", "<", "0", "||", "index", ">=", "constantPool", ".", "length", "||", "constantPool", "[", "index", "]", "==", "null", ")...
Check that a constant pool index is valid. @param index the index to check @throws InvalidClassFileFormatException if the index is not valid
[ "Check", "that", "a", "constant", "pool", "index", "is", "valid", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java#L348-L352
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java
ClassParser.checkConstantTag
private void checkConstantTag(Constant constant, int expectedTag) throws InvalidClassFileFormatException { if (constant.tag != expectedTag) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } }
java
private void checkConstantTag(Constant constant, int expectedTag) throws InvalidClassFileFormatException { if (constant.tag != expectedTag) { throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry); } }
[ "private", "void", "checkConstantTag", "(", "Constant", "constant", ",", "int", "expectedTag", ")", "throws", "InvalidClassFileFormatException", "{", "if", "(", "constant", ".", "tag", "!=", "expectedTag", ")", "{", "throw", "new", "InvalidClassFileFormatException", ...
Check that a constant has the expected tag. @param constant the constant to check @param expectedTag the expected constant tag @throws InvalidClassFileFormatException if the constant's tag does not match the expected tag
[ "Check", "that", "a", "constant", "has", "the", "expected", "tag", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java#L364-L368
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java
ClassParser.getSignatureFromNameAndType
private String getSignatureFromNameAndType(int index) throws InvalidClassFileFormatException { checkConstantPoolIndex(index); Constant constant = constantPool[index]; checkConstantTag(constant, IClassConstants.CONSTANT_NameAndType); return getUtf8String((Integer) constant.data[1]); }
java
private String getSignatureFromNameAndType(int index) throws InvalidClassFileFormatException { checkConstantPoolIndex(index); Constant constant = constantPool[index]; checkConstantTag(constant, IClassConstants.CONSTANT_NameAndType); return getUtf8String((Integer) constant.data[1]); }
[ "private", "String", "getSignatureFromNameAndType", "(", "int", "index", ")", "throws", "InvalidClassFileFormatException", "{", "checkConstantPoolIndex", "(", "index", ")", ";", "Constant", "constant", "=", "constantPool", "[", "index", "]", ";", "checkConstantTag", "...
Get the signature from a CONSTANT_NameAndType. @param index the index of the CONSTANT_NameAndType @return the signature @throws InvalidClassFileFormatException
[ "Get", "the", "signature", "from", "a", "CONSTANT_NameAndType", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/engine/ClassParser.java#L496-L501
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java
UnconditionalValueDerefAnalysis.checkUnconditionalDerefDatabase
private void checkUnconditionalDerefDatabase(Location location, ValueNumberFrame vnaFrame, UnconditionalValueDerefSet fact) throws DataflowAnalysisException { ConstantPoolGen constantPool = methodGen.getConstantPool(); for (ValueNumber vn : checkUnconditionalDerefDatabase(location, vnaFrame, constantPool, invDataflow.getFactAtLocation(location), typeDataflow)) { fact.addDeref(vn, location); } }
java
private void checkUnconditionalDerefDatabase(Location location, ValueNumberFrame vnaFrame, UnconditionalValueDerefSet fact) throws DataflowAnalysisException { ConstantPoolGen constantPool = methodGen.getConstantPool(); for (ValueNumber vn : checkUnconditionalDerefDatabase(location, vnaFrame, constantPool, invDataflow.getFactAtLocation(location), typeDataflow)) { fact.addDeref(vn, location); } }
[ "private", "void", "checkUnconditionalDerefDatabase", "(", "Location", "location", ",", "ValueNumberFrame", "vnaFrame", ",", "UnconditionalValueDerefSet", "fact", ")", "throws", "DataflowAnalysisException", "{", "ConstantPoolGen", "constantPool", "=", "methodGen", ".", "get...
Check method call at given location to see if it unconditionally dereferences a parameter. Mark any such arguments as derefs. @param location the Location of the method call @param vnaFrame ValueNumberFrame at the Location @param fact the dataflow value to modify @throws DataflowAnalysisException
[ "Check", "method", "call", "at", "given", "location", "to", "see", "if", "it", "unconditionally", "dereferences", "a", "parameter", ".", "Mark", "any", "such", "arguments", "as", "derefs", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java#L319-L327
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java
UnconditionalValueDerefAnalysis.checkInstance
private void checkInstance(Location location, ValueNumberFrame vnaFrame, UnconditionalValueDerefSet fact) throws DataflowAnalysisException { // See if this instruction has a null check. // If it does, the fall through predecessor will be // identify itself as the null check. if (!location.isFirstInstructionInBasicBlock()) { return; } if (invDataflow == null) { return; } BasicBlock fallThroughPredecessor = cfg.getPredecessorWithEdgeType(location.getBasicBlock(), EdgeTypes.FALL_THROUGH_EDGE); if (fallThroughPredecessor == null || !fallThroughPredecessor.isNullCheck()) { return; } // Get the null-checked value ValueNumber vn = vnaFrame.getInstance(location.getHandle().getInstruction(), methodGen.getConstantPool()); // Ignore dereferences of this if (!methodGen.isStatic()) { ValueNumber v = vnaFrame.getValue(0); if (v.equals(vn)) { return; } } if (vn.hasFlag(ValueNumber.CONSTANT_CLASS_OBJECT)) { return; } IsNullValueFrame startFact = null; startFact = invDataflow.getStartFact(fallThroughPredecessor); if (!startFact.isValid()) { return; } int slot = startFact.getInstanceSlot(location.getHandle().getInstruction(), methodGen.getConstantPool()); if (!reportDereference(startFact, slot)) { return; } if (DEBUG) { System.out.println("FOUND GUARANTEED DEREFERENCE"); System.out.println("Load: " + vnaFrame.getLoad(vn)); System.out.println("Pred: " + fallThroughPredecessor); System.out.println("startFact: " + startFact); System.out.println("Location: " + location); System.out.println("Value number frame: " + vnaFrame); System.out.println("Dereferenced valueNumber: " + vn); System.out.println("invDataflow: " + startFact); System.out.println("IGNORE_DEREF_OF_NCP: " + IGNORE_DEREF_OF_NCP); } // Mark the value number as being dereferenced at this location fact.addDeref(vn, location); }
java
private void checkInstance(Location location, ValueNumberFrame vnaFrame, UnconditionalValueDerefSet fact) throws DataflowAnalysisException { // See if this instruction has a null check. // If it does, the fall through predecessor will be // identify itself as the null check. if (!location.isFirstInstructionInBasicBlock()) { return; } if (invDataflow == null) { return; } BasicBlock fallThroughPredecessor = cfg.getPredecessorWithEdgeType(location.getBasicBlock(), EdgeTypes.FALL_THROUGH_EDGE); if (fallThroughPredecessor == null || !fallThroughPredecessor.isNullCheck()) { return; } // Get the null-checked value ValueNumber vn = vnaFrame.getInstance(location.getHandle().getInstruction(), methodGen.getConstantPool()); // Ignore dereferences of this if (!methodGen.isStatic()) { ValueNumber v = vnaFrame.getValue(0); if (v.equals(vn)) { return; } } if (vn.hasFlag(ValueNumber.CONSTANT_CLASS_OBJECT)) { return; } IsNullValueFrame startFact = null; startFact = invDataflow.getStartFact(fallThroughPredecessor); if (!startFact.isValid()) { return; } int slot = startFact.getInstanceSlot(location.getHandle().getInstruction(), methodGen.getConstantPool()); if (!reportDereference(startFact, slot)) { return; } if (DEBUG) { System.out.println("FOUND GUARANTEED DEREFERENCE"); System.out.println("Load: " + vnaFrame.getLoad(vn)); System.out.println("Pred: " + fallThroughPredecessor); System.out.println("startFact: " + startFact); System.out.println("Location: " + location); System.out.println("Value number frame: " + vnaFrame); System.out.println("Dereferenced valueNumber: " + vn); System.out.println("invDataflow: " + startFact); System.out.println("IGNORE_DEREF_OF_NCP: " + IGNORE_DEREF_OF_NCP); } // Mark the value number as being dereferenced at this location fact.addDeref(vn, location); }
[ "private", "void", "checkInstance", "(", "Location", "location", ",", "ValueNumberFrame", "vnaFrame", ",", "UnconditionalValueDerefSet", "fact", ")", "throws", "DataflowAnalysisException", "{", "// See if this instruction has a null check.", "// If it does, the fall through predece...
Check to see if the instruction has a null check associated with it, and if so, add a dereference. @param location the Location of the instruction @param vnaFrame ValueNumberFrame at the Location of the instruction @param fact the dataflow value to modify @throws DataflowAnalysisException
[ "Check", "to", "see", "if", "the", "instruction", "has", "a", "null", "check", "associated", "with", "it", "and", "if", "so", "add", "a", "dereference", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java#L600-L655
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java
UnconditionalValueDerefAnalysis.duplicateFact
private UnconditionalValueDerefSet duplicateFact(UnconditionalValueDerefSet fact) { UnconditionalValueDerefSet copyOfFact = createFact(); copy(fact, copyOfFact); fact = copyOfFact; return fact; }
java
private UnconditionalValueDerefSet duplicateFact(UnconditionalValueDerefSet fact) { UnconditionalValueDerefSet copyOfFact = createFact(); copy(fact, copyOfFact); fact = copyOfFact; return fact; }
[ "private", "UnconditionalValueDerefSet", "duplicateFact", "(", "UnconditionalValueDerefSet", "fact", ")", "{", "UnconditionalValueDerefSet", "copyOfFact", "=", "createFact", "(", ")", ";", "copy", "(", "fact", ",", "copyOfFact", ")", ";", "fact", "=", "copyOfFact", ...
Return a duplicate of given dataflow fact. @param fact a dataflow fact @return a duplicate of the input dataflow fact
[ "Return", "a", "duplicate", "of", "given", "dataflow", "fact", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java#L892-L897
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java
UnconditionalValueDerefAnalysis.findValueKnownNonnullOnBranch
private @CheckForNull ValueNumber findValueKnownNonnullOnBranch(UnconditionalValueDerefSet fact, Edge edge) { IsNullValueFrame invFrame = invDataflow.getResultFact(edge.getSource()); if (!invFrame.isValid()) { return null; } IsNullConditionDecision decision = invFrame.getDecision(); if (decision == null) { return null; } IsNullValue inv = decision.getDecision(edge.getType()); if (inv == null || !inv.isDefinitelyNotNull()) { return null; } ValueNumber value = decision.getValue(); if (DEBUG) { System.out.println("Value number " + value + " is known nonnull on " + edge); } return value; }
java
private @CheckForNull ValueNumber findValueKnownNonnullOnBranch(UnconditionalValueDerefSet fact, Edge edge) { IsNullValueFrame invFrame = invDataflow.getResultFact(edge.getSource()); if (!invFrame.isValid()) { return null; } IsNullConditionDecision decision = invFrame.getDecision(); if (decision == null) { return null; } IsNullValue inv = decision.getDecision(edge.getType()); if (inv == null || !inv.isDefinitelyNotNull()) { return null; } ValueNumber value = decision.getValue(); if (DEBUG) { System.out.println("Value number " + value + " is known nonnull on " + edge); } return value; }
[ "private", "@", "CheckForNull", "ValueNumber", "findValueKnownNonnullOnBranch", "(", "UnconditionalValueDerefSet", "fact", ",", "Edge", "edge", ")", "{", "IsNullValueFrame", "invFrame", "=", "invDataflow", ".", "getResultFact", "(", "edge", ".", "getSource", "(", ")",...
Clear deref sets of values if this edge is the non-null branch of an if comparison. @param fact a datflow fact @param edge edge to check @return possibly-modified dataflow fact
[ "Clear", "deref", "sets", "of", "values", "if", "this", "edge", "is", "the", "non", "-", "null", "branch", "of", "an", "if", "comparison", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java#L909-L931
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java
UnconditionalValueDerefAnalysis.isExceptionEdge
private boolean isExceptionEdge(Edge edge) { boolean isExceptionEdge = edge.isExceptionEdge(); if (isExceptionEdge) { if (DEBUG) { System.out.println("NOT Ignoring " + edge); } return true; // false } if (edge.getType() != EdgeTypes.FALL_THROUGH_EDGE) { return false; } InstructionHandle h = edge.getSource().getLastInstruction(); return h != null && h.getInstruction() instanceof IFNONNULL && isNullCheck(h, methodGen.getConstantPool()); }
java
private boolean isExceptionEdge(Edge edge) { boolean isExceptionEdge = edge.isExceptionEdge(); if (isExceptionEdge) { if (DEBUG) { System.out.println("NOT Ignoring " + edge); } return true; // false } if (edge.getType() != EdgeTypes.FALL_THROUGH_EDGE) { return false; } InstructionHandle h = edge.getSource().getLastInstruction(); return h != null && h.getInstruction() instanceof IFNONNULL && isNullCheck(h, methodGen.getConstantPool()); }
[ "private", "boolean", "isExceptionEdge", "(", "Edge", "edge", ")", "{", "boolean", "isExceptionEdge", "=", "edge", ".", "isExceptionEdge", "(", ")", ";", "if", "(", "isExceptionEdge", ")", "{", "if", "(", "DEBUG", ")", "{", "System", ".", "out", ".", "pr...
Determine whether dataflow should be propagated on given edge. @param edge the edge @return true if dataflow should be propagated on the edge, false otherwise
[ "Determine", "whether", "dataflow", "should", "be", "propagated", "on", "given", "edge", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/deref/UnconditionalValueDerefAnalysis.java#L941-L956
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.isSubtype
public static boolean isSubtype(ReferenceType t, ReferenceType possibleSupertype) throws ClassNotFoundException { return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype); }
java
public static boolean isSubtype(ReferenceType t, ReferenceType possibleSupertype) throws ClassNotFoundException { return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype); }
[ "public", "static", "boolean", "isSubtype", "(", "ReferenceType", "t", ",", "ReferenceType", "possibleSupertype", ")", "throws", "ClassNotFoundException", "{", "return", "Global", ".", "getAnalysisCache", "(", ")", ".", "getDatabase", "(", "Subtypes2", ".", "class",...
Determine if one reference type is a subtype of another. @param t a reference type @param possibleSupertype the possible supertype @return true if t is a subtype of possibleSupertype, false if not
[ "Determine", "if", "one", "reference", "type", "is", "a", "subtype", "of", "another", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L109-L111
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.isMonitorWait
public static boolean isMonitorWait(String methodName, String methodSig) { return "wait".equals(methodName) && ("()V".equals(methodSig) || "(J)V".equals(methodSig) || "(JI)V".equals(methodSig)); }
java
public static boolean isMonitorWait(String methodName, String methodSig) { return "wait".equals(methodName) && ("()V".equals(methodSig) || "(J)V".equals(methodSig) || "(JI)V".equals(methodSig)); }
[ "public", "static", "boolean", "isMonitorWait", "(", "String", "methodName", ",", "String", "methodSig", ")", "{", "return", "\"wait\"", ".", "equals", "(", "methodName", ")", "&&", "(", "\"()V\"", ".", "equals", "(", "methodSig", ")", "||", "\"(J)V\"", ".",...
Determine if method whose name and signature is specified is a monitor wait operation. @param methodName name of the method @param methodSig signature of the method @return true if the method is a monitor wait, false if not
[ "Determine", "if", "method", "whose", "name", "and", "signature", "is", "specified", "is", "a", "monitor", "wait", "operation", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L151-L153
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.isMonitorNotify
public static boolean isMonitorNotify(String methodName, String methodSig) { return ("notify".equals(methodName) || "notifyAll".equals(methodName)) && "()V".equals(methodSig); }
java
public static boolean isMonitorNotify(String methodName, String methodSig) { return ("notify".equals(methodName) || "notifyAll".equals(methodName)) && "()V".equals(methodSig); }
[ "public", "static", "boolean", "isMonitorNotify", "(", "String", "methodName", ",", "String", "methodSig", ")", "{", "return", "(", "\"notify\"", ".", "equals", "(", "methodName", ")", "||", "\"notifyAll\"", ".", "equals", "(", "methodName", ")", ")", "&&", ...
Determine if method whose name and signature is specified is a monitor notify operation. @param methodName name of the method @param methodSig signature of the method @return true if the method is a monitor notify, false if not
[ "Determine", "if", "method", "whose", "name", "and", "signature", "is", "specified", "is", "a", "monitor", "notify", "operation", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L190-L192
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.isMonitorNotify
public static boolean isMonitorNotify(Instruction ins, ConstantPoolGen cpg) { if (!(ins instanceof InvokeInstruction)) { return false; } if (ins.getOpcode() == Const.INVOKESTATIC) { return false; } InvokeInstruction inv = (InvokeInstruction) ins; String methodName = inv.getMethodName(cpg); String methodSig = inv.getSignature(cpg); return isMonitorNotify(methodName, methodSig); }
java
public static boolean isMonitorNotify(Instruction ins, ConstantPoolGen cpg) { if (!(ins instanceof InvokeInstruction)) { return false; } if (ins.getOpcode() == Const.INVOKESTATIC) { return false; } InvokeInstruction inv = (InvokeInstruction) ins; String methodName = inv.getMethodName(cpg); String methodSig = inv.getSignature(cpg); return isMonitorNotify(methodName, methodSig); }
[ "public", "static", "boolean", "isMonitorNotify", "(", "Instruction", "ins", ",", "ConstantPoolGen", "cpg", ")", "{", "if", "(", "!", "(", "ins", "instanceof", "InvokeInstruction", ")", ")", "{", "return", "false", ";", "}", "if", "(", "ins", ".", "getOpco...
Determine if given Instruction is a monitor wait. @param ins the Instruction @param cpg the ConstantPoolGen for the Instruction @return true if the instruction is a monitor wait, false if not
[ "Determine", "if", "given", "Instruction", "is", "a", "monitor", "wait", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L204-L217
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.visitSuperClassMethods
public static JavaClassAndMethod visitSuperClassMethods(JavaClassAndMethod method, JavaClassAndMethodChooser chooser) throws ClassNotFoundException { return findMethod(method.getJavaClass().getSuperClasses(), method.getMethod().getName(), method.getMethod() .getSignature(), chooser); }
java
public static JavaClassAndMethod visitSuperClassMethods(JavaClassAndMethod method, JavaClassAndMethodChooser chooser) throws ClassNotFoundException { return findMethod(method.getJavaClass().getSuperClasses(), method.getMethod().getName(), method.getMethod() .getSignature(), chooser); }
[ "public", "static", "JavaClassAndMethod", "visitSuperClassMethods", "(", "JavaClassAndMethod", "method", ",", "JavaClassAndMethodChooser", "chooser", ")", "throws", "ClassNotFoundException", "{", "return", "findMethod", "(", "method", ".", "getJavaClass", "(", ")", ".", ...
Visit all superclass methods which the given method overrides. @param method the method @param chooser chooser which visits each superclass method @return the chosen method, or null if no method is chosen @throws ClassNotFoundException
[ "Visit", "all", "superclass", "methods", "which", "the", "given", "method", "overrides", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L272-L276
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.visitSuperInterfaceMethods
public static JavaClassAndMethod visitSuperInterfaceMethods(JavaClassAndMethod method, JavaClassAndMethodChooser chooser) throws ClassNotFoundException { return findMethod(method.getJavaClass().getAllInterfaces(), method.getMethod().getName(), method.getMethod() .getSignature(), chooser); }
java
public static JavaClassAndMethod visitSuperInterfaceMethods(JavaClassAndMethod method, JavaClassAndMethodChooser chooser) throws ClassNotFoundException { return findMethod(method.getJavaClass().getAllInterfaces(), method.getMethod().getName(), method.getMethod() .getSignature(), chooser); }
[ "public", "static", "JavaClassAndMethod", "visitSuperInterfaceMethods", "(", "JavaClassAndMethod", "method", ",", "JavaClassAndMethodChooser", "chooser", ")", "throws", "ClassNotFoundException", "{", "return", "findMethod", "(", "method", ".", "getJavaClass", "(", ")", "....
Visit all superinterface methods which the given method implements. @param method the method @param chooser chooser which visits each superinterface method @return the chosen method, or null if no method is chosen @throws ClassNotFoundException
[ "Visit", "all", "superinterface", "methods", "which", "the", "given", "method", "implements", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L288-L292
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.resolveMethodCallTargets
public static Set<JavaClassAndMethod> resolveMethodCallTargets(ReferenceType receiverType, InvokeInstruction invokeInstruction, ConstantPoolGen cpg) throws ClassNotFoundException { return resolveMethodCallTargets(receiverType, invokeInstruction, cpg, false); }
java
public static Set<JavaClassAndMethod> resolveMethodCallTargets(ReferenceType receiverType, InvokeInstruction invokeInstruction, ConstantPoolGen cpg) throws ClassNotFoundException { return resolveMethodCallTargets(receiverType, invokeInstruction, cpg, false); }
[ "public", "static", "Set", "<", "JavaClassAndMethod", ">", "resolveMethodCallTargets", "(", "ReferenceType", "receiverType", ",", "InvokeInstruction", "invokeInstruction", ",", "ConstantPoolGen", "cpg", ")", "throws", "ClassNotFoundException", "{", "return", "resolveMethodC...
Resolve possible instance method call targets. Assumes that invokevirtual and invokeinterface methods may call any subtype of the receiver class. @param receiverType type of the receiver object @param invokeInstruction the InvokeInstruction @param cpg the ConstantPoolGen @return Set of methods which might be called @throws ClassNotFoundException
[ "Resolve", "possible", "instance", "method", "call", "targets", ".", "Assumes", "that", "invokevirtual", "and", "invokeinterface", "methods", "may", "call", "any", "subtype", "of", "the", "receiver", "class", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L774-L777
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.isConcrete
@Deprecated public static boolean isConcrete(XMethod xmethod) { int accessFlags = xmethod.getAccessFlags(); return (accessFlags & Const.ACC_ABSTRACT) == 0 && (accessFlags & Const.ACC_NATIVE) == 0; }
java
@Deprecated public static boolean isConcrete(XMethod xmethod) { int accessFlags = xmethod.getAccessFlags(); return (accessFlags & Const.ACC_ABSTRACT) == 0 && (accessFlags & Const.ACC_NATIVE) == 0; }
[ "@", "Deprecated", "public", "static", "boolean", "isConcrete", "(", "XMethod", "xmethod", ")", "{", "int", "accessFlags", "=", "xmethod", ".", "getAccessFlags", "(", ")", ";", "return", "(", "accessFlags", "&", "Const", ".", "ACC_ABSTRACT", ")", "==", "0", ...
Return whether or not the given method is concrete. @param xmethod the method @return true if the method is concrete, false otherwise
[ "Return", "whether", "or", "not", "the", "given", "method", "is", "concrete", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L875-L879
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.findField
public static Field findField(String className, String fieldName) throws ClassNotFoundException { JavaClass jclass = Repository.lookupClass(className); while (jclass != null) { Field[] fieldList = jclass.getFields(); for (Field field : fieldList) { if (field.getName().equals(fieldName)) { return field; } } jclass = jclass.getSuperClass(); } return null; }
java
public static Field findField(String className, String fieldName) throws ClassNotFoundException { JavaClass jclass = Repository.lookupClass(className); while (jclass != null) { Field[] fieldList = jclass.getFields(); for (Field field : fieldList) { if (field.getName().equals(fieldName)) { return field; } } jclass = jclass.getSuperClass(); } return null; }
[ "public", "static", "Field", "findField", "(", "String", "className", ",", "String", "fieldName", ")", "throws", "ClassNotFoundException", "{", "JavaClass", "jclass", "=", "Repository", ".", "lookupClass", "(", "className", ")", ";", "while", "(", "jclass", "!="...
Find a field with given name defined in given class. @param className the name of the class @param fieldName the name of the field @return the Field, or null if no such field could be found
[ "Find", "a", "field", "with", "given", "name", "defined", "in", "given", "class", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L890-L905
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.isInnerClassAccess
public static boolean isInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) { String methodName = inv.getName(cpg); return methodName.startsWith("access$"); }
java
public static boolean isInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) { String methodName = inv.getName(cpg); return methodName.startsWith("access$"); }
[ "public", "static", "boolean", "isInnerClassAccess", "(", "INVOKESTATIC", "inv", ",", "ConstantPoolGen", "cpg", ")", "{", "String", "methodName", "=", "inv", ".", "getName", "(", "cpg", ")", ";", "return", "methodName", ".", "startsWith", "(", "\"access$\"", "...
Determine whether the given INVOKESTATIC instruction is an inner-class field accessor method. @param inv the INVOKESTATIC instruction @param cpg the ConstantPoolGen for the method @return true if the instruction is an inner-class field accessor, false if not
[ "Determine", "whether", "the", "given", "INVOKESTATIC", "instruction", "is", "an", "inner", "-", "class", "field", "accessor", "method", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L970-L973
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
Hierarchy.getInnerClassAccess
public static InnerClassAccess getInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) throws ClassNotFoundException { String className = inv.getClassName(cpg); String methodName = inv.getName(cpg); String methodSig = inv.getSignature(cpg); InnerClassAccess access = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap() .getInnerClassAccess(className, methodName); return (access != null && access.getMethodSignature().equals(methodSig)) ? access : null; }
java
public static InnerClassAccess getInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) throws ClassNotFoundException { String className = inv.getClassName(cpg); String methodName = inv.getName(cpg); String methodSig = inv.getSignature(cpg); InnerClassAccess access = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap() .getInnerClassAccess(className, methodName); return (access != null && access.getMethodSignature().equals(methodSig)) ? access : null; }
[ "public", "static", "InnerClassAccess", "getInnerClassAccess", "(", "INVOKESTATIC", "inv", ",", "ConstantPoolGen", "cpg", ")", "throws", "ClassNotFoundException", "{", "String", "className", "=", "inv", ".", "getClassName", "(", "cpg", ")", ";", "String", "methodNam...
Get the InnerClassAccess for access method called by given INVOKESTATIC. @param inv the INVOKESTATIC instruction @param cpg the ConstantPoolGen for the method @return the InnerClassAccess, or null if the instruction is not an inner-class access
[ "Get", "the", "InnerClassAccess", "for", "access", "method", "called", "by", "given", "INVOKESTATIC", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L985-L994
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/SortedProperties.java
SortedProperties.keys
@SuppressWarnings("unchecked") @Override public synchronized Enumeration<Object> keys() { // sort elements based on detector (prop key) names Set<?> set = keySet(); return (Enumeration<Object>) sortKeys((Set<String>) set); }
java
@SuppressWarnings("unchecked") @Override public synchronized Enumeration<Object> keys() { // sort elements based on detector (prop key) names Set<?> set = keySet(); return (Enumeration<Object>) sortKeys((Set<String>) set); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "synchronized", "Enumeration", "<", "Object", ">", "keys", "(", ")", "{", "// sort elements based on detector (prop key) names", "Set", "<", "?", ">", "set", "=", "keySet", "(", ")", ...
Overriden to be able to write properties sorted by keys to the disk @see java.util.Hashtable#keys()
[ "Overriden", "to", "be", "able", "to", "write", "properties", "sorted", "by", "keys", "to", "the", "disk" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/SortedProperties.java#L19-L25
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java
FindBugsWorker.loadXml
public void loadXml(String fileName) throws CoreException { if (fileName == null) { return; } st = new StopTimer(); // clear markers clearMarkers(null); final Project findBugsProject = new Project(); final Reporter bugReporter = new Reporter(javaProject, findBugsProject, monitor); bugReporter.setPriorityThreshold(userPrefs.getUserDetectorThreshold()); reportFromXml(fileName, findBugsProject, bugReporter); // Merge new results into existing results. updateBugCollection(findBugsProject, bugReporter, false); monitor.done(); }
java
public void loadXml(String fileName) throws CoreException { if (fileName == null) { return; } st = new StopTimer(); // clear markers clearMarkers(null); final Project findBugsProject = new Project(); final Reporter bugReporter = new Reporter(javaProject, findBugsProject, monitor); bugReporter.setPriorityThreshold(userPrefs.getUserDetectorThreshold()); reportFromXml(fileName, findBugsProject, bugReporter); // Merge new results into existing results. updateBugCollection(findBugsProject, bugReporter, false); monitor.done(); }
[ "public", "void", "loadXml", "(", "String", "fileName", ")", "throws", "CoreException", "{", "if", "(", "fileName", "==", "null", ")", "{", "return", ";", "}", "st", "=", "new", "StopTimer", "(", ")", ";", "// clear markers", "clearMarkers", "(", "null", ...
Load existing FindBugs xml report for the given collection of files. @param fileName xml file name to load bugs from @throws CoreException
[ "Load", "existing", "FindBugs", "xml", "report", "for", "the", "given", "collection", "of", "files", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java#L247-L264
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java
FindBugsWorker.clearMarkers
private void clearMarkers(List<WorkItem> files) throws CoreException { if (files == null) { project.deleteMarkers(FindBugsMarker.NAME, true, IResource.DEPTH_INFINITE); return; } for (WorkItem item : files) { if (item != null) { item.clearMarkers(); } } }
java
private void clearMarkers(List<WorkItem> files) throws CoreException { if (files == null) { project.deleteMarkers(FindBugsMarker.NAME, true, IResource.DEPTH_INFINITE); return; } for (WorkItem item : files) { if (item != null) { item.clearMarkers(); } } }
[ "private", "void", "clearMarkers", "(", "List", "<", "WorkItem", ">", "files", ")", "throws", "CoreException", "{", "if", "(", "files", "==", "null", ")", "{", "project", ".", "deleteMarkers", "(", "FindBugsMarker", ".", "NAME", ",", "true", ",", "IResourc...
Clear associated markers @param files
[ "Clear", "associated", "markers" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java#L271-L281
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java
FindBugsWorker.collectClassFiles
private void collectClassFiles(List<WorkItem> resources, Map<IPath, IPath> outLocations, Project fbProject) { for (WorkItem workItem : resources) { workItem.addFilesToProject(fbProject, outLocations); } }
java
private void collectClassFiles(List<WorkItem> resources, Map<IPath, IPath> outLocations, Project fbProject) { for (WorkItem workItem : resources) { workItem.addFilesToProject(fbProject, outLocations); } }
[ "private", "void", "collectClassFiles", "(", "List", "<", "WorkItem", ">", "resources", ",", "Map", "<", "IPath", ",", "IPath", ">", "outLocations", ",", "Project", "fbProject", ")", "{", "for", "(", "WorkItem", "workItem", ":", "resources", ")", "{", "wor...
Updates given outputFiles map with class name patterns matching given java source names @param resources java sources @param outLocations key is src root, value is output location this directory @param fbProject
[ "Updates", "given", "outputFiles", "map", "with", "class", "name", "patterns", "matching", "given", "java", "source", "names" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java#L293-L297
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java
FindBugsWorker.runFindBugs
private void runFindBugs(final FindBugs2 findBugs) { if (DEBUG) { FindbugsPlugin.log("Running findbugs in thread " + Thread.currentThread().getName()); } System.setProperty("findbugs.progress", "true"); try { // Perform the analysis! (note: This is not thread-safe) findBugs.execute(); } catch (InterruptedException e) { if (DEBUG) { FindbugsPlugin.getDefault().logException(e, "Worker interrupted"); } Thread.currentThread().interrupt(); } catch (IOException e) { FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs analysis"); } finally { findBugs.dispose(); } }
java
private void runFindBugs(final FindBugs2 findBugs) { if (DEBUG) { FindbugsPlugin.log("Running findbugs in thread " + Thread.currentThread().getName()); } System.setProperty("findbugs.progress", "true"); try { // Perform the analysis! (note: This is not thread-safe) findBugs.execute(); } catch (InterruptedException e) { if (DEBUG) { FindbugsPlugin.getDefault().logException(e, "Worker interrupted"); } Thread.currentThread().interrupt(); } catch (IOException e) { FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs analysis"); } finally { findBugs.dispose(); } }
[ "private", "void", "runFindBugs", "(", "final", "FindBugs2", "findBugs", ")", "{", "if", "(", "DEBUG", ")", "{", "FindbugsPlugin", ".", "log", "(", "\"Running findbugs in thread \"", "+", "Thread", ".", "currentThread", "(", ")", ".", "getName", "(", ")", ")...
this method will block current thread until the findbugs is running @param findBugs fb engine, which will be <b>disposed</b> after the analysis is done
[ "this", "method", "will", "block", "current", "thread", "until", "the", "findbugs", "is", "running" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java#L306-L325
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java
FindBugsWorker.updateBugCollection
private void updateBugCollection(Project findBugsProject, Reporter bugReporter, boolean incremental) { SortedBugCollection newBugCollection = bugReporter.getBugCollection(); try { st.newPoint("getBugCollection"); SortedBugCollection oldBugCollection = FindbugsPlugin.getBugCollection(project, monitor); st.newPoint("mergeBugCollections"); SortedBugCollection resultCollection = mergeBugCollections(oldBugCollection, newBugCollection, incremental); resultCollection.getProject().setGuiCallback(new EclipseGuiCallback(project)); resultCollection.setTimestamp(System.currentTimeMillis()); // will store bugs in the default FB file + Eclipse project session // props st.newPoint("storeBugCollection"); FindbugsPlugin.storeBugCollection(project, resultCollection, monitor); } catch (IOException e) { FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs results update"); } catch (CoreException e) { FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs results update"); } // will store bugs as markers in Eclipse workspace st.newPoint("createMarkers"); MarkerUtil.createMarkers(javaProject, newBugCollection, resource, monitor); }
java
private void updateBugCollection(Project findBugsProject, Reporter bugReporter, boolean incremental) { SortedBugCollection newBugCollection = bugReporter.getBugCollection(); try { st.newPoint("getBugCollection"); SortedBugCollection oldBugCollection = FindbugsPlugin.getBugCollection(project, monitor); st.newPoint("mergeBugCollections"); SortedBugCollection resultCollection = mergeBugCollections(oldBugCollection, newBugCollection, incremental); resultCollection.getProject().setGuiCallback(new EclipseGuiCallback(project)); resultCollection.setTimestamp(System.currentTimeMillis()); // will store bugs in the default FB file + Eclipse project session // props st.newPoint("storeBugCollection"); FindbugsPlugin.storeBugCollection(project, resultCollection, monitor); } catch (IOException e) { FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs results update"); } catch (CoreException e) { FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs results update"); } // will store bugs as markers in Eclipse workspace st.newPoint("createMarkers"); MarkerUtil.createMarkers(javaProject, newBugCollection, resource, monitor); }
[ "private", "void", "updateBugCollection", "(", "Project", "findBugsProject", ",", "Reporter", "bugReporter", ",", "boolean", "incremental", ")", "{", "SortedBugCollection", "newBugCollection", "=", "bugReporter", ".", "getBugCollection", "(", ")", ";", "try", "{", "...
Update the BugCollection for the project. @param findBugsProject FindBugs project representing analyzed classes @param bugReporter Reporter used to collect the new warnings
[ "Update", "the", "BugCollection", "for", "the", "project", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java#L334-L358
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java
FindBugsWorker.getFilterPath
public static IPath getFilterPath(String filePath, IProject project) { IPath path = new Path(filePath); if (path.isAbsolute()) { return path; } if (project != null) { // try first project relative location IPath newPath = project.getLocation().append(path); if (newPath.toFile().exists()) { return newPath; } } // try to resolve relative to workspace (if we use workspace properties // for project) IPath wspLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation(); IPath newPath = wspLocation.append(path); if (newPath.toFile().exists()) { return newPath; } // something which we have no idea what it can be (or missing/wrong file // path) return path; }
java
public static IPath getFilterPath(String filePath, IProject project) { IPath path = new Path(filePath); if (path.isAbsolute()) { return path; } if (project != null) { // try first project relative location IPath newPath = project.getLocation().append(path); if (newPath.toFile().exists()) { return newPath; } } // try to resolve relative to workspace (if we use workspace properties // for project) IPath wspLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation(); IPath newPath = wspLocation.append(path); if (newPath.toFile().exists()) { return newPath; } // something which we have no idea what it can be (or missing/wrong file // path) return path; }
[ "public", "static", "IPath", "getFilterPath", "(", "String", "filePath", ",", "IProject", "project", ")", "{", "IPath", "path", "=", "new", "Path", "(", "filePath", ")", ";", "if", "(", "path", ".", "isAbsolute", "(", ")", ")", "{", "return", "path", "...
Checks the given path and convert it to absolute path if it is specified relative to the given project or workspace @param filePath project relative OR workspace relative OR absolute OS file path (1.3.8+ version) @param project might be null (only for workspace relative or absolute paths) @return absolute path which matches given relative or absolute path, never null
[ "Checks", "the", "given", "path", "and", "convert", "it", "to", "absolute", "path", "if", "it", "is", "specified", "relative", "to", "the", "given", "project", "or", "workspace" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java#L403-L427
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java
FindBugsWorker.toFilterPath
public static IPath toFilterPath(String filePath, IProject project) { IPath path = new Path(filePath); IPath commonPath; if (project != null) { commonPath = project.getLocation(); IPath relativePath = getRelativePath(path, commonPath); if (!relativePath.equals(path)) { return relativePath; } } commonPath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); return getRelativePath(path, commonPath); }
java
public static IPath toFilterPath(String filePath, IProject project) { IPath path = new Path(filePath); IPath commonPath; if (project != null) { commonPath = project.getLocation(); IPath relativePath = getRelativePath(path, commonPath); if (!relativePath.equals(path)) { return relativePath; } } commonPath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); return getRelativePath(path, commonPath); }
[ "public", "static", "IPath", "toFilterPath", "(", "String", "filePath", ",", "IProject", "project", ")", "{", "IPath", "path", "=", "new", "Path", "(", "filePath", ")", ";", "IPath", "commonPath", ";", "if", "(", "project", "!=", "null", ")", "{", "commo...
Checks the given absolute path and convert it to relative path if it is relative to the given project or workspace. This representation can be used to store filter paths in user preferences file @param filePath absolute OS file path @param project might be null @return filter file path as stored in preferences which matches given path
[ "Checks", "the", "given", "absolute", "path", "and", "convert", "it", "to", "relative", "path", "if", "it", "is", "relative", "to", "the", "given", "project", "or", "workspace", ".", "This", "representation", "can", "be", "used", "to", "store", "filter", "...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java#L441-L453
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java
ProjectFilterSettings.fromEncodedString
public static ProjectFilterSettings fromEncodedString(String s) { ProjectFilterSettings result = new ProjectFilterSettings(); if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String minPriority; if (bar >= 0) { minPriority = s.substring(0, bar); s = s.substring(bar + 1); } else { minPriority = s; s = ""; } if (priorityNameToValueMap.get(minPriority) == null) { minPriority = DEFAULT_PRIORITY; } result.setMinPriority(minPriority); } if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String categories; if (bar >= 0) { categories = s.substring(0, bar); s = s.substring(bar + 1); } else { categories = s; s = ""; } StringTokenizer t = new StringTokenizer(categories, LISTITEM_DELIMITER); while (t.hasMoreTokens()) { String category = t.nextToken(); // 'result' probably already contains 'category', since // it contains all known bug category keys by default. // But add it to the set anyway in case it is an unknown key. result.addCategory(category); } } if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String displayFalseWarnings; if (bar >= 0) { displayFalseWarnings = s.substring(0, bar); s = s.substring(bar + 1); } else { displayFalseWarnings = s; s = ""; } result.setDisplayFalseWarnings(Boolean.valueOf(displayFalseWarnings).booleanValue()); } if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String minRankStr; if (bar >= 0) { minRankStr = s.substring(0, bar); // s = s.substring(bar + 1); } else { minRankStr = s; // s = ""; } result.setMinRank(Integer.parseInt(minRankStr)); } // if (s.length() > 0) { // // Can add other fields here... // assert true; // } return result; }
java
public static ProjectFilterSettings fromEncodedString(String s) { ProjectFilterSettings result = new ProjectFilterSettings(); if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String minPriority; if (bar >= 0) { minPriority = s.substring(0, bar); s = s.substring(bar + 1); } else { minPriority = s; s = ""; } if (priorityNameToValueMap.get(minPriority) == null) { minPriority = DEFAULT_PRIORITY; } result.setMinPriority(minPriority); } if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String categories; if (bar >= 0) { categories = s.substring(0, bar); s = s.substring(bar + 1); } else { categories = s; s = ""; } StringTokenizer t = new StringTokenizer(categories, LISTITEM_DELIMITER); while (t.hasMoreTokens()) { String category = t.nextToken(); // 'result' probably already contains 'category', since // it contains all known bug category keys by default. // But add it to the set anyway in case it is an unknown key. result.addCategory(category); } } if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String displayFalseWarnings; if (bar >= 0) { displayFalseWarnings = s.substring(0, bar); s = s.substring(bar + 1); } else { displayFalseWarnings = s; s = ""; } result.setDisplayFalseWarnings(Boolean.valueOf(displayFalseWarnings).booleanValue()); } if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String minRankStr; if (bar >= 0) { minRankStr = s.substring(0, bar); // s = s.substring(bar + 1); } else { minRankStr = s; // s = ""; } result.setMinRank(Integer.parseInt(minRankStr)); } // if (s.length() > 0) { // // Can add other fields here... // assert true; // } return result; }
[ "public", "static", "ProjectFilterSettings", "fromEncodedString", "(", "String", "s", ")", "{", "ProjectFilterSettings", "result", "=", "new", "ProjectFilterSettings", "(", ")", ";", "if", "(", "s", ".", "length", "(", ")", ">", "0", ")", "{", "int", "bar", ...
Create ProjectFilterSettings from an encoded string. @param s the encoded string @return the ProjectFilterSettings
[ "Create", "ProjectFilterSettings", "from", "an", "encoded", "string", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java#L151-L223
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java
ProjectFilterSettings.hiddenFromEncodedString
public static void hiddenFromEncodedString(ProjectFilterSettings result, String s) { if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String categories; if (bar >= 0) { categories = s.substring(0, bar); } else { categories = s; } StringTokenizer t = new StringTokenizer(categories, LISTITEM_DELIMITER); while (t.hasMoreTokens()) { String category = t.nextToken(); result.removeCategory(category); } } }
java
public static void hiddenFromEncodedString(ProjectFilterSettings result, String s) { if (s.length() > 0) { int bar = s.indexOf(FIELD_DELIMITER); String categories; if (bar >= 0) { categories = s.substring(0, bar); } else { categories = s; } StringTokenizer t = new StringTokenizer(categories, LISTITEM_DELIMITER); while (t.hasMoreTokens()) { String category = t.nextToken(); result.removeCategory(category); } } }
[ "public", "static", "void", "hiddenFromEncodedString", "(", "ProjectFilterSettings", "result", ",", "String", "s", ")", "{", "if", "(", "s", ".", "length", "(", ")", ">", "0", ")", "{", "int", "bar", "=", "s", ".", "indexOf", "(", "FIELD_DELIMITER", ")",...
set the hidden bug categories on the specifed ProjectFilterSettings from an encoded string @param result the ProjectFilterSettings from which to remove bug categories @param s the encoded string @see ProjectFilterSettings#hiddenFromEncodedString(ProjectFilterSettings, String)
[ "set", "the", "hidden", "bug", "categories", "on", "the", "specifed", "ProjectFilterSettings", "from", "an", "encoded", "string" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java#L236-L253
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java
ProjectFilterSettings.displayWarning
public boolean displayWarning(BugInstance bugInstance) { int priority = bugInstance.getPriority(); if (priority > getMinPriorityAsInt()) { return false; } int rank = bugInstance.getBugRank(); if (rank > getMinRank()) { return false; } BugPattern bugPattern = bugInstance.getBugPattern(); // HACK: it is conceivable that the detector plugin which generated // this warning is not available any more, in which case we can't // find out the category. Let the warning be visible in this case. if (!containsCategory(bugPattern.getCategory())) { return false; } if (!displayFalseWarnings) { boolean isFalseWarning = !Boolean.valueOf(bugInstance.getProperty(BugProperty.IS_BUG, "true")).booleanValue(); if (isFalseWarning) { return false; } } return true; }
java
public boolean displayWarning(BugInstance bugInstance) { int priority = bugInstance.getPriority(); if (priority > getMinPriorityAsInt()) { return false; } int rank = bugInstance.getBugRank(); if (rank > getMinRank()) { return false; } BugPattern bugPattern = bugInstance.getBugPattern(); // HACK: it is conceivable that the detector plugin which generated // this warning is not available any more, in which case we can't // find out the category. Let the warning be visible in this case. if (!containsCategory(bugPattern.getCategory())) { return false; } if (!displayFalseWarnings) { boolean isFalseWarning = !Boolean.valueOf(bugInstance.getProperty(BugProperty.IS_BUG, "true")).booleanValue(); if (isFalseWarning) { return false; } } return true; }
[ "public", "boolean", "displayWarning", "(", "BugInstance", "bugInstance", ")", "{", "int", "priority", "=", "bugInstance", ".", "getPriority", "(", ")", ";", "if", "(", "priority", ">", "getMinPriorityAsInt", "(", ")", ")", "{", "return", "false", ";", "}", ...
Return whether or not a warning should be displayed, according to the project filter settings. @param bugInstance the warning @return true if the warning should be displayed, false if not
[ "Return", "whether", "or", "not", "a", "warning", "should", "be", "displayed", "according", "to", "the", "project", "filter", "settings", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java#L263-L292
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java
ProjectFilterSettings.setMinPriority
public void setMinPriority(String minPriority) { this.minPriority = minPriority; Integer value = priorityNameToValueMap.get(minPriority); if (value == null) { value = priorityNameToValueMap.get(DEFAULT_PRIORITY); if (value == null) { throw new IllegalStateException(); } } this.minPriorityAsInt = value.intValue(); }
java
public void setMinPriority(String minPriority) { this.minPriority = minPriority; Integer value = priorityNameToValueMap.get(minPriority); if (value == null) { value = priorityNameToValueMap.get(DEFAULT_PRIORITY); if (value == null) { throw new IllegalStateException(); } } this.minPriorityAsInt = value.intValue(); }
[ "public", "void", "setMinPriority", "(", "String", "minPriority", ")", "{", "this", ".", "minPriority", "=", "minPriority", ";", "Integer", "value", "=", "priorityNameToValueMap", ".", "get", "(", "minPriority", ")", ";", "if", "(", "value", "==", "null", ")...
Set minimum warning priority threshold. @param minPriority the priority threshold: one of "High", "Medium", or "Low"
[ "Set", "minimum", "warning", "priority", "threshold", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java#L300-L313
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java
ProjectFilterSettings.hiddenToEncodedString
public String hiddenToEncodedString() { StringBuilder buf = new StringBuilder(); // Encode hidden bug categories for (Iterator<String> i = hiddenBugCategorySet.iterator(); i.hasNext();) { buf.append(i.next()); if (i.hasNext()) { buf.append(LISTITEM_DELIMITER); } } buf.append(FIELD_DELIMITER); return buf.toString(); }
java
public String hiddenToEncodedString() { StringBuilder buf = new StringBuilder(); // Encode hidden bug categories for (Iterator<String> i = hiddenBugCategorySet.iterator(); i.hasNext();) { buf.append(i.next()); if (i.hasNext()) { buf.append(LISTITEM_DELIMITER); } } buf.append(FIELD_DELIMITER); return buf.toString(); }
[ "public", "String", "hiddenToEncodedString", "(", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "// Encode hidden bug categories", "for", "(", "Iterator", "<", "String", ">", "i", "=", "hiddenBugCategorySet", ".", "iterator", "(", ...
Create a string containing the encoded form of the hidden bug categories @return an encoded string
[ "Create", "a", "string", "containing", "the", "encoded", "form", "of", "the", "hidden", "bug", "categories" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java#L416-L428
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java
ProjectFilterSettings.toEncodedString
public String toEncodedString() { // Priority threshold StringBuilder buf = new StringBuilder(); buf.append(getMinPriority()); // Encode enabled bug categories. Note that these aren't really used for // much. // They only come in to play when parsed by a version of FindBugs older // than 1.1. buf.append(FIELD_DELIMITER); for (Iterator<String> i = activeBugCategorySet.iterator(); i.hasNext();) { buf.append(i.next()); if (i.hasNext()) { buf.append(LISTITEM_DELIMITER); } } // Whether to display false warnings buf.append(FIELD_DELIMITER); buf.append(displayFalseWarnings ? "true" : "false"); buf.append(FIELD_DELIMITER); buf.append(getMinRank()); return buf.toString(); }
java
public String toEncodedString() { // Priority threshold StringBuilder buf = new StringBuilder(); buf.append(getMinPriority()); // Encode enabled bug categories. Note that these aren't really used for // much. // They only come in to play when parsed by a version of FindBugs older // than 1.1. buf.append(FIELD_DELIMITER); for (Iterator<String> i = activeBugCategorySet.iterator(); i.hasNext();) { buf.append(i.next()); if (i.hasNext()) { buf.append(LISTITEM_DELIMITER); } } // Whether to display false warnings buf.append(FIELD_DELIMITER); buf.append(displayFalseWarnings ? "true" : "false"); buf.append(FIELD_DELIMITER); buf.append(getMinRank()); return buf.toString(); }
[ "public", "String", "toEncodedString", "(", ")", "{", "// Priority threshold", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "buf", ".", "append", "(", "getMinPriority", "(", ")", ")", ";", "// Encode enabled bug categories. Note that these aren'...
Create a string containing the encoded form of the ProjectFilterSettings. @return an encoded string
[ "Create", "a", "string", "containing", "the", "encoded", "form", "of", "the", "ProjectFilterSettings", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java#L435-L461
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java
ProjectFilterSettings.getIntPriorityAsString
public static String getIntPriorityAsString(int prio) { String minPriority; switch (prio) { case Priorities.EXP_PRIORITY: minPriority = ProjectFilterSettings.EXPERIMENTAL_PRIORITY; break; case Priorities.LOW_PRIORITY: minPriority = ProjectFilterSettings.LOW_PRIORITY; break; case Priorities.NORMAL_PRIORITY: minPriority = ProjectFilterSettings.MEDIUM_PRIORITY; break; case Priorities.HIGH_PRIORITY: minPriority = ProjectFilterSettings.HIGH_PRIORITY; break; default: minPriority = ProjectFilterSettings.DEFAULT_PRIORITY; break; } return minPriority; }
java
public static String getIntPriorityAsString(int prio) { String minPriority; switch (prio) { case Priorities.EXP_PRIORITY: minPriority = ProjectFilterSettings.EXPERIMENTAL_PRIORITY; break; case Priorities.LOW_PRIORITY: minPriority = ProjectFilterSettings.LOW_PRIORITY; break; case Priorities.NORMAL_PRIORITY: minPriority = ProjectFilterSettings.MEDIUM_PRIORITY; break; case Priorities.HIGH_PRIORITY: minPriority = ProjectFilterSettings.HIGH_PRIORITY; break; default: minPriority = ProjectFilterSettings.DEFAULT_PRIORITY; break; } return minPriority; }
[ "public", "static", "String", "getIntPriorityAsString", "(", "int", "prio", ")", "{", "String", "minPriority", ";", "switch", "(", "prio", ")", "{", "case", "Priorities", ".", "EXP_PRIORITY", ":", "minPriority", "=", "ProjectFilterSettings", ".", "EXPERIMENTAL_PRI...
Convert an integer warning priority threshold value to a String.
[ "Convert", "an", "integer", "warning", "priority", "threshold", "value", "to", "a", "String", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java#L529-L549
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/graph/Transpose.java
Transpose.transpose
public GraphType transpose(GraphType orig, GraphToolkit<GraphType, EdgeType, VertexType> toolkit) { GraphType trans = toolkit.createGraph(); // For each vertex in original graph, create an equivalent // vertex in the transposed graph, // ensuring that vertex labels in the transposed graph // match vertex labels in the original graph for (Iterator<VertexType> i = orig.vertexIterator(); i.hasNext();) { VertexType v = i.next(); // Make a duplicate of original vertex // (Ensuring that transposed graph has same labeling as original) VertexType dupVertex = toolkit.duplicateVertex(v); dupVertex.setLabel(v.getLabel()); trans.addVertex(v); // Keep track of correspondence between equivalent vertices m_origToTransposeMap.put(v, dupVertex); m_transposeToOrigMap.put(dupVertex, v); } trans.setNumVertexLabels(orig.getNumVertexLabels()); // For each edge in the original graph, create a reversed edge // in the transposed graph for (Iterator<EdgeType> i = orig.edgeIterator(); i.hasNext();) { EdgeType e = i.next(); VertexType transSource = m_origToTransposeMap.get(e.getTarget()); VertexType transTarget = m_origToTransposeMap.get(e.getSource()); EdgeType dupEdge = trans.createEdge(transSource, transTarget); dupEdge.setLabel(e.getLabel()); // Copy auxiliary information for edge toolkit.copyEdge(e, dupEdge); } trans.setNumEdgeLabels(orig.getNumEdgeLabels()); return trans; }
java
public GraphType transpose(GraphType orig, GraphToolkit<GraphType, EdgeType, VertexType> toolkit) { GraphType trans = toolkit.createGraph(); // For each vertex in original graph, create an equivalent // vertex in the transposed graph, // ensuring that vertex labels in the transposed graph // match vertex labels in the original graph for (Iterator<VertexType> i = orig.vertexIterator(); i.hasNext();) { VertexType v = i.next(); // Make a duplicate of original vertex // (Ensuring that transposed graph has same labeling as original) VertexType dupVertex = toolkit.duplicateVertex(v); dupVertex.setLabel(v.getLabel()); trans.addVertex(v); // Keep track of correspondence between equivalent vertices m_origToTransposeMap.put(v, dupVertex); m_transposeToOrigMap.put(dupVertex, v); } trans.setNumVertexLabels(orig.getNumVertexLabels()); // For each edge in the original graph, create a reversed edge // in the transposed graph for (Iterator<EdgeType> i = orig.edgeIterator(); i.hasNext();) { EdgeType e = i.next(); VertexType transSource = m_origToTransposeMap.get(e.getTarget()); VertexType transTarget = m_origToTransposeMap.get(e.getSource()); EdgeType dupEdge = trans.createEdge(transSource, transTarget); dupEdge.setLabel(e.getLabel()); // Copy auxiliary information for edge toolkit.copyEdge(e, dupEdge); } trans.setNumEdgeLabels(orig.getNumEdgeLabels()); return trans; }
[ "public", "GraphType", "transpose", "(", "GraphType", "orig", ",", "GraphToolkit", "<", "GraphType", ",", "EdgeType", ",", "VertexType", ">", "toolkit", ")", "{", "GraphType", "trans", "=", "toolkit", ".", "createGraph", "(", ")", ";", "// For each vertex in ori...
Transpose a graph. Note that the original graph is not modified; the new graph and its vertices and edges are new objects. @param orig the graph to transpose @param toolkit a GraphToolkit to be used to create the transposed Graph @return the transposed Graph
[ "Transpose", "a", "graph", ".", "Note", "that", "the", "original", "graph", "is", "not", "modified", ";", "the", "new", "graph", "and", "its", "vertices", "and", "edges", "are", "new", "objects", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/graph/Transpose.java#L54-L95
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/vna/MergeTree.java
MergeTree.mapInputToOutput
public void mapInputToOutput(ValueNumber input, ValueNumber output) { BitSet inputSet = getInputSet(output); inputSet.set(input.getNumber()); if (DEBUG) { System.out.println(input.getNumber() + "->" + output.getNumber()); System.out.println("Input set for " + output.getNumber() + " is now " + inputSet); } }
java
public void mapInputToOutput(ValueNumber input, ValueNumber output) { BitSet inputSet = getInputSet(output); inputSet.set(input.getNumber()); if (DEBUG) { System.out.println(input.getNumber() + "->" + output.getNumber()); System.out.println("Input set for " + output.getNumber() + " is now " + inputSet); } }
[ "public", "void", "mapInputToOutput", "(", "ValueNumber", "input", ",", "ValueNumber", "output", ")", "{", "BitSet", "inputSet", "=", "getInputSet", "(", "output", ")", ";", "inputSet", ".", "set", "(", "input", ".", "getNumber", "(", ")", ")", ";", "if", ...
Map an input ValueNumber to an output ValueNumber. @param input the input ValueNumber @param output the output ValueNumber
[ "Map", "an", "input", "ValueNumber", "to", "an", "output", "ValueNumber", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/vna/MergeTree.java#L62-L69
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/vna/MergeTree.java
MergeTree.getInputSet
public BitSet getInputSet(ValueNumber output) { BitSet outputSet = outputToInputMap.get(output); if (outputSet == null) { if (DEBUG) { System.out.println("Create new input set for " + output.getNumber()); } outputSet = new BitSet(); outputToInputMap.put(output, outputSet); } return outputSet; }
java
public BitSet getInputSet(ValueNumber output) { BitSet outputSet = outputToInputMap.get(output); if (outputSet == null) { if (DEBUG) { System.out.println("Create new input set for " + output.getNumber()); } outputSet = new BitSet(); outputToInputMap.put(output, outputSet); } return outputSet; }
[ "public", "BitSet", "getInputSet", "(", "ValueNumber", "output", ")", "{", "BitSet", "outputSet", "=", "outputToInputMap", ".", "get", "(", "output", ")", ";", "if", "(", "outputSet", "==", "null", ")", "{", "if", "(", "DEBUG", ")", "{", "System", ".", ...
Get the set of input ValueNumbers which directly contributed to the given output ValueNumber. @param output the output ValueNumber @return the set of direct input ValueNumbers
[ "Get", "the", "set", "of", "input", "ValueNumbers", "which", "directly", "contributed", "to", "the", "given", "output", "ValueNumber", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/vna/MergeTree.java#L79-L89
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/Naming.java
Naming.mightInheritFromException
private static boolean mightInheritFromException(ClassDescriptor d) { while (d != null) { try { if ("java.lang.Exception".equals(d.getDottedClassName())) { return true; } XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, d); d = classNameAndInfo.getSuperclassDescriptor(); } catch (CheckedAnalysisException e) { return true; // don't know } } return false; }
java
private static boolean mightInheritFromException(ClassDescriptor d) { while (d != null) { try { if ("java.lang.Exception".equals(d.getDottedClassName())) { return true; } XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, d); d = classNameAndInfo.getSuperclassDescriptor(); } catch (CheckedAnalysisException e) { return true; // don't know } } return false; }
[ "private", "static", "boolean", "mightInheritFromException", "(", "ClassDescriptor", "d", ")", "{", "while", "(", "d", "!=", "null", ")", "{", "try", "{", "if", "(", "\"java.lang.Exception\"", ".", "equals", "(", "d", ".", "getDottedClassName", "(", ")", ")"...
Determine whether the class descriptor ultimately inherits from java.lang.Exception @param d class descriptor we want to check @return true iff the descriptor ultimately inherits from Exception
[ "Determine", "whether", "the", "class", "descriptor", "ultimately", "inherits", "from", "java", ".", "lang", ".", "Exception" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/Naming.java#L341-L354
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/LaunchAppropriateUI.java
LaunchAppropriateUI.launch
public void launch() throws Exception { // Sanity-check the loaded BCEL classes if (!CheckBcel.check()) { System.exit(1); } int launchProperty = getLaunchProperty(); if (GraphicsEnvironment.isHeadless() || launchProperty == TEXTUI) { FindBugs2.main(args); } else if (launchProperty == SHOW_HELP) { ShowHelp.main(args); } else if (launchProperty == SHOW_VERSION) { Version.main(new String[] { "-release" }); } else { Class<?> launchClass = Class.forName("edu.umd.cs.findbugs.gui2.Driver"); Method mainMethod = launchClass.getMethod("main", args.getClass()); mainMethod.invoke(null, (Object) args); } }
java
public void launch() throws Exception { // Sanity-check the loaded BCEL classes if (!CheckBcel.check()) { System.exit(1); } int launchProperty = getLaunchProperty(); if (GraphicsEnvironment.isHeadless() || launchProperty == TEXTUI) { FindBugs2.main(args); } else if (launchProperty == SHOW_HELP) { ShowHelp.main(args); } else if (launchProperty == SHOW_VERSION) { Version.main(new String[] { "-release" }); } else { Class<?> launchClass = Class.forName("edu.umd.cs.findbugs.gui2.Driver"); Method mainMethod = launchClass.getMethod("main", args.getClass()); mainMethod.invoke(null, (Object) args); } }
[ "public", "void", "launch", "(", ")", "throws", "Exception", "{", "// Sanity-check the loaded BCEL classes", "if", "(", "!", "CheckBcel", ".", "check", "(", ")", ")", "{", "System", ".", "exit", "(", "1", ")", ";", "}", "int", "launchProperty", "=", "getLa...
Launch the appropriate UI. @throws java.lang.Exception
[ "Launch", "the", "appropriate", "UI", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/LaunchAppropriateUI.java#L97-L117
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/LaunchAppropriateUI.java
LaunchAppropriateUI.getLaunchProperty
private int getLaunchProperty() { // See if the first command line argument specifies the UI. if (args.length > 0) { String firstArg = args[0]; if (firstArg.startsWith("-")) { String uiName = firstArg.substring(1); if (uiNameToCodeMap.containsKey(uiName)) { // Strip the first argument from the command line arguments. String[] modifiedArgs = new String[args.length - 1]; System.arraycopy(args, 1, modifiedArgs, 0, args.length - 1); args = modifiedArgs; return uiNameToCodeMap.get(uiName); } } } // Check findbugs.launchUI property. // "gui2" is the default if not otherwise specified. String s = System.getProperty("findbugs.launchUI"); if (s == null) { for (String a : args) { if ("-output".equals(a) || "-xml".equals(a) || a.endsWith(".class") || a.endsWith(".jar")) { return TEXTUI; } } s = "gui2"; } // See if the property value is one of the human-readable // UI names. if (uiNameToCodeMap.containsKey(s)) { return uiNameToCodeMap.get(s); } // Fall back: try to parse it as an integer. try { return Integer.parseInt(s); } catch (NumberFormatException nfe) { return GUI2; } }
java
private int getLaunchProperty() { // See if the first command line argument specifies the UI. if (args.length > 0) { String firstArg = args[0]; if (firstArg.startsWith("-")) { String uiName = firstArg.substring(1); if (uiNameToCodeMap.containsKey(uiName)) { // Strip the first argument from the command line arguments. String[] modifiedArgs = new String[args.length - 1]; System.arraycopy(args, 1, modifiedArgs, 0, args.length - 1); args = modifiedArgs; return uiNameToCodeMap.get(uiName); } } } // Check findbugs.launchUI property. // "gui2" is the default if not otherwise specified. String s = System.getProperty("findbugs.launchUI"); if (s == null) { for (String a : args) { if ("-output".equals(a) || "-xml".equals(a) || a.endsWith(".class") || a.endsWith(".jar")) { return TEXTUI; } } s = "gui2"; } // See if the property value is one of the human-readable // UI names. if (uiNameToCodeMap.containsKey(s)) { return uiNameToCodeMap.get(s); } // Fall back: try to parse it as an integer. try { return Integer.parseInt(s); } catch (NumberFormatException nfe) { return GUI2; } }
[ "private", "int", "getLaunchProperty", "(", ")", "{", "// See if the first command line argument specifies the UI.", "if", "(", "args", ".", "length", ">", "0", ")", "{", "String", "firstArg", "=", "args", "[", "0", "]", ";", "if", "(", "firstArg", ".", "start...
Find out what UI should be launched. <p> First, we check the command line arguments to see if the first argument specifies the UI (e.g., "-textui", "-gui", etc.) <p> If the first command line argument does not specify the UI, then we check the <code>findbugs.launchUI</code> system property to one of the following values: <ul> <li>-Dfindbugs.launchUI=textui for textui,</li> <li>-Dfindbugs.launchUI=gui1 for the original swing gui,</li> <li>-Dfindbugs.launchUI=gui2 for the new swing gui,</li> <li>-Dfindbugs.launchUI=version for the ShowVersion main() method, or</li> <li>-Dfindbugs.launchUI=help for the ShowHelp main() method.</li> </ul> Any other value (or the absence of any value) will not change the default behavior, which is to launch the newer "gui2" on systems that support it. @return an integer UI code: TEXTUI, GUI1, GUI2, SHOW_VERSION, SHOW_HELP, or possibly another user-set int value
[ "Find", "out", "what", "UI", "should", "be", "launched", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/LaunchAppropriateUI.java#L145-L187
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java
FindBugsNature.configure
@Override public void configure() throws CoreException { if (DEBUG) { System.out.println("Adding findbugs to the project build spec."); } // register FindBugs builder addToBuildSpec(FindbugsPlugin.BUILDER_ID); }
java
@Override public void configure() throws CoreException { if (DEBUG) { System.out.println("Adding findbugs to the project build spec."); } // register FindBugs builder addToBuildSpec(FindbugsPlugin.BUILDER_ID); }
[ "@", "Override", "public", "void", "configure", "(", ")", "throws", "CoreException", "{", "if", "(", "DEBUG", ")", "{", "System", ".", "out", ".", "println", "(", "\"Adding findbugs to the project build spec.\"", ")", ";", "}", "// register FindBugs builder", "add...
Adds the FindBugs builder to the project. @see IProjectNature#configure
[ "Adds", "the", "FindBugs", "builder", "to", "the", "project", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java#L52-L59
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java
FindBugsNature.deconfigure
@Override public void deconfigure() throws CoreException { if (DEBUG) { System.out.println("Removing findbugs from the project build spec."); } // de-register FindBugs builder removeFromBuildSpec(FindbugsPlugin.BUILDER_ID); }
java
@Override public void deconfigure() throws CoreException { if (DEBUG) { System.out.println("Removing findbugs from the project build spec."); } // de-register FindBugs builder removeFromBuildSpec(FindbugsPlugin.BUILDER_ID); }
[ "@", "Override", "public", "void", "deconfigure", "(", ")", "throws", "CoreException", "{", "if", "(", "DEBUG", ")", "{", "System", ".", "out", ".", "println", "(", "\"Removing findbugs from the project build spec.\"", ")", ";", "}", "// de-register FindBugs builder...
Removes the FindBugs builder from the project. @see IProjectNature#deconfigure
[ "Removes", "the", "FindBugs", "builder", "from", "the", "project", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java#L66-L73
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java
FindBugsNature.removeFromBuildSpec
protected void removeFromBuildSpec(String builderID) throws CoreException { MarkerUtil.removeMarkers(getProject()); IProjectDescription description = getProject().getDescription(); ICommand[] commands = description.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(builderID)) { ICommand[] newCommands = new ICommand[commands.length - 1]; System.arraycopy(commands, 0, newCommands, 0, i); System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); description.setBuildSpec(newCommands); getProject().setDescription(description, null); return; } } }
java
protected void removeFromBuildSpec(String builderID) throws CoreException { MarkerUtil.removeMarkers(getProject()); IProjectDescription description = getProject().getDescription(); ICommand[] commands = description.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(builderID)) { ICommand[] newCommands = new ICommand[commands.length - 1]; System.arraycopy(commands, 0, newCommands, 0, i); System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); description.setBuildSpec(newCommands); getProject().setDescription(description, null); return; } } }
[ "protected", "void", "removeFromBuildSpec", "(", "String", "builderID", ")", "throws", "CoreException", "{", "MarkerUtil", ".", "removeMarkers", "(", "getProject", "(", ")", ")", ";", "IProjectDescription", "description", "=", "getProject", "(", ")", ".", "getDesc...
Removes the given builder from the build spec for the given project.
[ "Removes", "the", "given", "builder", "from", "the", "build", "spec", "for", "the", "given", "project", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java#L78-L92
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java
FindBugsNature.addToBuildSpec
protected void addToBuildSpec(String builderID) throws CoreException { IProjectDescription description = getProject().getDescription(); ICommand findBugsCommand = getFindBugsCommand(description); if (findBugsCommand == null) { // Add a Java command to the build spec ICommand newCommand = description.newCommand(); newCommand.setBuilderName(builderID); setFindBugsCommand(description, newCommand); } }
java
protected void addToBuildSpec(String builderID) throws CoreException { IProjectDescription description = getProject().getDescription(); ICommand findBugsCommand = getFindBugsCommand(description); if (findBugsCommand == null) { // Add a Java command to the build spec ICommand newCommand = description.newCommand(); newCommand.setBuilderName(builderID); setFindBugsCommand(description, newCommand); } }
[ "protected", "void", "addToBuildSpec", "(", "String", "builderID", ")", "throws", "CoreException", "{", "IProjectDescription", "description", "=", "getProject", "(", ")", ".", "getDescription", "(", ")", ";", "ICommand", "findBugsCommand", "=", "getFindBugsCommand", ...
Adds a builder to the build spec for the given project.
[ "Adds", "a", "builder", "to", "the", "build", "spec", "for", "the", "given", "project", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java#L97-L106
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java
FindBugsNature.getFindBugsCommand
private ICommand getFindBugsCommand(IProjectDescription description) { ICommand[] commands = description.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (FindbugsPlugin.BUILDER_ID.equals(commands[i].getBuilderName())) { return commands[i]; } } return null; }
java
private ICommand getFindBugsCommand(IProjectDescription description) { ICommand[] commands = description.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (FindbugsPlugin.BUILDER_ID.equals(commands[i].getBuilderName())) { return commands[i]; } } return null; }
[ "private", "ICommand", "getFindBugsCommand", "(", "IProjectDescription", "description", ")", "{", "ICommand", "[", "]", "commands", "=", "description", ".", "getBuildSpec", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "commands", ".", "l...
Find the specific FindBugs command amongst the build spec of a given description
[ "Find", "the", "specific", "FindBugs", "command", "amongst", "the", "build", "spec", "of", "a", "given", "description" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/nature/FindBugsNature.java#L112-L120
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java
CommandLine.addSwitch
public void addSwitch(String option, String description) { optionList.add(option); optionDescriptionMap.put(option, description); if (option.length() > maxWidth) { maxWidth = option.length(); } }
java
public void addSwitch(String option, String description) { optionList.add(option); optionDescriptionMap.put(option, description); if (option.length() > maxWidth) { maxWidth = option.length(); } }
[ "public", "void", "addSwitch", "(", "String", "option", ",", "String", "description", ")", "{", "optionList", ".", "add", "(", "option", ")", ";", "optionDescriptionMap", ".", "put", "(", "option", ",", "description", ")", ";", "if", "(", "option", ".", ...
Add a command line switch. This method is for adding options that do not require an argument. @param option the option, must start with "-" @param description single line description of the option
[ "Add", "a", "command", "line", "switch", ".", "This", "method", "is", "for", "adding", "options", "that", "do", "not", "require", "an", "argument", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java#L94-L101
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java
CommandLine.addSwitchWithOptionalExtraPart
public void addSwitchWithOptionalExtraPart(String option, String optionExtraPartSynopsis, String description) { optionList.add(option); optionExtraPartSynopsisMap.put(option, optionExtraPartSynopsis); optionDescriptionMap.put(option, description); // Option will display as -foo[:extraPartSynopsis] int length = option.length() + optionExtraPartSynopsis.length() + 3; if (length > maxWidth) { maxWidth = length; } }
java
public void addSwitchWithOptionalExtraPart(String option, String optionExtraPartSynopsis, String description) { optionList.add(option); optionExtraPartSynopsisMap.put(option, optionExtraPartSynopsis); optionDescriptionMap.put(option, description); // Option will display as -foo[:extraPartSynopsis] int length = option.length() + optionExtraPartSynopsis.length() + 3; if (length > maxWidth) { maxWidth = length; } }
[ "public", "void", "addSwitchWithOptionalExtraPart", "(", "String", "option", ",", "String", "optionExtraPartSynopsis", ",", "String", "description", ")", "{", "optionList", ".", "add", "(", "option", ")", ";", "optionExtraPartSynopsisMap", ".", "put", "(", "option",...
Add a command line switch that allows optional extra information to be specified as part of it. @param option the option, must start with "-" @param optionExtraPartSynopsis synopsis of the optional extra information @param description single-line description of the option
[ "Add", "a", "command", "line", "switch", "that", "allows", "optional", "extra", "information", "to", "be", "specified", "as", "part", "of", "it", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java#L114-L124
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java
CommandLine.addOption
public void addOption(String option, String argumentDesc, String description) { optionList.add(option); optionDescriptionMap.put(option, description); requiresArgumentSet.add(option); argumentDescriptionMap.put(option, argumentDesc); int width = option.length() + 3 + argumentDesc.length(); if (width > maxWidth) { maxWidth = width; } }
java
public void addOption(String option, String argumentDesc, String description) { optionList.add(option); optionDescriptionMap.put(option, description); requiresArgumentSet.add(option); argumentDescriptionMap.put(option, argumentDesc); int width = option.length() + 3 + argumentDesc.length(); if (width > maxWidth) { maxWidth = width; } }
[ "public", "void", "addOption", "(", "String", "option", ",", "String", "argumentDesc", ",", "String", "description", ")", "{", "optionList", ".", "add", "(", "option", ")", ";", "optionDescriptionMap", ".", "put", "(", "option", ",", "description", ")", ";",...
Add an option requiring an argument. @param option the option, must start with "-" @param argumentDesc brief (one or two word) description of the argument @param description single line description of the option
[ "Add", "an", "option", "requiring", "an", "argument", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java#L136-L146
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java
CommandLine.printUsage
public void printUsage(OutputStream os) { int count = 0; PrintStream out = UTF8.printStream(os); for (String option : optionList) { if (optionGroups.containsKey(count)) { out.println(" " + optionGroups.get(count)); } count++; if (unlistedOptions.contains(option)) { continue; } out.print(" "); StringBuilder buf = new StringBuilder(); buf.append(option); if (optionExtraPartSynopsisMap.get(option) != null) { String optionExtraPartSynopsis = optionExtraPartSynopsisMap.get(option); buf.append("[:"); buf.append(optionExtraPartSynopsis); buf.append("]"); } if (requiresArgumentSet.contains(option)) { buf.append(" <"); buf.append(argumentDescriptionMap.get(option)); buf.append(">"); } printField(out, buf.toString(), maxWidth + 1); out.println(optionDescriptionMap.get(option)); } out.flush(); }
java
public void printUsage(OutputStream os) { int count = 0; PrintStream out = UTF8.printStream(os); for (String option : optionList) { if (optionGroups.containsKey(count)) { out.println(" " + optionGroups.get(count)); } count++; if (unlistedOptions.contains(option)) { continue; } out.print(" "); StringBuilder buf = new StringBuilder(); buf.append(option); if (optionExtraPartSynopsisMap.get(option) != null) { String optionExtraPartSynopsis = optionExtraPartSynopsisMap.get(option); buf.append("[:"); buf.append(optionExtraPartSynopsis); buf.append("]"); } if (requiresArgumentSet.contains(option)) { buf.append(" <"); buf.append(argumentDescriptionMap.get(option)); buf.append(">"); } printField(out, buf.toString(), maxWidth + 1); out.println(optionDescriptionMap.get(option)); } out.flush(); }
[ "public", "void", "printUsage", "(", "OutputStream", "os", ")", "{", "int", "count", "=", "0", ";", "PrintStream", "out", "=", "UTF8", ".", "printStream", "(", "os", ")", ";", "for", "(", "String", "option", ":", "optionList", ")", "{", "if", "(", "o...
Print command line usage information to given stream. @param os the output stream
[ "Print", "command", "line", "usage", "information", "to", "given", "stream", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java#L377-L410
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java
LockSet.setLockCount
public void setLockCount(int valueNumber, int lockCount) { int index = findIndex(valueNumber); if (index < 0) { addEntry(index, valueNumber, lockCount); } else { array[index + 1] = lockCount; } }
java
public void setLockCount(int valueNumber, int lockCount) { int index = findIndex(valueNumber); if (index < 0) { addEntry(index, valueNumber, lockCount); } else { array[index + 1] = lockCount; } }
[ "public", "void", "setLockCount", "(", "int", "valueNumber", ",", "int", "lockCount", ")", "{", "int", "index", "=", "findIndex", "(", "valueNumber", ")", ";", "if", "(", "index", "<", "0", ")", "{", "addEntry", "(", "index", ",", "valueNumber", ",", "...
Set the lock count for a lock object. @param valueNumber value number of the lock object @param lockCount the lock count for the lock
[ "Set", "the", "lock", "count", "for", "a", "lock", "object", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java#L103-L110
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java
LockSet.getNumLockedObjects
public int getNumLockedObjects() { int result = 0; for (int i = 0; i + 1 < array.length; i += 2) { if (array[i] == INVALID) { break; } if (array[i + 1] > 0) { ++result; } } return result; }
java
public int getNumLockedObjects() { int result = 0; for (int i = 0; i + 1 < array.length; i += 2) { if (array[i] == INVALID) { break; } if (array[i + 1] > 0) { ++result; } } return result; }
[ "public", "int", "getNumLockedObjects", "(", ")", "{", "int", "result", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "+", "1", "<", "array", ".", "length", ";", "i", "+=", "2", ")", "{", "if", "(", "array", "[", "i", "]", "==", ...
Get the number of distinct lock values with positive lock counts.
[ "Get", "the", "number", "of", "distinct", "lock", "values", "with", "positive", "lock", "counts", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java#L125-L136
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java
LockSet.copyFrom
public void copyFrom(LockSet other) { if (other.array.length != array.length) { array = new int[other.array.length]; } System.arraycopy(other.array, 0, array, 0, array.length); this.defaultLockCount = other.defaultLockCount; }
java
public void copyFrom(LockSet other) { if (other.array.length != array.length) { array = new int[other.array.length]; } System.arraycopy(other.array, 0, array, 0, array.length); this.defaultLockCount = other.defaultLockCount; }
[ "public", "void", "copyFrom", "(", "LockSet", "other", ")", "{", "if", "(", "other", ".", "array", ".", "length", "!=", "array", ".", "length", ")", "{", "array", "=", "new", "int", "[", "other", ".", "array", ".", "length", "]", ";", "}", "System"...
Make this LockSet the same as the given one. @param other the LockSet to copy
[ "Make", "this", "LockSet", "the", "same", "as", "the", "given", "one", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java#L144-L150
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java
LockSet.meetWith
public void meetWith(LockSet other) { for (int i = 0; i + 1 < array.length; i += 2) { int valueNumber = array[i]; if (valueNumber < 0) { break; } int mine = array[i + 1]; int his = other.getLockCount(valueNumber); array[i + 1] = mergeValues(mine, his); } for (int i = 0; i + 1 < other.array.length; i += 2) { int valueNumber = other.array[i]; if (valueNumber < 0) { break; } int mine = getLockCount(valueNumber); int his = other.array[i + 1]; setLockCount(valueNumber, mergeValues(mine, his)); } setDefaultLockCount(0); }
java
public void meetWith(LockSet other) { for (int i = 0; i + 1 < array.length; i += 2) { int valueNumber = array[i]; if (valueNumber < 0) { break; } int mine = array[i + 1]; int his = other.getLockCount(valueNumber); array[i + 1] = mergeValues(mine, his); } for (int i = 0; i + 1 < other.array.length; i += 2) { int valueNumber = other.array[i]; if (valueNumber < 0) { break; } int mine = getLockCount(valueNumber); int his = other.array[i + 1]; setLockCount(valueNumber, mergeValues(mine, his)); } setDefaultLockCount(0); }
[ "public", "void", "meetWith", "(", "LockSet", "other", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "+", "1", "<", "array", ".", "length", ";", "i", "+=", "2", ")", "{", "int", "valueNumber", "=", "array", "[", "i", "]", ";", "if", "...
Meet this LockSet with another LockSet, storing the result in this object. @param other the other LockSet
[ "Meet", "this", "LockSet", "with", "another", "LockSet", "storing", "the", "result", "in", "this", "object", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java#L168-L192
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java
LockSet.containsReturnValue
public boolean containsReturnValue(ValueNumberFactory factory) { for (int i = 0; i + 1 < array.length; i += 2) { int valueNumber = array[i]; if (valueNumber < 0) { break; } int lockCount = array[i + 1]; if (lockCount > 0 && factory.forNumber(valueNumber).hasFlag(ValueNumber.RETURN_VALUE)) { return true; } } return false; }
java
public boolean containsReturnValue(ValueNumberFactory factory) { for (int i = 0; i + 1 < array.length; i += 2) { int valueNumber = array[i]; if (valueNumber < 0) { break; } int lockCount = array[i + 1]; if (lockCount > 0 && factory.forNumber(valueNumber).hasFlag(ValueNumber.RETURN_VALUE)) { return true; } } return false; }
[ "public", "boolean", "containsReturnValue", "(", "ValueNumberFactory", "factory", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "+", "1", "<", "array", ".", "length", ";", "i", "+=", "2", ")", "{", "int", "valueNumber", "=", "array", "[", "i"...
Determine whether or not this lock set contains any locked values which are method return values. @param factory the ValueNumberFactory that produced the lock values
[ "Determine", "whether", "or", "not", "this", "lock", "set", "contains", "any", "locked", "values", "which", "are", "method", "return", "values", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java#L211-L223
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java
LockSet.isEmpty
public boolean isEmpty() { for (int i = 0; i + 1 < array.length; i += 2) { int valueNumber = array[i]; if (valueNumber < 0) { return true; } int myLockCount = array[i + 1]; if (myLockCount > 0) { return false; } } return true; }
java
public boolean isEmpty() { for (int i = 0; i + 1 < array.length; i += 2) { int valueNumber = array[i]; if (valueNumber < 0) { return true; } int myLockCount = array[i + 1]; if (myLockCount > 0) { return false; } } return true; }
[ "public", "boolean", "isEmpty", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "+", "1", "<", "array", ".", "length", ";", "i", "+=", "2", ")", "{", "int", "valueNumber", "=", "array", "[", "i", "]", ";", "if", "(", "valueNumber", ...
Return whether or not this lock set is empty, meaning that no locks have a positive lock count. @return true if no locks are held, false if at least one lock is held
[ "Return", "whether", "or", "not", "this", "lock", "set", "is", "empty", "meaning", "that", "no", "locks", "have", "a", "positive", "lock", "count", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java#L257-L269
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SimplePathEnumerator.java
SimplePathEnumerator.enumerate
public SimplePathEnumerator enumerate() { Iterator<Edge> entryOut = cfg.outgoingEdgeIterator(cfg.getEntry()); if (!entryOut.hasNext()) { throw new IllegalStateException(); } Edge entryEdge = entryOut.next(); LinkedList<Edge> init = new LinkedList<>(); init.add(entryEdge); work(init); if (DEBUG && work == maxWork) { System.out.println("**** Reached max work! ****"); } return this; }
java
public SimplePathEnumerator enumerate() { Iterator<Edge> entryOut = cfg.outgoingEdgeIterator(cfg.getEntry()); if (!entryOut.hasNext()) { throw new IllegalStateException(); } Edge entryEdge = entryOut.next(); LinkedList<Edge> init = new LinkedList<>(); init.add(entryEdge); work(init); if (DEBUG && work == maxWork) { System.out.println("**** Reached max work! ****"); } return this; }
[ "public", "SimplePathEnumerator", "enumerate", "(", ")", "{", "Iterator", "<", "Edge", ">", "entryOut", "=", "cfg", ".", "outgoingEdgeIterator", "(", "cfg", ".", "getEntry", "(", ")", ")", ";", "if", "(", "!", "entryOut", ".", "hasNext", "(", ")", ")", ...
Enumerate the simple paths. @return this object
[ "Enumerate", "the", "simple", "paths", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SimplePathEnumerator.java#L97-L113
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/NumberConstructor.java
NumberConstructor.visitClassContext
@Override public void visitClassContext(ClassContext classContext) { int majorVersion = classContext.getJavaClass().getMajor(); if (majorVersion >= Const.MAJOR_1_5 && hasInterestingMethod(classContext.getJavaClass().getConstantPool(), methods)) { super.visitClassContext(classContext); } }
java
@Override public void visitClassContext(ClassContext classContext) { int majorVersion = classContext.getJavaClass().getMajor(); if (majorVersion >= Const.MAJOR_1_5 && hasInterestingMethod(classContext.getJavaClass().getConstantPool(), methods)) { super.visitClassContext(classContext); } }
[ "@", "Override", "public", "void", "visitClassContext", "(", "ClassContext", "classContext", ")", "{", "int", "majorVersion", "=", "classContext", ".", "getJavaClass", "(", ")", ".", "getMajor", "(", ")", ";", "if", "(", "majorVersion", ">=", "Const", ".", "...
The detector is only meaningful for Java5 class libraries. @param classContext the context object that holds the JavaClass parsed
[ "The", "detector", "is", "only", "meaningful", "for", "Java5", "class", "libraries", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/NumberConstructor.java#L105-L111
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierResolver.java
TypeQualifierResolver.resolveTypeQualifiers
public static Collection<AnnotationValue> resolveTypeQualifiers(AnnotationValue value) { LinkedList<AnnotationValue> result = new LinkedList<>(); resolveTypeQualifierNicknames(value, result, new LinkedList<ClassDescriptor>()); return result; }
java
public static Collection<AnnotationValue> resolveTypeQualifiers(AnnotationValue value) { LinkedList<AnnotationValue> result = new LinkedList<>(); resolveTypeQualifierNicknames(value, result, new LinkedList<ClassDescriptor>()); return result; }
[ "public", "static", "Collection", "<", "AnnotationValue", ">", "resolveTypeQualifiers", "(", "AnnotationValue", "value", ")", "{", "LinkedList", "<", "AnnotationValue", ">", "result", "=", "new", "LinkedList", "<>", "(", ")", ";", "resolveTypeQualifierNicknames", "(...
Resolve an AnnotationValue into a list of AnnotationValues representing type qualifier annotations. @param value AnnotationValue representing the use of an annotation @return Collection of AnnotationValues representing resolved TypeQualifier annotations
[ "Resolve", "an", "AnnotationValue", "into", "a", "list", "of", "AnnotationValues", "representing", "type", "qualifier", "annotations", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierResolver.java#L88-L92
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/graph/MergeVertices.java
MergeVertices.mergeVertices
public void mergeVertices(Set<VertexType> vertexSet, GraphType g, VertexCombinator<VertexType> combinator, GraphToolkit<GraphType, EdgeType, VertexType> toolkit) { // Special case: if the vertex set contains a single vertex // or is empty, there is nothing to do if (vertexSet.size() <= 1) { return; } // Get all vertices to which we have outgoing edges // or from which we have incoming edges, since they'll need // to be fixed TreeSet<EdgeType> edgeSet = new TreeSet<>(); for (Iterator<EdgeType> i = g.edgeIterator(); i.hasNext();) { EdgeType e = i.next(); if (vertexSet.contains(e.getSource()) || vertexSet.contains(e.getTarget())) { edgeSet.add(e); } } // Combine all of the vertices into a single composite vertex VertexType compositeVertex = combinator.combineVertices(vertexSet); // For each original edge into or out of the vertex set, // create an equivalent edge referencing the composite // vertex for (EdgeType e : edgeSet) { VertexType source = vertexSet.contains(e.getSource()) ? compositeVertex : e.getSource(); VertexType target = vertexSet.contains(e.getTarget()) ? compositeVertex : e.getTarget(); // if (source != compositeVertex && target != compositeVertex) // System.out.println("BIG OOPS!"); // Don't create a self edge for the composite vertex // unless one of the vertices in the vertex set // had a self edge if (source == compositeVertex && target == compositeVertex && e.getSource() != e.getTarget()) { continue; } // Don't create duplicate edges. if (g.lookupEdge(source, target) != null) { continue; } EdgeType compositeEdge = g.createEdge(source, target); // FIXME: we really should have an EdgeCombinator here toolkit.copyEdge(e, compositeEdge); } // Remove all of the vertices in the vertex set; this will // automatically remove the edges into and out of those // vertices for (VertexType aVertexSet : vertexSet) { g.removeVertex(aVertexSet); } }
java
public void mergeVertices(Set<VertexType> vertexSet, GraphType g, VertexCombinator<VertexType> combinator, GraphToolkit<GraphType, EdgeType, VertexType> toolkit) { // Special case: if the vertex set contains a single vertex // or is empty, there is nothing to do if (vertexSet.size() <= 1) { return; } // Get all vertices to which we have outgoing edges // or from which we have incoming edges, since they'll need // to be fixed TreeSet<EdgeType> edgeSet = new TreeSet<>(); for (Iterator<EdgeType> i = g.edgeIterator(); i.hasNext();) { EdgeType e = i.next(); if (vertexSet.contains(e.getSource()) || vertexSet.contains(e.getTarget())) { edgeSet.add(e); } } // Combine all of the vertices into a single composite vertex VertexType compositeVertex = combinator.combineVertices(vertexSet); // For each original edge into or out of the vertex set, // create an equivalent edge referencing the composite // vertex for (EdgeType e : edgeSet) { VertexType source = vertexSet.contains(e.getSource()) ? compositeVertex : e.getSource(); VertexType target = vertexSet.contains(e.getTarget()) ? compositeVertex : e.getTarget(); // if (source != compositeVertex && target != compositeVertex) // System.out.println("BIG OOPS!"); // Don't create a self edge for the composite vertex // unless one of the vertices in the vertex set // had a self edge if (source == compositeVertex && target == compositeVertex && e.getSource() != e.getTarget()) { continue; } // Don't create duplicate edges. if (g.lookupEdge(source, target) != null) { continue; } EdgeType compositeEdge = g.createEdge(source, target); // FIXME: we really should have an EdgeCombinator here toolkit.copyEdge(e, compositeEdge); } // Remove all of the vertices in the vertex set; this will // automatically remove the edges into and out of those // vertices for (VertexType aVertexSet : vertexSet) { g.removeVertex(aVertexSet); } }
[ "public", "void", "mergeVertices", "(", "Set", "<", "VertexType", ">", "vertexSet", ",", "GraphType", "g", ",", "VertexCombinator", "<", "VertexType", ">", "combinator", ",", "GraphToolkit", "<", "GraphType", ",", "EdgeType", ",", "VertexType", ">", "toolkit", ...
Merge the specified set of vertices into a single vertex. @param vertexSet the set of vertices to be merged @param g the graph to be modified @param combinator object used to combine vertices @param toolkit GraphToolkit used to copy auxiliary information for edges
[ "Merge", "the", "specified", "set", "of", "vertices", "into", "a", "single", "vertex", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/graph/MergeVertices.java#L52-L109
train