diff --git a/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java b/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java index 8667a4ddea2..2a4d73b4618 100644 --- a/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java +++ b/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java @@ -140,9 +140,9 @@ public class JetSourceNavigationHelper { @Nullable private static JetDeclaration - getSourcePropertyOrFunction(final @NotNull Decl decompiledDeclaration, - JetTypeReference receiverType, - NavigationStrategy navigationStrategy + getSourcePropertyOrFunction( + final @NotNull Decl decompiledDeclaration, + NavigationStrategy navigationStrategy ) { String entityName = decompiledDeclaration.getName(); if (entityName == null) { @@ -151,6 +151,8 @@ public class JetSourceNavigationHelper { Name entityNameAsName = Name.identifier(entityName); + JetTypeReference receiverType = navigationStrategy.getReceiverType(decompiledDeclaration); + PsiElement declarationContainer = decompiledDeclaration.getParent(); if (declarationContainer instanceof JetFile) { Pair bindingContextAndNamespaceDescriptor = @@ -159,7 +161,7 @@ public class JetSourceNavigationHelper { BindingContext bindingContext = bindingContextAndNamespaceDescriptor.first; NamespaceDescriptor namespaceDescriptor = bindingContextAndNamespaceDescriptor.second; if (receiverType == null) { - // non-extension property + // non-extension member for (Descr candidate : navigationStrategy.getCandidateDescriptors(namespaceDescriptor.getMemberScope(), entityNameAsName)) { if (candidate.getReceiverParameter() == null) { if (navigationStrategy.declarationAndDescriptorMatch(decompiledDeclaration, candidate)) { @@ -169,7 +171,7 @@ public class JetSourceNavigationHelper { } } else { - // extension property + // extension member String expectedTypeString = receiverType.getText(); for (Descr candidate : navigationStrategy.getCandidateDescriptors(namespaceDescriptor.getMemberScope(), entityNameAsName)) { ReceiverParameterDescriptor receiverParameter = candidate.getReceiverParameter(); @@ -221,18 +223,20 @@ public class JetSourceNavigationHelper { @Nullable public static JetDeclaration getSourceProperty(final @NotNull JetProperty decompiledProperty) { - return getSourcePropertyOrFunction(decompiledProperty, decompiledProperty.getReceiverTypeRef(), new PropertyNavigationStrategy()); + return getSourcePropertyOrFunction(decompiledProperty, new PropertyNavigationStrategy()); } @Nullable public static JetDeclaration getSourceFunction(final @NotNull JetFunction decompiledFunction) { - return getSourcePropertyOrFunction(decompiledFunction, decompiledFunction.getReceiverTypeRef(), new FunctionNavigationStrategy()); + return getSourcePropertyOrFunction(decompiledFunction, new FunctionNavigationStrategy()); } private interface NavigationStrategy { boolean declarationAndDescriptorMatch(Decl declaration, Descr descriptor); Collection getCandidateDescriptors(JetScope scope, Name name); + + @Nullable JetTypeReference getReceiverType(@NotNull Decl declaration); } private static class FunctionNavigationStrategy implements NavigationStrategy { @@ -271,6 +275,12 @@ public class JetSourceNavigationHelper { public Collection getCandidateDescriptors(JetScope scope, Name name) { return scope.getFunctions(name); } + + @Nullable + @Override + public JetTypeReference getReceiverType(@NotNull JetFunction declaration) { + return declaration.getReceiverTypeRef(); + } } private static class PropertyNavigationStrategy implements NavigationStrategy { @@ -283,5 +293,11 @@ public class JetSourceNavigationHelper { public Collection getCandidateDescriptors(JetScope scope, Name name) { return scope.getProperties(name); } + + @Nullable + @Override + public JetTypeReference getReceiverType(@NotNull JetProperty declaration) { + return declaration.getReceiverTypeRef(); + } } }