|
35 | 35 |
|
36 | 36 | using namespace swift; |
37 | 37 |
|
| 38 | +bool Token::isEditorPlaceholder() const { |
| 39 | + return is(tok::identifier) && Identifier::isEditorPlaceholder(getRawText()); |
| 40 | +} |
| 41 | + |
38 | 42 | /// parseExpr |
39 | 43 | /// |
40 | 44 | /// expr: |
@@ -2206,7 +2210,7 @@ static bool tryParseArgLabelList(Parser &P, Parser::DeclNameOptions flags, |
2206 | 2210 | // An argument label. |
2207 | 2211 | bool nextIsArgLabel = next.canBeArgumentLabel() || next.is(tok::colon); |
2208 | 2212 | // An editor placeholder. |
2209 | | - bool nextIsPlaceholder = Identifier::isEditorPlaceholder(next.getText()); |
| 2213 | + bool nextIsPlaceholder = next.isEditorPlaceholder(); |
2210 | 2214 |
|
2211 | 2215 | if (!(nextIsRParen || nextIsArgLabel || nextIsPlaceholder)) |
2212 | 2216 | return false; |
@@ -2402,7 +2406,7 @@ ParserResult<Expr> Parser::parseExprIdentifier(bool allowKeyword) { |
2402 | 2406 | hasGenericArgumentList = true; |
2403 | 2407 | } |
2404 | 2408 |
|
2405 | | - if (name.getBaseName().isEditorPlaceholder()) { |
| 2409 | + if (IdentTok.isEditorPlaceholder()) { |
2406 | 2410 | return makeParserResult( |
2407 | 2411 | status, parseExprEditorPlaceholder(IdentTok, name.getBaseIdentifier())); |
2408 | 2412 | } |
@@ -3301,8 +3305,7 @@ static bool isStartOfLabelledTrailingClosure(Parser &P) { |
3301 | 3305 | return true; |
3302 | 3306 | // Parse editor placeholder as trailing closure so SourceKit can expand it to |
3303 | 3307 | // closure literal. |
3304 | | - if (P.peekToken().is(tok::identifier) && |
3305 | | - Identifier::isEditorPlaceholder(P.peekToken().getText())) |
| 3308 | + if (P.peekToken().isEditorPlaceholder()) |
3306 | 3309 | return true; |
3307 | 3310 | // Consider `label: <complete>` that the user is trying to write a closure. |
3308 | 3311 | if (P.peekToken().is(tok::code_complete) && !P.peekToken().isAtStartOfLine()) |
@@ -3360,8 +3363,8 @@ Parser::parseTrailingClosures(bool isExprBasic, SourceRange calleeRange, |
3360 | 3363 | closure = parseExprClosure(); |
3361 | 3364 | } else if (Tok.is(tok::identifier)) { |
3362 | 3365 | // Parse editor placeholder as a closure literal. |
3363 | | - assert(Identifier::isEditorPlaceholder(Tok.getText())); |
3364 | | - Identifier name = Context.getIdentifier(Tok.getText()); |
| 3366 | + assert(Tok.isEditorPlaceholder()); |
| 3367 | + Identifier name = Context.getIdentifier(Tok.getRawText()); |
3365 | 3368 | closure = makeParserResult(parseExprEditorPlaceholder(Tok, name)); |
3366 | 3369 | consumeToken(tok::identifier); |
3367 | 3370 | } else if (Tok.is(tok::code_complete)) { |
|
0 commit comments