Skip to content

Commit f842cba

Browse files
committed
[Completion] Add completion for sending specifier
This was added in SE-0430. rdar://130296278
1 parent 3d57297 commit f842cba

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,10 +1073,14 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
10731073
addKeyword(Sink, "consuming", CodeCompletionKeywordKind::None);
10741074
addKeyword(Sink, "isolated", CodeCompletionKeywordKind::None);
10751075
LLVM_FALLTHROUGH;
1076+
case CompletionKind::TypeDeclResultBeginning:
1077+
addKeyword(Sink, "sending", CodeCompletionKeywordKind::None);
1078+
LLVM_FALLTHROUGH;
10761079
case CompletionKind::TypeBeginning:
1077-
addKeyword(Sink, "repeat", CodeCompletionKeywordKind::None);
1080+
// Not technically allowed after '->', since you need to write in parens.
1081+
if (Kind != CompletionKind::TypeDeclResultBeginning)
1082+
addKeyword(Sink, "repeat", CodeCompletionKeywordKind::None);
10781083
LLVM_FALLTHROUGH;
1079-
case CompletionKind::TypeDeclResultBeginning:
10801084
case CompletionKind::TypeSimpleOrComposition:
10811085
addKeyword(Sink, "some", CodeCompletionKeywordKind::None);
10821086
addKeyword(Sink, "any", CodeCompletionKeywordKind::None);

test/IDE/complete_param_specifier.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func bar(_ x: borrowing #^FUNC_PARAM_2?check=SPECIFIER^#) {}
1313

1414
struct S {
1515
init(x: #^INIT_PARAM?check=SPECIFIER^#) {}
16-
subscript(x: #SUBSCRIPT_PARAM?check=SPECIFIER#) {}
16+
subscript(x: #SUBSCRIPT_PARAM?check=SPECIFIER#) -> #^SUBSCRIPT_RET?check=RESULT;check=RESULT_NOT^# {}
1717
}
1818

1919
// Don't complete for enum cases.
@@ -22,18 +22,32 @@ enum E {
2222
case f(x: #^ENUM_CASE_LABELED_TY?check=SPECIFIER_NOT^#)
2323
}
2424

25-
// Don't complete for a regular variable type.
26-
let x: #^VAR_TY?check=SPECIFIER_NOT^#
25+
// Don't complete the parameter specifiers for a variable type.
26+
//
27+
// Note that we will still complete 'sending' here, even though it isn't
28+
// currently supported for computed properties (it is supported for functions
29+
// and subscripts though).
30+
let x: #^VAR_TY?check=RESULT;check=RESULT_NOT^#
31+
var y: #^VAR_TY2?check=RESULT;check=RESULT_NOT^#
2732

2833
// Or for a return type.
29-
func bar() -> #^RETURN_TY?check=SPECIFIER_NOT^# {}
34+
func bar() -> #^RESULT_TY?check=RESULT;check=RESULT_NOT^# {}
3035

3136
// SPECIFIER-DAG: Keyword[inout]/None: inout; name=inout
3237
// SPECIFIER-DAG: Keyword/None: consuming; name=consuming
3338
// SPECIFIER-DAG: Keyword/None: borrowing; name=borrowing
3439
// SPECIFIER-DAG: Keyword/None: isolated; name=isolated
40+
// SPECIFIER-DAG: Keyword/None: sending; name=sending
3541

3642
// SPECIFIER_NOT-NOT: Keyword[inout]/None: inout
3743
// SPECIFIER_NOT-NOT: Keyword/None: consuming
3844
// SPECIFIER_NOT-NOT: Keyword/None: borrowing
3945
// SPECIFIER_NOT-NOT: Keyword/None: isolated
46+
// SPECIFIER_NOT-NOT: Keyword/None: sending
47+
48+
// RESULT_NOT-NOT: Keyword[inout]/None: inout
49+
// RESULT_NOT-NOT: Keyword/None: consuming
50+
// RESULT_NOT-NOT: Keyword/None: borrowing
51+
// RESULT_NOT-NOT: Keyword/None: isolated
52+
53+
// RESULT-DAG: Keyword/None: sending

0 commit comments

Comments
 (0)