-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.9][SourceKit] Add request to expand macros syntactically #66383
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
Closed
rintaro
wants to merge
9
commits into
swiftlang:release/5.9
from
rintaro:5.9-sourcekit-syntactic-macroexpansion
Closed
[5.9][SourceKit] Add request to expand macros syntactically #66383
rintaro
wants to merge
9
commits into
swiftlang:release/5.9
from
rintaro:5.9-sourcekit-syntactic-macroexpansion
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci Please test |
2a3e515
to
b8e9cf9
Compare
@swift-ci Please test |
Introduce 'createMacroSourceFile()' that creates macro expanded 'SourceFile' object. Use it from various macro expansion functions. (cherry picked from commit 78b2229)
'MacroExpansionDecl' and 'MacroExpansionExpr' have many common methods. Introduce a common base class 'FreestandingMacroExpansion' that holds 'MacroExpansionInfo'. Factor out common expansion logic to 'evaluateFreestandingMacro' function that resembles 'evaluateAttachedMacro'. (cherry picked from commit 86d405b)
Expand macros in the specified source file syntactically (without any module imports, nor typechecking). Request would look like: ``` { key.compilerargs: [...] key.sourcefile: <file name> key.sourcetext: <source text> (optional) key.expansions: [<expansion specifier>...] } ``` `key.compilerargs` are used for getting plugins search paths. If `key.sourcetext` is not specified, it's loaded from the file system. Each `<expansion sepecifier>` is ``` { key.offset: <offset> key.modulename: <plugin module name> key.typename: <macro typename> key.macro_roles: [<macro role UID>...] } ``` Clients have to provide the module and type names because that's semantic. Response is a `CategorizedEdits` just like (semantic) "ExpandMacro" refactoring. Each edit object has `key.buffer_name` that can be used for recursive expansion. If the client founds nested macro expansion in the expanded source, it can send another request with the same compiler arguments using the buffer name and the source to get the nested expansions. (cherry picked from commit 43908fa)
(cherry picked from commit 0c931e0)
(cherry picked from commit 5877c90)
This doesn't support nested expansions for now. So there is not much to reuse. (cherry picked from commit 4243599)
(cherry picked from commit de41f45)
b8e9cf9
to
5e61e92
Compare
@swift-ci Please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick #66295 into release/5.9