Skip to content

Commit

Permalink
Handle overlapping ranges in suppressedRegions
Browse files Browse the repository at this point in the history
#4040

PiperOrigin-RevId: 553911083
  • Loading branch information
cushon authored and Error Prone Team committed Aug 4, 2023
1 parent 449e6f4 commit 2533218
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Range;
import com.google.common.collect.TreeRangeSet;
import com.google.errorprone.BugCheckerInfo;
import com.google.errorprone.BugPattern.SeverityLevel;
import com.google.errorprone.ErrorProneOptions;
Expand Down Expand Up @@ -306,7 +307,7 @@ public boolean isSuppressed(Symbol sym, VisitorState state) {

/** Computes a RangeSet of code regions which are suppressed by this bug checker. */
public ImmutableRangeSet<Integer> suppressedRegions(VisitorState state) {
ImmutableRangeSet.Builder<Integer> suppressedRegions = ImmutableRangeSet.builder();
TreeRangeSet<Integer> suppressedRegions = TreeRangeSet.create();
new TreeScanner<Void, Void>() {
@Override
public Void scan(Tree tree, Void unused) {
Expand All @@ -318,7 +319,7 @@ public Void scan(Tree tree, Void unused) {
return null;
}
}.scan(state.getPath().getCompilationUnit(), null);
return suppressedRegions.build();
return ImmutableRangeSet.copyOf(suppressedRegions);
}

public interface AnnotationTreeMatcher extends Suppressible {
Expand Down

0 comments on commit 2533218

Please sign in to comment.