Skip to content

Parser: record a SourceRange per binding (not just per element) #64

Description

@hugithordarson

What

PBasicNode carries a SourceRange for the whole element, but individual bindings do not. PBasicNode.bindings() is a Map<String, NGBindingValue> (name → value), and NGBindingValue has no source position — so there's no way to know where in the template a given binding attribute sits.

Why

A consumer that wants to map a binding back to its exact location in the template source can currently only reveal the whole element. Concretely: Parsley's render heat map now attributes DB queries to the binding that triggered them (e.g. object="$x.y.z" · 240q), and we'd like clicking that binding to reveal the exact attribute in the editor. Today the best we can do is open the element's span.

More generally, per-binding positions would enable precise editor navigation, per-binding error underlining, and tooling that operates at attribute granularity.

Sketch

  • Add a SourceRange to each binding — either by making NGBindingValue carry one, or by changing bindings() to a structure that pairs each name → (value, sourceRange).
  • Populate it in the declaration parser where each binding is read.
  • Downstream (e.g. Parsley) can then thread the binding range through to reveal the exact attribute.

Priority

Nice-to-have — logging it now to track. Not urgent; the immediate heat-map feature (knowing which binding) already works without it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions