feat(reference): extract_token_at_cursor を C# lexer 化(Phase 4-C / Refs #191)#194
Merged
Conversation
SPEC #191 (Phase 4 umbrella) のサブタスク C として、Phase 3 (#188) で MVP land した extract_token_at_cursor の精度を上げる。これまでは 正規表現ベースで identifier 文字を機械的に拾うだけだったため、 コメント (`// ...`) 内や文字列リテラル (`"..."`) 内の identifier も hit してしまい、resolve-symbol-at が偽陽性候補を返していた。 主な変更: - src/reference/mod.rs::is_cursor_in_comment_or_string を新設し、 カーソル位置までを scan して // line comment 内と "..." string literal 内を判定する。エスケープシーケンス \" は string を閉じ ない、line comment は // 以降を全て comment として扱う。 - extract_token_at_cursor が cursor 位置の class を判定し、comment 内 / string 内なら None を返す。 - 新規 RED テスト 4 件: skips_line_comment / skips_string_literal / returns_ident_after_closed_string / handles_escaped_quote_in_string。 スコープ外(umbrella #191 で継続管理): - block comment /* ... */ の multi-line 対応。現状は 1 行内の判定 のみ。 - char literal '...' や interpolated string $"..." の特例。 - preprocessor directive #if/#endif の中の cursor。 ローカル検証: - cargo fmt -- --check: clean - cargo clippy --all-targets -- -D warnings: clean - cargo test --bin unity-cli: 386 passed / 0 failed - cargo llvm-cov --all-targets: TOTAL line coverage 91.03% - unity-cli skills lint --severity error: 15 skills / 0 violations Refs #191 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
11 tasks
This was referenced May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
extract_token_at_cursorをミニ C# lexer 化する。// ...) や string literal ("...") 内の identifier も拾ってしまう問題があった。resolve-symbol-atの偽陽性候補を抑制する。Changes
src/reference/mod.rs::is_cursor_in_comment_or_stringを新設。カーソル位置までの 1 行を scan し、// line comment内と"..." string literal内かを判定する。\"エスケープは string を閉じない扱い。extract_token_at_cursorがカーソル位置の class を判定し、comment 内 / string 内ならNoneを返すように改良。extract_token_at_cursor_skips_line_commentextract_token_at_cursor_skips_string_literalextract_token_at_cursor_returns_ident_after_closed_stringextract_token_at_cursor_handles_escaped_quote_in_stringTesting
cargo fmt -- --check— cleancargo clippy --all-targets -- -D warnings— cleancargo test --bin unity-cli— 386 passed / 0 failedcargo llvm-cov --all-targets --summary-only -- --test-threads=1— TOTAL line coverage 91.03%unity-cli skills lint --severity error— 15 skills / 0 violationsClosing Issues
Refsのみ)Related Issues / Links
Checklist
cargo clippy,cargo fmt,unity-cli skills lint)tokenNameがnullで返るケースが拡張されるだけfeat)Context
resolve-symbol-atは project file の cursor 位置から reference cache の候補を返す薄い wrapper。Phase 3 MVP では正規表現ベースの identifier 抽出だったため、LLM が cursor をコメントや文字列リテラル内に置いたときに偽のtokenNameを返してしまい、candidatesも虚しく埋まっていた。本 PR で line comment と string literal の 2 ケースを除外し、cursor が code 領域にあるときだけ token を抽出する。Out of Scope
umbrella SPEC #191 で継続管理する範囲:
/* ... */の multi-line 判定。現状は 1 行内のみ。'...'や interpolated string$"..."、verbatim string@"..."の特例。#if/#endifの中の cursor。reference fetchの zip fallback) / Phase 4-E (vector embedding) は umbrella の Tasks として未着手。Notes