[java-inspection] IDEA-378175 Inspection "'collect(toList())' can be replaced with 'toList()'" disappears on some newer JDKs

- more external annotations

GitOrigin-RevId: 349bb9e942e5f1278ba8531d3d79f507cf6eef39
This commit is contained in:
Mikhail Pyltsin
2025-09-05 23:23:50 +00:00
committed by intellij-monorepo-bot
parent b7d9354609
commit 07ca813ff6
2 changed files with 33 additions and 0 deletions
@@ -244,4 +244,19 @@ class MissingIteratorRemoveAnalysis {
list = new ArrayList<>();
list.add("foo");
}
}
class UnmodifiableListTest {
private final List<String> myList = Stream.of("foo", "barA").collect(Collectors.toList());
private final List<String> myList2 = Stream.of("foo", "barB").<warning descr="'collect(toList())' can be replaced with 'toList()'">collect(Collectors.toList())</warning>;
void add() {
myList.add("foo");
}
List<String> get(boolean b) {
return Collections.unmodifiableList(b ? myList : myList2);
}
}
@@ -2193,6 +2193,9 @@
<item name="java.util.Collections java.util.Collection&lt;T&gt; unmodifiableCollection(java.util.Collection&lt;? extends T&gt;)">
<annotation name="org.jetbrains.annotations.NotNull"/>
<annotation name="org.jetbrains.annotations.UnmodifiableView"/>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="pure" val="true"/>
</annotation>
</item>
<item name="java.util.Collections java.util.Collection&lt;T&gt; unmodifiableCollection(java.util.Collection&lt;? extends T&gt;) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
@@ -2304,6 +2307,9 @@
<item name="java.util.Collections java.util.List&lt;T&gt; unmodifiableList(java.util.List&lt;? extends T&gt;)">
<annotation name="org.jetbrains.annotations.NotNull"/>
<annotation name="org.jetbrains.annotations.UnmodifiableView"/>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="pure" val="true"/>
</annotation>
</item>
<item name="java.util.Collections java.util.List&lt;T&gt; unmodifiableList(java.util.List&lt;? extends T&gt;) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
@@ -2364,6 +2370,9 @@
<item name="java.util.Collections java.util.Map&lt;K,V&gt; unmodifiableMap(java.util.Map&lt;? extends K,? extends V&gt;)">
<annotation name="org.jetbrains.annotations.NotNull"/>
<annotation name="org.jetbrains.annotations.UnmodifiableView"/>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="pure" val="true"/>
</annotation>
</item>
<item name="java.util.Collections java.util.Map&lt;K,V&gt; unmodifiableMap(java.util.Map&lt;? extends K,? extends V&gt;) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
@@ -2496,6 +2505,9 @@
<item name="java.util.Collections java.util.Set&lt;T&gt; unmodifiableSet(java.util.Set&lt;? extends T&gt;)">
<annotation name="org.jetbrains.annotations.NotNull"/>
<annotation name="org.jetbrains.annotations.UnmodifiableView"/>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="pure" val="true"/>
</annotation>
</item>
<item name="java.util.Collections java.util.Set&lt;T&gt; unmodifiableSet(java.util.Set&lt;? extends T&gt;) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
@@ -2541,6 +2553,9 @@
<item name="java.util.Collections java.util.SortedMap&lt;K,V&gt; unmodifiableSortedMap(java.util.SortedMap&lt;K,? extends V&gt;)">
<annotation name="org.jetbrains.annotations.NotNull"/>
<annotation name="org.jetbrains.annotations.UnmodifiableView"/>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="pure" val="true"/>
</annotation>
</item>
<item name="java.util.Collections java.util.SortedMap&lt;K,V&gt; unmodifiableSortedMap(java.util.SortedMap&lt;K,? extends V&gt;) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
@@ -2586,6 +2601,9 @@
<item name="java.util.Collections java.util.SortedSet&lt;T&gt; unmodifiableSortedSet(java.util.SortedSet&lt;T&gt;)">
<annotation name="org.jetbrains.annotations.NotNull"/>
<annotation name="org.jetbrains.annotations.UnmodifiableView"/>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="pure" val="true"/>
</annotation>
</item>
<item name="java.util.Collections java.util.SortedSet&lt;T&gt; unmodifiableSortedSet(java.util.SortedSet&lt;T&gt;) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>