Skip to content

Commit e5fd194

Browse files
graememorganError Prone Team
authored and
Error Prone Team
committed
Add new tree types to ErrorProneScanner.
Some of these aren't actually that new. PiperOrigin-RevId: 696877937
1 parent 0d556b3 commit e5fd194

File tree

2 files changed

+197
-8
lines changed

2 files changed

+197
-8
lines changed

check_api/src/main/java/com/google/errorprone/bugpatterns/BugChecker.java

+54-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.sun.source.tree.AssertTree;
4444
import com.sun.source.tree.AssignmentTree;
4545
import com.sun.source.tree.BinaryTree;
46+
import com.sun.source.tree.BindingPatternTree;
4647
import com.sun.source.tree.BlockTree;
4748
import com.sun.source.tree.BreakTree;
4849
import com.sun.source.tree.CaseTree;
@@ -55,6 +56,7 @@
5556
import com.sun.source.tree.DoWhileLoopTree;
5657
import com.sun.source.tree.EmptyStatementTree;
5758
import com.sun.source.tree.EnhancedForLoopTree;
59+
import com.sun.source.tree.ExportsTree;
5860
import com.sun.source.tree.ExpressionStatementTree;
5961
import com.sun.source.tree.ForLoopTree;
6062
import com.sun.source.tree.IdentifierTree;
@@ -70,12 +72,18 @@
7072
import com.sun.source.tree.MethodInvocationTree;
7173
import com.sun.source.tree.MethodTree;
7274
import com.sun.source.tree.ModifiersTree;
75+
import com.sun.source.tree.ModuleTree;
7376
import com.sun.source.tree.NewArrayTree;
7477
import com.sun.source.tree.NewClassTree;
78+
import com.sun.source.tree.OpensTree;
79+
import com.sun.source.tree.PackageTree;
7580
import com.sun.source.tree.ParameterizedTypeTree;
7681
import com.sun.source.tree.ParenthesizedTree;
7782
import com.sun.source.tree.PrimitiveTypeTree;
83+
import com.sun.source.tree.ProvidesTree;
84+
import com.sun.source.tree.RequiresTree;
7885
import com.sun.source.tree.ReturnTree;
86+
import com.sun.source.tree.SwitchExpressionTree;
7987
import com.sun.source.tree.SwitchTree;
8088
import com.sun.source.tree.SynchronizedTree;
8189
import com.sun.source.tree.ThrowTree;
@@ -85,9 +93,11 @@
8593
import com.sun.source.tree.TypeParameterTree;
8694
import com.sun.source.tree.UnaryTree;
8795
import com.sun.source.tree.UnionTypeTree;
96+
import com.sun.source.tree.UsesTree;
8897
import com.sun.source.tree.VariableTree;
8998
import com.sun.source.tree.WhileLoopTree;
9099
import com.sun.source.tree.WildcardTree;
100+
import com.sun.source.tree.YieldTree;
91101
import com.sun.source.util.TreePath;
92102
import com.sun.source.util.TreePathScanner;
93103
import com.sun.source.util.TreeScanner;
@@ -342,14 +352,14 @@ public Void scan(Tree tree, Void unused) {
342352
return ImmutableRangeSet.copyOf(suppressedRegions);
343353
}
344354

345-
public interface AnnotationTreeMatcher extends Suppressible {
346-
Description matchAnnotation(AnnotationTree tree, VisitorState state);
347-
}
348-
349355
public interface AnnotatedTypeTreeMatcher extends Suppressible {
350356
Description matchAnnotatedType(AnnotatedTypeTree tree, VisitorState state);
351357
}
352358

359+
public interface AnnotationTreeMatcher extends Suppressible {
360+
Description matchAnnotation(AnnotationTree tree, VisitorState state);
361+
}
362+
353363
public interface ArrayAccessTreeMatcher extends Suppressible {
354364
Description matchArrayAccess(ArrayAccessTree tree, VisitorState state);
355365
}
@@ -370,6 +380,10 @@ public interface BinaryTreeMatcher extends Suppressible {
370380
Description matchBinary(BinaryTree tree, VisitorState state);
371381
}
372382

