From 49d614f15d3129b02e177851230dab935281bb31 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 7 Dec 2021 12:31:30 +0100 Subject: [PATCH] PSM-1165 `StaticImportCheck` handle `package-info.java` files --- .../tech/picnic/errorprone/bugpatterns/StaticImportCheck.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java index 9c9abe5a0ee..cc73da727b6 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java @@ -2,6 +2,7 @@ import static com.sun.source.tree.Tree.Kind.MEMBER_SELECT; import static com.sun.source.tree.Tree.Kind.METHOD_INVOCATION; +import static com.sun.source.tree.Tree.Kind.PACKAGE; import static java.util.Objects.requireNonNull; import com.google.auto.service.AutoService; @@ -184,7 +185,8 @@ private static boolean isCandidate(VisitorState state) { private static boolean isExempted(VisitorState state) { Tree currentTree = state.getPath().getLeaf(); Tree parentTree = state.getPath().getParentPath().getLeaf(); - if (currentTree.getKind() != MEMBER_SELECT && parentTree.getKind() != METHOD_INVOCATION) { + if ((currentTree.getKind() != MEMBER_SELECT && parentTree.getKind() != METHOD_INVOCATION) + || parentTree.getKind() == PACKAGE) { return false; }