Skip to content

[CodeCompletion] Suggest 'actor' decl introducer keyword #58698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2022

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 5, 2022

Previously actor keyword was suggested as (deprecated) actor decl modifier, and it was gated by -enable-experimental-concurrency compiler argument.
Add actor as a type decl introducer. This causes duplicated actor in code completion if -enable-experimental-concurrency, but that option is basically useless at this point, so I assume not many people is using it. Also actor as a modifier will be removed soon.

[#58520] rdar://92511769

Previously 'actor' keyword was suggested as (deprecated) 'actor' decl
modifier, and it was gated by '-enable-experimental-concurrency'
compiler argument.
Add 'actor' as a type decl introducer. This causes duplicated 'actor' in
code completion if '-enable-experimental-concurrency', but that option
is basically useless at this point, so I assume not many people is using
it. Also 'actor' as a modifier will be removed soon.

[swiftlang#58520] rdar://92511769
@rintaro
Copy link
Member Author

rintaro commented May 5, 2022

@swift-ci Please smoke test

@rintaro rintaro requested a review from ahoppen May 5, 2022 21:50
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor suggestion inline.

};

#define DECL_KEYWORD(kw) \
AddDeclKeyword(#kw, CodeCompletionKeywordKind::kw_##kw, None);
#include "swift/Syntax/TokenKinds.def"
// Manually add "actor" because it's a contextual keyword.
AddDeclKeyword("actor", CodeCompletionKeywordKind::None, None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t it be simpler to remove the special case in AddDeclKeyword and change this

Suggested change
AddDeclKeyword("actor", CodeCompletionKeywordKind::None, None);
AddDeclKeyword("actor", CodeCompletionKeywordKind::kw_class, None);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't 100% sure we can emit actor as CodeCompletionKeywordKind::kw_class. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn’t that exactly what you’re doing in line 783-784? Or am I missing something?

Copy link
Member Author

@rintaro rintaro May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm not rewriting the Kind, but I'm just using kw_class to get the flair for actor.
Using kw_class results

Keyword[class]/None: actor

instead of

Keyword/None: actor

I admit CodeCompletionKeywordKind is not used in many place, but for example, CodeCompletion::LimitedResultView has an ability to filter the results by the kind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I that case forget what I said.

@ktoso
Copy link
Contributor

ktoso commented May 6, 2022

Could we also do this for distributed actor or would it be weird to autocomplete complete the distributed...? 🤔

@rintaro
Copy link
Member Author

rintaro commented May 6, 2022

@ktoso Code completion should already be emitting distributed itself as a modifier. Are you suggesting to emit distributed actor and distributed func instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants