Follow-up from #297 and PR #300.
Problem
#297 added related "first declared here" locations to duplicate_route and
route_method_conflict (including contract-route conflicts). The diagnostic
contract now supports Related []source.RelatedSpan, but the rest of the
duplicate/conflict diagnostics still point at only the second occurrence and
leave the first declaration unlinked.
Relevant code (each builds a ValidationError without Related):
internal/compiler/validate_identity.go: duplicate_page_id,
duplicate_layout_id, duplicate_component_name, duplicate_component_emit
internal/compiler/validate_page.go: duplicate_revalidate_policy,
duplicate_page_store, duplicate_css_selection
internal/compiler/validate_source_uses.go: duplicate_gowdk_use_alias
internal/compiler/validate_component_contracts.go: duplicate_go_import_alias
internal/compiler/routes.go: duplicate_route_param
- Go endpoint comment duplicates:
duplicate_go_endpoint_comment
Scope
Thread the first-declaration span into the remaining duplicate/conflict
diagnostics using the existing relatedSpan helper (or an equivalent), so each
reports the primary span plus a related location. Where the first span is
genuinely unavailable, leave Related nil rather than fabricate a location.
Acceptance Criteria
- Each listed duplicate/conflict diagnostic carries a related location pointing
at the first declaration when its span is known.
check --json related array and LSP relatedInformation populate for them.
- Tests cover at least the id, store, use-alias, and route-param duplicates with
two locations.
Verification
go test ./internal/compiler ./internal/lang
Follow-up from #297 and PR #300.
Problem
#297 added related "first declared here" locations to
duplicate_routeandroute_method_conflict(including contract-route conflicts). The diagnosticcontract now supports
Related []source.RelatedSpan, but the rest of theduplicate/conflict diagnostics still point at only the second occurrence and
leave the first declaration unlinked.
Relevant code (each builds a
ValidationErrorwithoutRelated):internal/compiler/validate_identity.go:duplicate_page_id,duplicate_layout_id,duplicate_component_name,duplicate_component_emitinternal/compiler/validate_page.go:duplicate_revalidate_policy,duplicate_page_store,duplicate_css_selectioninternal/compiler/validate_source_uses.go:duplicate_gowdk_use_aliasinternal/compiler/validate_component_contracts.go:duplicate_go_import_aliasinternal/compiler/routes.go:duplicate_route_paramduplicate_go_endpoint_commentScope
Thread the first-declaration span into the remaining duplicate/conflict
diagnostics using the existing
relatedSpanhelper (or an equivalent), so eachreports the primary span plus a related location. Where the first span is
genuinely unavailable, leave
Relatednil rather than fabricate a location.Acceptance Criteria
at the first declaration when its span is known.
check --jsonrelatedarray and LSPrelatedInformationpopulate for them.two locations.
Verification
go test ./internal/compiler ./internal/lang