Skip to content

feat: classify dependent-name semantic token modifier - #387

Merged
Myriad-Dreamin merged 5 commits into
mainfrom
dependent-name-modifier
Apr 5, 2026
Merged

Myriad-Dreamin merged 5 commits into
mainfrom
dependent-name-modifier

Conversation

@Myriad-Dreamin

@Myriad-Dreamin Myriad-Dreamin commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • classify unresolved using declarations with the dependentName semantic token modifier
  • include the declaration modifier on definitions to match clangd's semantic token behavior
  • extend the semantic token modifier legend coverage in integration tests

Testing

  • pixi run python -m pytest -s --log-cli-level=INFO tests/integration/test_server.py -k 'semantic_token_modifier_legend or capabilities' --executable=./build/bin/clice

Summary by CodeRabbit

  • New Features

    • Added many new semantic token modifiers (deprecated, deduced, readonly, static, abstract, virtual, dependent-name, constructor/destructor, user-defined, mutable-usage flags) and new scope markers (function, class, file, global).
    • Improved tagging for declarations, definitions and dependent names in semantic tokens.
  • Tests

    • Added an integration test verifying the semantic token modifier legend and its ordering.

@coderabbitai

coderabbitai Bot commented Apr 3, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 548b6b06-5cfd-48e6-8bb1-6f67f66e97b5

📥 Commits

Reviewing files that changed from the base of the PR and between d997690 and 7d2e243.

📒 Files selected for processing (3)
  • src/feature/semantic_tokens.cpp
  • src/semantic/symbol_kind.h
  • tests/unit/feature/semantic_tokens_tests.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/feature/semantic_tokens.cpp

📝 Walkthrough

Walkthrough

Changed SymbolModifiers::Kind from explicit bitmasks to bit positions and added to_mask helper; updated semantic tokens collector to OR modifiers via to_mask, added is_dependent handling and placeholders; added an integration test for the LSP semantic token modifier legend and a unit test update to use to_mask.

Changes

Cohort / File(s) Summary
Symbol Modifiers Enum
src/semantic/symbol_kind.h
Converted SymbolModifiers::Kind enumerators from mask values to bit positions, added many new modifier/scope kinds, and introduced constexpr static to_mask(Kind); updated constructor/contains to use to_mask.
Semantic Token Handler
src/feature/semantic_tokens.cpp
Replaced helper bit computations by OR-ing with SymbolModifiers::to_mask(kind); added is_dependent(const clang::Decl*) and set DependentName when applicable; preserved existing Definition/Declaration modifier logic and added non-functional TODO placeholders.
Tests
tests/integration/test_server.py, tests/unit/feature/semantic_tokens_tests.cpp
Added test_semantic_token_modifier_legend to assert init capabilities' semantic_tokens_provider.legend.token_modifiers; updated unit test helper to compute masks via SymbolModifiers::to_mask(kind).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibbled bits and shifted their place,
Turning masks to positions with gentle grace.
I hid a dependent hop in the code,
And left a tiny legend upon the road.
Hop, nibble, push — a tidy little trace.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat: classify dependent-name semantic token modifier' accurately and specifically describes the main change: adding support for classifying the dependent-name semantic token modifier for unresolved using-declarations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dependent-name-modifier

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 and usage tips.

@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: 2

🧹 Nitpick comments (1)
src/feature/semantic_tokens.cpp (1)

69-90: Trim large commented-out placeholder blocks.

These stub/comment sections add noise and make the handler harder to scan. Prefer converting to concise TODOs with issue references (or remove until implemented).

Also applies to: 98-104, 121-124

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/feature/semantic_tokens.cpp` around lines 69 - 90, Remove the large
commented-out placeholder blocks in semantic_tokens.cpp (the commented
scopeModifier/Tok.addModifier block and the computeSymbolTags/TagModifierMap
sections) and replace each with a single-line TODO including a short description
and an issue or task ID (e.g., "// TODO(issue-1234): implement clangd-style
modifiers using scopeModifier/computeSymbolTags"). Apply the same replacement
for the other commented blocks mentioned (around the areas currently at 98-104
and 121-124), keeping only concise TODOs that reference the related symbols
(scopeModifier, computeSymbolTags, TagModifierMap, Tok.addModifier) so the
handler remains easy to scan.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/feature/semantic_tokens.cpp`:
- Around line 42-44: The is_dependent(const clang::Decl* D) function currently
only tests isa<clang::UnresolvedUsingValueDecl>(D); update it to also detect
clang::UnresolvedUsingTypenameDecl so unresolved using typename declarations are
treated as dependent; modify the check in is_dependent (or replace it with a
combined isa check such as testing both clang::UnresolvedUsingValueDecl and
clang::UnresolvedUsingTypenameDecl) to return true for either AST node type.

In `@tests/integration/test_server.py`:
- Around line 54-56: The test dereferences
client.init_result.capabilities.semantic_tokens_provider.legend without ensuring
the semantic_tokens_provider exists; add an explicit assertion that
client.init_result.capabilities.semantic_tokens_provider is not None before
accessing .legend (so replace or precede the legend assignment with an assert
that the provider is present to produce a clear failure instead of an
AttributeError).

---

