mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Compute constant expression as an inspection; minor improvements
Works for unary operation Do not suggested if replacement is the same as the original code Replacement is displayed in the quick-fix name
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
// "Compute constant value of '"The quick brown fox jumps " + 100000 + " times" + " over the lazy dog"'" "true"
|
||||
class Test {
|
||||
void test() {
|
||||
// Do not display the result in action name
|
||||
String foo = "The quick brown fox jumps 100000 times over the lazy dog";
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Replace '2 * 2' with constant value '4'" "true"
|
||||
class Test {
|
||||
int x = 4;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Fix all 'Constant expression can be evaluated' problems in file" "true"
|
||||
class Test {
|
||||
void test() {
|
||||
String[] squares = new String[10];
|
||||
squares[0] = "0*0=0";
|
||||
squares[1] = "1*1=1";
|
||||
squares[2] = "2*2=4";
|
||||
squares[3] = "3*3=9";
|
||||
squares[4] = "4*4=16";
|
||||
squares[5] = "5*5=25";
|
||||
squares[6] = "6*6=36";
|
||||
squares[7] = "7*7=49";
|
||||
squares[8] = "8*8=64";
|
||||
squares[9] = "9*9=81";
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Replace '~2' with constant value '-3'" "true"
|
||||
class Test {
|
||||
int x = -3;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Compute constant value of '"The quick brown fox jumps " + 100000 + " times" + " over the lazy dog"'" "true"
|
||||
class Test {
|
||||
void test() {
|
||||
// Do not display the result in action name
|
||||
String foo = "The quick brown fox jumps " + 10<caret>0000 + " times" + " over the lazy dog";
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Replace '2 * 2' with constant value '4'" "true"
|
||||
class Test {
|
||||
int x = 2*<caret>2;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Fix all 'Constant expression can be evaluated' problems in file" "true"
|
||||
class Test {
|
||||
void test() {
|
||||
String[] squares = new String[10];
|
||||
squares[0] = 0 <caret>+ "*" + 0 + "=" + 0 * 0;
|
||||
squares[1] = 1 + "*" + 1 + "=" + 1 * 1;
|
||||
squares[2] = 2 + "*" + 2 + "=" + 2 * 2;
|
||||
squares[3] = 3 + "*" + 3 + "=" + 3 * 3;
|
||||
squares[4] = 4 + "*" + 4 + "=" + 4 * 4;
|
||||
squares[5] = 5 + "*" + 5 + "=" + 5 * 5;
|
||||
squares[6] = 6 + "*" + 6 + "=" + 6 * 6;
|
||||
squares[7] = 7 + "*" + 7 + "=" + 7 * 7;
|
||||
squares[8] = 8 + "*" + 8 + "=" + 8 * 8;
|
||||
squares[9] = 9 + "*" + 9 + "=" + 9 * 9;
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Replace '~2' with constant value '-3'" "true"
|
||||
class Test {
|
||||
int x = ~<caret>2;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Fix all 'Constant expression can be evaluated' problems in file" "false"
|
||||
class Test {
|
||||
int x = -<caret>2;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Fix all 'Constant expression can be evaluated' problems in file" "false"
|
||||
class Test {
|
||||
void test() {
|
||||
// Do not suggest to compute for performance reasons
|
||||
String foo = "The quick brown fox jumps " + 10<caret>0000 + "times" + "over the lazy dog"+
|
||||
"The quick brown fox jumps " + 100000 + "times" + "over the lazy dog"+
|
||||
"The quick brown fox jumps " + 100000 + "times" + "over the lazy dog"+
|
||||
"The quick brown fox jumps " + 100000 + "times" + "over the lazy dog"+
|
||||
"The quick brown fox jumps " + 100000 + "times" + "over the lazy dog";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user