navigate to several elements if there are many
(not only in ambiguity case)
This commit is contained in:
@@ -130,6 +130,10 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
|||||||
.getBindingContext();
|
.getBindingContext();
|
||||||
Collection<? extends DeclarationDescriptor> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
Collection<? extends DeclarationDescriptor> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||||
if (declarationDescriptors == null) {
|
if (declarationDescriptors == null) {
|
||||||
|
List<PsiElement> psiElements = BindingContextUtils.resolveToDeclarationPsiElements(bindingContext, myExpression);
|
||||||
|
if (!psiElements.isEmpty()) {
|
||||||
|
return PsiElementResolveResult.createResults(psiElements);
|
||||||
|
}
|
||||||
List<PsiElement> standardLibraryElements = resolveStandardLibrarySymbol(bindingContext);
|
List<PsiElement> standardLibraryElements = resolveStandardLibrarySymbol(bindingContext);
|
||||||
if (!standardLibraryElements.isEmpty()) {
|
if (!standardLibraryElements.isEmpty()) {
|
||||||
return PsiElementResolveResult.createResults(standardLibraryElements);
|
return PsiElementResolveResult.createResults(standardLibraryElements);
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
trait A {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
trait B {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
trait C : A, B {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(c: C) {
|
||||||
|
c.<caret>foo()
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.resolve;
|
package org.jetbrains.jet.resolve;
|
||||||
|
|
||||||
import com.intellij.openapi.projectRoots.Sdk;
|
import com.intellij.openapi.projectRoots.Sdk;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiPolyVariantReference;
|
import com.intellij.psi.PsiPolyVariantReference;
|
||||||
import com.intellij.psi.PsiReference;
|
import com.intellij.psi.PsiReference;
|
||||||
import com.intellij.psi.ResolveResult;
|
import com.intellij.psi.ResolveResult;
|
||||||
@@ -78,10 +79,12 @@ public class ResolveBaseTest extends LightCodeInsightTestCase {
|
|||||||
|
|
||||||
final PsiPolyVariantReference variantReference = (PsiPolyVariantReference) psiReference;
|
final PsiPolyVariantReference variantReference = (PsiPolyVariantReference) psiReference;
|
||||||
|
|
||||||
|
PsiElement element = variantReference.resolve();
|
||||||
final ResolveResult[] results = variantReference.multiResolve(true);
|
final ResolveResult[] results = variantReference.multiResolve(true);
|
||||||
for (ResolveResult result : results) {
|
for (ResolveResult result : results) {
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
}
|
}
|
||||||
|
assertTrue("Nothing resolved by reference '" + psiReference.getElement().getText() + "'.", element != null || results.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user