From 064f1acc9f919bc11e04da95057167593dbc8934 Mon Sep 17 00:00:00 2001 From: vmussatto Date: Fri, 1 Apr 2022 11:40:15 +0200 Subject: [PATCH] Re-adding emptyList, emptySet and emptyMap templates --- .../errorprone/refastertemplates/ImmutableListTemplates.java | 5 +++++ .../errorprone/refastertemplates/ImmutableMapTemplates.java | 5 +++++ .../errorprone/refastertemplates/ImmutableSetTemplates.java | 5 +++++ .../bugpatterns/ImmutableListTemplatesTestInput.java | 4 ++-- .../bugpatterns/ImmutableListTemplatesTestOutput.java | 4 ++-- .../bugpatterns/ImmutableMapTemplatesTestInput.java | 4 ++-- .../bugpatterns/ImmutableMapTemplatesTestOutput.java | 4 ++-- .../bugpatterns/ImmutableSetTemplatesTestInput.java | 4 ++-- .../bugpatterns/ImmutableSetTemplatesTestOutput.java | 4 ++-- 9 files changed, 27 insertions(+), 12 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java index a122f3096af..de81b5f2fbc 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java @@ -197,6 +197,11 @@ List before() { return List.of(); } + @BeforeTemplate + List before2() { + return Collections.emptyList(); + } + @AfterTemplate ImmutableList after() { return ImmutableList.of(); diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java index 6bb3cd16f15..7d3d3b707fd 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java @@ -265,6 +265,11 @@ Map before() { return Map.of(); } + @BeforeTemplate + Map before2() { + return Collections.emptyMap(); + } + @AfterTemplate ImmutableMap after() { return ImmutableMap.of(); diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java index e131741cc7d..8aff3e21584 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java @@ -162,6 +162,11 @@ Set before() { return Set.of(); } + @BeforeTemplate + Set before2() { + return Collections.emptySet(); + } + @AfterTemplate ImmutableSet after() { return ImmutableSet.of(); diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestInput.java index 85f8128b6d3..26e08c80146 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestInput.java @@ -80,8 +80,8 @@ ImmutableList testStreamToDistinctImmutableList() { return Stream.of(1).distinct().collect(toImmutableList()); } - List testImmutableListOf() { - return List.of(); + ImmutableSet> testImmutableListOf() { + return ImmutableSet.of(List.of(), Collections.emptyList()); } List testImmutableListOf1() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestOutput.java index 7deec322efe..d7b62dfb3ee 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableListTemplatesTestOutput.java @@ -75,8 +75,8 @@ ImmutableList testStreamToDistinctImmutableList() { return Stream.of(1).collect(toImmutableSet()).asList(); } - List testImmutableListOf() { - return ImmutableList.of(); + ImmutableSet> testImmutableListOf() { + return ImmutableSet.of(ImmutableList.of(), ImmutableList.of()); } List testImmutableListOf1() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestInput.java index 505ecaf57e3..f36dd5e88e2 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestInput.java @@ -91,8 +91,8 @@ ImmutableMap testImmutableMapCopyOfImmutableMap() { return ImmutableMap.copyOf(ImmutableMap.of("foo", 1)); } - Map testImmutableMapOf() { - return Map.of(); + ImmutableSet> testImmutableMapOf() { + return ImmutableSet.of(Map.of(), Collections.emptyMap()); } Map testImmutableMapOf1() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestOutput.java index f18848daa5e..507028da728 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableMapTemplatesTestOutput.java @@ -77,8 +77,8 @@ ImmutableMap testImmutableMapCopyOfImmutableMap() { return ImmutableMap.of("foo", 1); } - Map testImmutableMapOf() { - return ImmutableMap.of(); + ImmutableSet> testImmutableMapOf() { + return ImmutableSet.of(ImmutableMap.of(), ImmutableMap.of()); } Map testImmutableMapOf1() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestInput.java index 4308c45365a..e4b8d3a3508 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestInput.java @@ -67,8 +67,8 @@ ImmutableSet testImmutableSetCopyOfSetView() { return ImmutableSet.copyOf(Sets.difference(ImmutableSet.of(1), ImmutableSet.of(2))); } - Set testImmutableSetOf() { - return Set.of(); + ImmutableSet> testImmutableSetOf() { + return ImmutableSet.of(Set.of(), Collections.emptySet()); } Set testImmutableSetOf1() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestOutput.java index 1304cbf9594..dc3b6ae1be0 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ImmutableSetTemplatesTestOutput.java @@ -66,8 +66,8 @@ ImmutableSet testImmutableSetCopyOfSetView() { return Sets.difference(ImmutableSet.of(1), ImmutableSet.of(2)).immutableCopy(); } - Set testImmutableSetOf() { - return ImmutableSet.of(); + ImmutableSet> testImmutableSetOf() { + return ImmutableSet.of(ImmutableSet.of(), ImmutableSet.of()); } Set testImmutableSetOf1() {