Skip to content

Commit

Permalink
Use SuppressibleTreePathScanner instead of rolling our own.
Browse files Browse the repository at this point in the history
This is already covered by tests, such as `negativeCases_suppressionForMethodTreeBased()`.

(`SuppressibleTreePathScanner` might actually correct some edge cases somewhere, even.)

PiperOrigin-RevId: 580260707
  • Loading branch information
cpovirk authored and Error Prone Team committed Nov 7, 2023
1 parent 18d5cdf commit 46122d1
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import com.sun.source.tree.MethodTree;
import com.sun.source.tree.ReturnTree;
import com.sun.source.tree.StatementTree;
import com.sun.source.tree.Tree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePathScanner;
import com.sun.tools.javac.code.Symbol;
Expand Down Expand Up @@ -230,7 +229,7 @@ void doVisitVariable(VariableTree tree) {
}.scan(tree, null);
ImmutableSet<VarSymbol> definitelyNullVars = definitelyNullVarsBuilder.build();

new TreePathScanner<Void, Void>() {
new SuppressibleTreePathScanner<Void, Void>(stateForCompilationUnit) {
@Override
public Void visitBlock(BlockTree block, Void unused) {
for (StatementTree statement : block.getStatements()) {
Expand Down Expand Up @@ -398,14 +397,6 @@ && methodCanBeOverridden(method)) {
}
}
}

@Override
public Void scan(Tree tree, Void unused) {
if (isSuppressed(tree, stateForCompilationUnit)) {
return null;
}
return super.scan(tree, unused);
}
}.scan(tree, null);

return NO_MATCH; // Any reports were made through state.reportMatch.
Expand Down

0 comments on commit 46122d1

Please sign in to comment.