Java: Convert intention "Join Declaration And Assignment" into inspection (IDEA-178919)

This commit is contained in:
Pavel Dolgov
2018-10-04 16:46:00 +03:00
parent f90397afe1
commit 799b769b2f
13 changed files with 176 additions and 34 deletions
@@ -0,0 +1,10 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
class C {
void foo() {
@A int n = 1;
}
@Target(ElementType.LOCAL_VARIABLE) @interface A {}
}
@@ -1,8 +1,13 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class Test {
{
String ss = "hello"; // comment A
// comment B
/*comment C*/ /*comment D*/ // comment E
}
{
/*comment 1*/
/*comment 2*/
/*comment 3*/
// comment 4
// comment A
/*comment B*/
/*comment C*/
String ss = "hello" + /*comment D*/ " world";/*comment E*/// comment F
}
}
@@ -1,6 +1,6 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class Test {
{
String ss = "hello";
String ss = "hello";
}
}
@@ -1,6 +1,7 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class Test {
{
String ss = "hello", a = "";
String a = "";
String ss = "hello";
}
}
@@ -1,6 +1,6 @@
// "Join declaration and assignment" "INFORMATION"
class Test {
{
int i = 4 * (2 + 3);
int i = 4 * (2 + 3);
}
}
@@ -1,6 +1,6 @@
// "Join declaration and assignment" "INFORMATION"
class Test {
{
String ss = "hello" + "world";
String ss = "hello" + "world";
}
}
@@ -0,0 +1,12 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
class C {
void foo() {
@A @B int k, m;
@A @B int n = 1;
}
@Target(ElementType.LOCAL_VARIABLE) @interface A {}
@Target(ElementType.LOCAL_VARIABLE) @interface B {}
}
@@ -0,0 +1,8 @@
// "Join declaration and assignment" "INFORMATION"
class C {
int foo (int a, int b){
int x = a;
x = x * 31 + b;
return x;
}
}
@@ -0,0 +1,11 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
class C {
void foo() {
@A int n;
<caret>n = 1;
}
@Target(ElementType.LOCAL_VARIABLE) @interface A {}
}
@@ -1,8 +1,8 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
class Test {
{
String s<caret>s = ""; // comment A
// comment B
/*comment C*/ ss /*comment D*/ = "hello"; // comment E
}
{
String /*comment 1*/ s<caret>s /*comment 2*/ = "" /*comment 3*/; // comment 4
// comment A
/*comment B*/ ss /*comment C*/ = "hello" + /*comment D*/ " world" /*comment E*/; // comment F
}
}
@@ -0,0 +1,12 @@
// "Join declaration and assignment" "GENERIC_ERROR_OR_WARNING"
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
class C {
void foo() {
@A @B int k, n, m;
<caret>n = 1;
}
@Target(ElementType.LOCAL_VARIABLE) @interface A {}
@Target(ElementType.LOCAL_VARIABLE) @interface B {}
}
@@ -0,0 +1,9 @@
// "Join declaration and assignment" "INFORMATION"
class C {
int foo (int a, int b){
int x;
<caret>x = a;
x = x * 31 + b;
return x;
}
}