Repository navigation
refactor(tests): annotation syntax with non-ASCII sigils - #537
Conversation
The old grammar reserved $ and @, which collide with LSP snippet
placeholders (${1:), $/cancelRequest, ${workspace} config vars and
Doxygen tags (@PARAM[in] matches @key[...] and asserts on bare @word).
The new grammar reserves no ASCII character at all:
§ nameless point §(name) named point
§⟦...⟧ nameless range §(name)⟦...⟧ named range
Ranges nest via a stack (the bracket-balance heuristic is gone, so
unbalanced brackets inside a range are now expressible), stray sigils
fail loudly, and §(name) requires an identifier so a nameless point
directly before real parentheses stays unambiguous (§()).
Also adds test/snap_region.h: whole-line /// <snap:begin>/<snap:end>
markers plus a containment filter, for snapshot fixtures that only want
a marked region's results.
All ~750 annotations across 40 files migrated mechanically; a semantic
differ verified byte-identical stripped sources and annotation tables
against the old parser (four sites in selection_tests relied on the old
$() quirk and were fixed, one signature-help point was recovered).
Review found the assert-only guards let NDEBUG builds wrap i past npos on an unterminated §( (infinite loop) and pop an empty stack on a stray ⟧ (UB). Malformed annotations now LOG_FATAL unconditionally. Also adds the review-suggested coverage: digit-only names, § at EOF, empty range body, end marker without trailing newline, empty snap region.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe annotation framework now uses ChangesAnnotation grammar and test infrastructure
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7863e7b1ce
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unit/feature/document_link_tests.cpp (1)
47-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove stray nameless point markers.
The trailing
§markers placed just before the range closing markers (⟧) define unused nameless points. Sincenameless_points()is not utilized in these test cases, they are functionally harmless but likely unintentional leftovers from the marker syntax migration.
tests/unit/feature/document_link_tests.cpp#L47-L52: remove the trailing§from the include arguments (e.g.,⟦"test.h"§⟧->⟦"test.h"⟧).tests/unit/feature/document_link_tests.cpp#L89-L89: remove the trailing§from⟦HEADER§⟧.tests/unit/feature/document_link_tests.cpp#L103-L103: remove the trailing§from⟦"bytes.bin"§⟧.tests/unit/feature/document_link_tests.cpp#L118-L118: remove the trailing§from⟦"data.bin"§⟧.🤖 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 `@tests/unit/feature/document_link_tests.cpp` around lines 47 - 52, Remove the unused trailing nameless-point markers from the marker ranges in tests/unit/feature/document_link_tests.cpp: lines 47-52 include arguments, line 89 HEADER, line 103 "bytes.bin", and line 118 "data.bin"; preserve the surrounding marker syntax and test content.
🤖 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 `@tests/unit/test/annotation.cpp`:
- Around line 81-83: Update the point-annotation insertion at
tests/unit/test/annotation.cpp lines 81-83 to assert that insertion succeeds
instead of silently ignoring duplicate keys; update the range-annotation
insertion at lines 91-94 to assert success and explicitly reject a second
nameless range keyed by the empty string, preserving the fail-loudly behavior
for duplicate annotation keys.
---
Nitpick comments:
In `@tests/unit/feature/document_link_tests.cpp`:
- Around line 47-52: Remove the unused trailing nameless-point markers from the
marker ranges in tests/unit/feature/document_link_tests.cpp: lines 47-52 include
arguments, line 89 HEADER, line 103 "bytes.bin", and line 118 "data.bin";
preserve the surrounding marker syntax and test content.
🪄 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: 444f980c-8a0b-413b-ad77-45613a8b3e98
📒 Files selected for processing (44)
tests/data/hover/.clang-formattests/data/hover/attributes.cpptests/data/hover/auto.cpptests/data/hover/basics.cpptests/data/hover/callee_args.cpptests/data/hover/concepts.cpptests/data/hover/decltype.cpptests/data/hover/docs.cpptests/data/hover/expressions.cpptests/data/hover/fields.cpptests/data/hover/functions.cpptests/data/hover/getter_setter.cpptests/data/hover/lambdas.cpptests/data/hover/misc.cpptests/data/hover/no_hover.cpptests/data/hover/no_hover_errors.cpptests/data/hover/pass_types.cpptests/data/hover/spaceship.cpptests/data/hover/tag_decls.cpptests/data/hover/template_params.cpptests/data/hover/templates.cpptests/data/hover/this_expr.cpptests/data/hover/using_decls.cpptests/data/hover/values.cpptests/data/hover/variables.cpptests/unit/compile/directive_tests.cpptests/unit/feature/code_completion_tests.cpptests/unit/feature/document_link_tests.cpptests/unit/feature/folding_range_tests.cpptests/unit/feature/hover_tests.cpptests/unit/feature/inlay_hint_tests.cpptests/unit/feature/semantic_tokens_tests.cpptests/unit/feature/signature_help_tests.cpptests/unit/index/index_query_tests.cpptests/unit/index/merged_index_tests.cpptests/unit/index/preamble_state_tests.cpptests/unit/index/tu_index_tests.cpptests/unit/index/usr_tests.cpptests/unit/semantic/selection_tests.cpptests/unit/server/query_freshness_tests.cpptests/unit/server/query_overlay_tests.cpptests/unit/test/annotation.cpptests/unit/test/annotation_tests.cpptests/unit/test/snap_region.h
try_emplace silently kept the first binding, so a duplicate §(name) or a second nameless range dropped an annotation without a trace.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b46a2f7112
ℹ️ 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".
Why
The test annotation grammar reserved
$and@, both of which collide with real content that tests need to contain:@param[in]matches the@key[...]annotation shape and destroys the input; a bare Doxygen tag like@briefaborts assertion-enabled builds. Net effect: no test source could contain Doxygen comments — the hover documentation fixtures avoid them entirely today.$collides with LSP snippet placeholders (${1:...}),$/cancelRequest, and${workspace}config variables.[...]range delimiter collides with C++ brackets: the balance heuristic cannot express a range containing unbalanced brackets (lambda captures, partial subscripts).New grammar
The grammar now reserves no ASCII character at all — sigil
§(U+00A7), range delimiters⟦/⟧(U+27E6/E7):§(name)requires an identifier name, keeping a nameless point directly before real parentheses unambiguous (§()).nposand loop forever).Also introduces
test/snap_region.h: whole-line/// <snap:begin [name]>//// <snap:end [name]>markers plus a containment filter, for snapshot fixtures that only want results from a marked region.Migration
~750 annotations across 40 files converted mechanically. A semantic differ replayed the old parser against the old files and the new parser against the new files and verified byte-identical stripped sources and annotation tables. Three findings from that process, all fixed:
$()meant point-plus-literal-parens; they now use the explicit§()()form.$during auditing.Tests