Skip to content

Commit 92722d6

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-issue5189
# Conflicts: # src/CodeIndex/Indexer/Symbols/SymbolExtractor.Contracts.cs
2 parents 53465d7 + 3dda2bc commit 92722d6

22 files changed

Lines changed: 1663 additions & 52 deletions

DEVELOPER_GUIDE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,15 @@ unqualified name receive a global candidate only when that name is unique in the
16931693
symbol set. Otherwise they remain `ambiguous` or `unresolved`, and dependency queries do not
16941694
fall back to a same-name edge.
16951695

1696+
C# unqualified calls and method groups that match local-function declarations resolve against
1697+
the narrowest complete lexical block inside the enclosing callable. Declaration order is not a
1698+
visibility gate; overloads from the winning block remain candidates and normal call-arity
1699+
filtering selects among them. Parameters, local values, and delegate-valued bindings shadow
1700+
local functions before graph resolution, while sibling blocks and unrelated enclosing
1701+
callables cannot contribute local candidates. Incomplete callable or block-range evidence stays
1702+
`unresolved` instead of falling back to a file-wide same-name edge. The persisted target
1703+
identity is shared by references, callers, inspect, impact, and LSP definition/reference reads.
1704+
16961705
C# type-reference resolution uses `LogicalPartialSymbolGrouper` for declarations that have a
16971706
valid logical partial-family identity. Full and scoped refreshes persist the same stable
16981707
`family:` target key used by grouped symbol discovery, so multiple physical declarations in one
@@ -2517,6 +2526,8 @@ Runtime diagnostic subcontracts:
25172526

25182527
For `references`, `callers`, and `callees`, an explicit `--snippet-lines` is valid only with `--body` and text or JSON result output. Location-only formats and `--count` reject the option before opening the database so a requested snippet length is never silently ignored or recorded in replay/query context without being applied. Explicitness comes from the argument parser, so option-like literals passed through `--query` or after `--` remain queries. Bounded JSON projection also removes the snippet-only control from its internal count replay, preserving clean stderr, total counts, and cursors for visible body excerpts.
25192528

2529+
Bounded `--fields` output is a generic JSON projection contract and can be combined only with `--format json` or `--format compact`; projection-incompatible formats such as CSV, TSV, quickfix, LSP, and SARIF are rejected with `E010_USAGE_ERROR` before the database is opened. For `references`, `callers`, and `callees`, a collection-bearing zero-result document is unwrapped authoritatively so an empty collection remains empty and its result, returned, and total counts remain zero. Selecting `body` or `body_content` automatically retains the companion start/end, requested/effective range, truncation flag/reasons, next-start, omission, and recovery fields. A byte budget omits the whole row or returns `E028_RESPONSE_BUDGET_TOO_SMALL` rather than stripping those companion fields.
2530+
25202531
Graph body mode keeps the established `body_*` definition/container excerpt and adds an independent `callsite_*` excerpt for `references`, `callers`, `callees`, and graph-backed `impact` rows. The call-site window is read from indexed source and centered on the deterministic `first_reference`: grouped rows choose the lowest source position, while an individual reference selects itself. `callsite_line`, available persisted `callsite_column` / `callsite_length`, `callsite_selection`, `callsite_reference_count`, and `callsite_omitted_reference_count` make that choice explicit; legacy rows omit a coordinate or span that was not indexed. The content/range fields mirror the body contract through requested/effective ranges, `line_width_cap` and other truncation reasons, redacted recovery metadata, and `callsite_content_unavailable_reason` when the exact focus line cannot be reconstructed from indexed chunks. A bounded projection containing only `callsite_*` fields still materializes body mode; a projection containing neither `body_*` nor `callsite_*` skips it. Existing output without `--body` remains unchanged.
25212532

25222533
`ReferenceResult` includes `is_self_reference` and `is_mutual_recursion`; `CallerResult` includes `has_self_reference` and `has_mutual_recursion`. These fields identify self-recursive edges and direct two-symbol cycles without removing valid recursive calls from default graph results. Reader APIs that need a non-recursive view can opt into self-reference exclusion.
@@ -5807,6 +5818,14 @@ resolution を再構築し、同じ transaction で marker を設定します。
58075818
対象となる symbol 集合で名前が一意の場合だけ global candidate を持ちます。それ以外は
58085819
`ambiguous` または `unresolved` のままとし、dependency query は同名 edge へ fallback しません。
58095820

