Shopify / Shopify/rubydex

Expose the location range of a constant's assigned value

Open
#844 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
355
Forks
24
Avg merge
2d 6h
Merged PRs (30d)
17

Description

A constant definition's location spans only the constant's name, not its
assigned value. For a multi-line literal there is no way to know where the
value ends without re-reading and parsing the source.

VALUES = [
  "a",
  "b",
]

graph["VALUES"].definitions.first.location covers the VALUES token only;
the array value's location is unavailable.

Why it matters

A consumer that reads a constant's value from source (for example, to compare a
checked-in list against the graph and point diagnostics at entries) must
re-open the file and scan for the closing delimiter. That breaks across literal
forms ([ ... ], %w( ... ), %i[ ... ], { ... }, method calls) and
formatting, and every consumer reimplements it.

Proposed

Add a #value_location (a Location) on constant definitions that covers the
assigned value. For VALUES above it would span lines 1 through 4.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how constant definitions expose location and how Location spans are constructed; no source file or test is named in the issue. Add coverage for the multiline VALUES literal and verify that the assigned value's location reaches its closing delimiter.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, rust
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.