KT-2796 Variable name is not completed in the receiver position of a chained call
#KT-2796 Fixed
This commit is contained in:
@@ -49,9 +49,10 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
|
||||
public JetExpression getReceiverExpression() {
|
||||
PsiElement parent = getParent();
|
||||
if (parent instanceof JetQualifiedExpression && !isImportDirectiveExpression()) {
|
||||
JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) parent;
|
||||
if (!isFirstPartInQualifiedExpression(qualifiedExpression)) {
|
||||
return qualifiedExpression.getReceiverExpression();
|
||||
JetExpression receiverExpression = ((JetQualifiedExpression) parent).getReceiverExpression();
|
||||
// Name expression can't be receiver for itself
|
||||
if (receiverExpression != this) {
|
||||
return receiverExpression;
|
||||
}
|
||||
}
|
||||
else if (parent instanceof JetCallExpression) {
|
||||
@@ -63,18 +64,10 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
|
||||
return qualifiedExpression.getReceiverExpression();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that this is simple name expression is first part in full qualified name: firstPart.otherPart.otherPart.call()
|
||||
private boolean isFirstPartInQualifiedExpression(JetQualifiedExpression qualifiedExpression) {
|
||||
if (qualifiedExpression.getParent() instanceof JetQualifiedExpression) {
|
||||
return isFirstPartInQualifiedExpression((JetQualifiedExpression) qualifiedExpression.getParent());
|
||||
}
|
||||
|
||||
return qualifiedExpression.getFirstChild() == this;
|
||||
}
|
||||
|
||||
public boolean isImportDirectiveExpression() {
|
||||
PsiElement parent = getParent();
|
||||
if (parent == null) return false;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// For KT-2796
|
||||
|
||||
fun test() {
|
||||
val bVal = 1
|
||||
b<caret>.app().app() // b is not there
|
||||
}
|
||||
|
||||
// EXIST: bVal
|
||||
@@ -153,6 +153,10 @@ public class JetBasicCompletionTest extends JetCompletionTestBase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInLongDotQualifiedExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInMiddleOfNamespace() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user