File tree Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,8 @@ enum class CompletionKind : uint8_t {
214
214
ReturnStmtExpr,
215
215
YieldStmtExpr,
216
216
ForEachSequence,
217
+
218
+ // / The \c in keyword in a for-each loop.
217
219
ForEachInKw,
218
220
AfterPoundExpr,
219
221
AfterPoundDirective,
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ class CodeCompletionCallbacks {
137
137
// / -- no tokens provided by user.
138
138
virtual void completeForEachSequenceBeginning (CodeCompletionExpr *E) {};
139
139
140
- // / Add comment
140
+ // / Complete the \c in keyword in a for-each loop.
141
141
virtual void completeForEachInKeyword (){};
142
142
143
143
// / Complete a given expr-postfix.
Original file line number Diff line number Diff line change @@ -2292,14 +2292,14 @@ ParserResult<Stmt> Parser::parseStmtForEach(LabeledStmtInfo LabelInfo) {
2292
2292
diagnose (LBraceLoc, diag::expected_foreach_container);
2293
2293
Container = makeParserErrorResult (new (Context) ErrorExpr (LBraceLoc));
2294
2294
} else if (Tok.is (tok::code_complete)) {
2295
+ // If there is no "in" keyword, suggest it. Otherwise, complete the
2296
+ // sequence.
2295
2297
if (InLoc.isInvalid ()) {
2296
- // Write something to complete In
2297
2298
if (CodeCompletion)
2298
2299
CodeCompletion->completeForEachInKeyword ();
2299
2300
consumeToken (tok::code_complete);
2300
2301
return makeParserCodeCompletionStatus ();
2301
2302
} else {
2302
- // Complete everything else
2303
2303
Container =
2304
2304
makeParserResult (new (Context) CodeCompletionExpr (Tok.getLoc ()));
2305
2305
Container.setHasCodeCompletionAndIsError ();
Original file line number Diff line number Diff line change 6
6
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_4 | %FileCheck %s -check-prefix=LOOP_4
7
7
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_5 | %FileCheck %s -check-prefix=LOOP_5
8
8
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_6 | %FileCheck %s -check-prefix=LOOP_6
9
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_7 | %FileCheck %s -check-prefix=LOOP_6
9
10
10
11
class Gen {
11
12
func IntGen( ) -> Int { return 0 }
@@ -69,10 +70,13 @@ class C {
69
70
// LOOP_5: Begin completions
70
71
}
71
72
73
+ // https://github.com/apple/swift/issues/58633
72
74
do {
73
75
for value #^LOOP_6 ^#
74
76
}
77
+ do {
78
+ for value #^LOOP_7 ^# 1 ..< 7 { }
79
+ }
75
80
// LOOP_6: Begin completions, 1 items
76
81
// LOOP_6-CHECK-NEXT: Keyword[in]/None: in; name=in
77
82
// LOOP_6-CHECK-NEXT: End completions
78
-
You can’t perform that action at this time.
0 commit comments