mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Inline inner: check when possible to inline this ref only (IDEA-39274)
This commit is contained in:
+53
@@ -6,6 +6,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.psi.PsiCall;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiClassType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
@@ -377,4 +378,56 @@ public class InlineToAnonymousClassTest extends LightCodeInsightTestCase {
|
||||
assertEquals(0, conflicts.size());
|
||||
processor.run();
|
||||
}
|
||||
|
||||
public void testCanBeInvokedOnReference() throws Exception {
|
||||
doTestCanBeInvokedOnReference(true);
|
||||
}
|
||||
|
||||
public void testCanBeInvokedOnReference1() throws Exception {
|
||||
doTestCanBeInvokedOnReference(true);
|
||||
}
|
||||
|
||||
public void testCanBeInvokedOnReferenceSubstitution() throws Exception {
|
||||
doTestCanBeInvokedOnReference(true);
|
||||
}
|
||||
|
||||
public void testCanBeInvokedOnReferenceSubstitution1() throws Exception {
|
||||
doTestCanBeInvokedOnReference(true);
|
||||
}
|
||||
|
||||
public void testCanBeInvokedOnReferenceVarargs() throws Exception {
|
||||
doTestCanBeInvokedOnReference(true);
|
||||
}
|
||||
|
||||
public void testCantBeInvokedOnReference() throws Exception {
|
||||
doTestCanBeInvokedOnReference(false);
|
||||
}
|
||||
|
||||
public void testCantBeInvokedOnReference1() throws Exception {
|
||||
doTestCanBeInvokedOnReference(false);
|
||||
}
|
||||
|
||||
public void testCantBeInvokedOnReferenceReturnStatement() throws Exception {
|
||||
doTestCanBeInvokedOnReference(false);
|
||||
}
|
||||
|
||||
public void testCanBeInvokedOnReferenceSyncStatement() throws Exception {
|
||||
doTestCanBeInvokedOnReference(true);
|
||||
}
|
||||
|
||||
public void testCantBeInvokedOnReferenceThrowStatement() throws Exception {
|
||||
doTestCanBeInvokedOnReference(false);
|
||||
}
|
||||
|
||||
private void doTestCanBeInvokedOnReference(boolean canBeInvokedOnReference) throws Exception {
|
||||
configureByFile("/refactoring/inlineToAnonymousClass/" + getTestName(false) + ".java");
|
||||
PsiElement element = TargetElementUtilBase
|
||||
.findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED);
|
||||
PsiCall callToInline = InlineToAnonymousClassHandler.findCallToInline(myEditor);
|
||||
PsiClass classToInline = (PsiClass) element;
|
||||
assertEquals(null, InlineToAnonymousClassHandler.getCannotInlineMessage(classToInline));
|
||||
final PsiClassType superType = InlineToAnonymousClassProcessor.getSuperType(classToInline);
|
||||
assertTrue(superType != null);
|
||||
assertEquals(canBeInvokedOnReference, InlineToAnonymousClassHandler.canBeInvokedOnReference(callToInline, superType));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user