5821+
C# の無修飾 call と method group が local function 宣言に一致する場合、enclosing callable 内の
5822+
最も狭い完全な字句 block に対して解決します。宣言順は visibility gate とせず、選択された block の
5823+
overload 群を候補に残したうえで通常の call arity filter で絞り込みます。parameter、local value、
5824+
delegate value binding は graph 解決より先に local function を shadow し、兄弟 block や無関係な
5825+
enclosing callable の local function は候補になりません。callable または block range の evidence が
5826+
不完全な場合は file 全体の同名 edge へ fallback せず `unresolved` のままにします。永続化した target
5827+
identity は references、callers、inspect、impact、LSP definition/reference read で共有します。
5828+
58105829
C# の type-reference resolution は、有効な論理 partial-family identity を持つ declaration に
58115830
`LogicalPartialSymbolGrouper` を使用します。full / scoped refresh は grouped symbol discovery と同じ
58125831
安定した `family:` target key を永続化するため、language、kind、namespace / container、generic arity が
@@ -6654,6 +6673,8 @@ runtime diagnostic subcontract:
66546673

66556674
`references`、`callers`、`callees` で明示した `--snippet-lines` は、`--body` と text または JSON の結果出力を併用する場合だけ有効です。location-only format と `--count` は database を開く前にこの option を拒否するため、要求した snippet 長が黙って無視されたり、適用されないまま replay / query context に記録されたりすることはありません。明示指定かどうかは引数 parser の状態で判定するため、`--query` の値または `--` 以降に渡した option 風の literal は query のままです。bounded JSON projection の内部 count replay からは snippet 専用 control も除去し、表示可能な body excerpt で stderr、total count、cursor を正しく維持します。
66566675

6676+
bounded `--fields` 出力は汎用 JSON projection 契約であり、`--format json` または `--format compact` とだけ併用できます。CSV、TSV、quickfix、LSP、SARIF など projection と互換性のない形式は、database を開く前に `E010_USAGE_ERROR` で拒否されます。`references`、`callers`、`callees` では、collection を持つ 0 件 response を authoritative に展開するため、空 collection は空のまま維持され、result / returned / total count はすべて 0 になります。`body` または `body_content` を選択すると、開始/終了位置、requested/effective range、truncation flag/reason、next-start、omission、recovery の付随 field も自動的に保持されます。byte budget に収まらない場合は、付随 field だけを削らずに row 全体を省略するか `E028_RESPONSE_BUDGET_TOO_SMALL` を返します。
6677+
66576678
graph body mode は既存の定義 / container 抜粋である `body_*` を維持し、`references`、`callers`、`callees`、graph-backed な `impact` row に独立した `callsite_*` 抜粋を追加します。call-site window は indexed source から取得し、決定的な `first_reference` を中心にします。group row は source position が最小の参照を選び、個別 reference は自分自身を選びます。`callsite_line`、永続化済みの場合の `callsite_column` / `callsite_length`、`callsite_selection`、`callsite_reference_count`、`callsite_omitted_reference_count` でその選択を明示し、座標または span を index していない legacy row では該当 field を省略します。content / range field は requested / effective range、`line_width_cap` などの truncation reason、伏字化した recovery metadata、indexed chunk から正確な focus 行を復元できない場合の `callsite_content_unavailable_reason` まで body 契約を反映します。`callsite_*` field だけを含む bounded projection でも body mode を materialize し、`body_*` と `callsite_*` のどちらも含まない投影では省略します。`--body` なしの既存出力は変わりません。
66586679

66596680
`ReferenceResult` は `is_self_reference` と `is_mutual_recursion` を含み、`CallerResult` は `has_self_reference` と `has_mutual_recursion` を含む。これらのフィールドは、正当な再帰呼び出しを既定の graph 結果から削除せずに、自己再帰エッジと直接の2シンボル循環を識別する。非再帰 view が必要な reader API は自己参照除外を opt-in で使える。

