diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java index 7107ad83658..4d0fcfbaacc 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java @@ -220,7 +220,10 @@ private static ImmutableList> getStructure(ExpressionTree private static AnnotationAttributeMatcher createAnnotationAttributeMatcher( ErrorProneFlags flags) { return AnnotationAttributeMatcher.create( - flags.getList(INCLUDED_ANNOTATIONS_FLAG), excludedAnnotations(flags)); + flags.get(INCLUDED_ANNOTATIONS_FLAG).isPresent() + ? Optional.of(flags.getListOrEmpty(INCLUDED_ANNOTATIONS_FLAG)) + : Optional.empty(), + excludedAnnotations(flags)); } private static ImmutableList excludedAnnotations(ErrorProneFlags flags) { diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/Flags.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/Flags.java index ec5f4e92b3b..349a003befe 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/Flags.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/Flags.java @@ -16,10 +16,7 @@ private Flags() {} * provided, or if the flag's value is the empty string. */ public static ImmutableList getList(ErrorProneFlags errorProneFlags, String name) { - return errorProneFlags - .getList(name) - .map(ImmutableList::copyOf) - .filter(flags -> !flags.equals(ImmutableList.of(""))) - .orElseGet(ImmutableList::of); + ImmutableList list = errorProneFlags.getListOrEmpty(name); + return list.equals(ImmutableList.of("")) ? ImmutableList.of() : list; } } diff --git a/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java b/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java index 4d68be3781f..e7841404070 100644 --- a/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java +++ b/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java @@ -42,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.regex.Pattern; import javax.inject.Inject; import org.jspecify.annotations.Nullable; @@ -180,7 +179,7 @@ private static ImmutableRangeMap indexRuleMatches( for (Description description : matches) { String ruleName = extractRefasterRuleName(description); - Set replacements = + ImmutableSet replacements = Iterables.getOnlyElement(description.fixes).getReplacements(endPositions); for (Replacement replacement : replacements) { ruleMatches.put(replacement.range(), ruleName);