@@ -284,8 +284,6 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks,
284284 void completeUnresolvedMember (CodeCompletionExpr *E,
285285 SourceLoc DotLoc) override ;
286286 void completeCallArg (CodeCompletionExpr *E, bool isFirst) override ;
287- void completeLabeledTrailingClosure (CodeCompletionExpr *E,
288- bool isAtStartOfLine) override ;
289287
290288 bool canPerformCompleteLabeledTrailingClosure () const override {
291289 return true ;
@@ -576,15 +574,6 @@ void CodeCompletionCallbacksImpl::completeCallArg(CodeCompletionExpr *E,
576574 }
577575}
578576
579- void CodeCompletionCallbacksImpl::completeLabeledTrailingClosure (
580- CodeCompletionExpr *E, bool isAtStartOfLine) {
581- CurDeclContext = P.CurDeclContext ;
582- CodeCompleteTokenExpr = E;
583- Kind = CompletionKind::LabeledTrailingClosure;
584- IsAtStartOfLine = isAtStartOfLine;
585- ShouldCompleteCallPatternAfterParen = false ;
586- }
587-
588577void CodeCompletionCallbacksImpl::completeReturnStmt (CodeCompletionExpr *E) {
589578 CurDeclContext = P.CurDeclContext ;
590579 CodeCompleteTokenExpr = E;
@@ -973,7 +962,6 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
973962 case CompletionKind::PoundAvailablePlatform:
974963 case CompletionKind::Import:
975964 case CompletionKind::UnresolvedMember:
976- case CompletionKind::LabeledTrailingClosure:
977965 case CompletionKind::AfterPoundExpr:
978966 case CompletionKind::AfterPoundDirective:
979967 case CompletionKind::PlatformConditon:
@@ -1558,19 +1546,15 @@ bool CodeCompletionCallbacksImpl::trySolverCompletion(bool MaybeFuncBody) {
15581546 return true ;
15591547 }
15601548 case CompletionKind::PostfixExprParen:
1561- case CompletionKind::CallArg:
1562- case CompletionKind::LabeledTrailingClosure: {
1563- // FIXME: Delete LabeledTrailingClosure
1549+ case CompletionKind::CallArg: {
15641550 assert (CodeCompleteTokenExpr);
15651551 assert (CurDeclContext);
15661552 ArgumentTypeCheckCompletionCallback Lookup (CodeCompleteTokenExpr,
15671553 CurDeclContext);
15681554 typeCheckWithLookup (Lookup);
15691555
1570- bool IsLabeledTrailingClosure =
1571- (Kind == CompletionKind::LabeledTrailingClosure);
15721556 Lookup.collectResults (ShouldCompleteCallPatternAfterParen,
1573- IsLabeledTrailingClosure, CompletionLoc,
1557+ /* IsLabeledTrailingClosure= */ false , CompletionLoc,
15741558 CurDeclContext, CompletionContext);
15751559 Consumer.handleResults (CompletionContext);
15761560 return true ;
@@ -1884,116 +1868,6 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
18841868 Lookup.addImportModuleNames ();
18851869 break ;
18861870 }
1887- case CompletionKind::LabeledTrailingClosure: {
1888- ExprContextInfo ContextInfo (CurDeclContext, CodeCompleteTokenExpr);
1889-
1890- SmallVector<PossibleParamInfo, 2 > params;
1891- // Only complete function type parameters
1892- llvm::copy_if (ContextInfo.getPossibleParams (), std::back_inserter (params),
1893- [](const PossibleParamInfo &P) {
1894- // nullptr indicates out of bounds.
1895- if (!P.Param )
1896- return true ;
1897- return P.Param ->getPlainType ()
1898- ->lookThroughAllOptionalTypes ()
1899- ->is <AnyFunctionType>();
1900- });
1901-
1902- bool allRequired = false ;
1903- if (!params.empty ()) {
1904- Lookup.addCallArgumentCompletionResults (
1905- params, /* isLabeledTrailingClosure=*/ true );
1906- allRequired = llvm::all_of (
1907- params, [](const PossibleParamInfo &P) { return P.IsRequired ; });
1908- }
1909-
1910- // If there're optional parameters, do global completion or member
1911- // completion depending on the completion is happening at the start of line.
1912- if (!allRequired) {
1913- if (IsAtStartOfLine) {
1914- // foo() {}
1915- // <HERE>
1916-
1917- auto &Sink = CompletionContext.getResultSink ();
1918- if (isa<Initializer>(CurDeclContext))
1919- CurDeclContext = CurDeclContext->getParent ();
1920-
1921- if (CurDeclContext->isTypeContext ()) {
1922- // Override completion (CompletionKind::NominalMemberBeginning).
1923- addDeclKeywords (Sink, CurDeclContext,
1924- Context.LangOpts .EnableExperimentalConcurrency );
1925- addLetVarKeywords (Sink);
1926- SmallVector<StringRef, 0 > ParsedKeywords;
1927- CompletionOverrideLookup OverrideLookup (Sink, Context, CurDeclContext,
1928- ParsedKeywords, SourceLoc ());
1929- OverrideLookup.getOverrideCompletions (SourceLoc ());
1930- } else {
1931- // Global completion (CompletionKind::PostfixExprBeginning).
1932- addDeclKeywords (Sink, CurDeclContext,
1933- Context.LangOpts .EnableExperimentalConcurrency );
1934- addStmtKeywords (Sink, CurDeclContext, MaybeFuncBody);
1935- addSuperKeyword (Sink, CurDeclContext);
1936- addLetVarKeywords (Sink);
1937- addExprKeywords (Sink, CurDeclContext);
1938- addAnyTypeKeyword (Sink, Context.TheAnyType );
1939- DoPostfixExprBeginning ();
1940- }
1941- } else {
1942- // foo() {} <HERE>
1943- // Member completion.
1944- Expr *analyzedExpr = ContextInfo.getAnalyzedExpr ();
1945- if (!analyzedExpr)
1946- break ;
1947-
1948- // Only if the completion token is the last token in the call.
1949- if (analyzedExpr->getEndLoc () != CodeCompleteTokenExpr->getLoc ())
1950- break ;
1951-
1952- Type resultTy = analyzedExpr->getType ();
1953- // If the call expression doesn't have a type, fallback to:
1954- if (!resultTy || resultTy->is <ErrorType>()) {
1955- // 1) Try to type check removing CodeCompletionExpr from the call.
1956- Expr *removedExpr = analyzedExpr;
1957- removeCodeCompletionExpr (CurDeclContext->getASTContext (),
1958- removedExpr);
1959- ConcreteDeclRef referencedDecl;
1960- auto optT = getTypeOfCompletionContextExpr (
1961- CurDeclContext->getASTContext (), CurDeclContext,
1962- CompletionTypeCheckKind::Normal, removedExpr, referencedDecl);
1963- if (optT) {
1964- resultTy = *optT;
1965- analyzedExpr->setType (resultTy);
1966- }
1967- }
1968- if (!resultTy || resultTy->is <ErrorType>()) {
1969- // 2) Infer it from the possible callee info.
1970- if (!ContextInfo.getPossibleCallees ().empty ()) {
1971- auto calleeInfo = ContextInfo.getPossibleCallees ()[0 ];
1972- resultTy = calleeInfo.Type ->getResult ();
1973- analyzedExpr->setType (resultTy);
1974- }
1975- }
1976- if (!resultTy || resultTy->is <ErrorType>()) {
1977- // 3) Give up providing postfix completions.
1978- break ;
1979- }
1980-
1981- auto &SM = CurDeclContext->getASTContext ().SourceMgr ;
1982- auto leadingChar = SM.extractText (
1983- {SM.getIDEInspectionTargetLoc ().getAdvancedLoc (-1 ), 1 });
1984- Lookup.setHaveLeadingSpace (leadingChar.find_first_of (" \t\f\v " ) !=
1985- StringRef::npos);
1986-
1987- if (isDynamicLookup (resultTy))
1988- Lookup.setIsDynamicLookup ();
1989- Lookup.getValueExprCompletions (resultTy, /* VD=*/ nullptr ,
1990- /* IncludeFunctionCallCompletions=*/ true );
1991- Lookup.getOperatorCompletions (analyzedExpr, leadingSequenceExprs);
1992- Lookup.getPostfixKeywordCompletions (resultTy, analyzedExpr);
1993- }
1994- }
1995- break ;
1996- }
19971871
19981872 case CompletionKind::ReturnStmtExpr : {
19991873 SourceLoc Loc = P.Context .SourceMgr .getIDEInspectionTargetLoc ();
0 commit comments