TESTING_GUIDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Candidate-ordered parallel-index recovery tests must prove that the fatal result
115115
YAML sequence-hierarchy fixtures must keep sequence items path-only, count empty/scalar/alias items in stable indexes, preserve anchor and block-scalar boundaries, assert logical qualified paths separately from nearest emitted symbol parents, and prove a normal full scan refreshes unchanged YAML rows stamped with the prior extractor contract.
116116
C# declaration-boundary regressions should pair a direct extractor fixture with a real-index `symbols --exact-name` query. Keep invocation and parameter continuations beside valid multi-line methods, constructors, delegates, and local functions so both false-positive rejection and declaration ranges remain observable. Scope-continuation fixtures must also place unmatched delimiters in character/string literals and comments before later methods, then assert that the later methods remain definitions rather than unresolved declaration-shaped calls.
117117
C# explicit-interface identity coverage pairs extractor assertions for methods, properties, events, and indexers with persisted exact qualified/unqualified queries, fold rewrite validation, inspect/outline checks, and LSP definition/reference scoping. Include multiple and inherited interfaces, generic arity, a same-named public member, and a qualified return type that must not be mistaken for an explicit-interface qualifier.
118-
C# callable-containment fixtures should cover block-bodied test methods, local and nested local functions, named lambdas, expression-bodied members, and nested types together, asserting both symbol parents and call-reference containers.
118+
C# callable-containment fixtures should cover block-bodied test methods, local and nested local functions, named lambdas, expression-bodied members, and nested types together, asserting both symbol parents and call-reference containers. Local-function identity coverage additionally keeps pre/post-declaration calls, nested and sibling blocks, overloads, parameter/local delegate shadowing, method groups, identical enclosing names in unrelated types, incomplete ranges, persisted graph/query/inspect/impact behavior, and LSP definition/reference parity in one coordinated contract (#5188, extending #4840).
119119
C# switch-expression returned-lambda coverage pairs a direct `ReferenceExtractorCSharpTests` regression with an `IndexCommandRunnerFullScanTests` `--rebuild` graph fixture. Keep expression/block, parenthesized, multiline, nested-switch, async, qualified/unqualified, and non-lambda arms together; assert raw call rows, enclosing containers, exact locations, callers/callees, complete graph readiness, and negative positional-pattern/enum controls including guarded, nested, and contextual-keyword-designation patterns with a following-line arrow (#5085).
120120
Repository-metadata coverage lives in `SymbolExtractorRepositoryMetadataTests.cs` and `ReferenceExtractorRepositoryMetadataTests.cs`; keep TOML, JSON Lines, ignore/attributes, EditorConfig, `.rules`, and application-manifest capability assertions coordinated with conservative local-path and malformed-record controls.
121121
Capability-regression fixtures that require an unsupported language use the explicit `text` placeholder or an ambiguity bucket; do not use a recognized repository-metadata format as the unsupported control.
@@ -1255,7 +1255,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"
12551255
C# の明示的 interface identity coverage では、method、property、event、indexer の extractor assertion と、永続化後の修飾 / 非修飾の完全一致 query、fold rewrite 検証、inspect / outline、LSP の definition / reference scope を組み合わせます。複数および継承 interface、generic arity、同名 public member に加え、明示的 interface qualifier と誤認してはならない修飾 return type を含めてください。
12561256
C# generic outline 表示の coverage は、generic / 非 generic overload、extension / local / explicit-interface method、nested generic の tuple / nullable / array parameter type、constraint、overload を区別する modifier、修飾型 / 具体型名との衝突、escaped / Unicode identifier、attribute / 既定値 literal 内の区切り文字を、抽出と reader setup を共有する1つの `DbReaderTests` fixture に維持します。line 移動を検証する対の fixture は先頭改行以外を同一にし、canonical name / path が不変であることを assertion に含め、旧 index の `Name@line` fallback 用に不完全 signature を手動永続化した row も1件残してください(#4916)。
12571257
C# の位置 record に対する検索帰属 coverage は、extractor の座標 assertion、1つの indexed reader fixture、1つの CLI fixture を組み合わせます。record keyword と型名、attribute と component 型、base 引数、body member、同一行の通常 property、複数行 `record struct` component、正規化された verbatim identifier の列、言語未指定の exact grouping、multi-hit の focus 選択、focus の行・列出力、symbol grouping を共通契約に維持します。component 列を持たない旧 symbol では行ベースの fallback を維持してください。C# の座標維持のために comment padding を変更する場合、Java/Kotlin の record component comment が既存 signature を維持することも assertion してください(#5095)。
1258-
C# の callable containment fixture では、block body の test method、local / nested local function、named lambda、expression-bodied member、nested type を同居させ、symbol の親と call reference の container の両方を検証してください。
1258+
C# の callable containment fixture では、block body の test method、local / nested local function、named lambda、expression-bodied member、nested type を同居させ、symbol の親と call reference の container の両方を検証してください。local function identity の coverage ではさらに、宣言前後の call、nested / sibling block、overload、parameter / local delegate shadowing、method group、無関係な型にある同名 enclosing member、不完全な range、永続 graph / query / inspect / impact の挙動、LSP definition/reference の一致を、1つの連携した契約として維持してください(#5188、#4840 を拡張)。
12591259
C# switch expression が返す lambda の coverage では、`ReferenceExtractorCSharpTests` の直接 regression と `IndexCommandRunnerFullScanTests` の `--rebuild` graph fixture を組み合わせます。expression / block、parenthesized、multiline、nested switch、async、qualified / unqualified、non-lambda の各 arm を同居させ、raw call row、enclosing container、正確な location、callers / callees、完全な graph readiness、次行に arrow がある guarded / nested / contextual-keyword-designation pattern を含む positional pattern / enum の負例を検証してください(#5085)。
12601260
repository metadata の coverage は `SymbolExtractorRepositoryMetadataTests.cs` と `ReferenceExtractorRepositoryMetadataTests.cs` に置きます。TOML、JSON Lines、ignore / attributes、EditorConfig、`.rules`、application manifest の capability assertion を、保守的な local-path 抽出と malformed-record control に同期させてください。
12611261
未対応言語を必要とする capability regression fixture には明示的な `text` placeholder または ambiguity bucket を使い、認識済み repository metadata 形式を未対応 control に使わないでください。
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 5188
5+
affected:
6+
- src/CodeIndex/Indexer/References/ReferenceExtractor.CSharpLocalFunctionScopes.cs
7+
- src/CodeIndex/Indexer/References/ReferenceExtractor.Patterns.cs
8+
- src/CodeIndex/Database/DbReader.References.cs
9+
- src/CodeIndex/Database/DbWriter.References.cs
10+
- src/CodeIndex/Lsp/LspServer.PositionResolution.cs
11+
- src/CodeIndex/Indexer/Symbols/SymbolExtractor.Contracts.cs
12+
- src/CodeIndex/Database/DbContext.SchemaMetadata.cs
13+
---
14+
15+
## English
16+
17+
- **C# local functions now resolve by lexical scope (#5188)** — Calls and method groups bind to the nearest visible local-function overload family across declaration order, nested blocks, top-level statement files, lambdas, and expression-bodied declarations. Parameter and local delegate values shadow local functions, sibling or unrelated enclosing scopes and files no longer create false candidates, and incomplete range evidence remains unresolved across graph queries and LSP reads. Existing C# indexes are refreshed through the updated extractor and reference-identity contracts.
18+
19+
## 日本語
20+
21+
- **C# の local function を字句スコープで解決するよう修正しました (#5188)** — call と method group は、宣言順、nested block、top-level statement file、lambda、expression-bodied 宣言を含め、最も近い可視 local function の overload family に結び付きます。parameter と local delegate value は local function を shadow し、兄弟または無関係な enclosing scope と file は誤った候補を生成せず、不完全な range evidence は graph query と LSP read の双方で未解決のままになります。既存の C# index は更新した extractor と reference-identity contract により再抽出されます。
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 5190
5+
affected:
6+
- src/CodeIndex/Cli/JsonEnvelopeWrapper.cs
7+
- src/CodeIndex/Cli/JsonEnvelopeWrapper.Bounded.cs
8+
- src/CodeIndex/Cli/ProgramRunner.OutputFormatValidation.cs
9+
- tests/CodeIndex.Tests/JsonEnvelopeWrapperIssue4585Tests.cs
10+
- tests/CodeIndex.Tests/ProgramRunnerTests.cs
11+
- DEVELOPER_GUIDE.md
12+
---
13+
14+
## English
15+
16+
- **Bounded field projection now preserves truthful response contracts (#5190)** — empty graph collections remain empty with zero counts, projection-incompatible explicit formats return a usage error, and `body` / `body_content` projections retain the range, truncation, omission, and recovery metadata needed to interpret or resume bounded content.
17+
18+
## 日本語
19+
20+
- **bounded field projection が正確な response 契約を維持するようになりました (#5190)** — 空の graph collection は count 0 の空配列として維持され、projection と互換性のない明示形式は usage error を返し、`body` / `body_content` projection は bounded content の解釈や再取得に必要な range、truncation、omission、recovery metadata を保持します。

0 commit comments

Comments
 (0)