[java-intention] More tests for IDEA-314907

GitOrigin-RevId: 2ca51ee0d02ff7d36cd59efb8ce6b81af2372ea7
This commit is contained in:
Tagir Valeev
2023-03-20 10:46:13 +01:00
committed by intellij-monorepo-bot
parent 32339d4c71
commit 31990e349d
10 changed files with 122 additions and 4 deletions

View File

@@ -16,8 +16,8 @@ class MainController {
class Wrapper<T> {
private T data;
public static <T> Wrapper<T> wrap(T t) {
Wrapper<T> res = new Wrapper<>();
public static <T1> Wrapper<T1> wrap(T1 t) {
Wrapper<T1> res = new Wrapper<>();
res.data = t;
return res;
}

View File

@@ -0,0 +1,22 @@
// "Create method 'list'" "true-preview"
import java.util.*;
class MainService {
public Map<String, Data> list() {
return null;
}
}
class MainController {
private final MainService service = new MainService();
public Wrapper<Map<String, Optional<Data>>> listData() {
return Wrapper.wrap(service.list());
}
}
class Wrapper<T> {
private T data;
public static native <T1, T2> Wrapper<Map<T1, Optional<T2>>> wrap(Map<T1, T2> t);
}
interface Data {}

View File

@@ -0,0 +1,14 @@
// "Create method 'nextFn'" "true-preview"
import java.util.function.Function;
class X {
void x() {
Function<Double, Character> fn1 = d -> String.valueOf(d)
.charAt(0);
Function<Double, Integer> fn = fn1.andThen(nextFn());
}
private Function<? super Character, Integer> nextFn() {
return null;
}
}

View File

@@ -0,0 +1,16 @@
// "Create method 'getKey'" "true-preview"
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class X {
void x() {
Map<Double, List<String>> map = Stream.of("x").collect(Collectors.groupingBy(getKey()));
}
private Function<? super String, Double> getKey() {
return null;
}
}

View File

@@ -0,0 +1,15 @@
// "Create method 'getKey'" "true-preview"
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class X {
void x() {
Map<Double, List<String>> map = Stream.of("x").collect(Collectors.groupingBy(k -> getKey(k)));
}
private Double getKey(String k) {
return null;
}
}

View File

@@ -13,8 +13,8 @@ class MainController {
class Wrapper<T> {
private T data;
public static <T> Wrapper<T> wrap(T t) {
Wrapper<T> res = new Wrapper<>();
public static <T1> Wrapper<T1> wrap(T1 t) {
Wrapper<T1> res = new Wrapper<>();
res.data = t;
return res;
}

View File

@@ -0,0 +1,19 @@
// "Create method 'list'" "true-preview"
import java.util.*;
class MainService {
}
class MainController {
private final MainService service = new MainService();
public Wrapper<Map<String, Optional<Data>>> listData() {
return Wrapper.wrap(service.<caret>list());
}
}
class Wrapper<T> {
private T data;
public static native <T1, T2> Wrapper<Map<T1, Optional<T2>>> wrap(Map<T1, T2> t);
}
interface Data {}

View File

@@ -0,0 +1,10 @@
// "Create method 'nextFn'" "true-preview"
import java.util.function.Function;
class X {
void x() {
Function<Double, Character> fn1 = d -> String.valueOf(d)
.charAt(0);
Function<Double, Integer> fn = fn1.andThen(<caret>nextFn());
}
}

View File

@@ -0,0 +1,11 @@
// "Create method 'getKey'" "true-preview"
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class X {
void x() {
Map<Double, List<String>> map = Stream.of("x").collect(Collectors.groupingBy(<caret>getKey()));
}
}

View File

@@ -0,0 +1,11 @@
// "Create method 'getKey'" "true-preview"
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class X {
void x() {
Map<Double, List<String>> map = Stream.of("x").collect(Collectors.groupingBy(k -> <caret>getKey(k)));
}
}