Macro Expansion

You can inspect the code generated by the expansion of a macro in two ways:

  • inline: DVT replaces the macro call with the generated code in place; the expanded code is guarded by pragmas that allow DVT to collapse the code back to the original

  • in a separate editor: DVT opens a new editor window that shows the generated code

To expand

Place the cursor on a macro call in the editor and use one of the following expansion commands:

  • DVT: Expand Macro One Level

  • DVT: Expand Macro One Level Inline

  • DVT: Expand Macro All Levels

  • DVT: Expand Macro All Levels Inline

Expansion also works for an entire region of code, and all macros in the selection will be expanded.

Note

You can also expand all macros in the current file by placing the cursor anywhere in the editor and using either “DVT: Expand All Macros Inline”, for expansion in the source file, or “DVT: Expand All Macros”, for expansion in a temporary file.

To collapse

Place the cursor on the expansion start pragma, and use the DVT: Collapse Inline Macro Expansion.

../../_images/macro_expansion_from_context_menu.gif

Note

You can also collapse all macro expansions in the current file by placing the cursor anywhere in the editor and using DVT: Collapse All Inline Macro Expansions.

You can also expand or collapse a macro by using Code Lens, which can be enabled using the DVT.codeLens.expandCollapseMacros setting accessible using Preferences: Open Settings (UI) command.

../../_images/macro_expansion_using_code_lens.gif

Danger

Do not modify the pragmas generated by DVT because this might break the collapse functionality!

Note

The pragmas are:

  • @DVT_EXPAND_MACRO_INLINE_START

  • @DVT_EXPAND_MACRO_INLINE_ORIGINAL

  • @DVT_EXPAND_MACRO_INLINE_END