From b3ed88bec0416196d82863bdf6ba5b901c521972 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Wed, 13 Apr 2022 11:22:36 -0700 Subject: [PATCH] Handle all annotations with the simple name `Generated` in `-XepDisableWarningsInGeneratedCode` Follow-up to https://github.com/google/error-prone/commit/4d6a0cce2d2ccc6a945352c2ba38201f753994bd See also https://github.com/google/error-prone/issues/3094 PiperOrigin-RevId: 441532440 --- .../java/com/google/errorprone/SuppressionInfo.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/check_api/src/main/java/com/google/errorprone/SuppressionInfo.java b/check_api/src/main/java/com/google/errorprone/SuppressionInfo.java index 8ef94ca6456..cb23c08dea3 100644 --- a/check_api/src/main/java/com/google/errorprone/SuppressionInfo.java +++ b/check_api/src/main/java/com/google/errorprone/SuppressionInfo.java @@ -16,8 +16,6 @@ package com.google.errorprone; -import static com.google.common.collect.ImmutableSet.toImmutableSet; - import com.google.common.collect.ImmutableSet; import com.google.errorprone.annotations.CheckReturnValue; import com.google.errorprone.annotations.Immutable; @@ -37,7 +35,6 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Stream; /** * Immutable container of "suppression signals" - annotations or other information gathered from @@ -57,12 +54,6 @@ public class SuppressionInfo { private static final Supplier ANDROID_SUPPRESS_LINT = VisitorState.memoize(state -> state.getName("android.annotation.SuppressLint")); private static final Supplier VALUE = VisitorState.memoize(state -> state.getName("value")); - private static final Supplier> GENERATED_ANNOTATIONS = - VisitorState.memoize( - state -> - Stream.of("javax.annotation.Generated", "javax.annotation.processing.Generated") - .map(state::getName) - .collect(toImmutableSet())); private final ImmutableSet suppressWarningsStrings; @SuppressWarnings("Immutable") /* Name is javac's interned version of a string. */ @@ -78,7 +69,7 @@ private SuppressionInfo( } private static boolean isGenerated(Symbol sym, VisitorState state) { - return !ASTHelpers.annotationsAmong(sym, GENERATED_ANNOTATIONS.get(state), state).isEmpty(); + return !ASTHelpers.getGeneratedBy(sym, state).isEmpty(); } /**