Skip to content

Model: add nameSpans and bodySpan to Node for bidirectional navigation #20

Closed

Description

@melonamin

Split out from #17.

Problem

Node.span is a single source location (crates/flowscope-core/src/types/response.rs:121-170). Graph↔text navigation needs every occurrence of a name in SQL, plus (for CTEs) the separate span of the CTE body.

Proposal

  • Add nameSpans: Vec<Span> to Node — byte ranges of every occurrence of the node's name in the original SQL.
  • Add bodySpan: Option<Span> — only populated for NodeType::Cte (the parenthesized subquery body after AS).
  • Populate in analyzer/transform.rs during graph construction; keep span as the primary/declaration location.
  • Mirror in packages/core/src/types.ts.

Acceptance

  • Tests in crates/flowscope-core/tests/lineage_engine.rs assert name-occurrence counts for table, CTE, and column nodes across representative fixtures.
  • For WITH a AS (SELECT …) SELECT a.x FROM a the CTE node reports 3 nameSpans and 1 bodySpan.

Prerequisite for the graph↔text navigation issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions