/** * Add a field annotation * * @param fieldAnnotation * the field annotation * @return this object */ @Nonnull public BugInstance addField(FieldAnnotation fieldAnnotation) { add(fieldAnnotation); return this; }
private BugInstance addClassFieldAndAccess(BugInstance instance, XField f) { if (data.writtenNonNullFields.contains(f) && data.readFields.contains(f)) { throw new IllegalArgumentException("No information for fields that are both read and written nonnull"); } instance.addClass(f.getClassName()).addField(f); if (data.fieldAccess.containsKey(f)) { instance.add(data.fieldAccess.get(f)); } return instance; }
@Nonnull public BugInstance addClassAndMethod(MethodDescriptor methodDescriptor) { addClass(ClassName.toDottedClassName(methodDescriptor.getSlashedClassName())); add(MethodAnnotation.fromMethodDescriptor(methodDescriptor)); return this; }
@Override public void visit(LocalVariable obj) { if (isReservedName(obj.getName())) { LocalVariableAnnotation var = new LocalVariableAnnotation(obj.getName(), obj.getIndex(), obj.getStartPC()); SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this, obj.getStartPC()); BugInstance bug = new BugInstance(this, "NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER", NORMAL_PRIORITY) .addClassAndMethod(this).add(var).add(source); bugReporter.reportBug(bug); } }
public BugInstance addOptionalAnnotation(@CheckForNull BugAnnotation annotation) { if (annotation == null) { return this; } return add(annotation); }
/** * Add a source line annotation. * * @param sourceLine * the source line annotation * @return this object */ @Nonnull public BugInstance addSourceLine(SourceLineAnnotation sourceLine) { add(sourceLine); return this; }
public BugInstance addOptionalUniqueAnnotationsWithFallback(BugAnnotation fallback, BugAnnotation... annotations) { HashSet<BugAnnotation> added = new HashSet<>(); for (BugAnnotation a : annotations) { if (a != null && added.add(a)) { add(a); } } if (added.isEmpty()) { add(fallback); } return this; }
public BugInstance addOptionalUniqueAnnotations(BugAnnotation... annotations) { HashSet<BugAnnotation> added = new HashSet<>(); for (BugAnnotation a : annotations) { if (a != null && added.add(a)) { add(a); } } return this; }
public boolean tryAddingOptionalUniqueAnnotations(BugAnnotation... annotations) { HashSet<BugAnnotation> added = new HashSet<>(); for (BugAnnotation a : annotations) { if (a != null && added.add(a)) { add(a); } } return !added.isEmpty(); }
/** * Add an integer annotation. * * @param value * the integer value * @return this object */ @Nonnull public BugInstance addInt(int value) { add(new IntAnnotation(value)); return this; }
/** * Add a String annotation. * * @param value * the String value * @return this object */ @Nonnull public BugInstance addString(String value) { add(StringAnnotation.fromRawString(value)); return this; }
public BugInstance addOptionalAnnotation(@CheckForNull BugAnnotation annotation, String role) { if (annotation == null) { return this; } return add(annotation).describe(role); }
/** * Add a String annotation. * * @param c * the char value * @return this object */ @Nonnull public BugInstance addString(char c) { add(StringAnnotation.fromRawString(Character.toString(c))); return this; }
@Override public void visitClassAnnotation(ClassAnnotation classAnnotation) { result.add(obfuscate(classAnnotation)); } };
@Nonnull public BugInstance addType(Type type) { TypeAnnotation typeAnnotation = new TypeAnnotation(type); add(typeAnnotation); return this; }
@Nonnull public BugInstance addTypeOfNamedClass(@DottedClassName String typeName) { TypeAnnotation typeAnnotation = new TypeAnnotation("L" + typeName.replace('.', '/') + ";"); add(typeAnnotation); return this; }
@Nonnull public BugInstance addType(ClassDescriptor c) { TypeAnnotation typeAnnotation = new TypeAnnotation(c.getSignature()); add(typeAnnotation); return this; }
/** * Local variable adders */ @Nonnull public BugInstance addOptionalLocalVariable(DismantleBytecode dbc, OpcodeStack.Item item) { int register = item.getRegisterNumber(); if (register >= 0) { this.add(LocalVariableAnnotation.getLocalVariableAnnotation(dbc.getMethod(), register, dbc.getPC() - 1, dbc.getPC())); } return this; }