Skip to content

feat(hover): show include paths and TagDecl members - #497

Closed
zaragoza-xu wants to merge 2 commits into
clice-io:mainfrom
zaragoza-xu:feat/include-hover
Closed

zaragoza-xu wants to merge 2 commits into
clice-io:mainfrom
zaragoza-xu:feat/include-hover

Conversation

@zaragoza-xu

@zaragoza-xu zaragoza-xu commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

This pull request significantly improves the hover feature in the codebase by enhancing the information shown when hovering over struct, enum, and #include directives. The main changes include implementing detailed type-level hover for structs/enums, adding hover support for #include directives to show resolved header paths, and updating documentation and tests to reflect these new capabilities.

Hover Feature Enhancements:

  • Added detailed type-level hover for structs and enums, displaying their members and enumerators in the hover popup. This includes handling explicit values, inherited members, template instantiations, and inline/lambda initializers. (src/feature/hover.cpp, tests/data/hover/tag_decls.cpp, tests/snapshots/hover/snapshot/tag_decls.cpp.snap.yml) [1] [2] [3] [4] [5] [6] [7]
  • Implemented hover support for #include directives, showing the resolved header path when hovering over the header name. (src/feature/hover.cpp, tests/unit/feature/hover_tests.cpp) [1] [2] [3] [4]

Documentation Updates:

  • Updated English and Chinese hover feature documentation to mark struct/enum member hover and #include directive hover as implemented. (docs/en/features/hover.md, docs/zh/features/hover.md) [1] [2] [3] [4]

Testing Improvements:

  • Added comprehensive tests for the new hover features, including various struct and enum scenarios and #include directive hover. (tests/data/hover/tag_decls.cpp, tests/snapshots/hover/snapshot/tag_decls.cpp.snap.yml, tests/unit/feature/hover_tests.cpp) [1] [2] [3]

These changes collectively provide much richer and more informative hover experiences for users, especially when working with complex types and include directives.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extends hover rendering to show full record and enum definitions and adds hover information for #include directive arguments. Test fixtures, snapshots, unit tests, and English and Chinese documentation checklists are updated.

Changes

Hover Feature Enhancements

Layer / File(s) Summary
Tag definition rendering
src/feature/hover.cpp, tests/data/hover/tag_decls.cpp, tests/snapshots/hover/snapshot/tag_decls.cpp.snap.yml, docs/en/features/hover.md, docs/zh/features/hover.md
Record and enum hovers now include fields, bases, enumerators, and relevant initializers, with expanded fixture and snapshot coverage.
Include-directive hover support
src/feature/hover.cpp, tests/unit/feature/hover_tests.cpp, docs/en/features/hover.md, docs/zh/features/hover.md
Hovering an include argument returns header metadata and its resolved path, with unit-test coverage and completed documentation checklists.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Editor
  participant hover_info
  participant include_hover
  Editor->>hover_info: request hover at offset
  hover_info->>include_hover: check include argument range
  include_hover-->>hover_info: return Header hover with resolved path
  hover_info-->>Editor: return hover result
Loading

Possibly related PRs

  • clice-io/clice#452: Modifies the hover implementation and its hover information pipeline.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: include path hover support and expanded TagDecl member hovers.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zaragoza-xu zaragoza-xu changed the title feat(server): hover on includes and show type members feat(hover): show include paths and class/struct/enum members Jul 9, 2026
@zaragoza-xu
zaragoza-xu marked this pull request as ready for review July 9, 2026 13:57
Copilot AI review requested due to automatic review settings July 9, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds richer hover support in the C++ feature layer by introducing header/include directive hovers and expanding type hover output to include enum constants and record fields, with accompanying tests/snapshots/docs updates.

Changes:

  • Added include-directive hover support that returns header name, resolved path, and directive argument range.
  • Updated hover definition rendering for records/enums to include record fields and enum enumerators (with computed values for implicit enumerators).
  • Added/updated unit tests, hover snapshots, and documentation checklists for the new hover behaviors.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/feature/hover_tests.cpp Adds a unit test covering hover behavior on #include header arguments (name/path/range + rendered hover content).