383+
public interface BindingPatternTreeMatcher extends Suppressible {
384+
Description matchBindingPattern(BindingPatternTree tree, VisitorState state);
385+
}
386+
373387
public interface BlockTreeMatcher extends Suppressible {
374388
Description matchBlock(BlockTree tree, VisitorState state);
375389
}
@@ -420,6 +434,10 @@ public interface EnhancedForLoopTreeMatcher extends Suppressible {
420434

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

437+
public interface ExportsTreeMatcher extends Suppressible {
438+
Description matchExports(ExportsTree tree, VisitorState state);
439+
}
440+
423441
public interface ExpressionStatementTreeMatcher extends Suppressible {
424442
Description matchExpressionStatement(ExpressionStatementTree tree, VisitorState state);
425443
}
@@ -480,6 +498,10 @@ public interface ModifiersTreeMatcher extends Suppressible {
480498
Description matchModifiers(ModifiersTree tree, VisitorState state);
481499
}
482500

501+
public interface ModuleTreeMatcher extends Suppressible {
502+
Description matchModule(ModuleTree tree, VisitorState state);
503+
}
504+
483505
public interface NewArrayTreeMatcher extends Suppressible {
484506
Description matchNewArray(NewArrayTree tree, VisitorState state);
485507
}
@@ -491,6 +513,14 @@ public interface NewClassTreeMatcher extends Suppressible {
491513
// Intentionally skip OtherTreeMatcher. It seems to be used only for let expressions, which are
492514
// generated by javac to implement autoboxing. We are only interested in source-level constructs.
493515

516+
public interface OpensTreeMatcher extends Suppressible {
517+
Description matchOpens(OpensTree tree, VisitorState state);
518+
}
519+
520+
public interface PackageTreeMatcher extends Suppressible {
521+
Description matchPackage(PackageTree tree, VisitorState state);
522+
}
523+
494524
public interface ParameterizedTypeTreeMatcher extends Suppressible {
495525
Description matchParameterizedType(ParameterizedTypeTree tree, VisitorState state);
496526
}
@@ -503,10 +533,22 @@ public interface PrimitiveTypeTreeMatcher extends Suppressible {
503533
Description matchPrimitiveType(PrimitiveTypeTree tree, VisitorState state);
504534
}
505535

536+
public interface ProvidesTreeMatcher extends Suppressible {
537+
Description matchProvides(ProvidesTree tree, VisitorState state);
538+
}
539+
540+
public interface RequiresTreeMatcher extends Suppressible {
541+
Description matchRequires(RequiresTree tree, VisitorState state);
542+
}
543+
506544
public interface ReturnTreeMatcher extends Suppressible {
507545
Description matchReturn(ReturnTree tree, VisitorState state);
508546
}
509547

548+
public interface SwitchExpressionTreeMatcher extends Suppressible {
549+
Description matchSwitchExpression(SwitchExpressionTree tree, VisitorState state);
550+
}
551+
510552
public interface SwitchTreeMatcher extends Suppressible {
511553
Description matchSwitch(SwitchTree tree, VisitorState state);
512554
}
@@ -539,6 +581,10 @@ public interface UnionTypeTreeMatcher extends Suppressible {
539581
Description matchUnionType(UnionTypeTree tree, VisitorState state);
540582
}
541583

584+
public interface UsesTreeMatcher extends Suppressible {
585+
Description matchUses(UsesTree tree, VisitorState state);
586+
}
587+
542588
public interface VariableTreeMatcher extends Suppressible {
543589
Description matchVariable(VariableTree tree, VisitorState state);
544590
}
@@ -551,6 +597,10 @@ public interface WildcardTreeMatcher extends Suppressible {
551597
Description matchWildcard(WildcardTree tree, VisitorState state);
552598
}
553599

600+
public interface YieldTreeMatcher extends Suppressible {
601+
Description matchYield(YieldTree tree, VisitorState state);
602+
}
603+
554604
@Override
555605
public boolean equals(Object obj) {
556606
if (!(obj instanceof BugChecker)) {

0 commit comments

Comments
 (0)