Skip to content

Commit

Permalink
Add new tree types to ErrorProneScanner.
Browse files Browse the repository at this point in the history
Some of these aren't actually that new.

PiperOrigin-RevId: 696877937
  • Loading branch information
graememorgan authored and Error Prone Team committed Nov 15, 2024
1 parent 0d556b3 commit e5fd194
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.sun.source.tree.AssertTree;
import com.sun.source.tree.AssignmentTree;
import com.sun.source.tree.BinaryTree;
import com.sun.source.tree.BindingPatternTree;
import com.sun.source.tree.BlockTree;
import com.sun.source.tree.BreakTree;
import com.sun.source.tree.CaseTree;
Expand All @@ -55,6 +56,7 @@
import com.sun.source.tree.DoWhileLoopTree;
import com.sun.source.tree.EmptyStatementTree;
import com.sun.source.tree.EnhancedForLoopTree;
import com.sun.source.tree.ExportsTree;
import com.sun.source.tree.ExpressionStatementTree;
import com.sun.source.tree.ForLoopTree;
import com.sun.source.tree.IdentifierTree;
Expand All @@ -70,12 +72,18 @@
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.MethodTree;
import com.sun.source.tree.ModifiersTree;
import com.sun.source.tree.ModuleTree;
import com.sun.source.tree.NewArrayTree;
import com.sun.source.tree.NewClassTree;
import com.sun.source.tree.OpensTree;
import com.sun.source.tree.PackageTree;
import com.sun.source.tree.ParameterizedTypeTree;
import com.sun.source.tree.ParenthesizedTree;
import com.sun.source.tree.PrimitiveTypeTree;
import com.sun.source.tree.ProvidesTree;
import com.sun.source.tree.RequiresTree;
import com.sun.source.tree.ReturnTree;
import com.sun.source.tree.SwitchExpressionTree;
import com.sun.source.tree.SwitchTree;
import com.sun.source.tree.SynchronizedTree;
import com.sun.source.tree.ThrowTree;
Expand All @@ -85,9 +93,11 @@
import com.sun.source.tree.TypeParameterTree;
import com.sun.source.tree.UnaryTree;
import com.sun.source.tree.UnionTypeTree;
import com.sun.source.tree.UsesTree;
import com.sun.source.tree.VariableTree;
import com.sun.source.tree.WhileLoopTree;
import com.sun.source.tree.WildcardTree;
import com.sun.source.tree.YieldTree;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import com.sun.source.util.TreeScanner;
Expand Down Expand Up @@ -342,14 +352,14 @@ public Void scan(Tree tree, Void unused) {
return ImmutableRangeSet.copyOf(suppressedRegions);
}

public interface AnnotationTreeMatcher extends Suppressible {
Description matchAnnotation(AnnotationTree tree, VisitorState state);
}

public interface AnnotatedTypeTreeMatcher extends Suppressible {
Description matchAnnotatedType(AnnotatedTypeTree tree, VisitorState state);
}

public interface AnnotationTreeMatcher extends Suppressible {
Description matchAnnotation(AnnotationTree tree, VisitorState state);
}

public interface ArrayAccessTreeMatcher extends Suppressible {
Description matchArrayAccess(ArrayAccessTree tree, VisitorState state);
}
Expand All @@ -370,6 +380,10 @@ public interface BinaryTreeMatcher extends Suppressible {
Description matchBinary(BinaryTree tree, VisitorState state);
}

public interface BindingPatternTreeMatcher extends Suppressible {
Description matchBindingPattern(BindingPatternTree tree, VisitorState state);
}

public interface BlockTreeMatcher extends Suppressible {
Description matchBlock(BlockTree tree, VisitorState state);
}
Expand Down Expand Up @@ -420,6 +434,10 @@ public interface EnhancedForLoopTreeMatcher extends Suppressible {

// Intentionally skip ErroneousTreeMatcher -- we don't analyze malformed expressions.

public interface ExportsTreeMatcher extends Suppressible {
Description matchExports(ExportsTree tree, VisitorState state);
}

public interface ExpressionStatementTreeMatcher extends Suppressible {
Description matchExpressionStatement(ExpressionStatementTree tree, VisitorState state);
}
Expand Down Expand Up @@ -480,6 +498,10 @@ public interface ModifiersTreeMatcher extends Suppressible {
Description matchModifiers(ModifiersTree tree, VisitorState state);
}

public interface ModuleTreeMatcher extends Suppressible {
Description matchModule(ModuleTree tree, VisitorState state);
}

public interface NewArrayTreeMatcher extends Suppressible {
Description matchNewArray(NewArrayTree tree, VisitorState state);
}
Expand All @@ -491,6 +513,14 @@ public interface NewClassTreeMatcher extends Suppressible {
// Intentionally skip OtherTreeMatcher. It seems to be used only for let expressions, which are
// generated by javac to implement autoboxing. We are only interested in source-level constructs.

public interface OpensTreeMatcher extends Suppressible {
Description matchOpens(OpensTree tree, VisitorState state);
}

public interface PackageTreeMatcher extends Suppressible {
Description matchPackage(PackageTree tree, VisitorState state);
}

public interface ParameterizedTypeTreeMatcher extends Suppressible {
Description matchParameterizedType(ParameterizedTypeTree tree, VisitorState state);
}
Expand All @@ -503,10 +533,22 @@ public interface PrimitiveTypeTreeMatcher extends Suppressible {
Description matchPrimitiveType(PrimitiveTypeTree tree, VisitorState state);
}

public interface ProvidesTreeMatcher extends Suppressible {
Description matchProvides(ProvidesTree tree, VisitorState state);
}

public interface RequiresTreeMatcher extends Suppressible {
Description matchRequires(RequiresTree tree, VisitorState state);
}

public interface ReturnTreeMatcher extends Suppressible {
Description matchReturn(ReturnTree tree, VisitorState state);
}

public interface SwitchExpressionTreeMatcher extends Suppressible {
Description matchSwitchExpression(SwitchExpressionTree tree, VisitorState state);
}

public interface SwitchTreeMatcher extends Suppressible {
Description matchSwitch(SwitchTree tree, VisitorState state);
}
Expand Down Expand Up @@ -539,6 +581,10 @@ public interface UnionTypeTreeMatcher extends Suppressible {
Description matchUnionType(UnionTypeTree tree, VisitorState state);
}

public interface UsesTreeMatcher extends Suppressible {
Description matchUses(UsesTree tree, VisitorState state);
}

public interface VariableTreeMatcher extends Suppressible {
Description matchVariable(VariableTree tree, VisitorState state);
}
Expand All @@ -551,6 +597,10 @@ public interface WildcardTreeMatcher extends Suppressible {
Description matchWildcard(WildcardTree tree, VisitorState state);
}

public interface YieldTreeMatcher extends Suppressible {
Description matchYield(YieldTree tree, VisitorState state);
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof BugChecker)) {
Expand Down
Loading

0 comments on commit e5fd194

Please sign in to comment.