Java: Improved inspection "Join Declaration And Assignment" (IDEA-177132)

This commit is contained in:
Pavel Dolgov
2018-10-04 19:31:15 +03:00
parent 8db151021f
commit 82abf56a28
10 changed files with 137 additions and 23 deletions
@@ -1,10 +1,6 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class Test {
{
/*comment 1*/
/*comment 2*/
/*comment 3*/
// comment 4
{/*comment 1*//*comment 2*//*comment 3*/// comment 4
// comment A
/*comment B*/
/*comment C*/
@@ -0,0 +1,11 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class C {
void foo() {
/*comment 1*/
bar();/*comment 2*//*comment 3*///comment 4
// comment A
/*comment B*/
int n = 1;// comment C
}
void bar(){}
}
@@ -0,0 +1,8 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class C {
void foo() {
bar();
int n = 1;
}
void bar(){}
}
@@ -0,0 +1,8 @@
// "Join declaration and assignment" "false"
class C {
void foo(int[] a) {
for (int n = 0; ; <caret>n+=1) {
if (n >= a.length) break;
}
}
}
@@ -0,0 +1,11 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class C {
void foo() {
/*comment 1*/int /*comment 2*/ n /*comment 3*/; //comment 4
bar();
// comment A
/*comment B*/
<caret>n = 1; // comment C
}
void bar(){}
}
@@ -0,0 +1,9 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class C {
void foo() {
int n;
bar();
<caret>n = 1;
}
void bar(){}
}
@@ -0,0 +1,9 @@
// "Join declaration and assignment" "false"
class C {
void foo() throws Exception {
int n = System.in.read();
bar();
<caret>n = 1;
}
void bar(){}
}
@@ -0,0 +1,9 @@
// "Join declaration and assignment" "false"
class C {
void foo() {
int n = 0;
bar(n);
<caret>n = 1;
}
void bar(int i){}
}