Fix JetSimpleNameExpression#getReceiver
Correct behaviour for unary, binary expressions and type references Add instanceof checks in TipsManager so it's clear it only takes care of certain types of JetSimpleNameExpression
This commit is contained in:
@@ -292,8 +292,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
@NotNull GlobalSearchScope searchScope
|
||||
) {
|
||||
BindingContext context = resolveSession.resolveToElement(expression);
|
||||
JetExpression receiverExpression = getReceiverForExtensionCall(expression);
|
||||
|
||||
JetExpression receiverExpression = expression.getReceiverExpression();
|
||||
if (receiverExpression == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -325,18 +324,6 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
return resultDescriptors;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetExpression getReceiverForExtensionCall(@NotNull JetSimpleNameExpression expression) {
|
||||
PsiElement parent = expression.getParent();
|
||||
if (parent instanceof JetBinaryExpression && ((JetBinaryExpression) parent).getOperationReference() == expression) {
|
||||
return ((JetBinaryExpression) parent).getLeft();
|
||||
}
|
||||
else if (parent instanceof JetUnaryExpression && ((JetUnaryExpression) parent).getOperationReference() == expression) {
|
||||
return ((JetUnaryExpression) parent).getBaseExpression();
|
||||
}
|
||||
return expression.getReceiverExpression();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Set<FqName> extensionFunctionsFromSourceFqNames(
|
||||
@NotNull Condition<String> acceptedNameCondition,
|
||||
|
||||
@@ -20,16 +20,14 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPackageDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
@@ -54,7 +52,9 @@ public final class TipsManager {
|
||||
@NotNull BindingContext context
|
||||
) {
|
||||
JetExpression receiverExpression = expression.getReceiverExpression();
|
||||
if (receiverExpression != null) {
|
||||
PsiElement parent = expression.getParent();
|
||||
boolean inPositionForCompletionWithReceiver = parent instanceof JetCallExpression || parent instanceof JetQualifiedExpression;
|
||||
if (receiverExpression != null && inPositionForCompletionWithReceiver) {
|
||||
// Process as call expression
|
||||
JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||
JetType expressionType = context.get(BindingContext.EXPRESSION_TYPE, receiverExpression);
|
||||
|
||||
Reference in New Issue
Block a user