Files
codegraph/__tests__
Colby MchenryandClaude Opus 5.5 efb091ec2f fix(liquid): editor-saved Shopify JSON and {% sections %} groups link their sections (#2812)
Shopify's theme editor writes a block comment ("IMPORTANT: The contents
of this file are auto-generated...") at the top of every JSON template
and section group it saves. The Liquid extractor read theme JSON with
JSON.parse, which rejects comments and trailing commas, so such a file
linked none of the sections it lists, and in an editor-saved theme most
sections looked unused. All 14 of Shopify/horizon's templates and
section groups carry the comment, so none of them linked. The links a
JSON file did produce all sat at line 1, column 0.

The same report found two more gaps. A layout's
{% sections 'header-group' %} tag, which renders the section group
sections/header-group.json, was never read. And a {% schema %} written
inside {% comment %} or {% raw %} was indexed as the section's own
schema, because only the tag scanner skipped those regions.

Fix:
- Read theme JSON with jsonc-parser's parseTree, which accepts
  comments, and allow trailing commas. Shopify's theme docs say theme
  JSON supports both, and Shopify's theme-check parses it with the same
  options. Any other parse error still links nothing.
- Put each section reference at its "type" value's line and column.
- Read the plural sections tag wherever the singular one is read:
  braced, whitespace-trimmed, or as a line of a {% liquid %} tag. It
  links to sections/<group>.json, and its component is named
  ::sections:<group>, apart from a section of the same name. The
  Shopify theme matcher already keeps any sections/ path inside the
  file's own theme, so a group resolves only there (its doc comment now
  says so).
- Compute the comment and raw regions once per file and share them
  between the tag scanner and the schema extractor. A schema inside one
  is skipped, and the search resumes after the region.

Validation:
- 10 new regression tests in __tests__/extraction.test.ts fail with
  main's extractor and pass with the fix. Re-run on 08478eea: 30 passed
  and 10 failed with main's extractor, 40 passed with the fix. 3
  strictness guards (a missing brace, an unclosed comment, a missing
  comma) pass on both.
- A/B on base 80c36800, each arm built from its own sources with the
  kernel: 8 theme repos (Shopify/dawn, Shopify/horizon,
  Shopify/skeleton-theme, ChumsInc/chums-impulse-dev,
  agencecinq/cinquante-et-un, noclocks/shopify-devstore-theme,
  panoply/syncify, Shopify/theme-tools) and 2 controls (express,
  requests). The controls and skeleton-theme are byte-identical, and no
  node or edge is removed anywhere. All 299 changed reference edges
  were checked against the source text: 299 right, 0 wrong. 197 are new
  links (horizon 25, chums-impulse-dev 138, cinquante-et-un 11,
  shopify-devstore-theme 16, dawn 2, syncify 2, theme-tools 3), 14 of
  them from sections tags, and 102 moved from 1:0 to their "type"
  value. 22 sections tags add 44 import and component nodes. The only
  new failed refs are a "multirow" section that cinquante-et-un's theme
  does not have, and 8 sections tags in theme-tools' prettier-plugin
  test fixtures that name a group no file provides.
- Cost: an extractor microbenchmark over 1,386 Liquid files (8 MB),
  median of 15 runs in 3 interleaved rounds, gave 436 ms on main and
  439 ms with the fix. Index wall time, median of 3 interleaved runs,
  main vs fix: horizon 2891 vs 3064 ms, chums-impulse-dev 2429 vs 2368,
  syncify 3846 vs 3810, theme-tools 6698 vs 6620. The byte-identical
  controls moved as much (express 2312 vs 2445, requests 1946 vs 2080),
  so that is noise on a shared machine.
- Rebased onto 08478eea, which adds only Pascal (PR #2810) and JS/TS
  resolution (PR #2811) changes. There the Liquid tests pass, and
  re-indexing the 8 theme repos gives graphs byte-identical to the
  pre-rebase fix arm, except for theme-tools' TypeScript calls, which
  PR #2811 changes.
- Kernel parity: not applicable, the kernel does not extract Liquid.

Fixes #2494

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:43:54 +00:00
..