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() {
|
public JetExpression getReceiverExpression() {
|
||||||
PsiElement parent = getParent();
|
PsiElement parent = getParent();
|
||||||
if (parent instanceof JetQualifiedExpression && !isImportDirectiveExpression()) {
|
if (parent instanceof JetQualifiedExpression && !isImportDirectiveExpression()) {
|
||||||
JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) parent;
|
JetExpression receiverExpression = ((JetQualifiedExpression) parent).getReceiverExpression();
|
||||||
if (!isFirstPartInQualifiedExpression(qualifiedExpression)) {
|
// Name expression can't be receiver for itself
|
||||||
return qualifiedExpression.getReceiverExpression();
|
if (receiverExpression != this) {
|
||||||
|
return receiverExpression;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (parent instanceof JetCallExpression) {
|
else if (parent instanceof JetCallExpression) {
|
||||||
@@ -63,18 +64,10 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
|
|||||||
return qualifiedExpression.getReceiverExpression();
|
return qualifiedExpression.getReceiverExpression();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
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() {
|
public boolean isImportDirectiveExpression() {
|
||||||
PsiElement parent = getParent();
|
PsiElement parent = getParent();
|
||||||
if (parent == null) return false;
|
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();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInLongDotQualifiedExpression() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
public void testInMiddleOfNamespace() {
|
public void testInMiddleOfNamespace() {
|
||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user