Skip to content

Commit 137ca65

Browse files
committed
[CodeCompletion] Simplify getPositionInArgs()
* Don't need to look for CodeCompletionExpr. It's wrong anyway because what we are looking for is not neccessarily a 'CodeCompletionExpr'. * Use getElementLoc(i).isValid() instead of !getElementName(i).empty(). Just in case users write '_:' for call argument. * Don't suggest argument labels for implicit call expression. For instance, string interpolation segments.
1 parent 18582d3 commit 137ca65

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3947,19 +3947,12 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
39473947
if (!tuple)
39483948
return false;
39493949

3950-
for (unsigned i = 0, n = tuple->getNumElements(); i != n; ++i) {
3951-
if (isa<CodeCompletionExpr>(tuple->getElement(i))) {
3952-
HasName = !tuple->getElementName(i).empty();
3953-
Position = i;
3954-
return true;
3955-
}
3956-
}
39573950
auto &SM = DC.getASTContext().SourceMgr;
39583951
for (unsigned i = 0, n = tuple->getNumElements(); i != n; ++i) {
39593952
if (SM.isBeforeInBuffer(tuple->getElement(i)->getEndLoc(),
39603953
CCExpr->getStartLoc()))
39613954
continue;
3962-
HasName = !tuple->getElementName(i).empty();
3955+
HasName = tuple->getElementNameLoc(i).isValid();
39633956
Position = i;
39643957
return true;
39653958
}
@@ -3983,7 +3976,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
39833976

39843977
// Collect possible types (or labels) at the position.
39853978
{
3986-
bool MayNeedName = !HasName && isa<CallExpr>(CallE);
3979+
bool MayNeedName =
3980+
!HasName && isa<CallExpr>(CallE) && !CallE->isImplicit();
39873981
SmallPtrSet<TypeBase *, 4> seenTypes;
39883982
SmallPtrSet<Identifier, 4> seenNames;
39893983
for (auto Params : Candidates) {

0 commit comments

Comments
 (0)