WrapWithAdapterMethodCallFix replaces individual cases

WrapArrayToArraysAsListFix, WrapLongWithMathToIntExactFix, WrapStringWithFileFix are united into WrapWithAdapterMethodCallFix. Also Paths.get(), Collections.singleton(), Collections.singletonList(), Arrays.stream() wrappers added

Fixes IDEA-175129 Suggest to wrap a value with `Collections.singleton*()`
This commit is contained in:
Tagir Valeev
2017-08-25 14:33:41 +07:00
parent 0024a3aeb3
commit 661388f0c2
33 changed files with 330 additions and 402 deletions
@@ -0,0 +1,14 @@
// "Wrap parameter using 'new File()'" "true"
import java.io.File;
class Test {
void m() {
new FileReader(new File("my.txt"));
}
}
class FileReader {
public FileReader(File file) {
}
}
@@ -0,0 +1,10 @@
// "Wrap using 'Collections.singletonList()'" "true"
import java.util.*;
class Test {
void m(long l) {
List<Long> list = Collections.singletonList(l);
}
}
@@ -0,0 +1,14 @@
// "Wrap 2nd parameter using 'new File()'" "true"
import java.io.File;
class Test {
void m() {
readFile(0, new File("my.txt"), 2);
}
static String readFile(int additionalParameter1, File f, int additionalParameter2) {
return null;
}
}
@@ -0,0 +1,10 @@
// "Wrap using 'Paths.get()'" "true"
import java.nio.file.*;
class Test {
Path m() {
return Paths.get("/etc/passwd");
}
}
@@ -0,0 +1,14 @@
// "Wrap 1st parameter using 'Collections.singleton()'" "true"
import java.util.*;
class Test {
void method(Set<Long> set, double val) {
}
void m(long l) {
method(Collections.singleton(l), l);
}
}
@@ -0,0 +1,14 @@
// "Wrap parameter using 'new File()'" "true"
import java.io.File;
class Test {
void m() {
readFile(new File("my.txt"));
}
static String readFile(File f) {
return null;
}
}
@@ -0,0 +1,9 @@
// "Wrap using 'Arrays.stream()'" "true"
import java.util.*;
import java.util.stream.Stream;
public class Test {
Stream<String> testStream(List<String[]> list) {
return Arrays.stream(list.get(0));
}
}
@@ -0,0 +1,14 @@
// "Wrap parameter using 'new File()'" "true"
import java.io.File;
class Test {
void m() {
new FileReader("m<caret>y.txt");
}
}
class FileReader {
public FileReader(File file) {
}
}
@@ -0,0 +1,10 @@
// "Wrap using 'Collections.singletonList()'" "true"
import java.util.*;
class Test {
void m(long l) {
List<Long> list = <caret>l;
}
}
@@ -0,0 +1,10 @@
// "Wrap using 'Collections.singletonList()'" "false"
import java.util.*;
class Test {
void m(long l) {
List<Integer> list = <caret>l;
}
}
@@ -0,0 +1,14 @@
// "Wrap 2nd parameter using 'new File()'" "true"
import java.io.File;
class Test {
void m() {
readFile(0, "m<caret>y.txt", 2);
}
static String readFile(int additionalParameter1, File f, int additionalParameter2) {
return null;
}
}
@@ -0,0 +1,14 @@
// "Wrap parameter using 'new File()'" "false"
import java.io.File;
class Test {
void m(CharSequence sequence) {
readFile(sequen<caret>ce);
}
static String readFile(File f) {
return null;
}
}
@@ -0,0 +1,10 @@
// "Wrap using 'Paths.get()'" "true"
import java.nio.file.*;
class Test {
Path m() {
return "/<caret>etc/passwd";
}
}
@@ -0,0 +1,14 @@
// "Wrap 1st parameter using 'Collections.singleton()'" "true"
import java.util.*;
class Test {
void method(Set<Long> set, double val) {
}
void m(long l) {
method(<caret>l, l);
}
}
@@ -0,0 +1,14 @@
// "Wrap parameter using 'new File()'" "true"
import java.io.File;
class Test {
void m() {
readFile("my<caret>.txt");
}
static String readFile(File f) {
return null;
}
}
@@ -0,0 +1,9 @@
// "Wrap using 'Arrays.stream()'" "true"
import java.util.*;
import java.util.stream.Stream;
public class Test {
Stream<String> testStream(List<String[]> list) {
return list.<caret>get(0);
}
}