|
35 | 35 | #include "swift/IDE/Utils.h" |
36 | 36 | #include "swift/Parse/CodeCompletionCallbacks.h" |
37 | 37 | #include "swift/Sema/IDETypeChecking.h" |
| 38 | +#include "swift/Sema/CodeCompletionTypeChecking.h" |
38 | 39 | #include "swift/Syntax/SyntaxKind.h" |
39 | 40 | #include "swift/Strings.h" |
40 | 41 | #include "swift/Subsystems.h" |
@@ -5911,17 +5912,18 @@ static void deliverCompletionResults(CodeCompletionContext &CompletionContext, |
5911 | 5912 | DCForModules); |
5912 | 5913 | } |
5913 | 5914 |
|
5914 | | -void DotExprLookup::performLookup(ide::CodeCompletionContext &CompletionCtx, |
5915 | | - CodeCompletionConsumer &Consumer, |
5916 | | - bool IsInSelector) const { |
| 5915 | +void deliverDotExprResults( |
| 5916 | + ArrayRef<DotExprTypeCheckCompletionCallback::Result> Solutions, |
| 5917 | + Expr *BaseExpr, DeclContext *DC, SourceLoc DotLoc, bool IsInSelector, |
| 5918 | + ide::CodeCompletionContext &CompletionCtx, |
| 5919 | + CodeCompletionConsumer &Consumer) { |
5917 | 5920 | ASTContext &Ctx = DC->getASTContext(); |
5918 | 5921 | CompletionLookup Lookup(CompletionCtx.getResultSink(), Ctx, DC, |
5919 | 5922 | &CompletionCtx); |
5920 | 5923 |
|
5921 | 5924 | if (DotLoc.isValid()) |
5922 | 5925 | Lookup.setHaveDot(DotLoc); |
5923 | 5926 |
|
5924 | | - Expr *BaseExpr = CompletionExpr->getBase(); |
5925 | 5927 | Lookup.setIsSuperRefExpr(isa<SuperRefExpr>(BaseExpr)); |
5926 | 5928 |
|
5927 | 5929 | if (auto *DRE = dyn_cast<DeclRefExpr>(BaseExpr)) |
@@ -5980,21 +5982,26 @@ bool CodeCompletionCallbacksImpl::trySolverCompletion() { |
5980 | 5982 | assert(CodeCompleteTokenExpr); |
5981 | 5983 | assert(CurDeclContext); |
5982 | 5984 |
|
5983 | | - DotExprLookup Lookup(DotLoc, CurDeclContext, CodeCompleteTokenExpr); |
5984 | | - llvm::SaveAndRestore<CompletionCollector*> |
| 5985 | + DotExprTypeCheckCompletionCallback Lookup(CurDeclContext, |
| 5986 | + CodeCompleteTokenExpr); |
| 5987 | + llvm::SaveAndRestore<TypeCheckCompletionCallback*> |
5985 | 5988 | CompletionCollector(Context.CompletionCallback, &Lookup); |
5986 | 5989 | typeCheckContextAt(CurDeclContext, CompletionLoc); |
5987 | 5990 |
|
5988 | 5991 | // This (hopefully) only happens in cases where the expression isn't |
5989 | 5992 | // typechecked during normal compilation either (e.g. member completion in a |
5990 | | - // switch case where there switched value is invalid). Having normal |
| 5993 | + // switch case where there control expression is invalid). Having normal |
5991 | 5994 | // typechecking still resolve even these cases would be beneficial for |
5992 | 5995 | // tooling in general though. |
5993 | 5996 | if (!Lookup.gotCallback()) |
5994 | 5997 | Lookup.fallbackTypeCheck(); |
5995 | 5998 |
|
5996 | 5999 | addKeywords(CompletionContext.getResultSink(), MaybeFuncBody); |
5997 | | - Lookup.performLookup(CompletionContext, Consumer, isInsideObjCSelector()); |
| 6000 | + |
| 6001 | + Expr *CheckedBase = CodeCompleteTokenExpr->getBase(); |
| 6002 | + deliverDotExprResults(Lookup.getResults(), CheckedBase, CurDeclContext, |
| 6003 | + DotLoc, isInsideObjCSelector(), CompletionContext, |
| 6004 | + Consumer); |
5998 | 6005 | return true; |
5999 | 6006 | } |
6000 | 6007 | default: |
|
0 commit comments