Nitpick comments:
In `@src/feature/semantic_tokens.cpp`:
- Around line 69-90: Remove the large commented-out placeholder blocks in
semantic_tokens.cpp (the commented scopeModifier/Tok.addModifier block and the
computeSymbolTags/TagModifierMap sections) and replace each with a single-line
TODO including a short description and an issue or task ID (e.g., "//
TODO(issue-1234): implement clangd-style modifiers using
scopeModifier/computeSymbolTags"). Apply the same replacement for the other
commented blocks mentioned (around the areas currently at 98-104 and 121-124),
keeping only concise TODOs that reference the related symbols (scopeModifier,
computeSymbolTags, TagModifierMap, Tok.addModifier) so the handler remains easy
to scan.
🪄 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: a125c8d3-5125-493e-a925-7bc4f82b0230

📥 Commits

Reviewing files that changed from the base of the PR and between e24eff6 and 02458be.

📒 Files selected for processing (3)
  • src/feature/semantic_tokens.cpp
  • src/semantic/symbol_kind.h
  • tests/integration/test_server.py

Comment thread src/feature/semantic_tokens.cpp
Comment thread tests/integration/test_server.py

@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.

♻️ Duplicate comments (1)
src/feature/semantic_tokens.cpp (1)

42-44: ⚠️ Potential issue | 🟠 Major

is_dependent() still misses unresolved using typename declarations.

Line 43 only checks clang::UnresolvedUsingValueDecl, so dependent-name tagging is still incomplete for clang::UnresolvedUsingTypenameDecl (downstream impact at Line 95-96).

🔧 Proposed fix
 bool is_dependent(const clang::Decl* D) {
-    return isa<clang::UnresolvedUsingValueDecl>(D);
+    return llvm::isa<clang::UnresolvedUsingValueDecl>(D) ||
+           llvm::isa<clang::UnresolvedUsingTypenameDecl>(D);
 }
#!/bin/bash
# Verify dependent-name coverage for unresolved using decl kinds.
rg -n -C3 'is_dependent\(|UnresolvedUsing(Value|Typename)Decl' \
  src/feature/semantic_tokens.cpp src/index/usr_generation.cpp
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/feature/semantic_tokens.cpp` around lines 42 - 44, The is_dependent
function currently only checks for clang::UnresolvedUsingValueDecl which misses
unresolved using typename declarations; update is_dependent to also return true
for clang::UnresolvedUsingTypenameDecl so dependent-name tagging covers both
cases (this affects downstream logic in the semantic tokens flow around where
is_dependent is used, e.g., the checks at the locations corresponding to lines
~95-96). Locate the is_dependent(const clang::Decl* D) function and add an
additional isa<> check for clang::UnresolvedUsingTypenameDecl (or combine with a
logical OR) so both UnresolvedUsingValueDecl and UnresolvedUsingTypenameDecl are
treated as dependent.
🧹 Nitpick comments (1)
src/feature/semantic_tokens.cpp (1)

69-90: Trim large commented-out scaffolding before merge.

These TODO/commented blocks add noise without behavior. Prefer removing them or converting to a tracked issue reference.

Also applies to: 98-104, 121-124

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/feature/semantic_tokens.cpp` around lines 69 - 90, Remove the large
commented-out scaffolding in src/feature/semantic_tokens.cpp (the blocks
referencing scopeModifier, Tok.addModifier, computeSymbolTags, TagModifierMap,
SymbolTag and HighlightingModifier) and replace them with a single short comment
linking to a tracked issue/PR number or remove entirely; also clean up the
similar commented blocks at the other noted ranges (lines referenced around the
second block and the third block) so the file contains only active code and a
concise note pointing to the issue where the clangd-style modifiers will be
implemented.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/feature/semantic_tokens.cpp`:
- Around line 42-44: The is_dependent function currently only checks for
clang::UnresolvedUsingValueDecl which misses unresolved using typename
declarations; update is_dependent to also return true for
clang::UnresolvedUsingTypenameDecl so dependent-name tagging covers both cases
(this affects downstream logic in the semantic tokens flow around where
is_dependent is used, e.g., the checks at the locations corresponding to lines
~95-96). Locate the is_dependent(const clang::Decl* D) function and add an
additional isa<> check for clang::UnresolvedUsingTypenameDecl (or combine with a
logical OR) so both UnresolvedUsingValueDecl and UnresolvedUsingTypenameDecl are
treated as dependent.

---

Nitpick comments:
In `@src/feature/semantic_tokens.cpp`:
- Around line 69-90: Remove the large commented-out scaffolding in
src/feature/semantic_tokens.cpp (the blocks referencing scopeModifier,
Tok.addModifier, computeSymbolTags, TagModifierMap, SymbolTag and
HighlightingModifier) and replace them with a single short comment linking to a
tracked issue/PR number or remove entirely; also clean up the similar commented
blocks at the other noted ranges (lines referenced around the second block and
the third block) so the file contains only active code and a concise note
pointing to the issue where the clangd-style modifiers will be implemented.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f0f36dfd-669d-4e8a-bc8f-cdba72825f70

📥 Commits

Reviewing files that changed from the base of the PR and between 02458be and b776914.

📒 Files selected for processing (1)
  • src/feature/semantic_tokens.cpp

@Myriad-Dreamin
Myriad-Dreamin merged commit 8d4ad26 into main Apr 5, 2026
14 checks passed
@16bit-ykiko
16bit-ykiko deleted the dependent-name-modifier branch April 6, 2026 07:57
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.

1 participant