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();
|
||||
|
||||
Reference in New Issue
Block a user