Skip to content

Commit 90984b7

Browse files
committed
Cleanup; add comments
1 parent 5e28b06 commit 90984b7

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

include/swift/IDE/CodeCompletionResult.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ enum class CompletionKind : uint8_t {
214214
ReturnStmtExpr,
215215
YieldStmtExpr,
216216
ForEachSequence,
217+
218+
/// The \c in keyword in a for-each loop.
217219
ForEachInKw,
218220
AfterPoundExpr,
219221
AfterPoundDirective,

include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class CodeCompletionCallbacks {
137137
/// -- no tokens provided by user.
138138
virtual void completeForEachSequenceBeginning(CodeCompletionExpr *E) {};
139139

140-
/// Add comment
140+
/// Complete the \c in keyword in a for-each loop.
141141
virtual void completeForEachInKeyword(){};
142142

143143
/// Complete a given expr-postfix.

lib/Parse/ParseStmt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,14 +2292,14 @@ ParserResult<Stmt> Parser::parseStmtForEach(LabeledStmtInfo LabelInfo) {
22922292
diagnose(LBraceLoc, diag::expected_foreach_container);
22932293
Container = makeParserErrorResult(new (Context) ErrorExpr(LBraceLoc));
22942294
} else if (Tok.is(tok::code_complete)) {
2295+
// If there is no "in" keyword, suggest it. Otherwise, complete the
2296+
// sequence.
22952297
if (InLoc.isInvalid()) {
2296-
// Write something to complete In
22972298
if (CodeCompletion)
22982299
CodeCompletion->completeForEachInKeyword();
22992300
consumeToken(tok::code_complete);
23002301
return makeParserCodeCompletionStatus();
23012302
} else {
2302-
// Complete everything else
23032303
Container =
23042304
makeParserResult(new (Context) CodeCompletionExpr(Tok.getLoc()));
23052305
Container.setHasCodeCompletionAndIsError();

test/IDE/complete_loop.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_4 | %FileCheck %s -check-prefix=LOOP_4
77
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_5 | %FileCheck %s -check-prefix=LOOP_5
88
// 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
910

1011
class Gen {
1112
func IntGen() -> Int { return 0 }
@@ -69,10 +70,13 @@ class C {
6970
// LOOP_5: Begin completions
7071
}
7172

73+
// https://github.com/apple/swift/issues/58633
7274
do {
7375
for value #^LOOP_6^#
7476
}
77+
do {
78+
for value #^LOOP_7^# 1..<7 {}
79+
}
7580
// LOOP_6: Begin completions, 1 items
7681
// LOOP_6-CHECK-NEXT: Keyword[in]/None: in; name=in
7782
// LOOP_6-CHECK-NEXT: End completions
78-

0 commit comments

Comments
 (0)