Skip to content

[Compiler] Extend related spans to remaining duplicate/conflict diagnostics #302

@cssbruno

Description

@cssbruno

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerCompiler internals, pipeline, and generated metadatadiagnosticsDiagnostic codes, spans, and messages

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions