| 768 | if(auto info = try_directive(has_embed.loc, unit.file_path(*has_embed.file))) { |
| 769 | return info; |
| 770 | } |
| 771 | } |
| 772 | } |
| 773 | return std::nullopt; |
| 774 | } |
| 775 | |
| 776 | /// A macro name at the cursor, rendered from the preprocessor record — |
| 777 | /// macro semantics never reach the AST. The card shows the `#define` text, |
| 778 | /// plus a preview of the expanded tokens at expansion sites. |
| 779 | auto macro_hover(CompilationUnitRef unit, std::uint32_t offset) -> std::optional<HoverInfo> { |
| 780 | auto directives_it = unit.directives().find(unit.main_file()); |
| 781 | if(directives_it == unit.directives().end()) { |
| 782 | return std::nullopt; |
| 783 | } |
| 784 | |
| 785 | for(const auto& macro: directives_it->second.macros) { |
| 786 | /// A reference inside another expansion has no written token here. |
| 787 | if(macro.loc.isMacroID()) { |
| 788 | continue; |
| 789 | } |
| 790 | auto [fid, range] = unit.decompose_range(macro.loc); |
| 791 | if(offset < range.begin || offset >= range.end) { |
no test coverage detected