mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
introduce constant: add constant to destination class (IDEA-146787)
This commit is contained in:
+3
-6
@@ -894,13 +894,10 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
return field;
|
||||
}
|
||||
else {
|
||||
if (forwardReference != null ) {
|
||||
return forwardReference.getParent() == destClass ?
|
||||
(PsiField)destClass.addAfter(psiField, forwardReference) :
|
||||
(PsiField)forwardReference.getParent().addAfter(psiField, forwardReference);
|
||||
} else {
|
||||
return (PsiField)destClass.add(psiField);
|
||||
if (forwardReference != null &&forwardReference.getParent() == destClass) {
|
||||
return (PsiField)destClass.addAfter(psiField, forwardReference);
|
||||
}
|
||||
return (PsiField)destClass.add(psiField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
|
||||
public String getString() {
|
||||
return <selection>StaticInner.STRING</selection>;
|
||||
}
|
||||
|
||||
static class StaticInner {
|
||||
public static String STRING = "aaaa";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
|
||||
public static final String xxx = StaticInner.STRING;
|
||||
|
||||
public String getString() {
|
||||
return xxx;
|
||||
}
|
||||
|
||||
static class StaticInner {
|
||||
public static String STRING = "aaaa";
|
||||
}
|
||||
}
|
||||
@@ -116,11 +116,19 @@ public class IntroduceConstantTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
public void testComments() throws Exception {
|
||||
doTestExpr();
|
||||
}
|
||||
|
||||
private void doTestExpr() throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
checkDefaultType(CommonClassNames.JAVA_LANG_STRING);
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
public void testContainingClass() throws Exception {
|
||||
doTestExpr();
|
||||
}
|
||||
|
||||
public void testEscalateVisibility() throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
final PsiClass[] classes = ((PsiJavaFile)getFile()).getClasses();
|
||||
|
||||
Reference in New Issue
Block a user