mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-refactoring] IDEA-340087 produce accurate PsiType for implicit classes
- fix Introduce variable throws exception in implicit classes GitOrigin-RevId: c3489b1c6df3669f01b6e5defbf8a2208a7b441d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a7355dae7
commit
7ed93305c1
@@ -224,7 +224,7 @@ public class PsiImmediateClassType extends PsiClassType.Stub {
|
||||
PsiClass enclosingClass = null;
|
||||
if (!aClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
PsiElement parent = aClass.getParent();
|
||||
if (parent instanceof PsiClass && !(parent instanceof PsiAnonymousClass)) {
|
||||
if (parent instanceof PsiClass && !(parent instanceof PsiAnonymousClass) && !(parent instanceof PsiImplicitClass)) {
|
||||
enclosingClass = (PsiClass)parent;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ public class C {
|
||||
private final String myStr;
|
||||
|
||||
public C() {
|
||||
myStr = "";
|
||||
String strings = myStr;
|
||||
strings = "";
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Nested {
|
||||
}
|
||||
|
||||
void main() {
|
||||
Class<Nested> x = Nested.class;
|
||||
System.out.println(x);
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Nested {
|
||||
}
|
||||
|
||||
void main() {
|
||||
System.out.println(<selection>Nested.class</selection>);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class cTest {
|
||||
{
|
||||
cTest cTest = new cTest();<caret>
|
||||
cTest <caret>cTest = new cTest();
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,7 @@ class C {
|
||||
|
||||
void test () {
|
||||
C c = new C();
|
||||
String wrong = c.f();
|
||||
for (; wrong != null;) {
|
||||
for (;c.f() != null;) {
|
||||
c = c.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,6 +510,10 @@ public class IntroduceVariableTest extends LightJavaCodeInsightTestCase {
|
||||
doTest("x", true, false, true, "int");
|
||||
}
|
||||
|
||||
public void testIntroduceVariableInsideImplicitClass() {
|
||||
doTest("x", true, false, false, "java.lang.Class<Nested>");
|
||||
}
|
||||
|
||||
private void doTestWithVarType(IntroduceVariableBase testMe) {
|
||||
Boolean asVarType = JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE;
|
||||
try {
|
||||
@@ -540,8 +544,9 @@ public class IntroduceVariableTest extends LightJavaCodeInsightTestCase {
|
||||
testMe.invoke(getProject(), getEditor(), getFile(), null);
|
||||
NonBlockingReadActionImpl.waitForAsyncTaskCompletion();
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
|
||||
if (state == null) return;
|
||||
state.gotoEnd(false);
|
||||
if (state != null) {
|
||||
state.gotoEnd(false);
|
||||
}
|
||||
checkResultByFile(baseName + ".after.java");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user