Skip to content

feat(reference): member-level シンボル抽出 MVP(Phase 4-A / Refs #191)#197

Merged
akiojin merged 1 commit into
developfrom
work/20260511-0223
May 11, 2026
Merged

feat(reference): member-level シンボル抽出 MVP(Phase 4-A / Refs #191)#197
akiojin merged 1 commit into
developfrom
work/20260511-0223

Conversation

@akiojin
Copy link
Copy Markdown
Owner

@akiojin akiojin commented May 11, 2026

Summary

Changes

  • src/reference/index.rs::extract_symbols_from_text を 3 つの regex (TYPE_RE / METHOD_RE / PROPERTY_RE) で順に走査する形に書き換え。overlaps_consumed で既に capture 済みの span (type declaration) を skip し、class Foo {}Foo が method として double-capture されないようにする。
  • METHOD_RE: public|internal|protected|private + optional modifiers + return type + name + ( の 1 行パターン。
  • PROPERTY_RE: 同上だが name { get|set で終わる行を property として認識。
  • 新規 RED テスト 3 件:
    • extract_symbols_from_text_finds_methods
    • extract_symbols_from_text_finds_property
    • extract_symbols_from_text_does_not_double_capture_class_name

Testing

  • cargo fmt -- --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo test --bin unity-cli392 passed / 0 failed
  • cargo llvm-cov --all-targets --summary-only -- --test-threads=1 — TOTAL line coverage 90.89%
  • unity-cli skills lint --severity error — 15 skills / 0 violations

Closing Issues

Related Issues / Links

Checklist

  • Tests added/updated (3 件 + 既存 9 件が GREEN を維持)
  • Lint/format passed (cargo clippy, cargo fmt, unity-cli skills lint)
  • Documentation updated — none required (find-symbol の公開 API は不変、--kind method|property を返せる対象が増えるだけ)
  • Migration/backfill plan included — Not applicable: 既存 cache の .unity-cli-index/symbols.json は新コードで再 build される(signature 差分が検出され次第)
  • CHANGELOG impact considered — minor bump per Conventional Commits (feat)

Context

Phase 2 (SPEC #187) では型のみを index に含めていたため、ユーザーが find-symbol --name Play --kind method を試しても空配列が返っていた。本 PR の MVP は単純な 1 行 regex で method / property を捕捉し、reference find-symbol の実用範囲を広げる。

Out of Scope(umbrella #191 で継続管理)

  • 多行シグネチャ(戻り値型と method 名が改行で分かれるケース)
  • constructor / destructor(戻り値型を持たないため現 regex を通らない)
  • field / event 抽出
  • ジェネリック制約句 where T : ... の取り扱い
  • record / record struct のような新しい型構文
  • Phase 4-E (vector embedding) は未着手

regex MVP は偽陽性を含む可能性があるが、--kind method / --kind property フィルタで noise を抑えやすい。本格的な精度は Roslyn 経由解析の別 PR として後追い検討する余地がある。

Notes

  • 既存 type 抽出 (TYPE_RE) の挙動は変えていない。class / interface / struct / enum を見つけたファイルでは consumed_spans に span を入れ、その範囲を method / property regex の対象から除外する。これにより public class Bar {}Bar が method として捕捉されない。
  • index ファイル .unity-cli-index/symbols.json の version は維持。新コードで再 build される際、signature が変わっているファイルは新形式で書き直される。

SPEC #191 (Phase 4 umbrella) のサブタスク A を最小 MVP として land する。
`extract_symbols_from_text` を拡張し、`public` / `internal` /
`protected` / `private` で始まる method と property を index に含め
られるようにする。Phase 2 の `reference find-symbol --kind method`
が「Animator.Play」のような典型シンボルを直接 lookup できる。

主な変更:

- src/reference/index.rs::extract_symbols_from_text: METHOD_RE と
  PROPERTY_RE を追加し、既存の TYPE_RE と組み合わせて symbol を抽出。
  既に capture 済みの span (type declaration) は overlaps_consumed で
  skip し、class 名が method として double-capture されないように
  する。
- 新規 RED テスト 3 件:
  - extract_symbols_from_text_finds_methods: void / static int の
    両方のシグネチャを method として抽出
  - extract_symbols_from_text_finds_property: { get; set; } と
    { get { ... } } の両方を property として抽出
  - extract_symbols_from_text_does_not_double_capture_class_name:
    class 名が method として捕捉されない回帰防止

スコープ外(umbrella #191 で継続管理):

- 多行シグネチャ(戻り値型と method 名が改行で分かれるケース)
- constructor / destructor(戻り値型を持たないため現 regex は通らない)
- field / event 抽出
- ジェネリック制約句 `where T : ...` の取り扱い
- record / record struct のような新しい型構文

regex MVP は偽陽性を含む可能性があるが、`--kind method` / `--kind
property` のフィルタで noise を抑えやすい。本格的な精度は Phase 4 の
後追い改善か、別 SPEC として Roslyn 経由の解析を立てる余地がある。

ローカル検証:

- cargo fmt -- --check: clean
- cargo clippy --all-targets -- -D warnings: clean
- cargo test --bin unity-cli: 392 passed / 0 failed
- cargo llvm-cov --all-targets: TOTAL line coverage 90.89%
- unity-cli skills lint --severity error: 15 skills / 0 violations

Refs #191

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@akiojin akiojin merged commit ab6d829 into develop May 11, 2026
8 checks passed
@akiojin akiojin deleted the work/20260511-0223 branch May 11, 2026 16:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f8951b8c-50a3-4c56-9260-4c77d3af6bcb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch work/20260511-0223

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.

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