Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,11 @@ Use `docs/test-doc-maintenance-plan.md` before moving oversized suites or adding
keeps C# LINQ range-member, parenthesized group-by, awaited keyword-local, nullable suffix, ternary, and keyword-local boundaries beside a Visual Basic query-syntax call in one multi-language workspace with one CLI index. Keep unique per-file sentinels and language-specific queries so zero-reference negatives and positive context, kind, container, and line contracts remain independently diagnostic.
- `QueryCommandRunnerTests.CSharpTypeReferences_ResolveOnlyToTypeLikeSymbolsWithMatchingArity_Issue4825`
indexes one real C# fixture containing user-defined generic classes and delegates, block-comment generic trivia, repeated same-line generic names under indentation, unrelated same-name properties, ordinal-case type/property collisions, `Action<T>` / `Stream` references, and uppercase property receivers split across partial-class and inherited-base files. Keep CLI `references`, `inspect`, and `deps` assertions together with the MCP `references`, `analyze_symbol`, and `deps` wrappers so unresolved diagnostics, generic-arity selection, case-sensitive receiver handling, false dependency-edge suppression, and preservation of real member dependencies cannot drift across surfaces.
- `QueryCommandRunnerTests.ConstructorCommands_KeepCallableAndPartialTypeResultsSeparate_Issue4850`
keeps explicit constructors split across partial declarations in one fixture. Preserve the separate `definition` / `goto --kind function` assertions and the grouped `--kind class --group-partials` assertion so callable constructor results cannot merge back into logical type-family results.
- `LspServerTests.cs`
LSP JSON-RPC behavior and indexed editor semantics. Reference parity coverage must compare LSP locations with the matching CLI candidate bundle, including overload identity and both `includeDeclaration` states. Keep document/workspace identifier ranges and explicit-versus-inferred inlay hints in one source-semantics fixture so persisted-column anchoring, source confirmation, and hint suppression cannot drift independently.
Constructor-navigation coverage keeps explicit zero- and one-argument constructors in separate partial files, including a caller beside the zero-argument declaration, plus an implicit partial constructor, a positional record, and an ordinary partial-type reference in one fixture. The adversarial fixtures add static constructors, finalizers, primary-plus-secondary constructors, coexisting generic arities, same-arity overloads, value-type default construction beside explicit constructors, enums, and delegates. Assert both definition and declaration requests so source-site identity, invocation-arity filtering, stable implicit representatives, constructor-only ambiguity, preserved non-class construction, and intentional type-family expansion remain separate.
Document-symbol hierarchy coverage keeps positional and body record members in one same-line fixture, asserts the complete root-to-member shape and deterministic sibling order, and retains the separate same-range top-level controls so order-independent parent resolution cannot over-nest unrelated symbols. Keep a same-line duplicate-container fixture with distinct positional members so selection-column disambiguation cannot move an earlier member beneath a later same-named container.
Symbol-progress coverage crosses the production chunk item limit with one sentinel, verifies the complete deterministic sequence across partial-result frames, and keeps live work-done delivery, truncation, typed request-ID cancellation, full-queue cancellation, queue-pressure notification preservation, backpressured `Server busy` response retention, emitted-count cancellation reporting, output-failure propagation, and invalid-token variants in the same protocol fixture. Assert both the item and UTF-8 JSON body budgets for every emitted chunk.
The server-busy backpressure cancellation fixture must stage the cancel frame until both the active symbol request and blocked response write have been observed. Block the request on its cancellation token instead of matching fixed delays so suite load cannot convert the expected cancellation into a successful response.
Expand Down Expand Up @@ -1413,8 +1416,11 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"
は C# LINQ の range-member、parenthesized group-by、awaited keyword-local、nullable suffix、ternary、keyword-local boundary と Visual Basic query syntax 内の call を、CLI index 1回の multi-language workspace で共有します。file ごとの固有 sentinel と言語別 query を使い、zero-reference negative と positive の context、kind、container、line 契約の診断性を独立に保ってください。
- `QueryCommandRunnerTests.CSharpTypeReferences_ResolveOnlyToTypeLikeSymbolsWithMatchingArity_Issue4825`
は user-defined generic class / delegate、generic 間の block comment trivia、indent 下で同一行に反復する同名 generic、無関係な同名 property、大文字小文字だけ異なる type / property collision、`Action<T>` / `Stream` reference、partial class の別ファイルおよび継承 base file に分かれた大文字始まりの property receiver を含む実 C# fixture を1回 index します。CLI の `references`、`inspect`、`deps` と MCP wrapper の `references`、`analyze_symbol`、`deps` を同じ fixture で検証し、unresolved 診断、generic arity による選択、case-sensitive receiver 判定、偽 dependency edge の抑制、実在する member dependency の維持が surface 間でずれないよう維持してください。
- `QueryCommandRunnerTests.ConstructorCommands_KeepCallableAndPartialTypeResultsSeparate_Issue4850`
は partial declaration の別ファイルに分かれた明示 constructor を 1 つの fixture にまとめます。callable constructor result が logical type-family result に再び混在しないよう、`definition` / `goto --kind function` の検証と、`--kind class --group-partials` による grouped type の検証を分離したまま維持してください。
- `LspServerTests.cs`
LSP の JSON-RPC 挙動と indexed editor semantics のテスト。reference parity coverage では、overload identity と `includeDeclaration` の両状態を含め、LSP location と対応する CLI candidate bundle を比較してください。document/workspace の identifier range と explicit/inferred inlay hint は 1 つの source-semantics fixture にまとめ、保存済み column の anchoring、source 上の確認、hint 抑制が別々に drift しないようにします。
constructor-navigation coverage は、0 引数と 1 引数の明示 constructor を別々の partial file に置き、0 引数 declaration と同じ file の caller、暗黙 partial constructor、positional record、通常の partial-type reference と同じ fixture にまとめます。adversarial fixture には static constructor、finalizer、primary / secondary constructor の併存、同名 type の generic arity 違い、同一 arity overload、明示 constructor と併存する value type の default construction、enum、delegate も含めます。source-site identity、invocation-arity filtering、暗黙 constructor の安定した代表 declaration、constructor だけの ambiguity、class 以外の construction の維持、意図的な type-family expansion が混在しないよう、definition と declaration の両 request を assert してください。
document-symbol hierarchy coverage は positional member と body member を同一行の record fixture にまとめ、root から member までの完全な形状と決定的な sibling 順序を assert します。順序非依存の親解決が無関係な symbol を過剰に nest しないよう、same-range top-level の control は独立したまま維持してください。selection column による曖昧性解消で前の member が行内で後にある同名 container の配下へ移動しないよう、異なる positional member を持つ同一行の duplicate-container fixture も維持してください。
symbol-progress coverage は production の chunk item limit を sentinel 1 件だけで超え、partial-result frame 全体の決定的な完全 sequence を検証します。live work-done delivery、truncation、型付き request ID の cancellation、full-queue cancellation、queue pressure 下の notification 保持、backpressure された `Server busy` response の保持、cancellation 時の送信済み件数、output-failure propagation、invalid-token variant は同じ protocol fixture にまとめ、送信した全 chunk の item 上限と UTF-8 JSON body budget の両方を assert してください。
server-busy backpressure cancellation fixture では、active symbol request と block された response write の両方を観測するまで cancel frame を stage してください。固定 delay の一致に依存せず cancellation token 上で request を block することで、suite load により期待する cancellation が成功 response に変わる競合を防ぎます。
Expand Down
33 changes: 33 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,23 @@ but do not speak MCP. It also advertises full `textDocument` sync and
conservative `hover`, `completion`, `documentHighlight`, `semanticTokens/full`,
`codeLens`, and `inlayHint` providers backed by indexed symbols and references
where available.
C# constructor navigation is source-position-aware. For `new Type(...)`,
`textDocument/definition` and `textDocument/declaration` use the exact indexed
reference site and invocation arity to select only matching explicit constructor
symbols. When no explicit constructor is indexed, including implicit constructors
on partial classes and positional records, they return one stable representative
type declaration. This is separate from ordinary type-reference navigation, which
may intentionally return every declaration in one logical partial-type family.
Static constructors and finalizers are never treated as `new` targets. Primary
constructor declarations remain eligible beside secondary constructors, generic
type arity scopes constructor identity, and same-arity overloads remain constructor
locations instead of falling back to same-named type declarations. Default
construction of value types remains attached to the type declaration even when
other explicit constructors exist, and enum and delegate construction remain
navigable.
CLI `definition` and `goto` are name-based; use `--kind function` for explicit
constructors, or a type kind together with `--group-partials` for the logical type
family.
Clients must follow the standard LSP lifecycle: send one `initialize` request
first, optionally send the `initialized` notification after its response, then
send ordinary requests, finish with one `shutdown` request, and finally send the
Expand Down Expand Up @@ -5836,6 +5853,22 @@ MCP stdio は line protocol です。LF 区切りの各行に compact な UTF-8
indexed symbols / references で答えられる範囲に限定した `hover`、`completion`、
`documentHighlight`、`semanticTokens/full`、`codeLens`、`inlayHint` provider を
advertise します。
C# の constructor navigation は source position を考慮します。`new Type(...)` に
対する `textDocument/definition` と `textDocument/declaration` は、index 済みの
正確な reference site と invocation arity を使い、一致する明示 constructor symbol
だけを選択します。partial class の暗黙 constructor や positional record のように
明示 constructor が index されていない場合は、安定した代表 type declaration を
1 件返します。この経路は通常の type-reference navigation と分離されており、後者は
1 つの logical partial-type family に属する全 declaration を意図的に返す場合があります。
static constructor と finalizer は `new` の target として扱いません。primary constructor
declaration は secondary constructor と併存しても候補に残り、generic type arity で
constructor identity を限定します。同一 arity の overload も同名 type declaration へ
fallback せず、constructor location の集合として返します。他の明示 constructor が
存在する場合も value type の default construction は type declaration に結び付けたままにし、
enum と delegate の construction も navigation 可能な状態を保ちます。
CLI の `definition` と `goto` は名前ベースなので、明示 constructor には
`--kind function`、logical type family には type kind と `--group-partials` を
組み合わせてください。
client は標準の LSP lifecycle に従う必要があります。最初に `initialize` request を 1 回だけ
送り、その response 後に必要なら `initialized` notification を送り、通常 request を処理した後、
`shutdown` request、最後に `exit` notification の順で終了してください。初期化完了前に受信した
Expand Down
26 changes: 26 additions & 0 deletions changelog.d/unreleased/4850.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
category: fixed
issues:
- 4850
affected:
- src/CodeIndex/Database/DbContext.ConnectionFunctions.cs
- src/CodeIndex/Database/DbContext.SchemaMetadata.cs
- src/CodeIndex/Database/DbReader.References.cs
- src/CodeIndex/Database/DbWriter.References.cs
- src/CodeIndex/Indexer/CSharpTypeReferenceArity.cs
- src/CodeIndex/Lsp/LspServer.PositionResolution.cs
- tests/CodeIndex.Tests/CSharpConstructorParameterCountIssue4850Tests.cs
- tests/CodeIndex.Tests/IndexCommandRunnerUpdateTests.cs
- tests/CodeIndex.Tests/LspServerTests.cs
- tests/CodeIndex.Tests/QueryCommandRunnerSymbolTests.cs
- USER_GUIDE.md
- TESTING_GUIDE.md
---

