mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
IDEA-169518 Convert "Move assignment to field declaration" to the inspection
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// "Move assignment to field declaration" "true"
|
||||
// "Move assignment to field declaration" "INFORMATION"
|
||||
|
||||
class X {
|
||||
int f = 0;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
// "Move assignment to field declaration" "true"
|
||||
// "Move assignment to field declaration" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
class X {
|
||||
static int f = 0;
|
||||
static {
|
||||
<caret>}
|
||||
X(int i) {
|
||||
/*
|
||||
Set to zero
|
||||
*/
|
||||
static int f = 0;
|
||||
|
||||
X(int i) {
|
||||
}
|
||||
void x() {
|
||||
int i = f;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// "Move assignment to field declaration" "true"
|
||||
|
||||
class X {
|
||||
Object f = new Runnable() {
|
||||
void x(int p) {
|
||||
int f = p;
|
||||
}
|
||||
// Create default runnable
|
||||
Object f = new Runnable() {
|
||||
void x(int p) {
|
||||
int f = p;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
public void run() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
X() {
|
||||
<caret>//
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// "Move assignment to field declaration" "INFORMATION"
|
||||
public class Test {
|
||||
static LoggingSystem LOG = LoggingSystem.getLogger();
|
||||
|
||||
static {
|
||||
LoggingSystem.init();
|
||||
}
|
||||
}
|
||||
|
||||
class LoggingSystem {
|
||||
private static LoggingSystem L;
|
||||
|
||||
static LoggingSystem getLogger() {
|
||||
return L;
|
||||
}
|
||||
|
||||
static void init() {
|
||||
if(L == null) {
|
||||
L = new LoggingSystem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// "Move assignment to field declaration" "true"
|
||||
public class X {
|
||||
int i = 0;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Move assignment to field declaration" "INFORMATION"
|
||||
public class Test {
|
||||
String myField = getValue();
|
||||
private String value;
|
||||
|
||||
void f() {
|
||||
}
|
||||
|
||||
public static String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Move assignment to field declaration" "true"
|
||||
// "Move assignment to field declaration" "INFORMATION"
|
||||
|
||||
class X {
|
||||
int f;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// "Move assignment to field declaration" "true"
|
||||
// "Move assignment to field declaration" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
class X {
|
||||
static int f;
|
||||
static {
|
||||
f = <caret>0;
|
||||
/*
|
||||
Set to zero
|
||||
*/
|
||||
<caret>f = 0;
|
||||
}
|
||||
X(int i) {
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class X {
|
||||
Object f;
|
||||
X() {
|
||||
// Create default runnable
|
||||
<caret>f = new Runnable() {
|
||||
void x(int p) {
|
||||
int f = p;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// "Move assignment to field declaration" "INFORMATION"
|
||||
public class Test {
|
||||
static LoggingSystem LOG;
|
||||
|
||||
static {
|
||||
LoggingSystem.init();
|
||||
<caret>LOG = LoggingSystem.getLogger();
|
||||
}
|
||||
}
|
||||
|
||||
class LoggingSystem {
|
||||
private static LoggingSystem L;
|
||||
|
||||
static LoggingSystem getLogger() {
|
||||
return L;
|
||||
}
|
||||
|
||||
static void init() {
|
||||
if(L == null) {
|
||||
L = new LoggingSystem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move assignment to field declaration" "false"
|
||||
public class Test {
|
||||
String myField;
|
||||
private String value;
|
||||
|
||||
void f() {
|
||||
<caret>myField = getValue();
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,6 @@
|
||||
public class X {
|
||||
int i;
|
||||
{
|
||||
(i)=<caret>0;
|
||||
(<caret>i)=0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Move assignment to field declaration" "false"
|
||||
public class Test {
|
||||
final static String FIELD;
|
||||
static {
|
||||
String data = " foo ";
|
||||
<caret>FIELD = data.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Move assignment to field declaration" "INFORMATION"
|
||||
public class Test {
|
||||
String myField;
|
||||
private String value;
|
||||
|
||||
void f() {
|
||||
<caret>myField = getValue();
|
||||
}
|
||||
|
||||
public static String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user