From bf6c1452907bb99130762a25665ff5b162a02100 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Wed, 29 Dec 2021 04:00:32 -0800 Subject: [PATCH] `s/isUsedReflectively/shouldKeep/g` PiperOrigin-RevId: 418767265 --- .../com/google/errorprone/bugpatterns/FieldCanBeLocal.java | 4 ++-- .../errorprone/bugpatterns/ImmutableMemberCollection.java | 4 ++-- .../errorprone/bugpatterns/ImmutableSetForContains.java | 4 ++-- .../java/com/google/errorprone/bugpatterns/UnusedMethod.java | 4 ++-- .../com/google/errorprone/bugpatterns/UnusedNestedClass.java | 4 ++-- .../com/google/errorprone/bugpatterns/inlineme/Suggester.java | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/FieldCanBeLocal.java b/core/src/main/java/com/google/errorprone/bugpatterns/FieldCanBeLocal.java index 6452c2f4f27..4f513dc14a3 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/FieldCanBeLocal.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/FieldCanBeLocal.java @@ -21,7 +21,7 @@ import static com.google.errorprone.util.ASTHelpers.getAnnotation; import static com.google.errorprone.util.ASTHelpers.getStartPosition; import static com.google.errorprone.util.ASTHelpers.getSymbol; -import static com.google.errorprone.util.ASTHelpers.isUsedReflectively; +import static com.google.errorprone.util.ASTHelpers.shouldKeep; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -87,7 +87,7 @@ public Void visitVariable(VariableTree variableTree, Void unused) { && symbol.getKind() == ElementKind.FIELD && symbol.isPrivate() && canBeLocal(variableTree) - && !isUsedReflectively(variableTree)) { + && !shouldKeep(variableTree)) { potentialFields.put(symbol, getCurrentPath()); } return null; diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableMemberCollection.java b/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableMemberCollection.java index 53ddef1f93d..afc9534a217 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableMemberCollection.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableMemberCollection.java @@ -26,7 +26,7 @@ import static com.google.errorprone.matchers.Matchers.kindIs; import static com.google.errorprone.util.ASTHelpers.getReceiver; import static com.google.errorprone.util.ASTHelpers.getSymbol; -import static com.google.errorprone.util.ASTHelpers.isUsedReflectively; +import static com.google.errorprone.util.ASTHelpers.shouldKeep; import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; @@ -117,7 +117,7 @@ public final class ImmutableMemberCollection extends BugChecker implements Class // TODO(ashishkedia) : Share this with ImmutableSetForContains. private static final Matcher EXCLUSIONS = anyOf( - (t, s) -> isUsedReflectively(t), + (t, s) -> shouldKeep(t), hasAnnotationWithSimpleName("Bind"), hasAnnotationWithSimpleName("Inject")); diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableSetForContains.java b/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableSetForContains.java index 73705f84e88..9760a136dcc 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableSetForContains.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/ImmutableSetForContains.java @@ -29,7 +29,7 @@ import static com.google.errorprone.matchers.Matchers.staticMethod; import static com.google.errorprone.util.ASTHelpers.getReceiver; import static com.google.errorprone.util.ASTHelpers.getSymbol; -import static com.google.errorprone.util.ASTHelpers.isUsedReflectively; +import static com.google.errorprone.util.ASTHelpers.shouldKeep; import static com.google.errorprone.util.ASTHelpers.streamReceivers; import static java.util.stream.Collectors.toMap; @@ -82,7 +82,7 @@ public final class ImmutableSetForContains extends BugChecker implements ClassTr private static final Matcher EXCLUSIONS = anyOf( - (t, s) -> isUsedReflectively(t), + (t, s) -> shouldKeep(t), hasAnnotationWithSimpleName("Bind"), hasAnnotationWithSimpleName("Inject")); diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java index 3dc6d1eceb6..98bfe1ba069 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedMethod.java @@ -24,7 +24,7 @@ import static com.google.errorprone.util.ASTHelpers.getSymbol; import static com.google.errorprone.util.ASTHelpers.getType; import static com.google.errorprone.util.ASTHelpers.isSubtype; -import static com.google.errorprone.util.ASTHelpers.isUsedReflectively; +import static com.google.errorprone.util.ASTHelpers.shouldKeep; import static com.google.errorprone.util.MoreAnnotations.asStrings; import static com.google.errorprone.util.MoreAnnotations.getAnnotationValue; @@ -190,7 +190,7 @@ private boolean isMethodSymbolEligibleForChecking(MethodTree tree) { if (exemptedByAnnotation(tree.getModifiers().getAnnotations())) { return false; } - if (isUsedReflectively(tree)) { + if (shouldKeep(tree)) { return false; } // Skip constructors and special methods. diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedNestedClass.java b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedNestedClass.java index 7b4e7044c23..8899df30a46 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/UnusedNestedClass.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/UnusedNestedClass.java @@ -20,7 +20,7 @@ import static com.google.errorprone.matchers.Description.NO_MATCH; import static com.google.errorprone.util.ASTHelpers.enclosingClass; import static com.google.errorprone.util.ASTHelpers.getSymbol; -import static com.google.errorprone.util.ASTHelpers.isUsedReflectively; +import static com.google.errorprone.util.ASTHelpers.shouldKeep; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; @@ -88,7 +88,7 @@ private boolean ignoreUnusedClass(ClassTree classTree) { if (isSuppressed(classTree)) { return true; } - if (isUsedReflectively(classTree)) { + if (shouldKeep(classTree)) { return true; } return false; diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/inlineme/Suggester.java b/core/src/main/java/com/google/errorprone/bugpatterns/inlineme/Suggester.java index 3aed6983ed8..11f5f7c031f 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/inlineme/Suggester.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/inlineme/Suggester.java @@ -20,7 +20,7 @@ import static com.google.errorprone.matchers.InjectMatchers.hasProvidesAnnotation; import static com.google.errorprone.util.ASTHelpers.hasAnnotation; import static com.google.errorprone.util.ASTHelpers.hasDirectAnnotationWithSimpleName; -import static com.google.errorprone.util.ASTHelpers.isUsedReflectively; +import static com.google.errorprone.util.ASTHelpers.shouldKeep; import com.google.errorprone.BugPattern; import com.google.errorprone.ErrorProneFlags; @@ -72,7 +72,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) { } // don't suggest on APIs that get called reflectively - if (isUsedReflectively(tree) || hasProvidesAnnotation().matches(tree, state)) { + if (shouldKeep(tree) || hasProvidesAnnotation().matches(tree, state)) { return Description.NO_MATCH; }