## English

- **Constructor navigation now stays separate from partial-type families (#4850)** — As a follow-up to #4566, C# `instantiate` references now resolve by exact source site, callable constructor identity, generic type arity, and invocation arity instead of mixing same-named type declarations into the candidate set. Explicit and primary overloads navigate only to matching constructor targets, static constructors and finalizers are excluded, and implicit partial constructors use one deterministic type representative. Value-type default construction remains attached to its type declaration even beside other explicit constructors, and enum and delegate construction remain navigable. Same-arity overloads remain constructor locations, while ordinary type references may still expose every declaration in the logical partial family. Existing indexes rebuild the affected candidate contract automatically.

## 日本語

- **constructor navigation と partial-type family を分離しました (#4850)** — #4566 の follow-up として、C# の `instantiate` reference は同名の type declaration を candidate set に混在させず、正確な source site、callable constructor identity、generic type arity、invocation arity で解決するようになりました。明示 / primary overload は一致する constructor target だけへ移動し、static constructor と finalizer を除外し、暗黙 partial constructor は決定的な代表 type を使います。他の明示 constructor と併存する場合も value type の default construction は type declaration に結び付き、enum と delegate の construction も navigation 可能です。同一 arity overload は constructor location のまま返し、通常の type reference は引き続き logical partial family の全 declaration を公開できます。既存 index では対象 candidate contract を自動再構築します。
12 changes: 12 additions & 0 deletions src/CodeIndex/Database/DbContext.ConnectionFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ internal static void RegisterConnectionFunctions(SqliteConnection connection)
"csharp_definition_type_arity",
(string? signature, string? identifier, string? symbolKind) =>
CSharpTypeReferenceArity.GetDefinitionArity(signature, identifier, symbolKind));
connection.CreateFunction(
"csharp_constructor_parameter_count",
(string? signature, string? identifier, string? symbolKind) =>
CSharpTypeReferenceArity.GetConstructorParameterCount(signature, identifier, symbolKind));
connection.CreateFunction(
"csharp_invocation_argument_count",
(string? context, string? identifier, long? columnNumber) =>
CSharpTypeReferenceArity.GetInvocationArgumentCount(context, identifier, columnNumber));
connection.CreateFunction(
"csharp_definition_is_value_type",
(string? signature, string? symbolKind) =>
CSharpTypeReferenceArity.IsValueTypeDeclaration(signature, symbolKind));
connection.CreateFunction(
"csharp_base_identifiers_json",
(string? signature) =>
Expand Down
16 changes: 7 additions & 9 deletions src/CodeIndex/Database/DbContext.SchemaMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ public static string BuildIncompleteHotspotFamilyMarkerFingerprint(string? finge
public const string SqlGraphContractVersionMetaKey = "sql_graph_contract_version";
public const int HdlGraphContractVersion = 1;
public const string HdlGraphContractVersionMetaKey = "hdl_graph_contract_version";
// Version 5 (#4846) invalidates name-only Markdown candidates written before
// fragment resolution became document/path-scoped. Version 4 (#4845) previously
// invalidated dependency-lock candidates written before resolution became file-local,
// and version 3 (#4825) constrained C# type-reference candidates by kind and arity.
// バージョン 5 (#4846) では、Markdown fragment の解決を document/path 内に限定する
// 前に書かれた name-only candidate を無効化する。バージョン 4 (#4845) では、それ以前の
// dependency-lock candidate を file 内に限定し、バージョン 3 (#4825) では C# 型参照を
// kind と arity で制約した。
public const int ReferenceIdentityContractVersion = 5;
// Version 6 (#4850) invalidates C# instantiate candidates written before constructor
// callables and logical partial-type families had separate identities. Version 5
// (#4846) previously made Markdown fragment resolution document/path-scoped.
// バージョン 6 (#4850) では、constructor callable と logical partial type family の
// identity 分離前に書かれた C# instantiate candidate を無効化する。バージョン 5
// (#4846) では Markdown fragment 解決を document/path 内に限定した。
public const int ReferenceIdentityContractVersion = 6;
public const string ReferenceIdentityContractVersionMetaKey = "reference_identity_contract_version";
public static string GetDynamicReferenceGraphContractVersionMetaKey(string lang) =>
$"dynamic_reference_graph_contract_version_{lang}";
Expand Down
Loading
Loading