Java: allow to introduce a constant as a field of an inner, local or anonymous class (IDEA-341923)

for Introduce Constant refactoring. Also fixes IDEABKL-3269 when introducing a compile-time constant from an expression.

GitOrigin-RevId: 169e7ee8e14306a265948537b62746d9a26c0298
This commit is contained in:
Bas Leijdekkers
2023-12-28 16:10:18 +01:00
committed by intellij-monorepo-bot
parent cf79dfa709
commit 0dbc31a8b6
11 changed files with 108 additions and 41 deletions

View File

@@ -0,0 +1,7 @@
class Foo {
class Bar {
void foo() {
String str = <caret>"42";
}
}
}

View File

@@ -0,0 +1,9 @@
class Foo {
class Bar {
public static final String xxx = "42";
void foo() {
String str = xxx;
}
}
}

View File

@@ -1,9 +1,11 @@
import org.jetbrains.annotations.NonNls;
class Foo {
class Bar {
public static final String xxx = "42";
@NonNls
private static final String xxx = "42";
void foo() {
String str = xxx;
}
}
}
}

View File

@@ -0,0 +1,10 @@
class X {
void x() {
new Object() {
void x() {
System.out.println(<selection>new <caret>Object()</selection>);
}
};
}
}

View File

@@ -0,0 +1,10 @@
class X {
void x() {
new Object() {
void x() {
System.out.println(<selection>new <caret>Object()</selection>);
}
};
}
}

View File

@@ -0,0 +1,12 @@
class X {
public static final Object xxx = new Object();
void x() {
new Object() {
void x() {
System.out.println(xxx);
}
};
}
}

View File

@@ -0,0 +1,12 @@
class X {
void x() {
new Object() {
public static final Object xxx = new Object();
void x() {
System.out.println(xxx);
}
};
}
}