Skip to content

Commit 7893f74

Browse files
authored
Merge pull request #41384 from rintaro/ide-completion-actorkind-rdar79733313
[CodeCompletion] Add a symbol kind for actors
2 parents d0b902c + d9011e0 commit 7893f74

File tree

8 files changed

+25
-3
lines changed

8 files changed

+25
-3
lines changed

include/swift/IDE/CodeCompletion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ using CodeCompletionFlair = OptionSet<CodeCompletionFlairBit>;
492492
enum class CodeCompletionDeclKind : uint8_t {
493493
Module,
494494
Class,
495+
Actor,
495496
Struct,
496497
Enum,
497498
EnumElement,

lib/IDE/CodeCompletion.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ ContextFreeCodeCompletionResult::getCodeCompletionDeclKind(const Decl *D) {
349349
case DeclKind::Struct:
350350
return CodeCompletionDeclKind::Struct;
351351
case DeclKind::Class:
352-
return CodeCompletionDeclKind::Class;
352+
if (cast<ClassDecl>(D)->isActor()) {
353+
return CodeCompletionDeclKind::Actor;
354+
} else {
355+
return CodeCompletionDeclKind::Class;
356+
}
353357
case DeclKind::Protocol:
354358
return CodeCompletionDeclKind::Protocol;
355359
case DeclKind::Var:
@@ -425,6 +429,9 @@ void CodeCompletionResult::printPrefix(raw_ostream &OS) const {
425429
case CodeCompletionDeclKind::Class:
426430
Prefix.append("[Class]");
427431
break;
432+
case CodeCompletionDeclKind::Actor:
433+
Prefix.append("[Actor]");
434+
break;
428435
case CodeCompletionDeclKind::Struct:
429436
Prefix.append("[Struct]");
430437
break;
@@ -7400,6 +7407,7 @@ copyCodeCompletionResults(CodeCompletionResultSink &targetSink,
74007407
switch (R->getAssociatedDeclKind()) {
74017408
case CodeCompletionDeclKind::Module:
74027409
case CodeCompletionDeclKind::Class:
7410+
case CodeCompletionDeclKind::Actor:
74037411
case CodeCompletionDeclKind::Struct:
74047412
case CodeCompletionDeclKind::Enum:
74057413
case CodeCompletionDeclKind::Protocol:

lib/IDE/REPLCodeCompletion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static void toDisplayString(CodeCompletionResult *Result,
127127
case CodeCompletionDeclKind::Module:
128128
case CodeCompletionDeclKind::PrecedenceGroup:
129129
case CodeCompletionDeclKind::Class:
130+
case CodeCompletionDeclKind::Actor:
130131
case CodeCompletionDeclKind::Struct:
131132
case CodeCompletionDeclKind::Enum:
132133
continue;

test/IDE/complete_actorisolation.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,12 @@ extension MyActor {
111111
// IN_ASYNCFUNC_OTHER_NODOT-DAG: Decl[Subscript]/CurrNominal: [{#(idx): Int#}][' async'][#Int#];
112112
// IN_ASYNCFUNC_OTHER_NODOT: End completions
113113
}
114+
115+
func testActorKind() {
116+
let _ = #^GLOBAL^#
117+
// GLOBAL: Begin completions
118+
// GLOBAL: Decl[Actor]/CurrModule: MyActor[#MyActor#]; name=MyActor
119+
// GLOBAL: End completions
120+
}
114121
}
115122

test/IDE/complete_cache_notrecommended.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ func testSync() -> Int{
2727
// GLOBAL_IN_SYNC: Begin completions
2828
// GLOBAL_IN_SYNC-DAG: Decl[FreeFunction]/OtherModule[MyModule]: globalAsyncFunc()[' async'][#Int#];
2929
// GLOBAL_IN_SYNC-DAG: Decl[FreeFunction]/OtherModule[MyModule]/NotRecommended: deprecatedFunc()[#Void#];
30-
// GLOBAL_IN_SYNC-DAG: Decl[Class]/OtherModule[MyModule]: MyActor[#MyActor#];
30+
// GLOBAL_IN_SYNC-DAG: Decl[Actor]/OtherModule[MyModule]: MyActor[#MyActor#];
3131
// GLOBAL_IN_SYNC: End completions
3232
}
3333
func testAsync() async -> Int {
3434
#^GLOBAL_IN_ASYNC^#
3535
// GLOBAL_IN_ASYNC: Begin completions
3636
// GLOBAL_IN_ASYNC-DAG: Decl[FreeFunction]/OtherModule[MyModule]: globalAsyncFunc()[' async'][#Int#];
3737
// GLOBAL_IN_ASYNC-DAG: Decl[FreeFunction]/OtherModule[MyModule]/NotRecommended: deprecatedFunc()[#Void#];
38-
// GLOBAL_IN_ASYNC-DAG: Decl[Class]/OtherModule[MyModule]: MyActor[#MyActor#];
38+
// GLOBAL_IN_ASYNC-DAG: Decl[Actor]/OtherModule[MyModule]: MyActor[#MyActor#];
3939
// GLOBAL_IN_ASYNC: End completions
4040
}
4141
func testSyncMember(obj: MyActor) -> Int {

tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ CodeCompletionOrganizer::Impl::Impl(CompletionKind kind, TypeContextKind typeCon
332332
static bool matchesExpectedStyle(Completion *completion, NameStyle style) {
333333
switch (completion->getAssociatedDeclKind()) {
334334
case CodeCompletionDeclKind::Class:
335+
case CodeCompletionDeclKind::Actor:
335336
case CodeCompletionDeclKind::Struct:
336337
case CodeCompletionDeclKind::Enum:
337338
case CodeCompletionDeclKind::Protocol:

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ UIdent SwiftLangSupport::getUIDForCodeCompletionDeclKind(
390390
switch (Kind) {
391391
case CodeCompletionDeclKind::Module: return KindRefModule;
392392
case CodeCompletionDeclKind::Class: return KindRefClass;
393+
case CodeCompletionDeclKind::Actor: return KindRefActor;
393394
case CodeCompletionDeclKind::Struct: return KindRefStruct;
394395
case CodeCompletionDeclKind::Enum: return KindRefEnum;
395396
case CodeCompletionDeclKind::EnumElement: return KindRefEnumElement;
@@ -417,6 +418,7 @@ UIdent SwiftLangSupport::getUIDForCodeCompletionDeclKind(
417418
switch (Kind) {
418419
case CodeCompletionDeclKind::Module: return KindDeclModule;
419420
case CodeCompletionDeclKind::Class: return KindDeclClass;
421+
case CodeCompletionDeclKind::Actor: return KindDeclActor;
420422
case CodeCompletionDeclKind::Struct: return KindDeclStruct;
421423
case CodeCompletionDeclKind::Enum: return KindDeclEnum;
422424
case CodeCompletionDeclKind::EnumElement: return KindDeclEnumElement;

utils/gyb_sourcekit_support/UIDs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ def __init__(self, internal_name, external_name):
346346
KIND('DeclModule', 'source.lang.swift.decl.module'),
347347
KIND('DeclClass', 'source.lang.swift.decl.class'),
348348
KIND('RefClass', 'source.lang.swift.ref.class'),
349+
KIND('DeclActor', 'source.lang.swift.decl.actor'),
350+
KIND('RefActor', 'source.lang.swift.ref.actor'),
349351
KIND('DeclStruct', 'source.lang.swift.decl.struct'),
350352
KIND('RefStruct', 'source.lang.swift.ref.struct'),
351353
KIND('DeclEnum', 'source.lang.swift.decl.enum'),

0 commit comments

Comments
 (0)