mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Parsing postfix exprs: if we have '.<keyword><code_complete>', try to recover
by creating an identifier with the same spelling as the keyword. Fixes code completion for cases like 'foo.is#^A^#'. Swift SVN r6727
This commit is contained in:
@@ -838,6 +838,27 @@ NullablePtr<Expr> Parser::parseExprPostfix(Diag<> ID) {
|
||||
}
|
||||
if (consumeIf(tok::period) || (IsPeriod && consumeIf(tok::period_prefix))) {
|
||||
if (Tok.isNot(tok::identifier) && Tok.isNot(tok::integer_literal)) {
|
||||
if (peekToken().is(tok::code_complete)) {
|
||||
switch (Tok.getKind()) {
|
||||
default:
|
||||
break;
|
||||
|
||||
#define KEYWORD(kw) \
|
||||
case tok::kw_##kw:
|
||||
#include "swift/Parse/Tokens.def"
|
||||
{
|
||||
// If we have a '.<keyword><code_complete>', then try to recover
|
||||
// by creating an identifier with the same spelling as the
|
||||
// keyword.
|
||||
Identifier Name = Context.getIdentifier(Tok.getText());
|
||||
Result = new (Context) UnresolvedDotExpr(Result.get(), TokLoc,
|
||||
Name, Tok.getLoc());
|
||||
consumeToken();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Tok.is(tok::code_complete) && CodeCompletion && Result.isNonNull()) {
|
||||
CodeCompletion->completeDotExpr(Result.get());
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user