private static <T> T extractBugAnnotation(BugInstance bugInstance, Class<T> annotationType) { for (BugAnnotation annotation : bugInstance.getAnnotations()) { if (annotation.getClass().equals(annotationType)) { return annotationType.cast(annotation); } } return null; }
boolean mightBeLaterCheckedUsingEquals(WarningWithProperties warning) { for (BugAnnotation a : warning.instance.getAnnotations()) { if (a instanceof TypeAnnotation) { String signature = ((TypeAnnotation) a).getTypeDescriptor(); Integer pc = comparedForEqualityInThisMethod.get(signature); if (pc != null && pc > warning.location.getHandle().getPosition()) { return true; } } } return false; }
@Override public boolean match(BugInstance bugInstance) { ClassAnnotation classAnnotation = bugInstance.getPrimaryClass(); if (role != null && !"".equals(role)) { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof ClassAnnotation && role.equals(a.getDescription())) { classAnnotation = (ClassAnnotation) a; break; } } } String bugClassName = classAnnotation.getClassName(); boolean result = className.match(bugClassName); if (DEBUG) { System.out.println("Matching " + bugClassName + " with " + className + ", result = " + result); } return result; }
@Override public boolean match(BugInstance bugInstance) { TypeAnnotation typeAnnotation = bugInstance.getPrimaryType(); if (role != null && !"".equals(role)) { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof TypeAnnotation && role.equals(a.getDescription())) { typeAnnotation = (TypeAnnotation) a; break; } } } if(typeAnnotation == null){ return false; } String typeDesctiptor = typeAnnotation.getTypeDescriptor(); if(!descriptor.match(typeDesctiptor)){ return false; } if (typeParameters != null && !typeParameters.equals(typeAnnotation.getTypeParameters())) { return false; } return true; }
@Override public boolean match(BugInstance bugInstance) { FieldAnnotation fieldAnnotation = null; if (role == null || "".equals(role)) { fieldAnnotation = bugInstance.getPrimaryField(); } else { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof FieldAnnotation && role.equals(a.getDescription())) { fieldAnnotation = (FieldAnnotation) a; break; } } } if (fieldAnnotation == null) { return false; } if (!name.match(fieldAnnotation.getFieldName())) { return false; } if (signature != null && !signature.match(fieldAnnotation.getFieldSignature())) { return false; } return true; }
/** * Returns a printable String concatenating bug locations. */ private static String getBugsLocations(List<BugInstance> unexpectedBugs) { StringBuilder message = new StringBuilder(); for (BugInstance bugInstance : unexpectedBugs) { message.append("\n"); if (bugInstance.getBugPattern().getType().equals(FB_MISSING_EXPECTED_WARNING)) { message.append("missing "); } else { message.append("unexpected "); } StringAnnotation pattern = (StringAnnotation) bugInstance.getAnnotations().get(2); message.append(pattern.getValue()); message.append(" "); message.append(bugInstance.getPrimarySourceLineAnnotation()); } return message.toString(); }
@Override public boolean match(BugInstance bugInstance) { MethodAnnotation methodAnnotation = null; if (role == null || "".equals(role)) { methodAnnotation = bugInstance.getPrimaryMethod(); } else { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof MethodAnnotation && role.equals(a.getDescription())) { methodAnnotation = (MethodAnnotation) a; break; } } } if (methodAnnotation == null) { return false; } if (!name.match(methodAnnotation.getMethodName())) { return false; } if (signature != null && !signature.match(methodAnnotation.getMethodSignature())) { return false; } return true; }
for (BugAnnotation b : getAnnotations()) { if (primaryAnnotations.contains(b)) { continue;
for (BugAnnotation a : b.getAnnotations()) { a.accept(visitor);
private static <T> T extractBugAnnotation(BugInstance bugInstance, Class<T> annotationType) { for (BugAnnotation annotation : bugInstance.getAnnotations()) { if (annotation.getClass().equals(annotationType)) { return annotationType.cast(annotation); } } return null; }
private <T> T extractBugAnnotation(BugInstance bugInstance, Class<T> annotationType) { for (BugAnnotation annotation : bugInstance.getAnnotations()) { if (annotation.getClass().equals(annotationType)) { return (T) annotation; } } return null; }
boolean mightBeLaterCheckedUsingEquals(WarningWithProperties warning) { for (BugAnnotation a : warning.instance.getAnnotations()) { if (a instanceof TypeAnnotation) { String signature = ((TypeAnnotation) a).getTypeDescriptor(); Integer pc = comparedForEqualityInThisMethod.get(signature); if (pc != null && pc > warning.location.getHandle().getPosition()) { return true; } } } return false; }
@Override public boolean match(BugInstance bugInstance) { ClassAnnotation classAnnotation = bugInstance.getPrimaryClass(); if (role != null && !"".equals(role)) { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof ClassAnnotation && role.equals(a.getDescription())) { classAnnotation = (ClassAnnotation) a; break; } } } String bugClassName = classAnnotation.getClassName(); boolean result = className.match(bugClassName); if (DEBUG) { System.out.println("Matching " + bugClassName + " with " + className + ", result = " + result); } return result; }
ClassAnnotation primaryClass = b.getPrimaryClass(); for (BugAnnotation a : b.getAnnotations()) { if (a == primaryClass) { out.println(a);
@Override public boolean match(BugInstance bugInstance) { TypeAnnotation typeAnnotation = bugInstance.getPrimaryType(); if (role != null && !"".equals(role)) { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof TypeAnnotation && role.equals(a.getDescription())) { typeAnnotation = (TypeAnnotation) a; break; } } } if(typeAnnotation == null){ return false; } String typeDesctiptor = typeAnnotation.getTypeDescriptor(); if(!descriptor.match(typeDesctiptor)){ return false; } if (typeParameters != null && !typeParameters.equals(typeAnnotation.getTypeParameters())) { return false; } return true; }
@Override public boolean match(BugInstance bugInstance) { MethodAnnotation methodAnnotation = null; if (role == null || "".equals(role)) { methodAnnotation = bugInstance.getPrimaryMethod(); } else { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof MethodAnnotation && role.equals(a.getDescription())) { methodAnnotation = (MethodAnnotation) a; break; } } } if (methodAnnotation == null) { return false; } if (!name.match(methodAnnotation.getMethodName())) { return false; } if (signature != null && !signature.match(methodAnnotation.getMethodSignature())) { return false; } return true; }
@Override public boolean match(BugInstance bugInstance) { FieldAnnotation fieldAnnotation = null; if (role == null || "".equals(role)) { fieldAnnotation = bugInstance.getPrimaryField(); } else { for (BugAnnotation a : bugInstance.getAnnotations()) { if (a instanceof FieldAnnotation && role.equals(a.getDescription())) { fieldAnnotation = (FieldAnnotation) a; break; } } } if (fieldAnnotation == null) { return false; } if (!name.match(fieldAnnotation.getFieldName())) { return false; } if (signature != null && !signature.match(fieldAnnotation.getFieldSignature())) { return false; } return true; }
for (BugAnnotation a : b.getAnnotations()) { if (a instanceof SourceLineAnnotation) { SourceLineAnnotation s = (SourceLineAnnotation) a;
for (BugAnnotation b : getAnnotations()) { if (primaryAnnotations.contains(b)) { continue;
for (BugAnnotation a : b.getAnnotations()) { a.accept(visitor);