AdjustFunctionContextFix: suggest to change method accepting lambda/methodRef

Fixes cases 1, 2 from IDEA-174219 Add quick-fixes for incompilable Stream API call chains when using primitive streams
This commit is contained in:
Tagir Valeev
2017-08-28 14:55:00 +07:00
parent fd653d3ade
commit 791c182306
16 changed files with 323 additions and 47 deletions
@@ -0,0 +1,10 @@
// "Replace 'flatMap()' with 'flatMapToDouble()'" "true"
import java.util.*;
import java.util.stream.*;
class Test {
void test() {
double[][] data = {{0,1,2},{3,4,5}};
Arrays.stream(data).flatMapToDouble(array -> Arrays.stream(array)).forEach(System.out::println);
}
}
@@ -0,0 +1,10 @@
// "Replace 'flatMap()' with 'flatMapToInt()'" "true"
import java.util.*;
import java.util.stream.*;
class Test {
void test() {
int[][] data = {{0,1,2},{3,4,5}};
Arrays.stream(data).flatMapToInt(Arrays::stream).forEach(System.out::println);
}
}
@@ -0,0 +1,8 @@
// "Replace 'map()' with 'mapToDouble()'" "true"
import java.util.stream.*;
class Test {
void test() {
IntStream.range(0, 100).mapToDouble(x -> x/1.0).forEach(s -> System.out.println(s));
}
}
@@ -0,0 +1,8 @@
// "Replace 'map()' with 'mapToObj()'" "true"
import java.util.stream.*;
class Test {
void test() {
IntStream.range(0, 100).mapToObj(String::valueOf).forEach(s -> System.out.println(s));
}
}
@@ -0,0 +1,8 @@
// "Replace 'mapToInt()' with 'map()'" "true"
import java.util.stream.*;
class Test {
void test() {
LongStream.range(0, 100).map(x -> x*2).forEach(s -> System.out.println(s));
}
}
@@ -0,0 +1,10 @@
// "Replace 'flatMap()' with 'flatMapToDouble()'" "true"
import java.util.*;
import java.util.stream.*;
class Test {
void test() {
double[][] data = {{0,1,2},{3,4,5}};
Arrays.stream(data).flatMap(array -> Arrays.<caret>stream(array)).forEach(System.out::println);
}
}
@@ -0,0 +1,10 @@
// "Replace 'flatMap()' with 'flatMapToInt()'" "true"
import java.util.*;
import java.util.stream.*;
class Test {
void test() {
int[][] data = {{0,1,2},{3,4,5}};
Arrays.stream(data).flatMap(Arrays<caret>::stream).forEach(System.out::println);
}
}
@@ -0,0 +1,8 @@
// "Replace 'map()' with 'mapToDouble()'" "true"
import java.util.stream.*;
class Test {
void test() {
IntStream.range(0, 100).map(x -> x/<caret>1.0).forEach(s -> System.out.println(s));
}
}
@@ -0,0 +1,8 @@
// "Replace 'map()' with 'mapToObj()'" "true"
import java.util.stream.*;
class Test {
void test() {
IntStream.range(0, 100).map(String<caret>::valueOf).forEach(s -> System.out.println(s));
}
}
@@ -0,0 +1,8 @@
// "Replace 'mapToInt()' with 'map()'" "true"
import java.util.stream.*;
class Test {
void test() {
LongStream.range(0, 100).mapToInt(x -> x<caret>*2).forEach(s -> System.out.println(s));
}
}