diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index f987ad278b..1d507ce287 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -17,3 +17,4 @@ - Globs: An edge case was fixed where globs used in edges were creating nodes when it shouldn't have [#2051](https://github.com/terrastruct/d2/pull/2051) - Render: Multi-line class labels/headers are rendered correctly [#2057](https://github.com/terrastruct/d2/pull/2057) - CLI: Watch mode uses correct backlinks (`_` usages) [#2058](https://github.com/terrastruct/d2/pull/2058) +- Vars: Spread variables are inserted in place instead of appending to end of scope [#TODO](https://github.com/terrastruct/d2/pull/TODO) diff --git a/d2ir/compile.go b/d2ir/compile.go index a0e63b261f..20af53d62c 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -261,11 +261,11 @@ func (c *compiler) resolveSubstitutions(varsStack []*Map, node Node) (removedFie } } case *Field: + m := ParentMap(n) if resolvedField.Map() != nil { - OverlayMap(ParentMap(n), resolvedField.Map()) + ExpandSubstitution(m, resolvedField.Map(), n) } // Remove the placeholder field - m := n.parent.(*Map) for i, f2 := range m.Fields { if n == f2 { m.Fields = append(m.Fields[:i], m.Fields[i+1:]...) diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index aa0f8f56d8..e65a03ae2a 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -28,6 +28,7 @@ func TestCompile(t *testing.T) { t.Run("imports", testCompileImports) t.Run("patterns", testCompilePatterns) t.Run("filters", testCompileFilters) + t.Run("vars", testCompileVars) } type testCase struct { @@ -698,3 +699,32 @@ layers: { } runa(t, tca) } + +func testCompileVars(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "spread-in-place", + run: func(t testing.TB) { + m, err := compile(t, `vars: { + person-shape: { + grid-columns: 1 + grid-rows: 2 + grid-gap: 0 + head + body + } +} + +dora: { + ...${person-shape} + body +} +`) + assert.Success(t, err) + assert.Equal(t, "grid-columns", m.Fields[1].Map().Fields[0].Name) + }, + }, + } + runa(t, tca) +} diff --git a/d2ir/merge.go b/d2ir/merge.go index e93ba9e2d5..7cd52d62f0 100644 --- a/d2ir/merge.go +++ b/d2ir/merge.go @@ -21,6 +21,39 @@ func OverlayMap(base, overlay *Map) { } } +func ExpandSubstitution(m, resolved *Map, placeholder *Field) { + fi := -1 + for i := 0; i < len(m.Fields); i++ { + if m.Fields[i] == placeholder { + fi = i + break + } + } + + for _, of := range resolved.Fields { + bf := m.GetField(of.Name) + if bf == nil { + m.Fields = append(append(m.Fields[:fi], of.Copy(m).(*Field)), m.Fields[fi:]...) + fi++ + continue + } + OverlayField(bf, of) + } + + // NOTE this doesn't expand edges in place, and just appends + // I suppose to do this, there needs to be an edge placeholder too on top of the field placeholder + // Will wait to see if a problem + for _, oe := range resolved.Edges { + bea := m.GetEdges(oe.ID, nil, nil) + if len(bea) == 0 { + m.Edges = append(m.Edges, oe.Copy(m).(*Edge)) + continue + } + be := bea[0] + OverlayEdge(be, oe) + } +} + func OverlayField(bf, of *Field) { if of.Primary_ != nil { bf.Primary_ = of.Primary_.Copy(bf).(*Scalar) diff --git a/testdata/d2ir/TestCompile/vars/spread-in-place.exp.json b/testdata/d2ir/TestCompile/vars/spread-in-place.exp.json new file mode 100644 index 0000000000..408ac597fe --- /dev/null +++ b/testdata/d2ir/TestCompile/vars/spread-in-place.exp.json @@ -0,0 +1,1318 @@ +{ + "fields": [ + { + "name": "vars", + "composite": { + "fields": [ + { + "name": "person-shape", + "composite": { + "fields": [ + { + "name": "grid-columns", + "primary": { + "value": { + "range": "TestCompile/vars/spread-in-place.d2,2:18:44-2:19:45", + "raw": "1", + "value": "1" + } + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:19:45", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,2:18:44-2:19:45", + "raw": "1", + "value": "1" + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "grid-rows", + "primary": { + "value": { + "range": "TestCompile/vars/spread-in-place.d2,3:15:61-3:16:62", + "raw": "2", + "value": "2" + } + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:16:62", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,3:15:61-3:16:62", + "raw": "2", + "value": "2" + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "grid-gap", + "primary": { + "value": { + "range": "TestCompile/vars/spread-in-place.d2,4:14:77-4:15:78", + "raw": "0", + "value": "0" + } + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:15:78", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,4:14:77-4:15:78", + "raw": "0", + "value": "0" + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "head", + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "body", + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-1:14:22", + "value": [ + { + "string": "person-shape", + "raw_string": "person-shape" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-1:14:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-1:14:22", + "value": [ + { + "string": "person-shape", + "raw_string": "person-shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-7:3:100", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-1:14:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-1:14:22", + "value": [ + { + "string": "person-shape", + "raw_string": "person-shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/vars/spread-in-place.d2,1:16:24-7:3:100", + "nodes": [ + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:19:45", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,2:18:44-2:19:45", + "raw": "1", + "value": "1" + } + } + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:16:62", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,3:15:61-3:16:62", + "raw": "2", + "value": "2" + } + } + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:15:78", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,4:14:77-4:15:78", + "raw": "0", + "value": "0" + } + } + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,0:0:0-0:4:4", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,0:0:0-0:4:4", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,0:0:0-8:1:102", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,0:0:0-0:4:4", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/vars/spread-in-place.d2,0:6:6-8:1:102", + "nodes": [ + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-7:3:100", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-1:14:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,1:2:10-1:14:22", + "value": [ + { + "string": "person-shape", + "raw_string": "person-shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/vars/spread-in-place.d2,1:16:24-7:3:100", + "nodes": [ + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:19:45", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,2:18:44-2:19:45", + "raw": "1", + "value": "1" + } + } + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:16:62", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,3:15:61-3:16:62", + "raw": "2", + "value": "2" + } + } + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:15:78", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,4:14:77-4:15:78", + "raw": "0", + "value": "0" + } + } + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "dora", + "composite": { + "fields": [ + { + "name": "body", + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,6:4:92-6:8:96", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "grid-columns", + "primary": { + "value": { + "range": "TestCompile/vars/spread-in-place.d2,2:18:44-2:19:45", + "raw": "1", + "value": "1" + } + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:19:45", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,2:4:30-2:16:42", + "value": [ + { + "string": "grid-columns", + "raw_string": "grid-columns" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,2:18:44-2:19:45", + "raw": "1", + "value": "1" + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "grid-rows", + "primary": { + "value": { + "range": "TestCompile/vars/spread-in-place.d2,3:15:61-3:16:62", + "raw": "2", + "value": "2" + } + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:16:62", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,3:4:50-3:13:59", + "value": [ + { + "string": "grid-rows", + "raw_string": "grid-rows" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,3:15:61-3:16:62", + "raw": "2", + "value": "2" + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "grid-gap", + "primary": { + "value": { + "range": "TestCompile/vars/spread-in-place.d2,4:14:77-4:15:78", + "raw": "0", + "value": "0" + } + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:15:78", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,4:4:67-4:12:75", + "value": [ + { + "string": "grid-gap", + "raw_string": "grid-gap" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "TestCompile/vars/spread-in-place.d2,4:14:77-4:15:78", + "raw": "0", + "value": "0" + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "head", + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + }, + { + "name": "head", + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,5:4:83-5:8:87", + "value": [ + { + "string": "head", + "raw_string": "head" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/vars/spread-in-place.d2,10:0:104-10:4:108", + "value": [ + { + "string": "dora", + "raw_string": "dora" + } + ] + }, + "key_path": { + "range": "TestCompile/vars/spread-in-place.d2,10:0:104-10:4:108", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,10:0:104-10:4:108", + "value": [ + { + "string": "dora", + "raw_string": "dora" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/vars/spread-in-place.d2,10:0:104-13:1:141", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,10:0:104-10:4:108", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,10:0:104-10:4:108", + "value": [ + { + "string": "dora", + "raw_string": "dora" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/vars/spread-in-place.d2,10:6:110-13:1:141", + "nodes": [ + { + "map_key": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "key": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,11:2:114-11:6:118", + "value": [ + { + "string": "body", + "raw_string": "body" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "substitution": { + "range": "TestCompile/vars/spread-in-place.d2,12:2:121-12:20:139", + "spread": true, + "path": [ + { + "unquoted_string": { + "range": "TestCompile/vars/spread-in-place.d2,12:7:126-12:19:138", + "value": [ + { + "string": "person-shape", + "raw_string": "person-shape" + } + ] + } + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + } + ] + } + ], + "edges": null +}