KT-1666 Invoking "Go to Declaration" for String type offers two variants - Temp boring fix
#KT-1666 fixed
This commit is contained in:
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.VariableAsFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.VariableAsFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
@@ -39,7 +40,18 @@ public class BindingContextUtils {
|
|||||||
if (declarationDescriptor == null) {
|
if (declarationDescriptor == null) {
|
||||||
return bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression);
|
return bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression);
|
||||||
}
|
}
|
||||||
return bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor);
|
|
||||||
|
PsiElement element = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor);
|
||||||
|
if (element != null) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Need to have a valid stubs for standard classes
|
||||||
|
if (referenceExpression != null && JetStandardClasses.getAllStandardClasses().contains(declarationDescriptor)) {
|
||||||
|
return referenceExpression.getContainingFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
~file~var x : `file`String = ""
|
||||||
@@ -156,11 +156,18 @@ public abstract class ExpectedResolveData {
|
|||||||
Position position = entry.getValue();
|
Position position = entry.getValue();
|
||||||
PsiElement element = position.getElement();
|
PsiElement element = position.getElement();
|
||||||
|
|
||||||
PsiElement ancestorOfType = getAncestorOfType(JetDeclaration.class, element);
|
PsiElement ancestorOfType;
|
||||||
if (ancestorOfType == null) {
|
|
||||||
JetNamespaceHeader header = getAncestorOfType(JetNamespaceHeader.class, element);
|
if (name.equals("file")) {
|
||||||
assert header != null : "Not a declaration: " + name;
|
ancestorOfType = element.getContainingFile();
|
||||||
ancestorOfType = element;
|
}
|
||||||
|
else {
|
||||||
|
ancestorOfType = getAncestorOfType(JetDeclaration.class, element);
|
||||||
|
if (ancestorOfType == null) {
|
||||||
|
JetNamespaceHeader header = getAncestorOfType(JetNamespaceHeader.class, element);
|
||||||
|
assert header != null : "Not a declaration: " + name;
|
||||||
|
ancestorOfType = element;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nameToDeclaration.put(name, ancestorOfType);
|
nameToDeclaration.put(name, ancestorOfType);
|
||||||
declarationToName.put(ancestorOfType, name);
|
declarationToName.put(ancestorOfType, name);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.jet.plugin.references;
|
package org.jetbrains.jet.plugin.references;
|
||||||
|
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiElementResolveResult;
|
import com.intellij.psi.PsiElementResolveResult;
|
||||||
import com.intellij.psi.PsiPolyVariantReference;
|
import com.intellij.psi.PsiPolyVariantReference;
|
||||||
@@ -111,13 +110,6 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
|||||||
Collection<? extends DeclarationDescriptor> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
Collection<? extends DeclarationDescriptor> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||||
if (declarationDescriptors != null) return null;
|
if (declarationDescriptors != null) return null;
|
||||||
|
|
||||||
|
|
||||||
VirtualFile elementFile = file.getVirtualFile();
|
|
||||||
if (elementFile != null && elementFile.getNameWithoutExtension().equals(getElement().getText())) {
|
|
||||||
LOG.warn("Possible problem with file rename: " + elementFile.getNameWithoutExtension() +
|
|
||||||
", element: " + getElement());
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Need a better resolution for Intrinsic function (KT-975)
|
// TODO: Need a better resolution for Intrinsic function (KT-975)
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user