Skip to content

Commit

Permalink
Remove old way of checking exclude annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaroclapp committed Jul 23, 2020
1 parent 6aab4f4 commit ddce326
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
import com.uber.nullaway.dataflow.EnclosingEnvironmentNullness;
import com.uber.nullaway.handlers.Handler;
import com.uber.nullaway.handlers.Handlers;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -222,8 +221,6 @@ public class NullAway extends BugChecker
*/
private final Map<ExpressionTree, Nullness> computedNullnessMap = new LinkedHashMap<>();

private final ImmutableSet<Class<? extends Annotation>> customSuppressionAnnotations;

/**
* Error Prone requires us to have an empty constructor for each Plugin, in addition to the
* constructor taking an ErrorProneFlags object. This constructor should not be used anywhere
Expand All @@ -234,35 +231,19 @@ public NullAway() {
config = new DummyOptionsConfig();
handler = Handlers.buildEmpty();
nonAnnotatedMethod = this::isMethodUnannotated;
customSuppressionAnnotations = ImmutableSet.of();
errorBuilder = new ErrorBuilder(config, "", ImmutableSet.of());
}

public NullAway(ErrorProneFlags flags) {
config = new ErrorProneCLIFlagsConfig(flags);
handler = Handlers.buildDefault(config);
nonAnnotatedMethod = this::isMethodUnannotated;
customSuppressionAnnotations = initCustomSuppressions();
errorBuilder = new ErrorBuilder(config, canonicalName(), allNames());
// workaround for Checker Framework static state bug;
// See https://github.com/typetools/checker-framework/issues/1482
AnnotationUtils.clear();
}

private ImmutableSet<Class<? extends Annotation>> initCustomSuppressions() {
ImmutableSet.Builder<Class<? extends Annotation>> builder = ImmutableSet.builder();
builder.addAll(super.customSuppressionAnnotations());
for (String annotName : config.getExcludedClassAnnotations()) {
try {
builder.add(Class.forName(annotName).asSubclass(Annotation.class));
} catch (ClassNotFoundException e) {
// in this case, the annotation may be a source file currently being compiled,
// in which case we won't be able to resolve the class
}
}
return builder.build();
}

private boolean isMethodUnannotated(MethodInvocationNode invocationNode) {
return invocationNode == null
|| NullabilityUtil.isUnannotated(ASTHelpers.getSymbol(invocationNode.getTree()), config);
Expand All @@ -274,11 +255,6 @@ public String linkUrl() {
return config.getErrorURL() + " ";
}

@Override
public Set<Class<? extends Annotation>> customSuppressionAnnotations() {
return customSuppressionAnnotations;
}

/**
* We are trying to see if (1) we are in a method guaranteed to return something non-null, and (2)
* this return statement can return something null.
Expand Down

0 comments on commit ddce326

Please sign in to comment.