mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-182206 Simplification for Arrays.asList().sublist().toArray()
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'clone()'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
String[] get() {
|
||||
return arr.clone();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOfRange'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
String[] get() {
|
||||
return Arrays.copyOfRange(arr, 1, 3);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOfRange'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
CharSequence[] get(int from, int to) {
|
||||
return Arrays.copyOfRange(arr, from, to, CharSequence[].class);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOf'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
String[] get(int newLength) {
|
||||
return Arrays.copyOf(arr, newLength);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOf'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
Object[] get(int newLength) {
|
||||
return Arrays.copyOf(arr, newLength, Object[].class);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'clone()'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
String[] get() {
|
||||
return Arrays.asList(arr).toAr<caret>ray(new String[0]);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOfRange'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
String[] get() {
|
||||
return Arrays.asList(arr).subList(1, 3).toAr<caret>ray(new String[2]);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOfRange'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
CharSequence[] get(int from, int to) {
|
||||
return Arrays.asList(arr).subList(from, to).toAr<caret>ray(new CharSequence[to-from]);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOfRange'" "false"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
String[] get() {
|
||||
return Arrays.asList(arr).subList(1, 3).toAr<caret>ray(new String[3]);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOf'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
String[] get(int newLength) {
|
||||
return Arrays.asList(arr).subList(0, newLength).toAr<caret>ray(new String[newLength]);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'Arrays.copyOf'" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
Object[] get(int newLength) {
|
||||
return Arrays.asList(arr).subList(0, newLength).toAr<caret>ray();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with 'clone()'" "false"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
String[] arr;
|
||||
|
||||
CharSequence[] get() {
|
||||
// Array type mismatch
|
||||
return Arrays.asList(arr).toAr<caret>ray(new CharSequence[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user