mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-28 04:37:32 +07:00
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:
+14
@@ -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) {
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Wrap using 'Collections.singletonList()'" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
|
||||
void m(long l) {
|
||||
List<Long> list = Collections.singletonList(l);
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Wrap using 'Paths.get()'" "true"
|
||||
import java.nio.file.*;
|
||||
|
||||
class Test {
|
||||
|
||||
Path m() {
|
||||
return Paths.get("/etc/passwd");
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -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));
|
||||
}
|
||||
}
|
||||
+14
@@ -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) {
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Wrap using 'Collections.singletonList()'" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
|
||||
void m(long l) {
|
||||
List<Long> list = <caret>l;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Wrap using 'Collections.singletonList()'" "false"
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
|
||||
void m(long l) {
|
||||
List<Integer> list = <caret>l;
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Wrap using 'Paths.get()'" "true"
|
||||
import java.nio.file.*;
|
||||
|
||||
class Test {
|
||||
|
||||
Path m() {
|
||||
return "/<caret>etc/passwd";
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user