StreamCollector10Inlining: +native; DataFlowInspection10Test: use Java10

Review ID: IDEA-CR-29835
This commit is contained in:
Tagir Valeev
2018-02-27 11:34:06 +07:00
parent 8b4360b936
commit 7f7c4df2d0
2 changed files with 17 additions and 7 deletions
@@ -9,10 +9,10 @@ import java.util.stream.*;
// Mock
class Collectors {
public static <T> Collector<T, ?, List<T>> toList() {<error descr="Missing return statement">}</error>
public static <T> Collector<T, ?, List<T>> toUnmodifiableList() {<error descr="Missing return statement">}</error>
public static <T> Collector<T, ?, Set<T>> toUnmodifiableSet() {<error descr="Missing return statement">}</error>
public static <T, K, U> Collector<T, ?, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) {<error descr="Missing return statement">}</error>
public static native <T> Collector<T, ?, List<T>> toList();
public static native <T> Collector<T, ?, List<T>> toUnmodifiableList();
public static native <T> Collector<T, ?, Set<T>> toUnmodifiableSet();
public static native <T, K, U> Collector<T, ?, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper);
}
public class StreamCollector10Inlining {
@@ -28,7 +28,7 @@ public class StreamCollector10Inlining {
}
void testToImmutableList() {
List<String> list = Stream.of("foo", "bar", "baz")
var list = Stream.of("foo", "bar", "baz")
.map(<warning descr="Function may return null, but it's not allowed here">this::convert</warning>)
.collect(Collectors.toUnmodifiableList());
list.<warning descr="Immutable object is modified">sort</warning>(null);
@@ -42,7 +42,7 @@ public class StreamCollector10Inlining {
}
void testToImmutableMap() {
Map<String, String> map = Stream.of("foo", "bar", "baz", "")
var map = Stream.of("foo", "bar", "baz", "")
.collect(Collectors.toUnmodifiableMap(<warning descr="Function may return null, but it's not allowed here">this::convert</warning>, <warning descr="Function may return null, but it's not allowed here">this::convert</warning>));
map.<warning descr="Immutable object is modified">put</warning>("qux", "qux");
}
@@ -2,7 +2,12 @@
package com.intellij.java.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.LanguageLevelModuleExtension;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.PsiTestUtil;
@@ -13,7 +18,12 @@ public class DataFlowInspection10Test extends DataFlowInspectionTestCase {
private static final DefaultLightProjectDescriptor PROJECT_DESCRIPTOR = new DefaultLightProjectDescriptor() {
@Override
public Sdk getSdk() {
return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk9());
return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk(LanguageLevel.JDK_10.toJavaVersion()));
}
@Override
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(LanguageLevel.JDK_10);
}
};