Skip to content

Showing Macro Expansion #564

Closed
swiftlang/sourcekit-lsp
#1479
@filip-sakel

Description

@filip-sakel

Is your feature request related to a problem? Please describe.
Without seeing what code macros generate, it's hard to understand macro-related errors. For example, a macro might try to access a variable "_count" but forget the underscore prefix: "count". Being able to see the macro expansion would make it easy to identify the problem, which is critical for developing macros.

Describe the solution you'd like
An Xcode-like action could be shown when opening the context menu (when right clicking) on a macro. Then, after finding the expansion, the extension could be shown below the code using the macro (similar to inlay hints). Otherwise, a pop up showing expanded code could appear (similar to when inspecting documentation).

Describe alternatives you've considered
The alternative is to use a compiler flag to see macro expansions. That lacks specificity, as all macro expansions are shown. Even if the compiler gains the ability to only show the expansion of one macro, typing that macro's name or source location into the command line can hamper productivity. Instead, it's much more convenient to click on the macro, right in the editor, and be shown its expansion.

Additional context
Related SourceKit LSP issue swiftlang/sourcekit-lsp#755

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions