Don't insert fqn even if current element is resolved into constructor
This commit is contained in:
@@ -18,10 +18,7 @@ package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
@@ -92,7 +89,18 @@ public class ImportInsertHelper {
|
||||
PsiElement target = reference.resolve();
|
||||
if (target != null) {
|
||||
boolean same = file.getManager().areElementsEquivalent(target, targetElement);
|
||||
same |= target instanceof PsiClass && importFqn.getFqName().equals(((PsiClass)target).getQualifiedName());
|
||||
|
||||
if (!same) {
|
||||
same = target instanceof PsiClass && importFqn.getFqName().equals(((PsiClass)target).getQualifiedName());
|
||||
}
|
||||
|
||||
if (!same) {
|
||||
if (target instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod) target;
|
||||
same = (method.isConstructor() && file.getManager().areElementsEquivalent(method.getContainingClass(), targetElement));
|
||||
}
|
||||
}
|
||||
|
||||
if (!same) {
|
||||
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
|
||||
TextRange refRange = reference.getElement().getTextRange();
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
throw IllegalAccessExceptio<caret>() //Press Ctrl+Space and select it
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
throw IllegalAccessException<caret>() //Press Ctrl+Space and select it
|
||||
}
|
||||
@@ -45,6 +45,10 @@ public class CompletionHandlerTest extends LightCompletionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDoNotInsertImportIfResolvedIntoJavaConstructor() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNonStandardArray() {
|
||||
doTest(CompletionType.BASIC, 2, "Array", "java.lang.reflect", '\n');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user