tests/snapshots/hover/snapshot/tag_decls.cpp.snap.yml Updates expected hover output to include enum constants and record fields in rendered definitions/markdown.
tests/data/hover/tag_decls.cpp Extends hover test input data with explicit-enum and struct-with-fields cases used by snapshots.
src/feature/hover.cpp Implements include directive hover; changes record/enum definition printing to include members; wires include hover into hover_info.
docs/zh/features/hover.md Marks the struct/enum-members-on-hover item as completed in the Chinese docs.
docs/en/features/hover.md Marks the struct/enum-members-on-hover item as completed in the English docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/feature/hover.cpp
Comment on lines +143 to +147
os << " {";
for(const clang::FieldDecl* field: decl.fields()) {
os << '\n';
field->print(os, policy);
os << ';';
Comment thread src/feature/hover.cpp
Comment on lines +1135 to +1143
auto try_directive = [&](clang::SourceLocation loc,
clang::FileID target) -> std::optional<HoverInfo> {
if(!target.isValid())
return std::nullopt;
auto [fid, directive_offset] = unit.decompose_location(loc);
if(fid != interested || directive_offset >= content.size())
return std::nullopt;
auto range = find_directive_argument(content, directive_offset, lang_opts);
if(!range || !range->contains(offset))

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/zh/features/hover.md (1)

269-269: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Mark the #include directive hover checkbox as implemented (Chinese docs).

Same as the English docs, line 269 still shows - [ ] #include 指令悬停显示解析后的头文件路径 as unimplemented, but this PR implements this feature. Update to [x] for consistency.

📝 Proposed fix
-- [ ] `#include` 指令悬停显示解析后的头文件路径
+- [x] `#include` 指令悬停显示解析后的头文件路径
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/zh/features/hover.md` at line 269, The Chinese hover docs still mark the
`#include` directive hover feature as unimplemented, but it is now implemented.
Update the checkbox item in the hover documentation so the `#include` directive
entry is marked as completed, keeping it consistent with the English docs and
the implemented behavior.
docs/en/features/hover.md (1)

269-269: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Mark the #include directive hover checkbox as implemented.

Line 269 still shows - [ ] #include directive hover showing resolved header path as unimplemented, but this PR adds the include_hover function and a dedicated include_header unit test that verifies exactly this behavior. The checkbox should be updated to [x] to reflect the implementation.

📝 Proposed fix
-- [ ] `#include` directive hover showing resolved header path
+- [x] `#include` directive hover showing resolved header path
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/en/features/hover.md` at line 269, The hover documentation still marks
the `#include` directive hover as unimplemented, but this feature is already
covered by `include_hover` and the `include_header` unit test. Update the
checkbox in the hover docs from unchecked to checked so the status matches the
implemented resolved-header-path behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/feature/hover.cpp`:
- Line 1148: `include_hover` can assign `SymbolKind::Header`, but
`symbol_kind_string` currently falls through to the empty default for that kind,
so `HoverInfo::present()` omits the label. Update the `symbol_kind_string`
switch in `HoverInfo::present()` handling to include a `SymbolKind::Header` case
that returns the header label string, alongside the existing symbol kinds.

---

Outside diff comments:
In `@docs/en/features/hover.md`:
- Line 269: The hover documentation still marks the `#include` directive hover
as unimplemented, but this feature is already covered by `include_hover` and the
`include_header` unit test. Update the checkbox in the hover docs from unchecked
to checked so the status matches the implemented resolved-header-path behavior.

In `@docs/zh/features/hover.md`:
- Line 269: The Chinese hover docs still mark the `#include` directive hover
feature as unimplemented, but it is now implemented. Update the checkbox item in
the hover documentation so the `#include` directive entry is marked as
completed, keeping it consistent with the English docs and the implemented
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c6938605-ee44-41b7-9615-02ea191f077f

📥 Commits

Reviewing files that changed from the base of the PR and between 87b1726 and 1823281.

📒 Files selected for processing (6)
  • docs/en/features/hover.md
  • docs/zh/features/hover.md
  • src/feature/hover.cpp
  • tests/data/hover/tag_decls.cpp
  • tests/snapshots/hover/snapshot/tag_decls.cpp.snap.yml
  • tests/unit/feature/hover_tests.cpp

Comment thread src/feature/hover.cpp

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 182328140a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/feature/hover.cpp
Comment thread src/feature/hover.cpp
Comment thread src/feature/hover.cpp
@zaragoza-xu zaragoza-xu changed the title feat(hover): show include paths and class/struct/enum members feat(hover): show include paths and struct/enum members Jul 9, 2026
@zaragoza-xu
zaragoza-xu marked this pull request as draft July 9, 2026 14:43
@zaragoza-xu
zaragoza-xu force-pushed the feat/include-hover branch 3 times, most recently from 0352b94 to 2375118 Compare July 10, 2026 06:41
@zaragoza-xu zaragoza-xu changed the title feat(hover): show include paths and struct/enum members feat(hover): show include paths and tag_decl members Jul 10, 2026
@zaragoza-xu zaragoza-xu changed the title feat(hover): show include paths and tag_decl members feat(hover): show include paths and TagDecl members Jul 10, 2026
@zaragoza-xu
zaragoza-xu marked this pull request as ready for review July 10, 2026 06:52
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.

2 participants