mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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.
This commit is contained in:
@@ -3947,19 +3947,12 @@ public:
|
||||
if (!tuple)
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0, n = tuple->getNumElements(); i != n; ++i) {
|
||||
if (isa<CodeCompletionExpr>(tuple->getElement(i))) {
|
||||
HasName = !tuple->getElementName(i).empty();
|
||||
Position = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
auto &SM = DC.getASTContext().SourceMgr;
|
||||
for (unsigned i = 0, n = tuple->getNumElements(); i != n; ++i) {
|
||||
if (SM.isBeforeInBuffer(tuple->getElement(i)->getEndLoc(),
|
||||
CCExpr->getStartLoc()))
|
||||
continue;
|
||||
HasName = !tuple->getElementName(i).empty();
|
||||
HasName = tuple->getElementNameLoc(i).isValid();
|
||||
Position = i;
|
||||
return true;
|
||||
}
|
||||
@@ -3983,7 +3976,8 @@ public:
|
||||
|
||||
// Collect possible types (or labels) at the position.
|
||||
{
|
||||
bool MayNeedName = !HasName && isa<CallExpr>(CallE);
|
||||
bool MayNeedName =
|
||||
!HasName && isa<CallExpr>(CallE) && !CallE->isImplicit();
|
||||
SmallPtrSet<TypeBase *, 4> seenTypes;
|
||||
SmallPtrSet<Identifier, 4> seenNames;
|
||||
for (auto Params : Candidates) {
|
||||
|
||||
Reference in New Issue
Block a user