[CodeCompletion] Migrate PostfixExprParen to solver-based

This commit is contained in:
Alex Hoppen
2023-02-16 13:57:02 +01:00
parent 1e723ddbc2
commit c385fe5e87
12 changed files with 48 additions and 75 deletions

View File

@@ -1507,6 +1507,7 @@ bool CodeCompletionCallbacksImpl::trySolverCompletion(bool MaybeFuncBody) {
Lookup.deliverResults(CurDeclContext, DotLoc, CompletionContext, Consumer);
return true;
}
case CompletionKind::PostfixExprParen:
case CompletionKind::CallArg: {
assert(CodeCompleteTokenExpr);
assert(CurDeclContext);
@@ -1692,6 +1693,7 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
case CompletionKind::AfterPoundExpr:
case CompletionKind::AccessorBeginning:
case CompletionKind::CaseStmtBeginning:
case CompletionKind::PostfixExprParen:
llvm_unreachable("should be already handled");
return;
@@ -1712,45 +1714,6 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
break;
}
case CompletionKind::PostfixExprParen: {
Lookup.setHaveLParen(true);
ExprContextInfo ContextInfo(CurDeclContext, CodeCompleteTokenExpr);
if (ShouldCompleteCallPatternAfterParen) {
ExprContextInfo ParentContextInfo(CurDeclContext, ParsedExpr);
Lookup.setExpectedTypes(
ParentContextInfo.getPossibleTypes(),
ParentContextInfo.isImplicitSingleExpressionReturn());
if (!ContextInfo.getPossibleCallees().empty()) {
for (auto &typeAndDecl : ContextInfo.getPossibleCallees())
Lookup.tryFunctionCallCompletions(typeAndDecl.Type, typeAndDecl.Decl,
typeAndDecl.SemanticContext);
} else if (ExprType && ((*ExprType)->is<AnyFunctionType>() ||
(*ExprType)->is<AnyMetatypeType>())) {
Lookup.getValueExprCompletions(*ExprType, ReferencedDecl.getDecl());
}
} else {
// Add argument labels, then fallthrough to get values.
Lookup.addCallArgumentCompletionResults(ContextInfo.getPossibleParams());
}
if (!Lookup.FoundFunctionCalls ||
(Lookup.FoundFunctionCalls &&
Lookup.FoundFunctionsWithoutFirstKeyword)) {
Lookup.setExpectedTypes(ContextInfo.getPossibleTypes(),
ContextInfo.isImplicitSingleExpressionReturn());
Lookup.setHaveLParen(false);
// Add any keywords that can be used in an argument expr position.
addSuperKeyword(CompletionContext.getResultSink(), CurDeclContext);
addExprKeywords(CompletionContext.getResultSink(), CurDeclContext);
DoPostfixExprBeginning();
}
break;
}
case CompletionKind::KeyPathExprObjC: {
if (DotLoc.isValid())
Lookup.setHaveDot(DotLoc);