mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ExplicitArrayFillingInspection: detect cases when for loop can be replaced with Arrays.fill call (IDEA-185394)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// "Replace loop with 'Arrays.fill' method call" "true"
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static<T> void fill(T[] data, T value) {
|
||||
/*comment*/
|
||||
/*in body*/
|
||||
/*in lvalue*/
|
||||
/*in rvalue*/
|
||||
Arrays.fill(data, value);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
// "Replace loop with Arrays.setAll" "true"
|
||||
// "Replace loop with 'Arrays.setAll' method call" "true"
|
||||
public class Test {
|
||||
private Object[] data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace loop with Arrays.setAll" "true"
|
||||
// "Replace loop with 'Arrays.setAll' method call" "true"
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Replace loop with 'Arrays.fill' method call" "true"
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static<T> void fill(T[] data, T value) {
|
||||
for(int <caret>idx = 0; (/*comment*/data).length > idx; idx+=1) {
|
||||
/*in body*/
|
||||
data[/*in lvalue*/idx] = /*in rvalue*/value;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace loop with Arrays.setAll" "true"
|
||||
// "Replace loop with 'Arrays.setAll' method call" "true"
|
||||
public class Test {
|
||||
private Object[] data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace loop with Arrays.setAll" "true"
|
||||
// "Replace loop with 'Arrays.setAll' method call" "true"
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace loop with Arrays.setAll" "false"
|
||||
// "Fix all 'Explicit array filling' problems in file" "false"
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace loop with Arrays.setAll" "false"
|
||||
// "Fix all 'Explicit array filling' problems in file" "false"
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
Reference in New Issue
Block a user