mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Deduplicate the two isMemberCompletion functions in ParseExpr.cpp and ParseDecl.cpp
Also: - propagate the Solution -> Result rename to Solution parameter of deliverDotExprResults - fixup header comment in CodeCompletionTypeChecking.h
This commit is contained in:
@@ -1185,6 +1185,34 @@ Parser::getStringLiteralIfNotInterpolated(SourceLoc Loc,
|
||||
Segments.front().Length));
|
||||
}
|
||||
|
||||
bool Parser::
|
||||
shouldSuppressSingleExpressionBodyTransform(ParserStatus Status,
|
||||
MutableArrayRef<ASTNode> BodyElems) {
|
||||
if (BodyElems.size() != 1)
|
||||
return true;
|
||||
|
||||
if (!Status.hasCodeCompletion())
|
||||
return false;
|
||||
|
||||
struct HasMemberCompletion: public ASTWalker {
|
||||
bool Value = false;
|
||||
std::pair<bool, Expr *> walkToExprPre(Expr *E) override {
|
||||
if (auto *CCE = dyn_cast<CodeCompletionExpr>(E)) {
|
||||
// If it has a base expression this is member completion, which is
|
||||
// performed using the new solver-based mechanism, so it's ok to go
|
||||
// ahead with the transform (and necessary to pick up the correct
|
||||
// expected type).
|
||||
Value = CCE->getBase();
|
||||
return {false, nullptr};
|
||||
}
|
||||
return {true, E};
|
||||
}
|
||||
};
|
||||
HasMemberCompletion Check;
|
||||
BodyElems.front().walk(Check);
|
||||
return !Check.Value;
|
||||
}
|
||||
|
||||
struct ParserUnit::Implementation {
|
||||
std::shared_ptr<SyntaxParseActions> SPActions;
|
||||
LangOptions LangOpts;
|
||||
|
||||
Reference in New Issue
Block a user