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
eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java
BugResolution.getLabel
@Override @Nonnull public String getLabel() { ASTVisitor labelFixingVisitor = getCustomLabelVisitor(); if (labelFixingVisitor instanceof CustomLabelVisitor) { if (customizedLabel == null) { String labelReplacement = findLabelReplacement(labelFixingVisitor); customizedLabel = label.replace(BugResolution.PLACEHOLDER_STRING, labelReplacement); } return customizedLabel; } return label; }
java
@Override @Nonnull public String getLabel() { ASTVisitor labelFixingVisitor = getCustomLabelVisitor(); if (labelFixingVisitor instanceof CustomLabelVisitor) { if (customizedLabel == null) { String labelReplacement = findLabelReplacement(labelFixingVisitor); customizedLabel = label.replace(BugResolution.PLACEHOLDER_STRING, labelReplacement); } return customizedLabel; } return label; }
[ "@", "Override", "@", "Nonnull", "public", "String", "getLabel", "(", ")", "{", "ASTVisitor", "labelFixingVisitor", "=", "getCustomLabelVisitor", "(", ")", ";", "if", "(", "labelFixingVisitor", "instanceof", "CustomLabelVisitor", ")", "{", "if", "(", "customizedLa...
Returns the short label that briefly describes the change that will be made. Typically, labels are static and defined in <code>plugin.xml</code>. For runtime-computed labels, define a base label in plugin.xml using the <code>PLACEHOLDER_STRING</code> "YYY" where any custom text should go. Then, override getLabelFixingVisitor() to scan the code and find the text to replace the placeholder. The visitor is only used to scan once, the result being cached on subsequent visits.
[ "Returns", "the", "short", "label", "that", "briefly", "describes", "the", "change", "that", "will", "be", "made", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java#L118-L130
train
spotbugs/spotbugs
eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java
BugResolution.runInternal
private void runInternal(IMarker marker) throws CoreException { Assert.isNotNull(marker); PendingRewrite pending = resolveWithoutWriting(marker); if(pending == null){ return; } try { IRegion region = completeRewrite(pending); if(region == null){ return; } IEditorPart part = EditorUtility.isOpenInEditor(pending.originalUnit); if (part instanceof ITextEditor) { ((ITextEditor) part).selectAndReveal(region.getOffset(), region.getLength()); } } finally { pending.originalUnit.discardWorkingCopy(); } }
java
private void runInternal(IMarker marker) throws CoreException { Assert.isNotNull(marker); PendingRewrite pending = resolveWithoutWriting(marker); if(pending == null){ return; } try { IRegion region = completeRewrite(pending); if(region == null){ return; } IEditorPart part = EditorUtility.isOpenInEditor(pending.originalUnit); if (part instanceof ITextEditor) { ((ITextEditor) part).selectAndReveal(region.getOffset(), region.getLength()); } } finally { pending.originalUnit.discardWorkingCopy(); } }
[ "private", "void", "runInternal", "(", "IMarker", "marker", ")", "throws", "CoreException", "{", "Assert", ".", "isNotNull", "(", "marker", ")", ";", "PendingRewrite", "pending", "=", "resolveWithoutWriting", "(", "marker", ")", ";", "if", "(", "pending", "=="...
This method is used by the test-framework, to catch the thrown exceptions and report it to the user. @see #run(IMarker)
[ "This", "method", "is", "used", "by", "the", "test", "-", "framework", "to", "catch", "the", "thrown", "exceptions", "and", "report", "it", "to", "the", "user", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java#L351-L371
train
spotbugs/spotbugs
eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java
BugResolution.getCompilationUnit
@CheckForNull protected ICompilationUnit getCompilationUnit(IMarker marker) { IResource res = marker.getResource(); if (res instanceof IFile && res.isAccessible()) { IJavaElement element = JavaCore.create((IFile) res); if (element instanceof ICompilationUnit) { return (ICompilationUnit) element; } } return null; }
java
@CheckForNull protected ICompilationUnit getCompilationUnit(IMarker marker) { IResource res = marker.getResource(); if (res instanceof IFile && res.isAccessible()) { IJavaElement element = JavaCore.create((IFile) res); if (element instanceof ICompilationUnit) { return (ICompilationUnit) element; } } return null; }
[ "@", "CheckForNull", "protected", "ICompilationUnit", "getCompilationUnit", "(", "IMarker", "marker", ")", "{", "IResource", "res", "=", "marker", ".", "getResource", "(", ")", ";", "if", "(", "res", "instanceof", "IFile", "&&", "res", ".", "isAccessible", "("...
Get the compilation unit for the marker. @param marker not null @return The compilation unit for the marker, or null if the file was not accessible or was not a Java file.
[ "Get", "the", "compilation", "unit", "for", "the", "marker", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java#L393-L403
train
spotbugs/spotbugs
eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java
BugResolution.reportException
protected void reportException(Exception e) { Assert.isNotNull(e); FindbugsPlugin.getDefault().logException(e, e.getLocalizedMessage()); MessageDialog.openError(FindbugsPlugin.getShell(), "BugResolution failed.", e.getLocalizedMessage()); }
java
protected void reportException(Exception e) { Assert.isNotNull(e); FindbugsPlugin.getDefault().logException(e, e.getLocalizedMessage()); MessageDialog.openError(FindbugsPlugin.getShell(), "BugResolution failed.", e.getLocalizedMessage()); }
[ "protected", "void", "reportException", "(", "Exception", "e", ")", "{", "Assert", ".", "isNotNull", "(", "e", ")", ";", "FindbugsPlugin", ".", "getDefault", "(", ")", ".", "logException", "(", "e", ",", "e", ".", "getLocalizedMessage", "(", ")", ")", ";...
Reports an exception to the user. This method could be overwritten by a subclass to handle some exceptions individual. @param e not null
[ "Reports", "an", "exception", "to", "the", "user", ".", "This", "method", "could", "be", "overwritten", "by", "a", "subclass", "to", "handle", "some", "exceptions", "individual", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/BugResolution.java#L412-L417
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getSizeOfSurroundingTryBlock
public int getSizeOfSurroundingTryBlock(String vmNameOfExceptionClass, int pc) { if (code == null) { throw new IllegalStateException("Not visiting Code"); } return Util.getSizeOfSurroundingTryBlock(constantPool, code, vmNameOfExceptionClass, pc); }
java
public int getSizeOfSurroundingTryBlock(String vmNameOfExceptionClass, int pc) { if (code == null) { throw new IllegalStateException("Not visiting Code"); } return Util.getSizeOfSurroundingTryBlock(constantPool, code, vmNameOfExceptionClass, pc); }
[ "public", "int", "getSizeOfSurroundingTryBlock", "(", "String", "vmNameOfExceptionClass", ",", "int", "pc", ")", "{", "if", "(", "code", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Not visiting Code\"", ")", ";", "}", "return", "Util...
Get lines of code in try block that surround pc @param pc @return number of lines of code in try block
[ "Get", "lines", "of", "code", "in", "try", "block", "that", "surround", "pc" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L221-L226
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getFullyQualifiedMethodName
public String getFullyQualifiedMethodName() { if (!visitingMethod) { throw new IllegalStateException("getFullyQualifiedMethodName called while not visiting method"); } if (fullyQualifiedMethodName == null) { getMethodName(); getDottedMethodSig(); StringBuilder ref = new StringBuilder(5 + dottedClassName.length() + methodName.length() + dottedMethodSig.length()); ref.append(dottedClassName).append(".").append(methodName).append(" : ").append(dottedMethodSig); fullyQualifiedMethodName = ref.toString(); } return fullyQualifiedMethodName; }
java
public String getFullyQualifiedMethodName() { if (!visitingMethod) { throw new IllegalStateException("getFullyQualifiedMethodName called while not visiting method"); } if (fullyQualifiedMethodName == null) { getMethodName(); getDottedMethodSig(); StringBuilder ref = new StringBuilder(5 + dottedClassName.length() + methodName.length() + dottedMethodSig.length()); ref.append(dottedClassName).append(".").append(methodName).append(" : ").append(dottedMethodSig); fullyQualifiedMethodName = ref.toString(); } return fullyQualifiedMethodName; }
[ "public", "String", "getFullyQualifiedMethodName", "(", ")", "{", "if", "(", "!", "visitingMethod", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getFullyQualifiedMethodName called while not visiting method\"", ")", ";", "}", "if", "(", "fullyQualifiedMethodN...
If currently visiting a method, get the method's fully qualified name
[ "If", "currently", "visiting", "a", "method", "get", "the", "method", "s", "fully", "qualified", "name" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L533-L546
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getMethodName
public String getMethodName() { if (!visitingMethod) { throw new IllegalStateException("getMethodName called while not visiting method"); } if (methodName == null) { methodName = getStringFromIndex(method.getNameIndex()); } return methodName; }
java
public String getMethodName() { if (!visitingMethod) { throw new IllegalStateException("getMethodName called while not visiting method"); } if (methodName == null) { methodName = getStringFromIndex(method.getNameIndex()); } return methodName; }
[ "public", "String", "getMethodName", "(", ")", "{", "if", "(", "!", "visitingMethod", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getMethodName called while not visiting method\"", ")", ";", "}", "if", "(", "methodName", "==", "null", ")", "{", "m...
If currently visiting a method, get the method's name
[ "If", "currently", "visiting", "a", "method", "get", "the", "method", "s", "name" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L579-L588
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.hasInterestingMethod
public static boolean hasInterestingMethod(ConstantPool cp, Collection<MethodDescriptor> methods) { for(Constant c : cp.getConstantPool()) { if(c instanceof ConstantMethodref || c instanceof ConstantInterfaceMethodref) { ConstantCP desc = (ConstantCP)c; ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(desc.getNameAndTypeIndex()); String className = cp.getConstantString(desc.getClassIndex(), Const.CONSTANT_Class); String name = ((ConstantUtf8)cp.getConstant(nameAndType.getNameIndex())).getBytes(); String signature = ((ConstantUtf8)cp.getConstant(nameAndType.getSignatureIndex())).getBytes(); // We don't know whether method is static thus cannot use equals int hash = FieldOrMethodDescriptor.getNameSigHashCode(name, signature); for(MethodDescriptor method : methods) { if (method.getNameSigHashCode() == hash && (method.getSlashedClassName().isEmpty() || method.getSlashedClassName().equals(className)) && method.getName().equals(name) && method.getSignature().equals(signature)) { return true; } } } } return false; }
java
public static boolean hasInterestingMethod(ConstantPool cp, Collection<MethodDescriptor> methods) { for(Constant c : cp.getConstantPool()) { if(c instanceof ConstantMethodref || c instanceof ConstantInterfaceMethodref) { ConstantCP desc = (ConstantCP)c; ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(desc.getNameAndTypeIndex()); String className = cp.getConstantString(desc.getClassIndex(), Const.CONSTANT_Class); String name = ((ConstantUtf8)cp.getConstant(nameAndType.getNameIndex())).getBytes(); String signature = ((ConstantUtf8)cp.getConstant(nameAndType.getSignatureIndex())).getBytes(); // We don't know whether method is static thus cannot use equals int hash = FieldOrMethodDescriptor.getNameSigHashCode(name, signature); for(MethodDescriptor method : methods) { if (method.getNameSigHashCode() == hash && (method.getSlashedClassName().isEmpty() || method.getSlashedClassName().equals(className)) && method.getName().equals(name) && method.getSignature().equals(signature)) { return true; } } } } return false; }
[ "public", "static", "boolean", "hasInterestingMethod", "(", "ConstantPool", "cp", ",", "Collection", "<", "MethodDescriptor", ">", "methods", ")", "{", "for", "(", "Constant", "c", ":", "cp", ".", "getConstantPool", "(", ")", ")", "{", "if", "(", "c", "ins...
Returns true if given constant pool probably has a reference to any of supplied methods Useful to exclude from analysis uninteresting classes @param cp constant pool @param methods methods collection @return true if method is found
[ "Returns", "true", "if", "given", "constant", "pool", "probably", "has", "a", "reference", "to", "any", "of", "supplied", "methods", "Useful", "to", "exclude", "from", "analysis", "uninteresting", "classes" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L635-L655
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getMethodSig
public String getMethodSig() { if (!visitingMethod) { throw new IllegalStateException("getMethodSig called while not visiting method"); } if (methodSig == null) { methodSig = getStringFromIndex(method.getSignatureIndex()); } return methodSig; }
java
public String getMethodSig() { if (!visitingMethod) { throw new IllegalStateException("getMethodSig called while not visiting method"); } if (methodSig == null) { methodSig = getStringFromIndex(method.getSignatureIndex()); } return methodSig; }
[ "public", "String", "getMethodSig", "(", ")", "{", "if", "(", "!", "visitingMethod", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getMethodSig called while not visiting method\"", ")", ";", "}", "if", "(", "methodSig", "==", "null", ")", "{", "meth...
If currently visiting a method, get the method's slash-formatted signature
[ "If", "currently", "visiting", "a", "method", "get", "the", "method", "s", "slash", "-", "formatted", "signature" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L677-L685
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getDottedMethodSig
public String getDottedMethodSig() { if (!visitingMethod) { throw new IllegalStateException("getDottedMethodSig called while not visiting method"); } if (dottedMethodSig == null) { dottedMethodSig = getMethodSig().replace('/', '.'); } return dottedMethodSig; }
java
public String getDottedMethodSig() { if (!visitingMethod) { throw new IllegalStateException("getDottedMethodSig called while not visiting method"); } if (dottedMethodSig == null) { dottedMethodSig = getMethodSig().replace('/', '.'); } return dottedMethodSig; }
[ "public", "String", "getDottedMethodSig", "(", ")", "{", "if", "(", "!", "visitingMethod", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getDottedMethodSig called while not visiting method\"", ")", ";", "}", "if", "(", "dottedMethodSig", "==", "null", "...
If currently visiting a method, get the method's dotted method signature
[ "If", "currently", "visiting", "a", "method", "get", "the", "method", "s", "dotted", "method", "signature" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L688-L696
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getFieldName
public String getFieldName() { if (!visitingField) { throw new IllegalStateException("getFieldName called while not visiting field"); } if (fieldName == null) { fieldName = getStringFromIndex(field.getNameIndex()); } return fieldName; }
java
public String getFieldName() { if (!visitingField) { throw new IllegalStateException("getFieldName called while not visiting field"); } if (fieldName == null) { fieldName = getStringFromIndex(field.getNameIndex()); } return fieldName; }
[ "public", "String", "getFieldName", "(", ")", "{", "if", "(", "!", "visitingField", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getFieldName called while not visiting field\"", ")", ";", "}", "if", "(", "fieldName", "==", "null", ")", "{", "fieldN...
If currently visiting a field, get the field's name
[ "If", "currently", "visiting", "a", "field", "get", "the", "field", "s", "name" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L699-L708
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getFieldSig
public String getFieldSig() { if (!visitingField) { throw new IllegalStateException("getFieldSig called while not visiting field"); } if (fieldSig == null) { fieldSig = getStringFromIndex(field.getSignatureIndex()); } return fieldSig; }
java
public String getFieldSig() { if (!visitingField) { throw new IllegalStateException("getFieldSig called while not visiting field"); } if (fieldSig == null) { fieldSig = getStringFromIndex(field.getSignatureIndex()); } return fieldSig; }
[ "public", "String", "getFieldSig", "(", ")", "{", "if", "(", "!", "visitingField", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getFieldSig called while not visiting field\"", ")", ";", "}", "if", "(", "fieldSig", "==", "null", ")", "{", "fieldSig"...
If currently visiting a field, get the field's slash-formatted signature
[ "If", "currently", "visiting", "a", "field", "get", "the", "field", "s", "slash", "-", "formatted", "signature" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L711-L719
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getFullyQualifiedFieldName
public String getFullyQualifiedFieldName() { if (!visitingField) { throw new IllegalStateException("getFullyQualifiedFieldName called while not visiting field"); } if (fullyQualifiedFieldName == null) { fullyQualifiedFieldName = getDottedClassName() + "." + getFieldName() + " : " + getFieldSig(); } return fullyQualifiedFieldName; }
java
public String getFullyQualifiedFieldName() { if (!visitingField) { throw new IllegalStateException("getFullyQualifiedFieldName called while not visiting field"); } if (fullyQualifiedFieldName == null) { fullyQualifiedFieldName = getDottedClassName() + "." + getFieldName() + " : " + getFieldSig(); } return fullyQualifiedFieldName; }
[ "public", "String", "getFullyQualifiedFieldName", "(", ")", "{", "if", "(", "!", "visitingField", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getFullyQualifiedFieldName called while not visiting field\"", ")", ";", "}", "if", "(", "fullyQualifiedFieldName",...
If currently visiting a field, get the field's fully qualified name
[ "If", "currently", "visiting", "a", "field", "get", "the", "field", "s", "fully", "qualified", "name" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L730-L738
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java
PreorderVisitor.getDottedFieldSig
@Deprecated public String getDottedFieldSig() { if (!visitingField) { throw new IllegalStateException("getDottedFieldSig called while not visiting field"); } if (dottedFieldSig == null) { dottedFieldSig = fieldSig.replace('/', '.'); } return dottedFieldSig; }
java
@Deprecated public String getDottedFieldSig() { if (!visitingField) { throw new IllegalStateException("getDottedFieldSig called while not visiting field"); } if (dottedFieldSig == null) { dottedFieldSig = fieldSig.replace('/', '.'); } return dottedFieldSig; }
[ "@", "Deprecated", "public", "String", "getDottedFieldSig", "(", ")", "{", "if", "(", "!", "visitingField", ")", "{", "throw", "new", "IllegalStateException", "(", "\"getDottedFieldSig called while not visiting field\"", ")", ";", "}", "if", "(", "dottedFieldSig", "...
If currently visiting a field, get the field's dot-formatted signature
[ "If", "currently", "visiting", "a", "field", "get", "the", "field", "s", "dot", "-", "formatted", "signature" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/visitclass/PreorderVisitor.java#L741-L750
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/ResourceNotFoundException.java
ResourceNotFoundException.toClassNotFoundException
public ClassNotFoundException toClassNotFoundException() { ClassDescriptor classDescriptor = DescriptorFactory.createClassDescriptorFromResourceName(resourceName); return new ClassNotFoundException("ResourceNotFoundException while looking for class " + classDescriptor.toDottedClassName() + ": " + getMessage()); }
java
public ClassNotFoundException toClassNotFoundException() { ClassDescriptor classDescriptor = DescriptorFactory.createClassDescriptorFromResourceName(resourceName); return new ClassNotFoundException("ResourceNotFoundException while looking for class " + classDescriptor.toDottedClassName() + ": " + getMessage()); }
[ "public", "ClassNotFoundException", "toClassNotFoundException", "(", ")", "{", "ClassDescriptor", "classDescriptor", "=", "DescriptorFactory", ".", "createClassDescriptorFromResourceName", "(", "resourceName", ")", ";", "return", "new", "ClassNotFoundException", "(", "\"Resou...
Convert this exception to a ClassNotFoundException. This method should only be called if the ResourceNotFoundException occurs while looking for a class. The message format is parseable by ClassNotFoundExceptionParser.
[ "Convert", "this", "exception", "to", "a", "ClassNotFoundException", ".", "This", "method", "should", "only", "be", "called", "if", "the", "ResourceNotFoundException", "occurs", "while", "looking", "for", "a", "class", ".", "The", "message", "format", "is", "par...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/ResourceNotFoundException.java#L70-L74
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/ClassPathImpl.java
ClassPathImpl.search
private ICodeBaseEntry search(List<? extends ICodeBase> codeBaseList, String resourceName) { for (ICodeBase codeBase : codeBaseList) { ICodeBaseEntry resource = codeBase.lookupResource(resourceName); if (resource != null) { return resource; } // Ignore, continue trying other codebases } return null; }
java
private ICodeBaseEntry search(List<? extends ICodeBase> codeBaseList, String resourceName) { for (ICodeBase codeBase : codeBaseList) { ICodeBaseEntry resource = codeBase.lookupResource(resourceName); if (resource != null) { return resource; } // Ignore, continue trying other codebases } return null; }
[ "private", "ICodeBaseEntry", "search", "(", "List", "<", "?", "extends", "ICodeBase", ">", "codeBaseList", ",", "String", "resourceName", ")", "{", "for", "(", "ICodeBase", "codeBase", ":", "codeBaseList", ")", "{", "ICodeBaseEntry", "resource", "=", "codeBase",...
Search list of codebases for named resource. @param codeBaseList list of codebases to search @param resourceName name of resourse @return codebase entry for the named resource, or null if the named resource cannot be found
[ "Search", "list", "of", "codebases", "for", "named", "resource", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/ClassPathImpl.java#L184-L193
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java
StateSet.copyFrom
public void copyFrom(StateSet other) { this.isTop = other.isTop; this.isBottom = other.isBottom; this.onExceptionPath = other.onExceptionPath; this.stateMap.clear(); for (State state : other.stateMap.values()) { State dup = state.duplicate(); this.stateMap.put(dup.getObligationSet(), dup); } }
java
public void copyFrom(StateSet other) { this.isTop = other.isTop; this.isBottom = other.isBottom; this.onExceptionPath = other.onExceptionPath; this.stateMap.clear(); for (State state : other.stateMap.values()) { State dup = state.duplicate(); this.stateMap.put(dup.getObligationSet(), dup); } }
[ "public", "void", "copyFrom", "(", "StateSet", "other", ")", "{", "this", ".", "isTop", "=", "other", ".", "isTop", ";", "this", ".", "isBottom", "=", "other", ".", "isBottom", ";", "this", ".", "onExceptionPath", "=", "other", ".", "onExceptionPath", ";...
Make this StateSet an exact copy of the given StateSet. @param other a StateSet; this StateSet will be made identical to it
[ "Make", "this", "StateSet", "an", "exact", "copy", "of", "the", "given", "StateSet", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java#L158-L167
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java
StateSet.addObligation
public void addObligation(final Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException { Map<ObligationSet, State> updatedStateMap = new HashMap<>(); if (stateMap.isEmpty()) { State s = new State(factory); s.getObligationSet().add(obligation); updatedStateMap.put(s.getObligationSet(), s); } else { for (State state : stateMap.values()) { checkCircularity(state, obligation, basicBlockId); state.getObligationSet().add(obligation); updatedStateMap.put(state.getObligationSet(), state); } } replaceMap(updatedStateMap); }
java
public void addObligation(final Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException { Map<ObligationSet, State> updatedStateMap = new HashMap<>(); if (stateMap.isEmpty()) { State s = new State(factory); s.getObligationSet().add(obligation); updatedStateMap.put(s.getObligationSet(), s); } else { for (State state : stateMap.values()) { checkCircularity(state, obligation, basicBlockId); state.getObligationSet().add(obligation); updatedStateMap.put(state.getObligationSet(), state); } } replaceMap(updatedStateMap); }
[ "public", "void", "addObligation", "(", "final", "Obligation", "obligation", ",", "int", "basicBlockId", ")", "throws", "ObligationAcquiredOrReleasedInLoopException", "{", "Map", "<", "ObligationSet", ",", "State", ">", "updatedStateMap", "=", "new", "HashMap", "<>", ...
Add an obligation to every State in the StateSet. @param obligation the obligation to add @param basicBlockId the id of the basic block (path component) adding the obligation
[ "Add", "an", "obligation", "to", "every", "State", "in", "the", "StateSet", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java#L189-L204
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java
StateSet.deleteObligation
public void deleteObligation(final Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException { Map<ObligationSet, State> updatedStateMap = new HashMap<>(); for (Iterator<State> i = stateIterator(); i.hasNext();) { State state = i.next(); checkCircularity(state, obligation, basicBlockId); ObligationSet obligationSet = state.getObligationSet(); obligationSet.remove(obligation); if (!obligationSet.isEmpty()) { updatedStateMap.put(obligationSet, state); } } replaceMap(updatedStateMap); }
java
public void deleteObligation(final Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException { Map<ObligationSet, State> updatedStateMap = new HashMap<>(); for (Iterator<State> i = stateIterator(); i.hasNext();) { State state = i.next(); checkCircularity(state, obligation, basicBlockId); ObligationSet obligationSet = state.getObligationSet(); obligationSet.remove(obligation); if (!obligationSet.isEmpty()) { updatedStateMap.put(obligationSet, state); } } replaceMap(updatedStateMap); }
[ "public", "void", "deleteObligation", "(", "final", "Obligation", "obligation", ",", "int", "basicBlockId", ")", "throws", "ObligationAcquiredOrReleasedInLoopException", "{", "Map", "<", "ObligationSet", ",", "State", ">", "updatedStateMap", "=", "new", "HashMap", "<>...
Remove an Obligation from every State in the StateSet. @param obligation the obligation to remove @param basicBlockId the id of the basic block (path component) removing the obligation @throws ObligationAcquiredOrReleasedInLoopException
[ "Remove", "an", "Obligation", "from", "every", "State", "in", "the", "StateSet", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java#L216-L229
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java
StateSet.checkCircularity
private void checkCircularity(State state, Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException { if (state.getPath().hasComponent(basicBlockId)) { throw new ObligationAcquiredOrReleasedInLoopException(obligation); } }
java
private void checkCircularity(State state, Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException { if (state.getPath().hasComponent(basicBlockId)) { throw new ObligationAcquiredOrReleasedInLoopException(obligation); } }
[ "private", "void", "checkCircularity", "(", "State", "state", ",", "Obligation", "obligation", ",", "int", "basicBlockId", ")", "throws", "ObligationAcquiredOrReleasedInLoopException", "{", "if", "(", "state", ".", "getPath", "(", ")", ".", "hasComponent", "(", "b...
Bail out of the analysis is an obligation is acquired or released in a loop. @param state a State to which an obligation is being added or removed @param obligation the Obligation being added or removed @param basicBlockId the id of the BasicBlock adding or removing the obligation
[ "Bail", "out", "of", "the", "analysis", "is", "an", "obligation", "is", "acquired", "or", "released", "in", "a", "loop", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java#L242-L247
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java
StateSet.getPrefixStates
public List<State> getPrefixStates(Path path) { List<State> result = new LinkedList<>(); for (State state : stateMap.values()) { if (state.getPath().isPrefixOf(path)) { result.add(state); } } return result; }
java
public List<State> getPrefixStates(Path path) { List<State> result = new LinkedList<>(); for (State state : stateMap.values()) { if (state.getPath().isPrefixOf(path)) { result.add(state); } } return result; }
[ "public", "List", "<", "State", ">", "getPrefixStates", "(", "Path", "path", ")", "{", "List", "<", "State", ">", "result", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "State", "state", ":", "stateMap", ".", "values", "(", ")", ")", ...
Get all States that have Paths which are prefixes of the given Path. @param path a Path @return Collection of States that have Paths which are prefixes of the given Path
[ "Get", "all", "States", "that", "have", "Paths", "which", "are", "prefixes", "of", "the", "given", "Path", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/obl/StateSet.java#L267-L275
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/FindBugsJob.java
FindBugsJob.acquireAnalysisPermitUnlessCancelled
private static boolean acquireAnalysisPermitUnlessCancelled(IProgressMonitor monitor) throws InterruptedException { do { if (analysisSem.tryAcquire(1, TimeUnit.SECONDS)) { return true; } } while (!monitor.isCanceled()); return false; }
java
private static boolean acquireAnalysisPermitUnlessCancelled(IProgressMonitor monitor) throws InterruptedException { do { if (analysisSem.tryAcquire(1, TimeUnit.SECONDS)) { return true; } } while (!monitor.isCanceled()); return false; }
[ "private", "static", "boolean", "acquireAnalysisPermitUnlessCancelled", "(", "IProgressMonitor", "monitor", ")", "throws", "InterruptedException", "{", "do", "{", "if", "(", "analysisSem", ".", "tryAcquire", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", ")", "{"...
Acquires an analysis permit unless first cancelled. @return {@code true} if permit has been acquired, {@code false} if cancellation was observed and permit has not been acquired
[ "Acquires", "an", "analysis", "permit", "unless", "first", "cancelled", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/FindBugsJob.java#L172-L180
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java
ProjectStats.setTimestamp
public void setTimestamp(String timestamp) throws ParseException { this.analysisTimestamp = new SimpleDateFormat(TIMESTAMP_FORMAT, Locale.ENGLISH).parse(timestamp); }
java
public void setTimestamp(String timestamp) throws ParseException { this.analysisTimestamp = new SimpleDateFormat(TIMESTAMP_FORMAT, Locale.ENGLISH).parse(timestamp); }
[ "public", "void", "setTimestamp", "(", "String", "timestamp", ")", "throws", "ParseException", "{", "this", ".", "analysisTimestamp", "=", "new", "SimpleDateFormat", "(", "TIMESTAMP_FORMAT", ",", "Locale", ".", "ENGLISH", ")", ".", "parse", "(", "timestamp", ")"...
Set the timestamp for this analysis run. @param timestamp the time of the analysis run this ProjectStats represents, as previously reported by writeXML.
[ "Set", "the", "timestamp", "for", "this", "analysis", "run", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java#L161-L163
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java
ProjectStats.addBug
public void addBug(BugInstance bug) { SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation(); PackageStats stat = getPackageStats(source.getPackageName()); stat.addError(bug); ++totalErrors[0]; int priority = bug.getPriority(); if (priority >= 1) { ++totalErrors[Math.min(priority, totalErrors.length - 1)]; } }
java
public void addBug(BugInstance bug) { SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation(); PackageStats stat = getPackageStats(source.getPackageName()); stat.addError(bug); ++totalErrors[0]; int priority = bug.getPriority(); if (priority >= 1) { ++totalErrors[Math.min(priority, totalErrors.length - 1)]; } }
[ "public", "void", "addBug", "(", "BugInstance", "bug", ")", "{", "SourceLineAnnotation", "source", "=", "bug", ".", "getPrimarySourceLineAnnotation", "(", ")", ";", "PackageStats", "stat", "=", "getPackageStats", "(", "source", ".", "getPackageName", "(", ")", "...
Called when a bug is reported.
[ "Called", "when", "a", "bug", "is", "reported", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java#L268-L278
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java
ProjectStats.clearBugCounts
public void clearBugCounts() { for (int i = 0; i < totalErrors.length; i++) { totalErrors[i] = 0; } for (PackageStats stats : packageStatsMap.values()) { stats.clearBugCounts(); } }
java
public void clearBugCounts() { for (int i = 0; i < totalErrors.length; i++) { totalErrors[i] = 0; } for (PackageStats stats : packageStatsMap.values()) { stats.clearBugCounts(); } }
[ "public", "void", "clearBugCounts", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "totalErrors", ".", "length", ";", "i", "++", ")", "{", "totalErrors", "[", "i", "]", "=", "0", ";", "}", "for", "(", "PackageStats", "stats", ":"...
Clear bug counts
[ "Clear", "bug", "counts" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java#L283-L290
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java
ProjectStats.transformSummaryToHTML
public void transformSummaryToHTML(Writer htmlWriter) throws IOException, TransformerException { ByteArrayOutputStream summaryOut = new ByteArrayOutputStream(8096); reportSummary(summaryOut); StreamSource in = new StreamSource(new ByteArrayInputStream(summaryOut.toByteArray())); StreamResult out = new StreamResult(htmlWriter); InputStream xslInputStream = this.getClass().getClassLoader().getResourceAsStream("summary.xsl"); if (xslInputStream == null) { throw new IOException("Could not load summary stylesheet"); } StreamSource xsl = new StreamSource(xslInputStream); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(xsl); transformer.transform(in, out); Reader rdr = in.getReader(); if (rdr != null) { rdr.close(); } htmlWriter.close(); InputStream is = xsl.getInputStream(); if (is != null) { is.close(); } }
java
public void transformSummaryToHTML(Writer htmlWriter) throws IOException, TransformerException { ByteArrayOutputStream summaryOut = new ByteArrayOutputStream(8096); reportSummary(summaryOut); StreamSource in = new StreamSource(new ByteArrayInputStream(summaryOut.toByteArray())); StreamResult out = new StreamResult(htmlWriter); InputStream xslInputStream = this.getClass().getClassLoader().getResourceAsStream("summary.xsl"); if (xslInputStream == null) { throw new IOException("Could not load summary stylesheet"); } StreamSource xsl = new StreamSource(xslInputStream); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(xsl); transformer.transform(in, out); Reader rdr = in.getReader(); if (rdr != null) { rdr.close(); } htmlWriter.close(); InputStream is = xsl.getInputStream(); if (is != null) { is.close(); } }
[ "public", "void", "transformSummaryToHTML", "(", "Writer", "htmlWriter", ")", "throws", "IOException", ",", "TransformerException", "{", "ByteArrayOutputStream", "summaryOut", "=", "new", "ByteArrayOutputStream", "(", "8096", ")", ";", "reportSummary", "(", "summaryOut"...
Transform summary information to HTML. @param htmlWriter the Writer to write the HTML output to
[ "Transform", "summary", "information", "to", "HTML", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ProjectStats.java#L499-L525
train
spotbugs/spotbugs
spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/MainFrameTree.java
MainFrameTree.createBugPopupMenu
JPopupMenu createBugPopupMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem filterMenuItem = MainFrameHelper.newJMenuItem("menu.filterBugsLikeThis", "Filter bugs like this"); filterMenuItem.addActionListener(evt -> { new NewFilterFromBug(new FilterFromBugPicker(currentSelectedBugLeaf.getBug(), Arrays.asList(mainFrame.getAvailableSortables())), new ApplyNewFilter(mainFrame.getProject().getSuppressionFilter(), PreferencesFrame.getInstance(), new FilterActivityNotifier())); mainFrame.setProjectChanged(true); mainFrame.getTree().setSelectionRow(0); // Selects the top of the Jtree so the CommentsArea syncs up. }); popupMenu.add(filterMenuItem); return popupMenu; }
java
JPopupMenu createBugPopupMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem filterMenuItem = MainFrameHelper.newJMenuItem("menu.filterBugsLikeThis", "Filter bugs like this"); filterMenuItem.addActionListener(evt -> { new NewFilterFromBug(new FilterFromBugPicker(currentSelectedBugLeaf.getBug(), Arrays.asList(mainFrame.getAvailableSortables())), new ApplyNewFilter(mainFrame.getProject().getSuppressionFilter(), PreferencesFrame.getInstance(), new FilterActivityNotifier())); mainFrame.setProjectChanged(true); mainFrame.getTree().setSelectionRow(0); // Selects the top of the Jtree so the CommentsArea syncs up. }); popupMenu.add(filterMenuItem); return popupMenu; }
[ "JPopupMenu", "createBugPopupMenu", "(", ")", "{", "JPopupMenu", "popupMenu", "=", "new", "JPopupMenu", "(", ")", ";", "JMenuItem", "filterMenuItem", "=", "MainFrameHelper", ".", "newJMenuItem", "(", "\"menu.filterBugsLikeThis\"", ",", "\"Filter bugs like this\"", ")", ...
Creates popup menu for bugs on tree.
[ "Creates", "popup", "menu", "for", "bugs", "on", "tree", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/MainFrameTree.java#L177-L196
train
spotbugs/spotbugs
spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/MainFrameTree.java
MainFrameTree.createBranchPopUpMenu
JPopupMenu createBranchPopUpMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem filterMenuItem = MainFrameHelper.newJMenuItem("menu.filterTheseBugs", "Filter these bugs"); filterMenuItem.addActionListener(evt -> { // TODO This code does a smarter version of filtering that is // only possible for branches, and does so correctly // However, it is still somewhat of a hack, because if we ever // add more tree listeners than simply the bugtreemodel, // They will not be called by this code. Using FilterActivity to // notify all listeners will however destroy any // benefit of using the smarter deletion method. try { int startCount; TreePath path = MainFrame.getInstance().getTree().getSelectionPath(); TreePath deletePath = path; startCount = ((BugAspects) (path.getLastPathComponent())).getCount(); int count = ((BugAspects) (path.getParentPath().getLastPathComponent())).getCount(); while (count == startCount) { deletePath = deletePath.getParentPath(); if (deletePath.getParentPath() == null)// We are at the // top of the // tree, don't // let this be // removed, // rebuild tree // from root. { Matcher m1 = mainFrame.getCurrentSelectedBugAspects().getMatcher(); Filter suppressionFilter1 = MainFrame.getInstance().getProject().getSuppressionFilter(); suppressionFilter1.addChild(m1); PreferencesFrame.getInstance().updateFilterPanel(); FilterActivity.notifyListeners(FilterListener.Action.FILTERING, null); return; } count = ((BugAspects) (deletePath.getParentPath().getLastPathComponent())).getCount(); } /* * deletePath should now be a path to the highest ancestor * branch with the same number of elements as the branch to * be deleted in other words, the branch that we actually * have to remove in order to correctly remove the selected * branch. */ BugTreeModel model = MainFrame.getInstance().getBugTreeModel(); TreeModelEvent event = new TreeModelEvent(mainFrame, deletePath.getParentPath(), new int[] { model.getIndexOfChild(deletePath.getParentPath().getLastPathComponent(), deletePath.getLastPathComponent()) }, new Object[] { deletePath.getLastPathComponent() }); Matcher m2 = mainFrame.getCurrentSelectedBugAspects().getMatcher(); Filter suppressionFilter2 = MainFrame.getInstance().getProject().getSuppressionFilter(); suppressionFilter2.addChild(m2); PreferencesFrame.getInstance().updateFilterPanel(); model.sendEvent(event, BugTreeModel.TreeModification.REMOVE); // FilterActivity.notifyListeners(FilterListener.Action.FILTERING, // null); mainFrame.setProjectChanged(true); MainFrame.getInstance().getTree().setSelectionRow(0);// Selects // the // top // of // the // Jtree // so // the // CommentsArea // syncs // up. } catch (RuntimeException e) { MainFrame.getInstance().showMessageDialog("Unable to create filter: " + e.getMessage()); } }); popupMenu.add(filterMenuItem); return popupMenu; }
java
JPopupMenu createBranchPopUpMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem filterMenuItem = MainFrameHelper.newJMenuItem("menu.filterTheseBugs", "Filter these bugs"); filterMenuItem.addActionListener(evt -> { // TODO This code does a smarter version of filtering that is // only possible for branches, and does so correctly // However, it is still somewhat of a hack, because if we ever // add more tree listeners than simply the bugtreemodel, // They will not be called by this code. Using FilterActivity to // notify all listeners will however destroy any // benefit of using the smarter deletion method. try { int startCount; TreePath path = MainFrame.getInstance().getTree().getSelectionPath(); TreePath deletePath = path; startCount = ((BugAspects) (path.getLastPathComponent())).getCount(); int count = ((BugAspects) (path.getParentPath().getLastPathComponent())).getCount(); while (count == startCount) { deletePath = deletePath.getParentPath(); if (deletePath.getParentPath() == null)// We are at the // top of the // tree, don't // let this be // removed, // rebuild tree // from root. { Matcher m1 = mainFrame.getCurrentSelectedBugAspects().getMatcher(); Filter suppressionFilter1 = MainFrame.getInstance().getProject().getSuppressionFilter(); suppressionFilter1.addChild(m1); PreferencesFrame.getInstance().updateFilterPanel(); FilterActivity.notifyListeners(FilterListener.Action.FILTERING, null); return; } count = ((BugAspects) (deletePath.getParentPath().getLastPathComponent())).getCount(); } /* * deletePath should now be a path to the highest ancestor * branch with the same number of elements as the branch to * be deleted in other words, the branch that we actually * have to remove in order to correctly remove the selected * branch. */ BugTreeModel model = MainFrame.getInstance().getBugTreeModel(); TreeModelEvent event = new TreeModelEvent(mainFrame, deletePath.getParentPath(), new int[] { model.getIndexOfChild(deletePath.getParentPath().getLastPathComponent(), deletePath.getLastPathComponent()) }, new Object[] { deletePath.getLastPathComponent() }); Matcher m2 = mainFrame.getCurrentSelectedBugAspects().getMatcher(); Filter suppressionFilter2 = MainFrame.getInstance().getProject().getSuppressionFilter(); suppressionFilter2.addChild(m2); PreferencesFrame.getInstance().updateFilterPanel(); model.sendEvent(event, BugTreeModel.TreeModification.REMOVE); // FilterActivity.notifyListeners(FilterListener.Action.FILTERING, // null); mainFrame.setProjectChanged(true); MainFrame.getInstance().getTree().setSelectionRow(0);// Selects // the // top // of // the // Jtree // so // the // CommentsArea // syncs // up. } catch (RuntimeException e) { MainFrame.getInstance().showMessageDialog("Unable to create filter: " + e.getMessage()); } }); popupMenu.add(filterMenuItem); return popupMenu; }
[ "JPopupMenu", "createBranchPopUpMenu", "(", ")", "{", "JPopupMenu", "popupMenu", "=", "new", "JPopupMenu", "(", ")", ";", "JMenuItem", "filterMenuItem", "=", "MainFrameHelper", ".", "newJMenuItem", "(", "\"menu.filterTheseBugs\"", ",", "\"Filter these bugs\"", ")", ";...
Creates the branch pop up menu that ask if the user wants to hide all the bugs in that branch.
[ "Creates", "the", "branch", "pop", "up", "menu", "that", "ask", "if", "the", "user", "wants", "to", "hide", "all", "the", "bugs", "in", "that", "branch", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/MainFrameTree.java#L202-L281
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/BugAccumulator.java
BugAccumulator.accumulateBug
public void accumulateBug(BugInstance bug, SourceLineAnnotation sourceLine) { if (sourceLine == null) { throw new NullPointerException("Missing source line"); } int priority = bug.getPriority(); if (!performAccumulation) { bug.addSourceLine(sourceLine); } else { bug.setPriority(Priorities.NORMAL_PRIORITY); } lastBug = bug; lastSourceLine = sourceLine; Data d = map.get(bug); if (d == null) { String hash = bug.getInstanceHash(); BugInstance conflictingBug = hashes.get(hash); if (conflictingBug != null) { if (conflictingBug.getPriority() <= priority) { return; } map.remove(conflictingBug); } d = new Data(priority, sourceLine); map.put(bug, d); hashes.put(hash, bug); } else if (d.priority > priority) { if (d.priority >= Priorities.LOW_PRIORITY) { reportBug(bug, d); d.allSource.clear(); } d.priority = priority; d.primarySource = sourceLine; } else if (priority >= Priorities.LOW_PRIORITY && priority > d.priority) { bug.setPriority(priority); reporter.reportBug(bug); return; } d.allSource.add(sourceLine); }
java
public void accumulateBug(BugInstance bug, SourceLineAnnotation sourceLine) { if (sourceLine == null) { throw new NullPointerException("Missing source line"); } int priority = bug.getPriority(); if (!performAccumulation) { bug.addSourceLine(sourceLine); } else { bug.setPriority(Priorities.NORMAL_PRIORITY); } lastBug = bug; lastSourceLine = sourceLine; Data d = map.get(bug); if (d == null) { String hash = bug.getInstanceHash(); BugInstance conflictingBug = hashes.get(hash); if (conflictingBug != null) { if (conflictingBug.getPriority() <= priority) { return; } map.remove(conflictingBug); } d = new Data(priority, sourceLine); map.put(bug, d); hashes.put(hash, bug); } else if (d.priority > priority) { if (d.priority >= Priorities.LOW_PRIORITY) { reportBug(bug, d); d.allSource.clear(); } d.priority = priority; d.primarySource = sourceLine; } else if (priority >= Priorities.LOW_PRIORITY && priority > d.priority) { bug.setPriority(priority); reporter.reportBug(bug); return; } d.allSource.add(sourceLine); }
[ "public", "void", "accumulateBug", "(", "BugInstance", "bug", ",", "SourceLineAnnotation", "sourceLine", ")", "{", "if", "(", "sourceLine", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Missing source line\"", ")", ";", "}", "int", "pri...
Accumulate a warning at given source location. @param bug the warning @param sourceLine the source location
[ "Accumulate", "a", "warning", "at", "given", "source", "location", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/BugAccumulator.java#L109-L148
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/BugAccumulator.java
BugAccumulator.accumulateBug
public void accumulateBug(BugInstance bug, BytecodeScanningDetector visitor) { SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(visitor); accumulateBug(bug, source); }
java
public void accumulateBug(BugInstance bug, BytecodeScanningDetector visitor) { SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(visitor); accumulateBug(bug, source); }
[ "public", "void", "accumulateBug", "(", "BugInstance", "bug", ",", "BytecodeScanningDetector", "visitor", ")", "{", "SourceLineAnnotation", "source", "=", "SourceLineAnnotation", ".", "fromVisitedInstruction", "(", "visitor", ")", ";", "accumulateBug", "(", "bug", ","...
Accumulate a warning at source location currently being visited by given BytecodeScanningDetector. @param bug the warning @param visitor the BytecodeScanningDetector
[ "Accumulate", "a", "warning", "at", "source", "location", "currently", "being", "visited", "by", "given", "BytecodeScanningDetector", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/BugAccumulator.java#L159-L162
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/BugAccumulator.java
BugAccumulator.reportAccumulatedBugs
public void reportAccumulatedBugs() { for (Map.Entry<BugInstance, Data> e : map.entrySet()) { BugInstance bug = e.getKey(); Data d = e.getValue(); reportBug(bug, d); } clearBugs(); }
java
public void reportAccumulatedBugs() { for (Map.Entry<BugInstance, Data> e : map.entrySet()) { BugInstance bug = e.getKey(); Data d = e.getValue(); reportBug(bug, d); } clearBugs(); }
[ "public", "void", "reportAccumulatedBugs", "(", ")", "{", "for", "(", "Map", ".", "Entry", "<", "BugInstance", ",", "Data", ">", "e", ":", "map", ".", "entrySet", "(", ")", ")", "{", "BugInstance", "bug", "=", "e", ".", "getKey", "(", ")", ";", "Da...
Report accumulated warnings to the BugReporter. Clears all accumulated warnings as a side-effect.
[ "Report", "accumulated", "warnings", "to", "the", "BugReporter", ".", "Clears", "all", "accumulated", "warnings", "as", "a", "side", "-", "effect", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/BugAccumulator.java#L177-L184
train
spotbugs/spotbugs
spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/BugTreeModel.java
BugTreeModel.rebuild
public void rebuild() { if (TRACE) { System.out.println("rebuilding bug tree model"); } NewFilterFromBug.closeAll(); // If this thread is not interrupting a previous thread, set the paths // to be opened when the new tree is complete // If the thread is interrupting another thread, don't do this, because // you don't have the tree with the correct paths selected // As of now, it should be impossible to interrupt a rebuilding thread, // in another version this may change, so this if statement check is // left in, even though it should always be true. if (rebuildingThread == null) { setOldSelectedBugs(); } Debug.println("Please Wait called right before starting rebuild thread"); mainFrame.acquireDisplayWait(); rebuildingThread = edu.umd.cs.findbugs.util.Util.runInDameonThread(new Runnable() { BugTreeModel newModel; @Override public void run() { try { newModel = new BugTreeModel(BugTreeModel.this); newModel.listeners = listeners; newModel.resetData(); newModel.bugSet.sortList(); } finally { rebuildingThread = null; SwingUtilities.invokeLater(() -> { if (newModel != null) { JTree newTree = new JTree(newModel); newModel.tree = newTree; mainFrame.mainFrameTree.newTree(newTree, newModel); mainFrame.releaseDisplayWait(); } getOffListenerList(); }); } } }, "Rebuilding thread"); }
java
public void rebuild() { if (TRACE) { System.out.println("rebuilding bug tree model"); } NewFilterFromBug.closeAll(); // If this thread is not interrupting a previous thread, set the paths // to be opened when the new tree is complete // If the thread is interrupting another thread, don't do this, because // you don't have the tree with the correct paths selected // As of now, it should be impossible to interrupt a rebuilding thread, // in another version this may change, so this if statement check is // left in, even though it should always be true. if (rebuildingThread == null) { setOldSelectedBugs(); } Debug.println("Please Wait called right before starting rebuild thread"); mainFrame.acquireDisplayWait(); rebuildingThread = edu.umd.cs.findbugs.util.Util.runInDameonThread(new Runnable() { BugTreeModel newModel; @Override public void run() { try { newModel = new BugTreeModel(BugTreeModel.this); newModel.listeners = listeners; newModel.resetData(); newModel.bugSet.sortList(); } finally { rebuildingThread = null; SwingUtilities.invokeLater(() -> { if (newModel != null) { JTree newTree = new JTree(newModel); newModel.tree = newTree; mainFrame.mainFrameTree.newTree(newTree, newModel); mainFrame.releaseDisplayWait(); } getOffListenerList(); }); } } }, "Rebuilding thread"); }
[ "public", "void", "rebuild", "(", ")", "{", "if", "(", "TRACE", ")", "{", "System", ".", "out", ".", "println", "(", "\"rebuilding bug tree model\"", ")", ";", "}", "NewFilterFromBug", ".", "closeAll", "(", ")", ";", "// If this thread is not interrupting a prev...
Swaps in a new BugTreeModel and a new JTree
[ "Swaps", "in", "a", "new", "BugTreeModel", "and", "a", "new", "JTree" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/BugTreeModel.java#L348-L394
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierValue.java
TypeQualifierValue.getComplementaryExclusiveTypeQualifierValue
public static Collection<TypeQualifierValue<?>> getComplementaryExclusiveTypeQualifierValue(TypeQualifierValue<?> tqv) { assert tqv.isExclusiveQualifier(); LinkedList<TypeQualifierValue<?>> result = new LinkedList<>(); for (TypeQualifierValue<?> t : instance.get().allKnownTypeQualifiers) { // // Any TypeQualifierValue with the same // annotation class but a different value is a complementary // type qualifier. // if (t.typeQualifier.equals(tqv.typeQualifier) && !Objects.equals(t.value, tqv.value)) { result.add(t); } } return result; }
java
public static Collection<TypeQualifierValue<?>> getComplementaryExclusiveTypeQualifierValue(TypeQualifierValue<?> tqv) { assert tqv.isExclusiveQualifier(); LinkedList<TypeQualifierValue<?>> result = new LinkedList<>(); for (TypeQualifierValue<?> t : instance.get().allKnownTypeQualifiers) { // // Any TypeQualifierValue with the same // annotation class but a different value is a complementary // type qualifier. // if (t.typeQualifier.equals(tqv.typeQualifier) && !Objects.equals(t.value, tqv.value)) { result.add(t); } } return result; }
[ "public", "static", "Collection", "<", "TypeQualifierValue", "<", "?", ">", ">", "getComplementaryExclusiveTypeQualifierValue", "(", "TypeQualifierValue", "<", "?", ">", "tqv", ")", "{", "assert", "tqv", ".", "isExclusiveQualifier", "(", ")", ";", "LinkedList", "<...
Get the "complementary" TypeQualifierValues for given exclusive type qualifier. @param tqv a type qualifier (which must be exclusive) @return Collection of complementary exclusive type qualifiers
[ "Get", "the", "complementary", "TypeQualifierValues", "for", "given", "exclusive", "type", "qualifier", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierValue.java#L324-L341
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/BadSyntaxForRegularExpression.java
BadSyntaxForRegularExpression.getIntValue
private int getIntValue(int stackDepth, int defaultValue) { if (stack.getStackDepth() < stackDepth) { return defaultValue; } OpcodeStack.Item it = stack.getStackItem(stackDepth); Object value = it.getConstant(); if (!(value instanceof Integer)) { return defaultValue; } return ((Number) value).intValue(); }
java
private int getIntValue(int stackDepth, int defaultValue) { if (stack.getStackDepth() < stackDepth) { return defaultValue; } OpcodeStack.Item it = stack.getStackItem(stackDepth); Object value = it.getConstant(); if (!(value instanceof Integer)) { return defaultValue; } return ((Number) value).intValue(); }
[ "private", "int", "getIntValue", "(", "int", "stackDepth", ",", "int", "defaultValue", ")", "{", "if", "(", "stack", ".", "getStackDepth", "(", ")", "<", "stackDepth", ")", "{", "return", "defaultValue", ";", "}", "OpcodeStack", ".", "Item", "it", "=", "...
return an int on the stack, or 'defaultValue' if can't determine
[ "return", "an", "int", "on", "the", "stack", "or", "defaultValue", "if", "can", "t", "determine" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/BadSyntaxForRegularExpression.java#L119-L129
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/DetectorsExtensionHelper.java
DetectorsExtensionHelper.getContributedDetectors
public static synchronized SortedMap<String, String> getContributedDetectors() { if (contributedDetectors != null) { return new TreeMap<>(contributedDetectors); } TreeMap<String, String> set = new TreeMap<>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); for (IConfigurationElement configElt : registry.getConfigurationElementsFor(EXTENSION_POINT_ID)) { addContribution(set, configElt); } contributedDetectors = set; return new TreeMap<>(contributedDetectors); }
java
public static synchronized SortedMap<String, String> getContributedDetectors() { if (contributedDetectors != null) { return new TreeMap<>(contributedDetectors); } TreeMap<String, String> set = new TreeMap<>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); for (IConfigurationElement configElt : registry.getConfigurationElementsFor(EXTENSION_POINT_ID)) { addContribution(set, configElt); } contributedDetectors = set; return new TreeMap<>(contributedDetectors); }
[ "public", "static", "synchronized", "SortedMap", "<", "String", ",", "String", ">", "getContributedDetectors", "(", ")", "{", "if", "(", "contributedDetectors", "!=", "null", ")", "{", "return", "new", "TreeMap", "<>", "(", "contributedDetectors", ")", ";", "}...
key is the plugin id, value is the plugin library path
[ "key", "is", "the", "plugin", "id", "value", "is", "the", "plugin", "library", "path" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/DetectorsExtensionHelper.java#L60-L72
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/DetectorsExtensionHelper.java
DetectorsExtensionHelper.resolvePluginClassesDir
@CheckForNull private static String resolvePluginClassesDir(String bundleName, File sourceDir) { if (sourceDir.listFiles() == null) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No files in the bundle!"), "Failed to create temporary detector package for bundle " + sourceDir); return null; } String outputDir = getBuildDirectory(bundleName, sourceDir); if (outputDir.length() == 0) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No output directory in build.properties"), "No output directory in build.properties " + sourceDir); return null; } File classDir = new File(sourceDir, outputDir); if (classDir.listFiles() == null) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No files in the bundle output dir!"), "Failed to create temporary detector package for bundle " + sourceDir); return null; } File etcDir = new File(sourceDir, "etc"); if (etcDir.listFiles() == null) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No files in the bundle etc dir!"), "Failed to create temporary detector package for bundle " + sourceDir); return null; } return classDir.getAbsolutePath(); }
java
@CheckForNull private static String resolvePluginClassesDir(String bundleName, File sourceDir) { if (sourceDir.listFiles() == null) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No files in the bundle!"), "Failed to create temporary detector package for bundle " + sourceDir); return null; } String outputDir = getBuildDirectory(bundleName, sourceDir); if (outputDir.length() == 0) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No output directory in build.properties"), "No output directory in build.properties " + sourceDir); return null; } File classDir = new File(sourceDir, outputDir); if (classDir.listFiles() == null) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No files in the bundle output dir!"), "Failed to create temporary detector package for bundle " + sourceDir); return null; } File etcDir = new File(sourceDir, "etc"); if (etcDir.listFiles() == null) { FindbugsPlugin.getDefault().logException(new IllegalStateException("No files in the bundle etc dir!"), "Failed to create temporary detector package for bundle " + sourceDir); return null; } return classDir.getAbsolutePath(); }
[ "@", "CheckForNull", "private", "static", "String", "resolvePluginClassesDir", "(", "String", "bundleName", ",", "File", "sourceDir", ")", "{", "if", "(", "sourceDir", ".", "listFiles", "(", ")", "==", "null", ")", "{", "FindbugsPlugin", ".", "getDefault", "("...
Used for Eclipse instances running inside debugger. During development Eclipse plugins are just directories. The code below tries to locate plugin's "bin" directory. It doesn't work if the plugin build.properties are not existing or contain invalid content
[ "Used", "for", "Eclipse", "instances", "running", "inside", "debugger", ".", "During", "development", "Eclipse", "plugins", "are", "just", "directories", ".", "The", "code", "below", "tries", "to", "locate", "plugin", "s", "bin", "directory", ".", "It", "doesn...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/DetectorsExtensionHelper.java#L154-L183
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/LocalVariableAnnotation.java
LocalVariableAnnotation.getParameterLocalVariableAnnotation
public static LocalVariableAnnotation getParameterLocalVariableAnnotation(Method method, int local) { LocalVariableAnnotation lva = getLocalVariableAnnotation(method, local, 0, 0); if (lva.isNamed()) { lva.setDescription(LocalVariableAnnotation.PARAMETER_NAMED_ROLE); } else { lva.setDescription(LocalVariableAnnotation.PARAMETER_ROLE); } return lva; }
java
public static LocalVariableAnnotation getParameterLocalVariableAnnotation(Method method, int local) { LocalVariableAnnotation lva = getLocalVariableAnnotation(method, local, 0, 0); if (lva.isNamed()) { lva.setDescription(LocalVariableAnnotation.PARAMETER_NAMED_ROLE); } else { lva.setDescription(LocalVariableAnnotation.PARAMETER_ROLE); } return lva; }
[ "public", "static", "LocalVariableAnnotation", "getParameterLocalVariableAnnotation", "(", "Method", "method", ",", "int", "local", ")", "{", "LocalVariableAnnotation", "lva", "=", "getLocalVariableAnnotation", "(", "method", ",", "local", ",", "0", ",", "0", ")", "...
Get a local variable annotation describing a parameter. @param method a Method @param local the local variable containing the parameter @return LocalVariableAnnotation describing the parameter
[ "Get", "a", "local", "variable", "annotation", "describing", "a", "parameter", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/LocalVariableAnnotation.java#L179-L187
train
spotbugs/spotbugs
spotbugs/src/gui/main/edu/umd/cs/findbugs/sourceViewer/DocumentCharacterIterator.java
DocumentCharacterIterator.next
@Override public char next() { ++docPos; if (docPos < segmentEnd || segmentEnd >= doc.getLength()) { return text.next(); } try { doc.getText(segmentEnd, doc.getLength() - segmentEnd, text); } catch (BadLocationException e) { throw new RuntimeException(e); } segmentEnd += text.count; return text.current(); }
java
@Override public char next() { ++docPos; if (docPos < segmentEnd || segmentEnd >= doc.getLength()) { return text.next(); } try { doc.getText(segmentEnd, doc.getLength() - segmentEnd, text); } catch (BadLocationException e) { throw new RuntimeException(e); } segmentEnd += text.count; return text.current(); }
[ "@", "Override", "public", "char", "next", "(", ")", "{", "++", "docPos", ";", "if", "(", "docPos", "<", "segmentEnd", "||", "segmentEnd", ">=", "doc", ".", "getLength", "(", ")", ")", "{", "return", "text", ".", "next", "(", ")", ";", "}", "try", ...
Increments the iterator's index by one and returns the character at the new index. @return the character at the new position, or DONE if the new position is off the end
[ "Increments", "the", "iterator", "s", "index", "by", "one", "and", "returns", "the", "character", "at", "the", "new", "index", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/sourceViewer/DocumentCharacterIterator.java#L98-L111
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java
ClassNameRewriterUtil.rewriteMethodSignature
public static String rewriteMethodSignature(ClassNameRewriter classNameRewriter, String methodSignature) { if (classNameRewriter != IdentityClassNameRewriter.instance()) { SignatureParser parser = new SignatureParser(methodSignature); StringBuilder buf = new StringBuilder(); buf.append('('); for (Iterator<String> i = parser.parameterSignatureIterator(); i.hasNext();) { buf.append(rewriteSignature(classNameRewriter, i.next())); } buf.append(')'); buf.append(rewriteSignature(classNameRewriter, parser.getReturnTypeSignature())); methodSignature = buf.toString(); } return methodSignature; }
java
public static String rewriteMethodSignature(ClassNameRewriter classNameRewriter, String methodSignature) { if (classNameRewriter != IdentityClassNameRewriter.instance()) { SignatureParser parser = new SignatureParser(methodSignature); StringBuilder buf = new StringBuilder(); buf.append('('); for (Iterator<String> i = parser.parameterSignatureIterator(); i.hasNext();) { buf.append(rewriteSignature(classNameRewriter, i.next())); } buf.append(')'); buf.append(rewriteSignature(classNameRewriter, parser.getReturnTypeSignature())); methodSignature = buf.toString(); } return methodSignature; }
[ "public", "static", "String", "rewriteMethodSignature", "(", "ClassNameRewriter", "classNameRewriter", ",", "String", "methodSignature", ")", "{", "if", "(", "classNameRewriter", "!=", "IdentityClassNameRewriter", ".", "instance", "(", ")", ")", "{", "SignatureParser", ...
Rewrite a method signature. @param classNameRewriter a ClassNameRewriter @param methodSignature a method signature @return the rewritten method signature
[ "Rewrite", "a", "method", "signature", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java#L44-L62
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java
ClassNameRewriterUtil.rewriteSignature
public static String rewriteSignature(ClassNameRewriter classNameRewriter, String signature) { if (classNameRewriter != IdentityClassNameRewriter.instance() && signature.startsWith("L")) { String className = signature.substring(1, signature.length() - 1).replace('/', '.'); className = classNameRewriter.rewriteClassName(className); signature = "L" + className.replace('.', '/') + ";"; } return signature; }
java
public static String rewriteSignature(ClassNameRewriter classNameRewriter, String signature) { if (classNameRewriter != IdentityClassNameRewriter.instance() && signature.startsWith("L")) { String className = signature.substring(1, signature.length() - 1).replace('/', '.'); className = classNameRewriter.rewriteClassName(className); signature = "L" + className.replace('.', '/') + ";"; } return signature; }
[ "public", "static", "String", "rewriteSignature", "(", "ClassNameRewriter", "classNameRewriter", ",", "String", "signature", ")", "{", "if", "(", "classNameRewriter", "!=", "IdentityClassNameRewriter", ".", "instance", "(", ")", "&&", "signature", ".", "startsWith", ...
Rewrite a signature. @param classNameRewriter a ClassNameRewriter @param signature a signature (parameter, return type, or field) @return rewritten signature with class name updated if required
[ "Rewrite", "a", "signature", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java#L73-L83
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java
ClassNameRewriterUtil.convertMethodAnnotation
public static MethodAnnotation convertMethodAnnotation(ClassNameRewriter classNameRewriter, MethodAnnotation annotation) { if (classNameRewriter != IdentityClassNameRewriter.instance()) { annotation = new MethodAnnotation(classNameRewriter.rewriteClassName(annotation.getClassName()), annotation.getMethodName(), rewriteMethodSignature(classNameRewriter, annotation.getMethodSignature()), annotation.isStatic()); } return annotation; }
java
public static MethodAnnotation convertMethodAnnotation(ClassNameRewriter classNameRewriter, MethodAnnotation annotation) { if (classNameRewriter != IdentityClassNameRewriter.instance()) { annotation = new MethodAnnotation(classNameRewriter.rewriteClassName(annotation.getClassName()), annotation.getMethodName(), rewriteMethodSignature(classNameRewriter, annotation.getMethodSignature()), annotation.isStatic()); } return annotation; }
[ "public", "static", "MethodAnnotation", "convertMethodAnnotation", "(", "ClassNameRewriter", "classNameRewriter", ",", "MethodAnnotation", "annotation", ")", "{", "if", "(", "classNameRewriter", "!=", "IdentityClassNameRewriter", ".", "instance", "(", ")", ")", "{", "an...
Rewrite a MethodAnnotation to update the class name, and any class names mentioned in the method signature. @param classNameRewriter a ClassNameRewriter @param annotation a MethodAnnotation @return the possibly-rewritten MethodAnnotation
[ "Rewrite", "a", "MethodAnnotation", "to", "update", "the", "class", "name", "and", "any", "class", "names", "mentioned", "in", "the", "method", "signature", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java#L95-L103
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java
ClassNameRewriterUtil.convertFieldAnnotation
public static FieldAnnotation convertFieldAnnotation(ClassNameRewriter classNameRewriter, FieldAnnotation annotation) { if (classNameRewriter != IdentityClassNameRewriter.instance()) { annotation = new FieldAnnotation(classNameRewriter.rewriteClassName(annotation.getClassName()), annotation.getFieldName(), rewriteSignature(classNameRewriter, annotation.getFieldSignature()), annotation.isStatic()); } return annotation; }
java
public static FieldAnnotation convertFieldAnnotation(ClassNameRewriter classNameRewriter, FieldAnnotation annotation) { if (classNameRewriter != IdentityClassNameRewriter.instance()) { annotation = new FieldAnnotation(classNameRewriter.rewriteClassName(annotation.getClassName()), annotation.getFieldName(), rewriteSignature(classNameRewriter, annotation.getFieldSignature()), annotation.isStatic()); } return annotation; }
[ "public", "static", "FieldAnnotation", "convertFieldAnnotation", "(", "ClassNameRewriter", "classNameRewriter", ",", "FieldAnnotation", "annotation", ")", "{", "if", "(", "classNameRewriter", "!=", "IdentityClassNameRewriter", ".", "instance", "(", ")", ")", "{", "annot...
Rewrite a FieldAnnotation to update the class name and field signature, if needed. @param classNameRewriter a ClassNameRewriter @param annotation a FieldAnnotation @return the possibly-rewritten FieldAnnotation
[ "Rewrite", "a", "FieldAnnotation", "to", "update", "the", "class", "name", "and", "field", "signature", "if", "needed", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/model/ClassNameRewriterUtil.java#L115-L123
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/BuildInterproceduralCallGraph.java
BuildInterproceduralCallGraph.findVertex
private InterproceduralCallGraphVertex findVertex(XMethod xmethod) { InterproceduralCallGraphVertex vertex; vertex = callGraph.lookupVertex(xmethod.getMethodDescriptor()); if (vertex == null) { vertex = new InterproceduralCallGraphVertex(); vertex.setXmethod(xmethod); callGraph.addVertex(vertex); } return vertex; }
java
private InterproceduralCallGraphVertex findVertex(XMethod xmethod) { InterproceduralCallGraphVertex vertex; vertex = callGraph.lookupVertex(xmethod.getMethodDescriptor()); if (vertex == null) { vertex = new InterproceduralCallGraphVertex(); vertex.setXmethod(xmethod); callGraph.addVertex(vertex); } return vertex; }
[ "private", "InterproceduralCallGraphVertex", "findVertex", "(", "XMethod", "xmethod", ")", "{", "InterproceduralCallGraphVertex", "vertex", ";", "vertex", "=", "callGraph", ".", "lookupVertex", "(", "xmethod", ".", "getMethodDescriptor", "(", ")", ")", ";", "if", "(...
Find the InterproceduralCallGraphVertex for given XMethod. @param xmethod an XMethod @return the XMethod's InterproceduralCallGraphVertex
[ "Find", "the", "InterproceduralCallGraphVertex", "for", "given", "XMethod", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/BuildInterproceduralCallGraph.java#L102-L111
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java
Path.hasComponent
public boolean hasComponent(int blockId) { for (int i = 0; i < length; i++) { if (blockIdList[i] == blockId) { return true; } } return false; }
java
public boolean hasComponent(int blockId) { for (int i = 0; i < length; i++) { if (blockIdList[i] == blockId) { return true; } } return false; }
[ "public", "boolean", "hasComponent", "(", "int", "blockId", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "blockIdList", "[", "i", "]", "==", "blockId", ")", "{", "return", "true", ";", ...
Determine whether or not the id of the given BasicBlock appears anywhere in the path. @param blockId the id (label) of a BasicBlock @return true if the BasicBlock's id appears in the path, false if not
[ "Determine", "whether", "or", "not", "the", "id", "of", "the", "given", "BasicBlock", "appears", "anywhere", "in", "the", "path", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java#L72-L79
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java
Path.copyFrom
public void copyFrom(Path other) { grow(other.length - 1); System.arraycopy(other.blockIdList, 0, this.blockIdList, 0, other.length); this.length = other.length; this.cachedHashCode = other.cachedHashCode; }
java
public void copyFrom(Path other) { grow(other.length - 1); System.arraycopy(other.blockIdList, 0, this.blockIdList, 0, other.length); this.length = other.length; this.cachedHashCode = other.cachedHashCode; }
[ "public", "void", "copyFrom", "(", "Path", "other", ")", "{", "grow", "(", "other", ".", "length", "-", "1", ")", ";", "System", ".", "arraycopy", "(", "other", ".", "blockIdList", ",", "0", ",", "this", ".", "blockIdList", ",", "0", ",", "other", ...
Make this Path identical to the given one. @param other a Path to which this object should be made identical
[ "Make", "this", "Path", "identical", "to", "the", "given", "one", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java#L119-L124
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java
Path.acceptVisitor
public void acceptVisitor(CFG cfg, PathVisitor visitor) { if (getLength() > 0) { BasicBlock startBlock = cfg.lookupBlockByLabel(getBlockIdAt(0)); acceptVisitorStartingFromLocation(cfg, visitor, startBlock, startBlock.getFirstInstruction()); } }
java
public void acceptVisitor(CFG cfg, PathVisitor visitor) { if (getLength() > 0) { BasicBlock startBlock = cfg.lookupBlockByLabel(getBlockIdAt(0)); acceptVisitorStartingFromLocation(cfg, visitor, startBlock, startBlock.getFirstInstruction()); } }
[ "public", "void", "acceptVisitor", "(", "CFG", "cfg", ",", "PathVisitor", "visitor", ")", "{", "if", "(", "getLength", "(", ")", ">", "0", ")", "{", "BasicBlock", "startBlock", "=", "cfg", ".", "lookupBlockByLabel", "(", "getBlockIdAt", "(", "0", ")", ")...
Accept a PathVisitor. @param cfg the control flow graph @param visitor a PathVisitor
[ "Accept", "a", "PathVisitor", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java#L134-L139
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java
Path.acceptVisitorStartingFromLocation
public void acceptVisitorStartingFromLocation(CFG cfg, PathVisitor visitor, BasicBlock startBlock, InstructionHandle startHandle) { // Find the start block in the path int index; for (index = 0; index < getLength(); index++) { if (getBlockIdAt(index) == startBlock.getLabel()) { break; } } assert index < getLength(); Iterator<InstructionHandle> i = startBlock.instructionIterator(); // Position iterator at start instruction handle if (startHandle != startBlock.getFirstInstruction()) { while (i.hasNext()) { InstructionHandle handle = i.next(); if (handle.getNext() == startHandle) { break; } } } BasicBlock basicBlock = startBlock; while (true) { // visit block visitor.visitBasicBlock(basicBlock); // visit instructions in block while (i.hasNext()) { visitor.visitInstructionHandle(i.next()); } // end of path? index++; if (index >= getLength()) { break; } // visit edge BasicBlock next = cfg.lookupBlockByLabel(getBlockIdAt(index)); Edge edge = cfg.lookupEdge(basicBlock, next); assert edge != null; visitor.visitEdge(edge); // continue to next block basicBlock = next; i = basicBlock.instructionIterator(); } }
java
public void acceptVisitorStartingFromLocation(CFG cfg, PathVisitor visitor, BasicBlock startBlock, InstructionHandle startHandle) { // Find the start block in the path int index; for (index = 0; index < getLength(); index++) { if (getBlockIdAt(index) == startBlock.getLabel()) { break; } } assert index < getLength(); Iterator<InstructionHandle> i = startBlock.instructionIterator(); // Position iterator at start instruction handle if (startHandle != startBlock.getFirstInstruction()) { while (i.hasNext()) { InstructionHandle handle = i.next(); if (handle.getNext() == startHandle) { break; } } } BasicBlock basicBlock = startBlock; while (true) { // visit block visitor.visitBasicBlock(basicBlock); // visit instructions in block while (i.hasNext()) { visitor.visitInstructionHandle(i.next()); } // end of path? index++; if (index >= getLength()) { break; } // visit edge BasicBlock next = cfg.lookupBlockByLabel(getBlockIdAt(index)); Edge edge = cfg.lookupEdge(basicBlock, next); assert edge != null; visitor.visitEdge(edge); // continue to next block basicBlock = next; i = basicBlock.instructionIterator(); } }
[ "public", "void", "acceptVisitorStartingFromLocation", "(", "CFG", "cfg", ",", "PathVisitor", "visitor", ",", "BasicBlock", "startBlock", ",", "InstructionHandle", "startHandle", ")", "{", "// Find the start block in the path", "int", "index", ";", "for", "(", "index", ...
Accept a PathVisitor, starting from a given BasicBlock and InstructionHandle. @param cfg the control flow graph @param visitor a PathVisitor @param startBlock BasicBlock where traversal should start @param startHandle InstructionHandle within the start block where traversal should start
[ "Accept", "a", "PathVisitor", "starting", "from", "a", "given", "BasicBlock", "and", "InstructionHandle", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java#L155-L205
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java
Path.isPrefixOf
public boolean isPrefixOf(Path path) { if (this.getLength() > path.getLength()) { return false; } for (int i = 0; i < getLength(); i++) { if (this.getBlockIdAt(i) != path.getBlockIdAt(i)) { return false; } } return true; }
java
public boolean isPrefixOf(Path path) { if (this.getLength() > path.getLength()) { return false; } for (int i = 0; i < getLength(); i++) { if (this.getBlockIdAt(i) != path.getBlockIdAt(i)) { return false; } } return true; }
[ "public", "boolean", "isPrefixOf", "(", "Path", "path", ")", "{", "if", "(", "this", ".", "getLength", "(", ")", ">", "path", ".", "getLength", "(", ")", ")", "{", "return", "false", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "g...
Determine whether or not given Path is a prefix of this one. @param path another Path @return true if this Path is a prefix of the other Path, false otherwise
[ "Determine", "whether", "or", "not", "given", "Path", "is", "a", "prefix", "of", "this", "one", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Path.java#L214-L224
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/IsNullValueFrameModelingVisitor.java
IsNullValueFrameModelingVisitor.produce
private void produce(IsNullValue value) { IsNullValueFrame frame = getFrame(); frame.pushValue(value); newValueOnTOS(); }
java
private void produce(IsNullValue value) { IsNullValueFrame frame = getFrame(); frame.pushValue(value); newValueOnTOS(); }
[ "private", "void", "produce", "(", "IsNullValue", "value", ")", "{", "IsNullValueFrame", "frame", "=", "getFrame", "(", ")", ";", "frame", ".", "pushValue", "(", "value", ")", ";", "newValueOnTOS", "(", ")", ";", "}" ]
to produce different values in each of the control successors.
[ "to", "produce", "different", "values", "in", "each", "of", "the", "control", "successors", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/IsNullValueFrameModelingVisitor.java#L160-L164
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/IsNullValueFrameModelingVisitor.java
IsNullValueFrameModelingVisitor.handleInvoke
private void handleInvoke(InvokeInstruction obj) { if (obj instanceof INVOKEDYNAMIC) { // should not happen return; } Type returnType = obj.getReturnType(getCPG()); Location location = getLocation(); if (trackValueNumbers) { try { ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location); Set<ValueNumber> nonnullParameters = UnconditionalValueDerefAnalysis.checkAllNonNullParams(location, vnaFrame, cpg, null, null, typeDataflow); if (!nonnullParameters.isEmpty()) { IsNullValue kaboom = IsNullValue.noKaboomNonNullValue(location); IsNullValueFrame frame = getFrame(); for (ValueNumber vn : nonnullParameters) { IsNullValue knownValue = frame.getKnownValue(vn); if (knownValue != null && !knownValue.isDefinitelyNotNull()) { if (knownValue.isDefinitelyNull()) { frame.setTop(); return; } frame.setKnownValue(vn, kaboom); } for (int i = 0; i < vnaFrame.getNumSlots(); i++) { IsNullValue value = frame.getValue(i); if (vnaFrame.getValue(i).equals(vn) && !value.isDefinitelyNotNull()) { frame.setValue(i, kaboom); if (value.isDefinitelyNull()) { frame.setTop(); return; } } } } } } catch (DataflowAnalysisException e) { AnalysisContext.logError("Error looking up nonnull parameters for invoked method", e); } } // Determine if we are going to model the return value of this call. boolean modelCallReturnValue = MODEL_NONNULL_RETURN && returnType instanceof ReferenceType; if (!modelCallReturnValue) { // Normal case: Assume returned values are non-reporting non-null. handleNormalInstruction(obj); } else { // Special case: some special value is pushed on the stack for the // return value IsNullValue result = null; TypeFrame typeFrame; try { typeFrame = typeDataflow.getFactAtLocation(location); Set<XMethod> targetSet = Hierarchy2.resolveMethodCallTargets(obj, typeFrame, cpg); if (targetSet.isEmpty()) { XMethod calledMethod = XFactory.createXMethod(obj, getCPG()); result = getReturnValueNullness(calledMethod); } else { for (XMethod calledMethod : targetSet) { IsNullValue pushValue = getReturnValueNullness(calledMethod); if (result == null) { result = pushValue; } else { result = IsNullValue.merge(result, pushValue); } } } } catch (DataflowAnalysisException e) { result = IsNullValue.nonReportingNotNullValue(); } catch (ClassNotFoundException e) { result = IsNullValue.nonReportingNotNullValue(); } modelInstruction(obj, getNumWordsConsumed(obj), getNumWordsProduced(obj), result); newValueOnTOS(); } }
java
private void handleInvoke(InvokeInstruction obj) { if (obj instanceof INVOKEDYNAMIC) { // should not happen return; } Type returnType = obj.getReturnType(getCPG()); Location location = getLocation(); if (trackValueNumbers) { try { ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location); Set<ValueNumber> nonnullParameters = UnconditionalValueDerefAnalysis.checkAllNonNullParams(location, vnaFrame, cpg, null, null, typeDataflow); if (!nonnullParameters.isEmpty()) { IsNullValue kaboom = IsNullValue.noKaboomNonNullValue(location); IsNullValueFrame frame = getFrame(); for (ValueNumber vn : nonnullParameters) { IsNullValue knownValue = frame.getKnownValue(vn); if (knownValue != null && !knownValue.isDefinitelyNotNull()) { if (knownValue.isDefinitelyNull()) { frame.setTop(); return; } frame.setKnownValue(vn, kaboom); } for (int i = 0; i < vnaFrame.getNumSlots(); i++) { IsNullValue value = frame.getValue(i); if (vnaFrame.getValue(i).equals(vn) && !value.isDefinitelyNotNull()) { frame.setValue(i, kaboom); if (value.isDefinitelyNull()) { frame.setTop(); return; } } } } } } catch (DataflowAnalysisException e) { AnalysisContext.logError("Error looking up nonnull parameters for invoked method", e); } } // Determine if we are going to model the return value of this call. boolean modelCallReturnValue = MODEL_NONNULL_RETURN && returnType instanceof ReferenceType; if (!modelCallReturnValue) { // Normal case: Assume returned values are non-reporting non-null. handleNormalInstruction(obj); } else { // Special case: some special value is pushed on the stack for the // return value IsNullValue result = null; TypeFrame typeFrame; try { typeFrame = typeDataflow.getFactAtLocation(location); Set<XMethod> targetSet = Hierarchy2.resolveMethodCallTargets(obj, typeFrame, cpg); if (targetSet.isEmpty()) { XMethod calledMethod = XFactory.createXMethod(obj, getCPG()); result = getReturnValueNullness(calledMethod); } else { for (XMethod calledMethod : targetSet) { IsNullValue pushValue = getReturnValueNullness(calledMethod); if (result == null) { result = pushValue; } else { result = IsNullValue.merge(result, pushValue); } } } } catch (DataflowAnalysisException e) { result = IsNullValue.nonReportingNotNullValue(); } catch (ClassNotFoundException e) { result = IsNullValue.nonReportingNotNullValue(); } modelInstruction(obj, getNumWordsConsumed(obj), getNumWordsProduced(obj), result); newValueOnTOS(); } }
[ "private", "void", "handleInvoke", "(", "InvokeInstruction", "obj", ")", "{", "if", "(", "obj", "instanceof", "INVOKEDYNAMIC", ")", "{", "// should not happen", "return", ";", "}", "Type", "returnType", "=", "obj", ".", "getReturnType", "(", "getCPG", "(", ")"...
Handle method invocations. Generally, we want to get rid of null information following a call to a likely exception thrower or assertion.
[ "Handle", "method", "invocations", ".", "Generally", "we", "want", "to", "get", "rid", "of", "null", "information", "following", "a", "call", "to", "a", "likely", "exception", "thrower", "or", "assertion", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/IsNullValueFrameModelingVisitor.java#L176-L258
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/IsNullValueFrameModelingVisitor.java
IsNullValueFrameModelingVisitor.checkForKnownValue
private boolean checkForKnownValue(Instruction obj) { if (trackValueNumbers) { try { // See if the value number loaded here is a known value ValueNumberFrame vnaFrameAfter = vnaDataflow.getFactAfterLocation(getLocation()); if (vnaFrameAfter.isValid()) { ValueNumber tosVN = vnaFrameAfter.getTopValue(); IsNullValue knownValue = getFrame().getKnownValue(tosVN); if (knownValue != null) { // System.out.println("Produce known value!"); // The value produced by this instruction is known. // Push the known value. modelNormalInstruction(obj, getNumWordsConsumed(obj), 0); produce(knownValue); return true; } } } catch (DataflowAnalysisException e) { // Ignore... } } return false; }
java
private boolean checkForKnownValue(Instruction obj) { if (trackValueNumbers) { try { // See if the value number loaded here is a known value ValueNumberFrame vnaFrameAfter = vnaDataflow.getFactAfterLocation(getLocation()); if (vnaFrameAfter.isValid()) { ValueNumber tosVN = vnaFrameAfter.getTopValue(); IsNullValue knownValue = getFrame().getKnownValue(tosVN); if (knownValue != null) { // System.out.println("Produce known value!"); // The value produced by this instruction is known. // Push the known value. modelNormalInstruction(obj, getNumWordsConsumed(obj), 0); produce(knownValue); return true; } } } catch (DataflowAnalysisException e) { // Ignore... } } return false; }
[ "private", "boolean", "checkForKnownValue", "(", "Instruction", "obj", ")", "{", "if", "(", "trackValueNumbers", ")", "{", "try", "{", "// See if the value number loaded here is a known value", "ValueNumberFrame", "vnaFrameAfter", "=", "vnaDataflow", ".", "getFactAfterLocat...
Check given Instruction to see if it produces a known value. If so, model the instruction and return true. Otherwise, do nothing and return false. Should only be used for instructions that produce a single value on the top of the stack. @param obj the Instruction the instruction @return true if the instruction produced a known value and was modeled, false otherwise
[ "Check", "given", "Instruction", "to", "see", "if", "it", "produces", "a", "known", "value", ".", "If", "so", "model", "the", "instruction", "and", "return", "true", ".", "Otherwise", "do", "nothing", "and", "return", "false", ".", "Should", "only", "be", ...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/IsNullValueFrameModelingVisitor.java#L439-L461
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/util/Strings.java
Strings.trimComma
public static String trimComma(String s) { if (s.endsWith(",")) { s = s.substring(0, s.length() - 1); } return s; }
java
public static String trimComma(String s) { if (s.endsWith(",")) { s = s.substring(0, s.length() - 1); } return s; }
[ "public", "static", "String", "trimComma", "(", "String", "s", ")", "{", "if", "(", "s", ".", "endsWith", "(", "\",\"", ")", ")", "{", "s", "=", "s", ".", "substring", "(", "0", ",", "s", ".", "length", "(", ")", "-", "1", ")", ";", "}", "ret...
Trim trailing comma from given string. @param s a string @return the same string with trailing comma trimmed (if any)
[ "Trim", "trailing", "comma", "from", "given", "string", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/util/Strings.java#L81-L86
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/util/Strings.java
Strings.initializeUnescapePattern
public static boolean initializeUnescapePattern() { if (paternIsInitialized == true) { return true; } synchronized (unescapeInitLockObject) { if (paternIsInitialized == true) { return true; } try { unescapePattern = Pattern.compile(unicodeUnescapeMatchExpression); } catch (PatternSyntaxException pse) { /* * the pattern is compiled from a final string, so this * exception should never be thrown */ System.err.println("Imposible error: " + "static final regular expression pattern " + "failed to compile. Exception: " + pse.toString()); return false; } paternIsInitialized = true; } return true; }
java
public static boolean initializeUnescapePattern() { if (paternIsInitialized == true) { return true; } synchronized (unescapeInitLockObject) { if (paternIsInitialized == true) { return true; } try { unescapePattern = Pattern.compile(unicodeUnescapeMatchExpression); } catch (PatternSyntaxException pse) { /* * the pattern is compiled from a final string, so this * exception should never be thrown */ System.err.println("Imposible error: " + "static final regular expression pattern " + "failed to compile. Exception: " + pse.toString()); return false; } paternIsInitialized = true; } return true; }
[ "public", "static", "boolean", "initializeUnescapePattern", "(", ")", "{", "if", "(", "paternIsInitialized", "==", "true", ")", "{", "return", "true", ";", "}", "synchronized", "(", "unescapeInitLockObject", ")", "{", "if", "(", "paternIsInitialized", "==", "tru...
Initialize regular expressions used in unescaping. This method will be invoked automatically the first time a string is unescaped.
[ "Initialize", "regular", "expressions", "used", "in", "unescaping", ".", "This", "method", "will", "be", "invoked", "automatically", "the", "first", "time", "a", "string", "is", "unescaped", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/util/Strings.java#L201-L225
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java
GenericSignatureParser.getReturnTypeSignature
public String getReturnTypeSignature() { int endOfParams = signature.lastIndexOf(')'); if (endOfParams < 0) { throw new IllegalArgumentException("Bad method signature: " + signature); } return signature.substring(endOfParams + 1); }
java
public String getReturnTypeSignature() { int endOfParams = signature.lastIndexOf(')'); if (endOfParams < 0) { throw new IllegalArgumentException("Bad method signature: " + signature); } return signature.substring(endOfParams + 1); }
[ "public", "String", "getReturnTypeSignature", "(", ")", "{", "int", "endOfParams", "=", "signature", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "endOfParams", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Bad method signa...
Get the method return type signature. @return the method return type signature
[ "Get", "the", "method", "return", "type", "signature", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java#L171-L177
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java
GenericSignatureParser.getNumParameters
public int getNumParameters() { int count = 0; for (Iterator<String> i = parameterSignatureIterator(); i.hasNext();) { i.next(); ++count; } return count; }
java
public int getNumParameters() { int count = 0; for (Iterator<String> i = parameterSignatureIterator(); i.hasNext();) { i.next(); ++count; } return count; }
[ "public", "int", "getNumParameters", "(", ")", "{", "int", "count", "=", "0", ";", "for", "(", "Iterator", "<", "String", ">", "i", "=", "parameterSignatureIterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "i", ".", "next", "(...
Get the number of parameters in the signature. @return the number of parameters
[ "Get", "the", "number", "of", "parameters", "in", "the", "signature", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java#L184-L191
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java
GenericSignatureParser.compareSignatures
public static boolean compareSignatures(String plainSignature, String genericSignature) { GenericSignatureParser plainParser = new GenericSignatureParser(plainSignature); GenericSignatureParser genericParser = new GenericSignatureParser(genericSignature); return plainParser.getNumParameters() == genericParser.getNumParameters(); }
java
public static boolean compareSignatures(String plainSignature, String genericSignature) { GenericSignatureParser plainParser = new GenericSignatureParser(plainSignature); GenericSignatureParser genericParser = new GenericSignatureParser(genericSignature); return plainParser.getNumParameters() == genericParser.getNumParameters(); }
[ "public", "static", "boolean", "compareSignatures", "(", "String", "plainSignature", ",", "String", "genericSignature", ")", "{", "GenericSignatureParser", "plainParser", "=", "new", "GenericSignatureParser", "(", "plainSignature", ")", ";", "GenericSignatureParser", "gen...
Compare a plain method signature to the a generic method Signature and return true if they match
[ "Compare", "a", "plain", "method", "signature", "to", "the", "a", "generic", "method", "Signature", "and", "return", "true", "if", "they", "match" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/generic/GenericSignatureParser.java#L245-L250
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/util/ClassPathUtil.java
ClassPathUtil.findCodeBaseInClassPath
public static String findCodeBaseInClassPath(Pattern codeBaseNamePattern, String classPath) { if (classPath == null) { return null; } StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator); while (tok.hasMoreTokens()) { String t = tok.nextToken(); File f = new File(t); Matcher m = codeBaseNamePattern.matcher(f.getName()); if (m.matches()) { return t; } } return null; }
java
public static String findCodeBaseInClassPath(Pattern codeBaseNamePattern, String classPath) { if (classPath == null) { return null; } StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator); while (tok.hasMoreTokens()) { String t = tok.nextToken(); File f = new File(t); Matcher m = codeBaseNamePattern.matcher(f.getName()); if (m.matches()) { return t; } } return null; }
[ "public", "static", "String", "findCodeBaseInClassPath", "(", "Pattern", "codeBaseNamePattern", ",", "String", "classPath", ")", "{", "if", "(", "classPath", "==", "null", ")", "{", "return", "null", ";", "}", "StringTokenizer", "tok", "=", "new", "StringTokeniz...
Try to find a codebase matching the given pattern in the given class path string. @param codeBaseNamePattern pattern describing a codebase (e.g., compiled from the regex "findbugs\\.jar$") @param classPath a classpath @return full path of named codebase, or null if the codebase couldn't be found
[ "Try", "to", "find", "a", "codebase", "matching", "the", "given", "pattern", "in", "the", "given", "class", "path", "string", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/util/ClassPathUtil.java#L75-L91
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/io/IO.java
IO.skipFully
public static void skipFully(InputStream in, long bytes) throws IOException { if (bytes < 0) { throw new IllegalArgumentException("Can't skip " + bytes + " bytes"); } long remaining = bytes; while (remaining > 0) { long skipped = in.skip(remaining); if (skipped <= 0) { throw new EOFException("Reached EOF while trying to skip a total of " + bytes); } remaining -= skipped; } }
java
public static void skipFully(InputStream in, long bytes) throws IOException { if (bytes < 0) { throw new IllegalArgumentException("Can't skip " + bytes + " bytes"); } long remaining = bytes; while (remaining > 0) { long skipped = in.skip(remaining); if (skipped <= 0) { throw new EOFException("Reached EOF while trying to skip a total of " + bytes); } remaining -= skipped; } }
[ "public", "static", "void", "skipFully", "(", "InputStream", "in", ",", "long", "bytes", ")", "throws", "IOException", "{", "if", "(", "bytes", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Can't skip \"", "+", "bytes", "+", "\" byt...
Provide a skip fully method. Either skips the requested number of bytes or throws an IOException; @param in The input stream on which to perform the skip @param bytes Number of bytes to skip @throws EOFException if we reach EOF and still need to skip more bytes @throws IOException if in.skip throws an IOException
[ "Provide", "a", "skip", "fully", "method", ".", "Either", "skips", "the", "requested", "number", "of", "bytes", "or", "throws", "an", "IOException", ";" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/io/IO.java#L245-L258
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/type/ExceptionObjectType.java
ExceptionObjectType.fromExceptionSet
public static Type fromExceptionSet(ExceptionSet exceptionSet) throws ClassNotFoundException { Type commonSupertype = exceptionSet.getCommonSupertype(); if (commonSupertype.getType() != Const.T_OBJECT) { return commonSupertype; } ObjectType exceptionSupertype = (ObjectType) commonSupertype; String className = exceptionSupertype.getClassName(); if ("java.lang.Throwable".equals(className)) { return exceptionSupertype; } return new ExceptionObjectType(className, exceptionSet); }
java
public static Type fromExceptionSet(ExceptionSet exceptionSet) throws ClassNotFoundException { Type commonSupertype = exceptionSet.getCommonSupertype(); if (commonSupertype.getType() != Const.T_OBJECT) { return commonSupertype; } ObjectType exceptionSupertype = (ObjectType) commonSupertype; String className = exceptionSupertype.getClassName(); if ("java.lang.Throwable".equals(className)) { return exceptionSupertype; } return new ExceptionObjectType(className, exceptionSet); }
[ "public", "static", "Type", "fromExceptionSet", "(", "ExceptionSet", "exceptionSet", ")", "throws", "ClassNotFoundException", "{", "Type", "commonSupertype", "=", "exceptionSet", ".", "getCommonSupertype", "(", ")", ";", "if", "(", "commonSupertype", ".", "getType", ...
Initialize object from an exception set. @param exceptionSet the exception set @return a Type that is a supertype of all of the exceptions in the exception set
[ "Initialize", "object", "from", "an", "exception", "set", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/type/ExceptionObjectType.java#L60-L73
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SignatureConverter.java
SignatureConverter.parseNext
public String parseNext() { StringBuilder result = new StringBuilder(); if (signature.startsWith("[")) { int dimensions = 0; do { ++dimensions; signature = signature.substring(1); } while (signature.charAt(0) == '['); result.append(parseNext()); while (dimensions-- > 0) { result.append("[]"); } } else if (signature.startsWith("L")) { int semi = signature.indexOf(';'); if (semi < 0) { throw new IllegalStateException("missing semicolon in signature " + signature); } result.append(signature.substring(1, semi).replace('/', '.')); signature = signature.substring(semi + 1); } else { switch (signature.charAt(0)) { case 'B': result.append("byte"); break; case 'C': result.append("char"); break; case 'D': result.append("double"); break; case 'F': result.append("float"); break; case 'I': result.append("int"); break; case 'J': result.append("long"); break; case 'S': result.append("short"); break; case 'Z': result.append("boolean"); break; case 'V': result.append("void"); break; default: throw new IllegalArgumentException("bad signature " + signature); } skip(); } return result.toString(); }
java
public String parseNext() { StringBuilder result = new StringBuilder(); if (signature.startsWith("[")) { int dimensions = 0; do { ++dimensions; signature = signature.substring(1); } while (signature.charAt(0) == '['); result.append(parseNext()); while (dimensions-- > 0) { result.append("[]"); } } else if (signature.startsWith("L")) { int semi = signature.indexOf(';'); if (semi < 0) { throw new IllegalStateException("missing semicolon in signature " + signature); } result.append(signature.substring(1, semi).replace('/', '.')); signature = signature.substring(semi + 1); } else { switch (signature.charAt(0)) { case 'B': result.append("byte"); break; case 'C': result.append("char"); break; case 'D': result.append("double"); break; case 'F': result.append("float"); break; case 'I': result.append("int"); break; case 'J': result.append("long"); break; case 'S': result.append("short"); break; case 'Z': result.append("boolean"); break; case 'V': result.append("void"); break; default: throw new IllegalArgumentException("bad signature " + signature); } skip(); } return result.toString(); }
[ "public", "String", "parseNext", "(", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "signature", ".", "startsWith", "(", "\"[\"", ")", ")", "{", "int", "dimensions", "=", "0", ";", "do", "{", "++", "dimensi...
Parse a single type out of the signature, starting at the beginning of the remaining part of the signature. For example, if the first character of the remaining part is "I", then this method will return "int", and the "I" will be consumed. Arrays, reference types, and basic types are all handled. @return the parsed type string
[ "Parse", "a", "single", "type", "out", "of", "the", "signature", "starting", "at", "the", "beginning", "of", "the", "remaining", "part", "of", "the", "signature", ".", "For", "example", "if", "the", "first", "character", "of", "the", "remaining", "part", "...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SignatureConverter.java#L78-L135
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
AnalysisContext.reportMissingClass
static public void reportMissingClass(ClassNotFoundException e) { requireNonNull(e, "argument is null"); String missing = AbstractBugReporter.getMissingClassName(e); if (skipReportingMissingClass(missing)) { return; } if (!analyzingApplicationClass()) { return; } RepositoryLookupFailureCallback lookupFailureCallback = getCurrentLookupFailureCallback(); if (lookupFailureCallback != null) { lookupFailureCallback.reportMissingClass(e); } }
java
static public void reportMissingClass(ClassNotFoundException e) { requireNonNull(e, "argument is null"); String missing = AbstractBugReporter.getMissingClassName(e); if (skipReportingMissingClass(missing)) { return; } if (!analyzingApplicationClass()) { return; } RepositoryLookupFailureCallback lookupFailureCallback = getCurrentLookupFailureCallback(); if (lookupFailureCallback != null) { lookupFailureCallback.reportMissingClass(e); } }
[ "static", "public", "void", "reportMissingClass", "(", "ClassNotFoundException", "e", ")", "{", "requireNonNull", "(", "e", ",", "\"argument is null\"", ")", ";", "String", "missing", "=", "AbstractBugReporter", ".", "getMissingClassName", "(", "e", ")", ";", "if"...
file a ClassNotFoundException with the lookupFailureCallback @see #getLookupFailureCallback()
[ "file", "a", "ClassNotFoundException", "with", "the", "lookupFailureCallback" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L298-L312
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
AnalysisContext.loadInterproceduralDatabases
public final void loadInterproceduralDatabases() { loadPropertyDatabase(getFieldStoreTypeDatabase(), FieldStoreTypeDatabase.DEFAULT_FILENAME, "field store type database"); loadPropertyDatabase(getUnconditionalDerefParamDatabase(), UNCONDITIONAL_DEREF_DB_FILENAME, "unconditional param deref database"); loadPropertyDatabase(getReturnValueNullnessPropertyDatabase(), NONNULL_RETURN_DB_FILENAME, "nonnull return db database"); }
java
public final void loadInterproceduralDatabases() { loadPropertyDatabase(getFieldStoreTypeDatabase(), FieldStoreTypeDatabase.DEFAULT_FILENAME, "field store type database"); loadPropertyDatabase(getUnconditionalDerefParamDatabase(), UNCONDITIONAL_DEREF_DB_FILENAME, "unconditional param deref database"); loadPropertyDatabase(getReturnValueNullnessPropertyDatabase(), NONNULL_RETURN_DB_FILENAME, "nonnull return db database"); }
[ "public", "final", "void", "loadInterproceduralDatabases", "(", ")", "{", "loadPropertyDatabase", "(", "getFieldStoreTypeDatabase", "(", ")", ",", "FieldStoreTypeDatabase", ".", "DEFAULT_FILENAME", ",", "\"field store type database\"", ")", ";", "loadPropertyDatabase", "(",...
If possible, load interprocedural property databases.
[ "If", "possible", "load", "interprocedural", "property", "databases", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L584-L589
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
AnalysisContext.setDatabaseInputDir
public final void setDatabaseInputDir(String databaseInputDir) { if (DEBUG) { System.out.println("Setting database input directory: " + databaseInputDir); } this.databaseInputDir = databaseInputDir; }
java
public final void setDatabaseInputDir(String databaseInputDir) { if (DEBUG) { System.out.println("Setting database input directory: " + databaseInputDir); } this.databaseInputDir = databaseInputDir; }
[ "public", "final", "void", "setDatabaseInputDir", "(", "String", "databaseInputDir", ")", "{", "if", "(", "DEBUG", ")", "{", "System", ".", "out", ".", "println", "(", "\"Setting database input directory: \"", "+", "databaseInputDir", ")", ";", "}", "this", ".",...
Set the interprocedural database input directory. @param databaseInputDir the interprocedural database input directory
[ "Set", "the", "interprocedural", "database", "input", "directory", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L636-L641
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
AnalysisContext.setDatabaseOutputDir
public final void setDatabaseOutputDir(String databaseOutputDir) { if (DEBUG) { System.out.println("Setting database output directory: " + databaseOutputDir); } this.databaseOutputDir = databaseOutputDir; }
java
public final void setDatabaseOutputDir(String databaseOutputDir) { if (DEBUG) { System.out.println("Setting database output directory: " + databaseOutputDir); } this.databaseOutputDir = databaseOutputDir; }
[ "public", "final", "void", "setDatabaseOutputDir", "(", "String", "databaseOutputDir", ")", "{", "if", "(", "DEBUG", ")", "{", "System", ".", "out", ".", "println", "(", "\"Setting database output directory: \"", "+", "databaseOutputDir", ")", ";", "}", "this", ...
Set the interprocedural database output directory. @param databaseOutputDir the interprocedural database output directory
[ "Set", "the", "interprocedural", "database", "output", "directory", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L658-L663
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
AnalysisContext.storePropertyDatabase
public <DatabaseType extends PropertyDatabase<KeyType, Property>, KeyType extends FieldOrMethodDescriptor, Property> void storePropertyDatabase( DatabaseType database, String fileName, String description) { try { File dbFile = new File(getDatabaseOutputDir(), fileName); if (DEBUG) { System.out.println("Writing " + description + " to " + dbFile.getPath() + "..."); } database.writeToFile(dbFile.getPath()); } catch (IOException e) { getLookupFailureCallback().logError("Error writing " + description, e); } }
java
public <DatabaseType extends PropertyDatabase<KeyType, Property>, KeyType extends FieldOrMethodDescriptor, Property> void storePropertyDatabase( DatabaseType database, String fileName, String description) { try { File dbFile = new File(getDatabaseOutputDir(), fileName); if (DEBUG) { System.out.println("Writing " + description + " to " + dbFile.getPath() + "..."); } database.writeToFile(dbFile.getPath()); } catch (IOException e) { getLookupFailureCallback().logError("Error writing " + description, e); } }
[ "public", "<", "DatabaseType", "extends", "PropertyDatabase", "<", "KeyType", ",", "Property", ">", ",", "KeyType", "extends", "FieldOrMethodDescriptor", ",", "Property", ">", "void", "storePropertyDatabase", "(", "DatabaseType", "database", ",", "String", "fileName",...
Write an interprocedural property database. @param <DatabaseType> actual type of the database @param <KeyType> type of key (e.g., method or field) @param <Property> type of properties stored in the database @param database the database @param fileName name of database file @param description description of the database
[ "Write", "an", "interprocedural", "property", "database", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L765-L777
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
AnalysisContext.setCurrentAnalysisContext
public static void setCurrentAnalysisContext(AnalysisContext analysisContext) { currentAnalysisContext.set(analysisContext); if (Global.getAnalysisCache() != null) { currentXFactory.set(new XFactory()); } }
java
public static void setCurrentAnalysisContext(AnalysisContext analysisContext) { currentAnalysisContext.set(analysisContext); if (Global.getAnalysisCache() != null) { currentXFactory.set(new XFactory()); } }
[ "public", "static", "void", "setCurrentAnalysisContext", "(", "AnalysisContext", "analysisContext", ")", "{", "currentAnalysisContext", ".", "set", "(", "analysisContext", ")", ";", "if", "(", "Global", ".", "getAnalysisCache", "(", ")", "!=", "null", ")", "{", ...
Set the current analysis context for this thread. @param analysisContext the current analysis context for this thread
[ "Set", "the", "current", "analysis", "context", "for", "this", "thread", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L785-L790
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
AnalysisContext.getClassContext
public ClassContext getClassContext(JavaClass javaClass) { // This is a bit silly since we're doing an unnecessary // ClassDescriptor->JavaClass lookup. // However, we can be assured that it will succeed. ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor( ClassName.toSlashedClassName(javaClass.getClassName())); try { return Global.getAnalysisCache().getClassAnalysis(ClassContext.class, classDescriptor); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("Could not get ClassContext for JavaClass"); ise.initCause(e); throw ise; } }
java
public ClassContext getClassContext(JavaClass javaClass) { // This is a bit silly since we're doing an unnecessary // ClassDescriptor->JavaClass lookup. // However, we can be assured that it will succeed. ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor( ClassName.toSlashedClassName(javaClass.getClassName())); try { return Global.getAnalysisCache().getClassAnalysis(ClassContext.class, classDescriptor); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("Could not get ClassContext for JavaClass"); ise.initCause(e); throw ise; } }
[ "public", "ClassContext", "getClassContext", "(", "JavaClass", "javaClass", ")", "{", "// This is a bit silly since we're doing an unnecessary", "// ClassDescriptor->JavaClass lookup.", "// However, we can be assured that it will succeed.", "ClassDescriptor", "classDescriptor", "=", "Des...
Get the ClassContext for a class. @param javaClass the class @return the ClassContext for that class
[ "Get", "the", "ClassContext", "for", "a", "class", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L856-L871
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/BlockType.java
BlockType.copyFrom
public void copyFrom(BlockType other) { this.isValid = other.isValid; this.isTop = other.isTop; if (isValid) { this.depth = other.depth; this.clear(); this.or(other); } }
java
public void copyFrom(BlockType other) { this.isValid = other.isValid; this.isTop = other.isTop; if (isValid) { this.depth = other.depth; this.clear(); this.or(other); } }
[ "public", "void", "copyFrom", "(", "BlockType", "other", ")", "{", "this", ".", "isValid", "=", "other", ".", "isValid", ";", "this", ".", "isTop", "=", "other", ".", "isTop", ";", "if", "(", "isValid", ")", "{", "this", ".", "depth", "=", "other", ...
Make this object an exact duplicate of given object. @param other the other BlockType object
[ "Make", "this", "object", "an", "exact", "duplicate", "of", "given", "object", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/BlockType.java#L187-L195
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/BlockType.java
BlockType.sameAs
public boolean sameAs(BlockType other) { if (!this.isValid) { return !other.isValid && (this.isTop == other.isTop); } else { if (!other.isValid) { return false; } else { // Both facts are valid if (this.depth != other.depth) { return false; } // Compare bits for (int i = 0; i < this.depth; ++i) { if (this.get(i) != other.get(i)) { return false; } } return true; } } }
java
public boolean sameAs(BlockType other) { if (!this.isValid) { return !other.isValid && (this.isTop == other.isTop); } else { if (!other.isValid) { return false; } else { // Both facts are valid if (this.depth != other.depth) { return false; } // Compare bits for (int i = 0; i < this.depth; ++i) { if (this.get(i) != other.get(i)) { return false; } } return true; } } }
[ "public", "boolean", "sameAs", "(", "BlockType", "other", ")", "{", "if", "(", "!", "this", ".", "isValid", ")", "{", "return", "!", "other", ".", "isValid", "&&", "(", "this", ".", "isTop", "==", "other", ".", "isTop", ")", ";", "}", "else", "{", ...
Return whether or not this object is identical to the one given. @param other the other BlockType object @return true if this object is identical to the one given, false otherwise
[ "Return", "whether", "or", "not", "this", "object", "is", "identical", "to", "the", "one", "given", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/BlockType.java#L205-L227
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/BlockType.java
BlockType.mergeWith
public void mergeWith(BlockType other) { if (this.isTop() || other.isBottom()) { copyFrom(other); } else if (isValid()) { // To merge, we take the common prefix int pfxLen = Math.min(this.depth, other.depth); int commonLen; for (commonLen = 0; commonLen < pfxLen; ++commonLen) { if (this.get(commonLen) != other.get(commonLen)) { break; } } this.depth = commonLen; } }
java
public void mergeWith(BlockType other) { if (this.isTop() || other.isBottom()) { copyFrom(other); } else if (isValid()) { // To merge, we take the common prefix int pfxLen = Math.min(this.depth, other.depth); int commonLen; for (commonLen = 0; commonLen < pfxLen; ++commonLen) { if (this.get(commonLen) != other.get(commonLen)) { break; } } this.depth = commonLen; } }
[ "public", "void", "mergeWith", "(", "BlockType", "other", ")", "{", "if", "(", "this", ".", "isTop", "(", ")", "||", "other", ".", "isBottom", "(", ")", ")", "{", "copyFrom", "(", "other", ")", ";", "}", "else", "if", "(", "isValid", "(", ")", ")...
Merge other dataflow value into this value. @param other the other BlockType value
[ "Merge", "other", "dataflow", "value", "into", "this", "value", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/BlockType.java#L235-L249
train
spotbugs/spotbugs
eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/QuickFixesExtensionHelper.java
QuickFixesExtensionHelper.getContributedQuickFixes
public static synchronized Map<String, List<QuickFixContribution>> getContributedQuickFixes() { if (contributedQuickFixes != null) { return contributedQuickFixes; } HashMap<String, List<QuickFixContribution>> set = new HashMap<>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); for (IConfigurationElement configElt : registry.getConfigurationElementsFor(EXTENSION_POINT_ID)) { addContribution(set, configElt); } Set<Entry<String, List<QuickFixContribution>>> entrySet = set.entrySet(); for (Entry<String, List<QuickFixContribution>> entry : entrySet) { entry.setValue(Collections.unmodifiableList(entry.getValue())); } contributedQuickFixes = Collections.unmodifiableMap(set); return contributedQuickFixes; }
java
public static synchronized Map<String, List<QuickFixContribution>> getContributedQuickFixes() { if (contributedQuickFixes != null) { return contributedQuickFixes; } HashMap<String, List<QuickFixContribution>> set = new HashMap<>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); for (IConfigurationElement configElt : registry.getConfigurationElementsFor(EXTENSION_POINT_ID)) { addContribution(set, configElt); } Set<Entry<String, List<QuickFixContribution>>> entrySet = set.entrySet(); for (Entry<String, List<QuickFixContribution>> entry : entrySet) { entry.setValue(Collections.unmodifiableList(entry.getValue())); } contributedQuickFixes = Collections.unmodifiableMap(set); return contributedQuickFixes; }
[ "public", "static", "synchronized", "Map", "<", "String", ",", "List", "<", "QuickFixContribution", ">", ">", "getContributedQuickFixes", "(", ")", "{", "if", "(", "contributedQuickFixes", "!=", "null", ")", "{", "return", "contributedQuickFixes", ";", "}", "Has...
key is the pattern id, the value is the corresponding contribution
[ "key", "is", "the", "pattern", "id", "the", "value", "is", "the", "corresponding", "contribution" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/QuickFixesExtensionHelper.java#L57-L73
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.getDirectApplications
public static void getDirectApplications(Set<TypeQualifierAnnotation> result, XMethod o, int parameter) { Collection<AnnotationValue> values = getDirectAnnotation(o, parameter); for (AnnotationValue v : values) { constructTypeQualifierAnnotation(result, v); } }
java
public static void getDirectApplications(Set<TypeQualifierAnnotation> result, XMethod o, int parameter) { Collection<AnnotationValue> values = getDirectAnnotation(o, parameter); for (AnnotationValue v : values) { constructTypeQualifierAnnotation(result, v); } }
[ "public", "static", "void", "getDirectApplications", "(", "Set", "<", "TypeQualifierAnnotation", ">", "result", ",", "XMethod", "o", ",", "int", "parameter", ")", "{", "Collection", "<", "AnnotationValue", ">", "values", "=", "getDirectAnnotation", "(", "o", ","...
Populate a Set of TypeQualifierAnnotations representing directly-applied type qualifier annotations on given method parameter. @param result Set of TypeQualifierAnnotations @param o a method @param parameter a parameter (0 == first parameter)
[ "Populate", "a", "Set", "of", "TypeQualifierAnnotations", "representing", "directly", "-", "applied", "type", "qualifier", "annotations", "on", "given", "method", "parameter", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L214-L220
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.getDirectApplications
public static void getDirectApplications(Set<TypeQualifierAnnotation> result, AnnotatedObject o, ElementType e) { if (!o.getElementType().equals(e)) { return; } Collection<AnnotationValue> values = getDirectAnnotation(o); for (AnnotationValue v : values) { constructTypeQualifierAnnotation(result, v); } }
java
public static void getDirectApplications(Set<TypeQualifierAnnotation> result, AnnotatedObject o, ElementType e) { if (!o.getElementType().equals(e)) { return; } Collection<AnnotationValue> values = getDirectAnnotation(o); for (AnnotationValue v : values) { constructTypeQualifierAnnotation(result, v); } }
[ "public", "static", "void", "getDirectApplications", "(", "Set", "<", "TypeQualifierAnnotation", ">", "result", ",", "AnnotatedObject", "o", ",", "ElementType", "e", ")", "{", "if", "(", "!", "o", ".", "getElementType", "(", ")", ".", "equals", "(", "e", "...
Populate a Set of TypeQualifierAnnotations representing directly-applied type qualifier annotations on given AnnotatedObject. @param result Set of TypeQualifierAnnotations @param o an AnnotatedObject @param e ElementType representing kind of annotated object
[ "Populate", "a", "Set", "of", "TypeQualifierAnnotations", "representing", "directly", "-", "applied", "type", "qualifier", "annotations", "on", "given", "AnnotatedObject", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L233-L242
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.constructTypeQualifierAnnotation
public static TypeQualifierAnnotation constructTypeQualifierAnnotation(AnnotationValue v) { assert v != null; EnumValue whenValue = (EnumValue) v.getValue("when"); When when = whenValue == null ? When.ALWAYS : When.valueOf(whenValue.value); ClassDescriptor annotationClass = v.getAnnotationClass(); TypeQualifierValue<?> tqv = TypeQualifierValue.getValue(annotationClass, v.getValue("value")); TypeQualifierAnnotation tqa = TypeQualifierAnnotation.getValue(tqv, when); return tqa; }
java
public static TypeQualifierAnnotation constructTypeQualifierAnnotation(AnnotationValue v) { assert v != null; EnumValue whenValue = (EnumValue) v.getValue("when"); When when = whenValue == null ? When.ALWAYS : When.valueOf(whenValue.value); ClassDescriptor annotationClass = v.getAnnotationClass(); TypeQualifierValue<?> tqv = TypeQualifierValue.getValue(annotationClass, v.getValue("value")); TypeQualifierAnnotation tqa = TypeQualifierAnnotation.getValue(tqv, when); return tqa; }
[ "public", "static", "TypeQualifierAnnotation", "constructTypeQualifierAnnotation", "(", "AnnotationValue", "v", ")", "{", "assert", "v", "!=", "null", ";", "EnumValue", "whenValue", "=", "(", "EnumValue", ")", "v", ".", "getValue", "(", "\"when\"", ")", ";", "Wh...
Resolve a raw AnnotationValue into a TypeQualifierAnnotation. @param v a raw AnnotationValue @return a constructed TypeQualifierAnnotation
[ "Resolve", "a", "raw", "AnnotationValue", "into", "a", "TypeQualifierAnnotation", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L251-L259
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.constructTypeQualifierAnnotation
public static void constructTypeQualifierAnnotation(Set<TypeQualifierAnnotation> set, AnnotationValue v) { assert set != null; TypeQualifierAnnotation tqa = constructTypeQualifierAnnotation(v); set.add(tqa); }
java
public static void constructTypeQualifierAnnotation(Set<TypeQualifierAnnotation> set, AnnotationValue v) { assert set != null; TypeQualifierAnnotation tqa = constructTypeQualifierAnnotation(v); set.add(tqa); }
[ "public", "static", "void", "constructTypeQualifierAnnotation", "(", "Set", "<", "TypeQualifierAnnotation", ">", "set", ",", "AnnotationValue", "v", ")", "{", "assert", "set", "!=", "null", ";", "TypeQualifierAnnotation", "tqa", "=", "constructTypeQualifierAnnotation", ...
Resolve a raw AnnotationValue into a TypeQualifierAnnotation, storing result in given Set. @param set Set of resolved TypeQualifierAnnotations @param v a raw AnnotationValue
[ "Resolve", "a", "raw", "AnnotationValue", "into", "a", "TypeQualifierAnnotation", "storing", "result", "in", "given", "Set", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L270-L274
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.findMatchingTypeQualifierAnnotation
private static @CheckForNull TypeQualifierAnnotation findMatchingTypeQualifierAnnotation(Collection<TypeQualifierAnnotation> typeQualifierAnnotations, TypeQualifierValue<?> typeQualifierValue) { for (TypeQualifierAnnotation typeQualifierAnnotation : typeQualifierAnnotations) { if (typeQualifierAnnotation.typeQualifier.equals(typeQualifierValue)) { return typeQualifierAnnotation; } } return null; }
java
private static @CheckForNull TypeQualifierAnnotation findMatchingTypeQualifierAnnotation(Collection<TypeQualifierAnnotation> typeQualifierAnnotations, TypeQualifierValue<?> typeQualifierValue) { for (TypeQualifierAnnotation typeQualifierAnnotation : typeQualifierAnnotations) { if (typeQualifierAnnotation.typeQualifier.equals(typeQualifierValue)) { return typeQualifierAnnotation; } } return null; }
[ "private", "static", "@", "CheckForNull", "TypeQualifierAnnotation", "findMatchingTypeQualifierAnnotation", "(", "Collection", "<", "TypeQualifierAnnotation", ">", "typeQualifierAnnotations", ",", "TypeQualifierValue", "<", "?", ">", "typeQualifierValue", ")", "{", "for", "...
Look up a TypeQualifierAnnotation matching given TypeQualifierValue. @param typeQualifierAnnotations a Collection of TypeQualifierAnnotations @param typeQualifierValue a TypeQualifierValue @return matching TypeQualifierAnnotation, or null if none
[ "Look", "up", "a", "TypeQualifierAnnotation", "matching", "given", "TypeQualifierValue", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L387-L396
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.getDefaultAnnotation
private static @CheckForNull TypeQualifierAnnotation getDefaultAnnotation(AnnotatedObject o, TypeQualifierValue<?> typeQualifierValue, ElementType elementType) { // // Try to find a default annotation using the standard JSR-305 // default annotation mechanism. // TypeQualifierAnnotation result; Collection<AnnotationValue> values = TypeQualifierResolver.resolveTypeQualifierDefaults(o.getAnnotations(), elementType); TypeQualifierAnnotation tqa = extractAnnotation(values, typeQualifierValue); if (tqa != null) { // System.out.println("Found default annotation of " + tqa + // " for element " + elementType + " in " + o); return tqa; } // // Try one of the FindBugs-specific default annotation mechanisms. // if ((result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION, o, typeQualifierValue)) != null) { return result; } switch (elementType) { case FIELD: result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_FIELDS, o, typeQualifierValue); break; case METHOD: result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_METHODS, o, typeQualifierValue); break; case PARAMETER: result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_PARAMETERS, o, typeQualifierValue); break; default: // ignore break; } // Try out default JDT (Eclipse) annotations if(result == null){ AnnotationValue annotationValue = o.getAnnotation(TypeQualifierResolver.eclipseNonNullByDefault); if(annotationValue != null){ Collection<AnnotationValue> resolvedTypeQualifiers = TypeQualifierResolver.resolveTypeQualifiers(annotationValue); tqa = extractAnnotation(resolvedTypeQualifiers, typeQualifierValue); if(tqa != null){ return tqa; } } } return result; }
java
private static @CheckForNull TypeQualifierAnnotation getDefaultAnnotation(AnnotatedObject o, TypeQualifierValue<?> typeQualifierValue, ElementType elementType) { // // Try to find a default annotation using the standard JSR-305 // default annotation mechanism. // TypeQualifierAnnotation result; Collection<AnnotationValue> values = TypeQualifierResolver.resolveTypeQualifierDefaults(o.getAnnotations(), elementType); TypeQualifierAnnotation tqa = extractAnnotation(values, typeQualifierValue); if (tqa != null) { // System.out.println("Found default annotation of " + tqa + // " for element " + elementType + " in " + o); return tqa; } // // Try one of the FindBugs-specific default annotation mechanisms. // if ((result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION, o, typeQualifierValue)) != null) { return result; } switch (elementType) { case FIELD: result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_FIELDS, o, typeQualifierValue); break; case METHOD: result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_METHODS, o, typeQualifierValue); break; case PARAMETER: result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_PARAMETERS, o, typeQualifierValue); break; default: // ignore break; } // Try out default JDT (Eclipse) annotations if(result == null){ AnnotationValue annotationValue = o.getAnnotation(TypeQualifierResolver.eclipseNonNullByDefault); if(annotationValue != null){ Collection<AnnotationValue> resolvedTypeQualifiers = TypeQualifierResolver.resolveTypeQualifiers(annotationValue); tqa = extractAnnotation(resolvedTypeQualifiers, typeQualifierValue); if(tqa != null){ return tqa; } } } return result; }
[ "private", "static", "@", "CheckForNull", "TypeQualifierAnnotation", "getDefaultAnnotation", "(", "AnnotatedObject", "o", ",", "TypeQualifierValue", "<", "?", ">", "typeQualifierValue", ",", "ElementType", "elementType", ")", "{", "//", "// Try to find a default annotation ...
Look for a default type qualifier annotation. @param o an AnnotatedObject @param typeQualifierValue a TypeQualifierValue @param elementType type of element for which we're looking for a default annotation @return default TypeQualifierAnnotation, or null if none
[ "Look", "for", "a", "default", "type", "qualifier", "annotation", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L410-L464
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.getDirectTypeQualifierAnnotation
private static TypeQualifierAnnotation getDirectTypeQualifierAnnotation(AnnotatedObject o, TypeQualifierValue<?> typeQualifierValue) { TypeQualifierAnnotation result; Set<TypeQualifierAnnotation> applications = new HashSet<>(); getDirectApplications(applications, o, o.getElementType()); result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue); return result; }
java
private static TypeQualifierAnnotation getDirectTypeQualifierAnnotation(AnnotatedObject o, TypeQualifierValue<?> typeQualifierValue) { TypeQualifierAnnotation result; Set<TypeQualifierAnnotation> applications = new HashSet<>(); getDirectApplications(applications, o, o.getElementType()); result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue); return result; }
[ "private", "static", "TypeQualifierAnnotation", "getDirectTypeQualifierAnnotation", "(", "AnnotatedObject", "o", ",", "TypeQualifierValue", "<", "?", ">", "typeQualifierValue", ")", "{", "TypeQualifierAnnotation", "result", ";", "Set", "<", "TypeQualifierAnnotation", ">", ...
Get a directly-applied TypeQualifierAnnotation on given AnnotatedObject. @param o an AnnotatedObject @param typeQualifierValue the kind of TypeQualifierValue we are looking for @return directly-applied TypeQualifierAnnotation, or null if there is no such annotation on the AnnotatedObject
[ "Get", "a", "directly", "-", "applied", "TypeQualifierAnnotation", "on", "given", "AnnotatedObject", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L660-L670
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.getInheritedTypeQualifierAnnotation
public static TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod o, TypeQualifierValue<?> typeQualifierValue) { assert !o.isStatic(); ReturnTypeAnnotationAccumulator accumulator = new ReturnTypeAnnotationAccumulator(typeQualifierValue, o); try { AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypesDepthFirst(o.getClassDescriptor(), accumulator); TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation(); if (result == null && accumulator.overrides()) { return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION; } return result; } catch (ClassNotFoundException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e); return null; } }
java
public static TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod o, TypeQualifierValue<?> typeQualifierValue) { assert !o.isStatic(); ReturnTypeAnnotationAccumulator accumulator = new ReturnTypeAnnotationAccumulator(typeQualifierValue, o); try { AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypesDepthFirst(o.getClassDescriptor(), accumulator); TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation(); if (result == null && accumulator.overrides()) { return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION; } return result; } catch (ClassNotFoundException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e); return null; } }
[ "public", "static", "TypeQualifierAnnotation", "getInheritedTypeQualifierAnnotation", "(", "XMethod", "o", ",", "TypeQualifierValue", "<", "?", ">", "typeQualifierValue", ")", "{", "assert", "!", "o", ".", "isStatic", "(", ")", ";", "ReturnTypeAnnotationAccumulator", ...
Get the effective inherited TypeQualifierAnnotation on given instance method. @param o an XMethod @param typeQualifierValue the kind of TypeQualifierValue we are looking for @return effective TypeQualifierAnnotation inherited from overridden supertype methods, or null if there is no inherited TypeQualifierAnnotation
[ "Get", "the", "effective", "inherited", "TypeQualifierAnnotation", "on", "given", "instance", "method", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L684-L699
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.getDirectTypeQualifierAnnotation
public static @CheckForNull @CheckReturnValue TypeQualifierAnnotation getDirectTypeQualifierAnnotation(XMethod xmethod, int parameter, TypeQualifierValue<?> typeQualifierValue) { XMethod bridge = xmethod.bridgeTo(); if (bridge != null) { xmethod = bridge; } Set<TypeQualifierAnnotation> applications = new HashSet<>(); getDirectApplications(applications, xmethod, parameter); if (DEBUG_METHOD != null && DEBUG_METHOD.equals(xmethod.getName())) { System.out.println(" Direct applications are: " + applications); } return findMatchingTypeQualifierAnnotation(applications, typeQualifierValue); }
java
public static @CheckForNull @CheckReturnValue TypeQualifierAnnotation getDirectTypeQualifierAnnotation(XMethod xmethod, int parameter, TypeQualifierValue<?> typeQualifierValue) { XMethod bridge = xmethod.bridgeTo(); if (bridge != null) { xmethod = bridge; } Set<TypeQualifierAnnotation> applications = new HashSet<>(); getDirectApplications(applications, xmethod, parameter); if (DEBUG_METHOD != null && DEBUG_METHOD.equals(xmethod.getName())) { System.out.println(" Direct applications are: " + applications); } return findMatchingTypeQualifierAnnotation(applications, typeQualifierValue); }
[ "public", "static", "@", "CheckForNull", "@", "CheckReturnValue", "TypeQualifierAnnotation", "getDirectTypeQualifierAnnotation", "(", "XMethod", "xmethod", ",", "int", "parameter", ",", "TypeQualifierValue", "<", "?", ">", "typeQualifierValue", ")", "{", "XMethod", "bri...
Get the TypeQualifierAnnotation directly applied to given method parameter. @param xmethod a method @param parameter a parameter (0 == first parameter) @param typeQualifierValue the kind of TypeQualifierValue we are looking for @return TypeQualifierAnnotation directly applied to the parameter, or null if there is no directly applied TypeQualifierAnnotation
[ "Get", "the", "TypeQualifierAnnotation", "directly", "applied", "to", "given", "method", "parameter", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L924-L937
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java
TypeQualifierApplications.getInheritedTypeQualifierAnnotation
public static @CheckForNull TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod xmethod, int parameter, TypeQualifierValue<?> typeQualifierValue) { assert !xmethod.isStatic(); ParameterAnnotationAccumulator accumulator = new ParameterAnnotationAccumulator(typeQualifierValue, xmethod, parameter); try { AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypesDepthFirst(xmethod.getClassDescriptor(), accumulator); TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation(); if (result == null && accumulator.overrides()) { return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION; } return result; } catch (ClassNotFoundException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e); return null; } }
java
public static @CheckForNull TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod xmethod, int parameter, TypeQualifierValue<?> typeQualifierValue) { assert !xmethod.isStatic(); ParameterAnnotationAccumulator accumulator = new ParameterAnnotationAccumulator(typeQualifierValue, xmethod, parameter); try { AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypesDepthFirst(xmethod.getClassDescriptor(), accumulator); TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation(); if (result == null && accumulator.overrides()) { return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION; } return result; } catch (ClassNotFoundException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e); return null; } }
[ "public", "static", "@", "CheckForNull", "TypeQualifierAnnotation", "getInheritedTypeQualifierAnnotation", "(", "XMethod", "xmethod", ",", "int", "parameter", ",", "TypeQualifierValue", "<", "?", ">", "typeQualifierValue", ")", "{", "assert", "!", "xmethod", ".", "isS...
Get the effective inherited TypeQualifierAnnotation on the given instance method parameter. @param xmethod an instance method @param parameter a parameter (0 == first parameter) @param typeQualifierValue the kind of TypeQualifierValue we are looking for @return effective inherited TypeQualifierAnnotation on the parameter, or null if there is not effective TypeQualifierAnnotation
[ "Get", "the", "effective", "inherited", "TypeQualifierAnnotation", "on", "the", "given", "instance", "method", "parameter", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierApplications.java#L952-L969
train
spotbugs/spotbugs
spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/SorterDialog.java
SorterDialog.setSorterCheckBoxes
private void setSorterCheckBoxes() { SorterTableColumnModel sorter = MainFrame.getInstance().getSorter(); for (SortableCheckBox c : checkBoxSortList) { c.setSelected(sorter.isShown(c.sortable)); } }
java
private void setSorterCheckBoxes() { SorterTableColumnModel sorter = MainFrame.getInstance().getSorter(); for (SortableCheckBox c : checkBoxSortList) { c.setSelected(sorter.isShown(c.sortable)); } }
[ "private", "void", "setSorterCheckBoxes", "(", ")", "{", "SorterTableColumnModel", "sorter", "=", "MainFrame", ".", "getInstance", "(", ")", ".", "getSorter", "(", ")", ";", "for", "(", "SortableCheckBox", "c", ":", "checkBoxSortList", ")", "{", "c", ".", "s...
Sets the checkboxes in the sorter panel to what is shown in the MainFrame. This assumes that sorterTableColumnModel will return the list of which box is checked in the same order as the order that sorter panel has.
[ "Sets", "the", "checkboxes", "in", "the", "sorter", "panel", "to", "what", "is", "shown", "in", "the", "MainFrame", ".", "This", "assumes", "that", "sorterTableColumnModel", "will", "return", "the", "list", "of", "which", "box", "is", "checked", "in", "the",...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/SorterDialog.java#L155-L162
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java
MethodAnnotation.fromVisitedMethod
public static MethodAnnotation fromVisitedMethod(PreorderVisitor visitor) { String className = visitor.getDottedClassName(); MethodAnnotation result = new MethodAnnotation(className, visitor.getMethodName(), visitor.getMethodSig(), visitor .getMethod().isStatic()); // Try to find the source lines for the method SourceLineAnnotation srcLines = SourceLineAnnotation.fromVisitedMethod(visitor); result.setSourceLines(srcLines); return result; }
java
public static MethodAnnotation fromVisitedMethod(PreorderVisitor visitor) { String className = visitor.getDottedClassName(); MethodAnnotation result = new MethodAnnotation(className, visitor.getMethodName(), visitor.getMethodSig(), visitor .getMethod().isStatic()); // Try to find the source lines for the method SourceLineAnnotation srcLines = SourceLineAnnotation.fromVisitedMethod(visitor); result.setSourceLines(srcLines); return result; }
[ "public", "static", "MethodAnnotation", "fromVisitedMethod", "(", "PreorderVisitor", "visitor", ")", "{", "String", "className", "=", "visitor", ".", "getDottedClassName", "(", ")", ";", "MethodAnnotation", "result", "=", "new", "MethodAnnotation", "(", "className", ...
Factory method to create a MethodAnnotation from the method the given visitor is currently visiting. @param visitor the BetterVisitor currently visiting the method
[ "Factory", "method", "to", "create", "a", "MethodAnnotation", "from", "the", "method", "the", "given", "visitor", "is", "currently", "visiting", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java#L124-L134
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java
MethodAnnotation.fromCalledMethod
public static MethodAnnotation fromCalledMethod(DismantleBytecode visitor) { String className = visitor.getDottedClassConstantOperand(); String methodName = visitor.getNameConstantOperand(); String methodSig = visitor.getSigConstantOperand(); if (visitor instanceof OpcodeStackDetector && visitor.getOpcode() != Const.INVOKESTATIC) { int params = PreorderVisitor.getNumberArguments(methodSig); OpcodeStackDetector oVisitor = (OpcodeStackDetector) visitor; if (!oVisitor.getStack().isTop() && oVisitor.getStack().getStackDepth() > params) { OpcodeStack.Item item = oVisitor.getStack().getStackItem(params); String cName = ClassName.fromFieldSignature(item.getSignature()); if (cName != null) { className = cName; } } } return fromCalledMethod(className, methodName, methodSig, visitor.getOpcode() == Const.INVOKESTATIC); }
java
public static MethodAnnotation fromCalledMethod(DismantleBytecode visitor) { String className = visitor.getDottedClassConstantOperand(); String methodName = visitor.getNameConstantOperand(); String methodSig = visitor.getSigConstantOperand(); if (visitor instanceof OpcodeStackDetector && visitor.getOpcode() != Const.INVOKESTATIC) { int params = PreorderVisitor.getNumberArguments(methodSig); OpcodeStackDetector oVisitor = (OpcodeStackDetector) visitor; if (!oVisitor.getStack().isTop() && oVisitor.getStack().getStackDepth() > params) { OpcodeStack.Item item = oVisitor.getStack().getStackItem(params); String cName = ClassName.fromFieldSignature(item.getSignature()); if (cName != null) { className = cName; } } } return fromCalledMethod(className, methodName, methodSig, visitor.getOpcode() == Const.INVOKESTATIC); }
[ "public", "static", "MethodAnnotation", "fromCalledMethod", "(", "DismantleBytecode", "visitor", ")", "{", "String", "className", "=", "visitor", ".", "getDottedClassConstantOperand", "(", ")", ";", "String", "methodName", "=", "visitor", ".", "getNameConstantOperand", ...
Factory method to create a MethodAnnotation from a method called by the instruction the given visitor is currently visiting. @param visitor the visitor @return the MethodAnnotation representing the called method
[ "Factory", "method", "to", "create", "a", "MethodAnnotation", "from", "a", "method", "called", "by", "the", "instruction", "the", "given", "visitor", "is", "currently", "visiting", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java#L144-L164
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java
MethodAnnotation.fromCalledMethod
public static MethodAnnotation fromCalledMethod(String className, String methodName, String methodSig, boolean isStatic) { MethodAnnotation methodAnnotation = fromForeignMethod(className, methodName, methodSig, isStatic); methodAnnotation.setDescription(METHOD_CALLED); return methodAnnotation; }
java
public static MethodAnnotation fromCalledMethod(String className, String methodName, String methodSig, boolean isStatic) { MethodAnnotation methodAnnotation = fromForeignMethod(className, methodName, methodSig, isStatic); methodAnnotation.setDescription(METHOD_CALLED); return methodAnnotation; }
[ "public", "static", "MethodAnnotation", "fromCalledMethod", "(", "String", "className", ",", "String", "methodName", ",", "String", "methodSig", ",", "boolean", "isStatic", ")", "{", "MethodAnnotation", "methodAnnotation", "=", "fromForeignMethod", "(", "className", "...
Create a MethodAnnotation from a method that is not directly accessible. We will use the repository to try to find its class in order to populate the information as fully as possible. @param className class containing called method @param methodName name of called method @param methodSig signature of called method @param isStatic true if called method is static @return the MethodAnnotation for the called method
[ "Create", "a", "MethodAnnotation", "from", "a", "method", "that", "is", "not", "directly", "accessible", ".", "We", "will", "use", "the", "repository", "to", "try", "to", "find", "its", "class", "in", "order", "to", "populate", "the", "information", "as", ...
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java#L247-L253
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java
MethodAnnotation.fromXMethod
public static MethodAnnotation fromXMethod(XMethod xmethod) { return fromForeignMethod(xmethod.getClassName(), xmethod.getName(), xmethod.getSignature(), xmethod.isStatic()); }
java
public static MethodAnnotation fromXMethod(XMethod xmethod) { return fromForeignMethod(xmethod.getClassName(), xmethod.getName(), xmethod.getSignature(), xmethod.isStatic()); }
[ "public", "static", "MethodAnnotation", "fromXMethod", "(", "XMethod", "xmethod", ")", "{", "return", "fromForeignMethod", "(", "xmethod", ".", "getClassName", "(", ")", ",", "xmethod", ".", "getName", "(", ")", ",", "xmethod", ".", "getSignature", "(", ")", ...
Create a MethodAnnotation from an XMethod. @param xmethod the XMethod @return the MethodAnnotation
[ "Create", "a", "MethodAnnotation", "from", "an", "XMethod", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java#L262-L264
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java
MethodAnnotation.fromMethodDescriptor
public static MethodAnnotation fromMethodDescriptor(MethodDescriptor methodDescriptor) { return fromForeignMethod(methodDescriptor.getSlashedClassName(), methodDescriptor.getName(), methodDescriptor.getSignature(), methodDescriptor.isStatic()); }
java
public static MethodAnnotation fromMethodDescriptor(MethodDescriptor methodDescriptor) { return fromForeignMethod(methodDescriptor.getSlashedClassName(), methodDescriptor.getName(), methodDescriptor.getSignature(), methodDescriptor.isStatic()); }
[ "public", "static", "MethodAnnotation", "fromMethodDescriptor", "(", "MethodDescriptor", "methodDescriptor", ")", "{", "return", "fromForeignMethod", "(", "methodDescriptor", ".", "getSlashedClassName", "(", ")", ",", "methodDescriptor", ".", "getName", "(", ")", ",", ...
Create a MethodAnnotation from a MethodDescriptor. @param methodDescriptor the MethodDescriptor @return the MethodAnnotation
[ "Create", "a", "MethodAnnotation", "from", "a", "MethodDescriptor", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/MethodAnnotation.java#L273-L276
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/DiscoverSourceDirectories.java
DiscoverSourceDirectories.execute
public void execute() throws CheckedAnalysisException, IOException, InterruptedException { File dir = new File(rootSourceDirectory); if (!dir.isDirectory()) { throw new IOException("Path " + rootSourceDirectory + " is not a directory"); } // Find all directories underneath the root source directory progress.startRecursiveDirectorySearch(); RecursiveFileSearch rfs = new RecursiveFileSearch(rootSourceDirectory, pathname -> pathname.isDirectory()); rfs.search(); progress.doneRecursiveDirectorySearch(); List<String> candidateSourceDirList = rfs.getDirectoriesScanned(); // Build the classpath IClassFactory factory = ClassFactory.instance(); IClassPathBuilder builder = factory.createClassPathBuilder(errorLogger); try (IClassPath classPath = buildClassPath(builder, factory)) { // From the application classes, find the full list of // fully-qualified source file names. List<String> fullyQualifiedSourceFileNameList = findFullyQualifiedSourceFileNames(builder, classPath); // Attempt to find source directories for all source files, // and add them to the discoveredSourceDirectoryList if (DEBUG) { System.out.println("looking for " + fullyQualifiedSourceFileNameList.size() + " files"); } findSourceDirectoriesForAllSourceFiles(fullyQualifiedSourceFileNameList, candidateSourceDirList); } }
java
public void execute() throws CheckedAnalysisException, IOException, InterruptedException { File dir = new File(rootSourceDirectory); if (!dir.isDirectory()) { throw new IOException("Path " + rootSourceDirectory + " is not a directory"); } // Find all directories underneath the root source directory progress.startRecursiveDirectorySearch(); RecursiveFileSearch rfs = new RecursiveFileSearch(rootSourceDirectory, pathname -> pathname.isDirectory()); rfs.search(); progress.doneRecursiveDirectorySearch(); List<String> candidateSourceDirList = rfs.getDirectoriesScanned(); // Build the classpath IClassFactory factory = ClassFactory.instance(); IClassPathBuilder builder = factory.createClassPathBuilder(errorLogger); try (IClassPath classPath = buildClassPath(builder, factory)) { // From the application classes, find the full list of // fully-qualified source file names. List<String> fullyQualifiedSourceFileNameList = findFullyQualifiedSourceFileNames(builder, classPath); // Attempt to find source directories for all source files, // and add them to the discoveredSourceDirectoryList if (DEBUG) { System.out.println("looking for " + fullyQualifiedSourceFileNameList.size() + " files"); } findSourceDirectoriesForAllSourceFiles(fullyQualifiedSourceFileNameList, candidateSourceDirList); } }
[ "public", "void", "execute", "(", ")", "throws", "CheckedAnalysisException", ",", "IOException", ",", "InterruptedException", "{", "File", "dir", "=", "new", "File", "(", "rootSourceDirectory", ")", ";", "if", "(", "!", "dir", ".", "isDirectory", "(", ")", "...
Execute the search for source directories. @throws edu.umd.cs.findbugs.classfile.CheckedAnalysisException @throws java.io.IOException @throws java.lang.InterruptedException
[ "Execute", "the", "search", "for", "source", "directories", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/DiscoverSourceDirectories.java#L232-L263
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java
ResourceUtils.addFiles
public static void addFiles(final Project findBugsProject, File clzDir, final Pattern pat) { if (clzDir.isDirectory()) { clzDir.listFiles(new FileCollector(pat, findBugsProject)); } }
java
public static void addFiles(final Project findBugsProject, File clzDir, final Pattern pat) { if (clzDir.isDirectory()) { clzDir.listFiles(new FileCollector(pat, findBugsProject)); } }
[ "public", "static", "void", "addFiles", "(", "final", "Project", "findBugsProject", ",", "File", "clzDir", ",", "final", "Pattern", "pat", ")", "{", "if", "(", "clzDir", ".", "isDirectory", "(", ")", ")", "{", "clzDir", ".", "listFiles", "(", "new", "Fil...
recurse add all the files matching given name pattern inside the given directory and all subdirectories
[ "recurse", "add", "all", "the", "files", "matching", "given", "name", "pattern", "inside", "the", "given", "directory", "and", "all", "subdirectories" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java#L107-L111
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java
ResourceUtils.mapResource
private static void mapResource(WorkItem resource, Map<IProject, List<WorkItem>> projectsMap, boolean checkJavaProject) { IProject project = resource.getProject(); if (checkJavaProject && !ProjectUtilities.isJavaProject(project)) { // non java projects: can happen only for changesets return; } List<WorkItem> resources = projectsMap.get(project); if (resources == null) { resources = new ArrayList<>(); projectsMap.put(project, resources); } // do not need to check for duplicates, cause user cannot select // the same element twice if (!containsParents(resources, resource)) { resources.add(resource); } }
java
private static void mapResource(WorkItem resource, Map<IProject, List<WorkItem>> projectsMap, boolean checkJavaProject) { IProject project = resource.getProject(); if (checkJavaProject && !ProjectUtilities.isJavaProject(project)) { // non java projects: can happen only for changesets return; } List<WorkItem> resources = projectsMap.get(project); if (resources == null) { resources = new ArrayList<>(); projectsMap.put(project, resources); } // do not need to check for duplicates, cause user cannot select // the same element twice if (!containsParents(resources, resource)) { resources.add(resource); } }
[ "private", "static", "void", "mapResource", "(", "WorkItem", "resource", ",", "Map", "<", "IProject", ",", "List", "<", "WorkItem", ">", ">", "projectsMap", ",", "boolean", "checkJavaProject", ")", "{", "IProject", "project", "=", "resource", ".", "getProject"...
Maps the resource into its project @param resource @param projectsMap
[ "Maps", "the", "resource", "into", "its", "project" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java#L257-L274
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java
ResourceUtils.getResources
@SuppressWarnings("restriction") public static List<WorkItem> getResources(ChangeSet set) { if (set != null && !set.isEmpty()) { IResource[] resources = set.getResources(); List<WorkItem> filtered = new ArrayList<>(); for (IResource resource : resources) { if (resource.getType() == IResource.FILE && !Util.isJavaArtifact(resource)) { // Ignore non java files continue; } if (resource.exists()) { // add only resources which are NOT deleted filtered.add(new WorkItem(resource)); } } return filtered; } return EMPTY; }
java
@SuppressWarnings("restriction") public static List<WorkItem> getResources(ChangeSet set) { if (set != null && !set.isEmpty()) { IResource[] resources = set.getResources(); List<WorkItem> filtered = new ArrayList<>(); for (IResource resource : resources) { if (resource.getType() == IResource.FILE && !Util.isJavaArtifact(resource)) { // Ignore non java files continue; } if (resource.exists()) { // add only resources which are NOT deleted filtered.add(new WorkItem(resource)); } } return filtered; } return EMPTY; }
[ "@", "SuppressWarnings", "(", "\"restriction\"", ")", "public", "static", "List", "<", "WorkItem", ">", "getResources", "(", "ChangeSet", "set", ")", "{", "if", "(", "set", "!=", "null", "&&", "!", "set", ".", "isEmpty", "(", ")", ")", "{", "IResource", ...
Extracts only files from a change set @param set @return
[ "Extracts", "only", "files", "from", "a", "change", "set" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java#L282-L300
train
spotbugs/spotbugs
eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java
ResourceUtils.getResource
@javax.annotation.CheckForNull public static IResource getResource(Object element) { if (element instanceof IJavaElement) { return ((IJavaElement) element).getResource(); } return Util.getAdapter(IResource.class, element); }
java
@javax.annotation.CheckForNull public static IResource getResource(Object element) { if (element instanceof IJavaElement) { return ((IJavaElement) element).getResource(); } return Util.getAdapter(IResource.class, element); }
[ "@", "javax", ".", "annotation", ".", "CheckForNull", "public", "static", "IResource", "getResource", "(", "Object", "element", ")", "{", "if", "(", "element", "instanceof", "IJavaElement", ")", "{", "return", "(", "(", "IJavaElement", ")", "element", ")", "...
Convenient method to get resources from adaptables @param element an IAdaptable object which may provide an adapter for IResource @return resource object or null
[ "Convenient", "method", "to", "get", "resources", "from", "adaptables" ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/builder/ResourceUtils.java#L378-L385
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/TypeQualifierNullnessAnnotationDatabase.java
TypeQualifierNullnessAnnotationDatabase.getNullnessAnnotationClassDescriptor
private ClassDescriptor getNullnessAnnotationClassDescriptor(NullnessAnnotation n) { if (n == NullnessAnnotation.CHECK_FOR_NULL) { return JSR305NullnessAnnotations.CHECK_FOR_NULL; } else if (n == NullnessAnnotation.NONNULL) { return JSR305NullnessAnnotations.NONNULL; } else if (n == NullnessAnnotation.NULLABLE) { return JSR305NullnessAnnotations.NULLABLE; } else if (n == NullnessAnnotation.UNKNOWN_NULLNESS) { return JSR305NullnessAnnotations.NULLABLE; } else { throw new IllegalArgumentException("Unknown NullnessAnnotation: " + n); } }
java
private ClassDescriptor getNullnessAnnotationClassDescriptor(NullnessAnnotation n) { if (n == NullnessAnnotation.CHECK_FOR_NULL) { return JSR305NullnessAnnotations.CHECK_FOR_NULL; } else if (n == NullnessAnnotation.NONNULL) { return JSR305NullnessAnnotations.NONNULL; } else if (n == NullnessAnnotation.NULLABLE) { return JSR305NullnessAnnotations.NULLABLE; } else if (n == NullnessAnnotation.UNKNOWN_NULLNESS) { return JSR305NullnessAnnotations.NULLABLE; } else { throw new IllegalArgumentException("Unknown NullnessAnnotation: " + n); } }
[ "private", "ClassDescriptor", "getNullnessAnnotationClassDescriptor", "(", "NullnessAnnotation", "n", ")", "{", "if", "(", "n", "==", "NullnessAnnotation", ".", "CHECK_FOR_NULL", ")", "{", "return", "JSR305NullnessAnnotations", ".", "CHECK_FOR_NULL", ";", "}", "else", ...
Convert a NullnessAnnotation into the ClassDescriptor of the equivalent JSR-305 nullness type qualifier. @param n a NullnessAnnotation @return ClassDescriptor of the equivalent JSR-305 nullness type qualifier
[ "Convert", "a", "NullnessAnnotation", "into", "the", "ClassDescriptor", "of", "the", "equivalent", "JSR", "-", "305", "nullness", "type", "qualifier", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/npe/TypeQualifierNullnessAnnotationDatabase.java#L222-L234
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java
SortedBugCollection.addAll
public void addAll(Collection<BugInstance> collection, boolean updateActiveTime) { for (BugInstance warning : collection) { add(warning, updateActiveTime); } }
java
public void addAll(Collection<BugInstance> collection, boolean updateActiveTime) { for (BugInstance warning : collection) { add(warning, updateActiveTime); } }
[ "public", "void", "addAll", "(", "Collection", "<", "BugInstance", ">", "collection", ",", "boolean", "updateActiveTime", ")", "{", "for", "(", "BugInstance", "warning", ":", "collection", ")", "{", "add", "(", "warning", ",", "updateActiveTime", ")", ";", "...
Add a Collection of BugInstances to this BugCollection object. @param collection the Collection of BugInstances to add @param updateActiveTime true if active time of added BugInstances should be updated to match collection: false if not
[ "Add", "a", "Collection", "of", "BugInstances", "to", "this", "BugCollection", "object", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java#L207-L211
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java
SortedBugCollection.getCurrentAppVersion
@Override public AppVersion getCurrentAppVersion() { return new AppVersion(getSequenceNumber()).setReleaseName(getReleaseName()).setTimestamp(getTimestamp()) .setNumClasses(getProjectStats().getNumClasses()).setCodeSize(getProjectStats().getCodeSize()); }
java
@Override public AppVersion getCurrentAppVersion() { return new AppVersion(getSequenceNumber()).setReleaseName(getReleaseName()).setTimestamp(getTimestamp()) .setNumClasses(getProjectStats().getNumClasses()).setCodeSize(getProjectStats().getCodeSize()); }
[ "@", "Override", "public", "AppVersion", "getCurrentAppVersion", "(", ")", "{", "return", "new", "AppVersion", "(", "getSequenceNumber", "(", ")", ")", ".", "setReleaseName", "(", "getReleaseName", "(", ")", ")", ".", "setTimestamp", "(", "getTimestamp", "(", ...
Get the current AppVersion.
[ "Get", "the", "current", "AppVersion", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java#L242-L246
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java
SortedBugCollection.readXML
public void readXML(File file) throws IOException, DocumentException { project.setCurrentWorkingDirectory(file.getParentFile()); dataSource = file.getAbsolutePath(); InputStream in = progessMonitoredInputStream(file, "Loading analysis"); try { readXML(in, file); } catch (IOException e) { throw newIOException(file, e); } catch (DocumentException e) { throw new DocumentException("Failing reading " + file, e); } }
java
public void readXML(File file) throws IOException, DocumentException { project.setCurrentWorkingDirectory(file.getParentFile()); dataSource = file.getAbsolutePath(); InputStream in = progessMonitoredInputStream(file, "Loading analysis"); try { readXML(in, file); } catch (IOException e) { throw newIOException(file, e); } catch (DocumentException e) { throw new DocumentException("Failing reading " + file, e); } }
[ "public", "void", "readXML", "(", "File", "file", ")", "throws", "IOException", ",", "DocumentException", "{", "project", ".", "setCurrentWorkingDirectory", "(", "file", ".", "getParentFile", "(", ")", ")", ";", "dataSource", "=", "file", ".", "getAbsolutePath",...
Read XML data from given file into this object, populating given Project as a side effect. @param file the file
[ "Read", "XML", "data", "from", "given", "file", "into", "this", "object", "populating", "given", "Project", "as", "a", "side", "effect", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java#L267-L278
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java
SortedBugCollection.toDocument
@Override public Document toDocument() { // if (project == null) throw new NullPointerException("No project"); assert project != null; DocumentFactory docFactory = new DocumentFactory(); Document document = docFactory.createDocument(); Dom4JXMLOutput treeBuilder = new Dom4JXMLOutput(document); try { writeXML(treeBuilder); } catch (IOException e) { // Can't happen } return document; }
java
@Override public Document toDocument() { // if (project == null) throw new NullPointerException("No project"); assert project != null; DocumentFactory docFactory = new DocumentFactory(); Document document = docFactory.createDocument(); Dom4JXMLOutput treeBuilder = new Dom4JXMLOutput(document); try { writeXML(treeBuilder); } catch (IOException e) { // Can't happen } return document; }
[ "@", "Override", "public", "Document", "toDocument", "(", ")", "{", "// if (project == null) throw new NullPointerException(\"No project\");", "assert", "project", "!=", "null", ";", "DocumentFactory", "docFactory", "=", "new", "DocumentFactory", "(", ")", ";", "Document"...
Convert the BugCollection into a dom4j Document object. @return the Document representing the BugCollection as a dom4j tree
[ "Convert", "the", "BugCollection", "into", "a", "dom4j", "Document", "object", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java#L423-L438
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java
SortedBugCollection.cloneAll
public static void cloneAll(Collection<BugInstance> dest, Collection<BugInstance> source) { for (BugInstance obj : source) { dest.add((BugInstance) obj.clone()); } }
java
public static void cloneAll(Collection<BugInstance> dest, Collection<BugInstance> source) { for (BugInstance obj : source) { dest.add((BugInstance) obj.clone()); } }
[ "public", "static", "void", "cloneAll", "(", "Collection", "<", "BugInstance", ">", "dest", ",", "Collection", "<", "BugInstance", ">", "source", ")", "{", "for", "(", "BugInstance", "obj", ":", "source", ")", "{", "dest", ".", "add", "(", "(", "BugInsta...
Clone all of the BugInstance objects in the source Collection and add them to the destination Collection. @param dest the destination Collection @param source the source Collection
[ "Clone", "all", "of", "the", "BugInstance", "objects", "in", "the", "source", "Collection", "and", "add", "them", "to", "the", "destination", "Collection", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java#L813-L817
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/BugAnnotationUtil.java
BugAnnotationUtil.writeXML
public static void writeXML(XMLOutput xmlOutput, String elementName, BugAnnotation annotation, XMLAttributeList attributeList, boolean addMessages) throws IOException { SourceLineAnnotation src = null; if (annotation instanceof BugAnnotationWithSourceLines) { src = ((BugAnnotationWithSourceLines) annotation).getSourceLines(); } if (addMessages || src != null) { xmlOutput.openTag(elementName, attributeList); if (src != null) { src.writeXML(xmlOutput, addMessages, false); } if (addMessages) { xmlOutput.openTag(BugAnnotation.MESSAGE_TAG); xmlOutput.writeText(annotation.toString()); xmlOutput.closeTag(BugAnnotation.MESSAGE_TAG); } xmlOutput.closeTag(elementName); } else { xmlOutput.openCloseTag(elementName, attributeList); } }
java
public static void writeXML(XMLOutput xmlOutput, String elementName, BugAnnotation annotation, XMLAttributeList attributeList, boolean addMessages) throws IOException { SourceLineAnnotation src = null; if (annotation instanceof BugAnnotationWithSourceLines) { src = ((BugAnnotationWithSourceLines) annotation).getSourceLines(); } if (addMessages || src != null) { xmlOutput.openTag(elementName, attributeList); if (src != null) { src.writeXML(xmlOutput, addMessages, false); } if (addMessages) { xmlOutput.openTag(BugAnnotation.MESSAGE_TAG); xmlOutput.writeText(annotation.toString()); xmlOutput.closeTag(BugAnnotation.MESSAGE_TAG); } xmlOutput.closeTag(elementName); } else { xmlOutput.openCloseTag(elementName, attributeList); } }
[ "public", "static", "void", "writeXML", "(", "XMLOutput", "xmlOutput", ",", "String", "elementName", ",", "BugAnnotation", "annotation", ",", "XMLAttributeList", "attributeList", ",", "boolean", "addMessages", ")", "throws", "IOException", "{", "SourceLineAnnotation", ...
Write a BugAnnotation as XML. @param xmlOutput the XMLOutput @param elementName name of element for BugAnnotation @param annotation the BugAnnotation @param attributeList the XML attribute list @param addMessages true if descriptive messages should be added @throws IOException
[ "Write", "a", "BugAnnotation", "as", "XML", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/BugAnnotationUtil.java#L47-L70
train
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/InnerClassAccessMap.java
InnerClassAccessMap.getInnerClassAccess
public InnerClassAccess getInnerClassAccess(String className, String methodName) throws ClassNotFoundException { Map<String, InnerClassAccess> map = getAccessMapForClass(className); return map.get(methodName); }
java
public InnerClassAccess getInnerClassAccess(String className, String methodName) throws ClassNotFoundException { Map<String, InnerClassAccess> map = getAccessMapForClass(className); return map.get(methodName); }
[ "public", "InnerClassAccess", "getInnerClassAccess", "(", "String", "className", ",", "String", "methodName", ")", "throws", "ClassNotFoundException", "{", "Map", "<", "String", ",", "InnerClassAccess", ">", "map", "=", "getAccessMapForClass", "(", "className", ")", ...
Get the InnerClassAccess in given class with the given method name. @param className the name of the class @param methodName the name of the access method @return the InnerClassAccess object for the method, or null if the method doesn't seem to be an inner class access
[ "Get", "the", "InnerClassAccess", "in", "given", "class", "with", "the", "given", "method", "name", "." ]
f6365c6eea6515035bded38efa4a7c8b46ccf28c
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/InnerClassAccessMap.java#L93-L96
train