Skip to content
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

[CodeCompletion] Support completion for macro roles and the 'names:' argument label #65427

Merged
merged 3 commits into from
Apr 29, 2023

Conversation

ahoppen
Copy link
Contributor

@ahoppen ahoppen commented Apr 26, 2023

This PR contains two preliminary commits:

  • First we need to pass the ParserStatus from attribute parsing through to decl parsing, otherwise we’re don’t know the delayed decl state in which we’re completing (for @available parsing we got away without this by making the code completion token part of the declaration but that doesn’t work for the parser’s implementation of macro roles)
  • Disallow declaration of codeItem macros. Previously, it was perfectly fine to declare codeItem macros, you just couldn’t use them.

And finally, we can hook things up to perform suggest macro roles and the names: label in macro attributes.

rdar://108163121

@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 26, 2023

@swift-ci Please test

@ahoppen ahoppen force-pushed the ahoppen/macro-attribute-completions branch from e4ddd96 to d93185b Compare April 26, 2023 02:07
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 26, 2023

@swift-ci Please smoke test

1 similar comment
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 26, 2023

@swift-ci Please smoke test

@ahoppen ahoppen force-pushed the ahoppen/macro-attribute-completions branch from d93185b to e9ad00a Compare April 26, 2023 14:03
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 26, 2023

@swift-ci Please smoke test

@xedin xedin removed their request for review April 26, 2023 16:57
Comment on lines +10153 to +10201
case MacroRole::Expression:
case MacroRole::Declaration:
case MacroRole::Accessor:
case MacroRole::MemberAttribute:
case MacroRole::Member:
case MacroRole::Peer:
case MacroRole::Conformance:
Copy link
Member

Choose a reason for hiding this comment

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

It might not really matter, but there is "feature" flag for each macro roles e.g. CodeItemMacros, FreestandingMacros. Do we want to use them here perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I am using it for codeItem but I should also use them for freestanding declaration (and all the others even if the feature flags are off), you are right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, putting those behind a feature flag failed because then we can’t compile the stdlib anymore. I suspect that the issue is that the features are only enabled if we have swiftSwiftParser but we don’t have that yet while building the stdlib during bootstrapping. I just reverted it to always enable non-codeItem macros – freestanding declaration macros don’t have a feature flag (rdar://108637367).

…arsing

This is needed to be able to perform code completion inside `@freestanding` and `@attached`.
@ahoppen ahoppen force-pushed the ahoppen/macro-attribute-completions branch from e9ad00a to 0dff47a Compare April 28, 2023 01:21
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 28, 2023

@swift-ci Please smoke test

@ahoppen ahoppen force-pushed the ahoppen/macro-attribute-completions branch from 0dff47a to 6098a3c Compare April 28, 2023 04:48
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 28, 2023

@swift-ci Please smoke test

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.

None yet

2 participants