From db83fb8d1ae648fe9c488f27828cfc62adc844c9 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 4 Nov 2024 14:58:06 -0800 Subject: [PATCH] fix double globs in multiple scenarios --- ci/release/changelogs/next.md | 1 + d2ast/d2ast.go | 15 + d2compiler/compile_test.go | 34 + d2ir/compile.go | 4 +- d2ir/d2ir.go | 8 +- .../boards/style-nested-boards.exp.json | 1260 +++++++++++++++++ .../patterns/alixander-review/5.exp.json | 468 ------ .../patterns/double-glob/defaults.exp.json | 315 ++++- 8 files changed, 1568 insertions(+), 537 deletions(-) create mode 100644 testdata/d2compiler/TestCompile2/boards/style-nested-boards.exp.json diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 725b1a1007..74c24db4b3 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -14,3 +14,4 @@ - Render: fixes edge case of a 3d shape with outside label being cut off [#2132](https://github.com/terrastruct/d2/pull/2132) - Composition: labels for boards set with shorthand `x: y` was not applied [#2182](https://github.com/terrastruct/d2/pull/2182) +- Globs: double globs (`**`) were erroring when used with multiple scenario boards [#2195](https://github.com/terrastruct/d2/pull/2195) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 711316b41a..445625d75d 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -1006,6 +1006,21 @@ func (mk *Key) HasTripleGlob() bool { return false } +func (mk *Key) HasMultiGlob() bool { + if mk.Key.HasMultiGlob() { + return true + } + for _, e := range mk.Edges { + if e.Src.HasMultiGlob() || e.Dst.HasMultiGlob() { + return true + } + } + if mk.EdgeKey.HasMultiGlob() { + return true + } + return false +} + func (mk *Key) SupportsGlobFilters() bool { if mk.Key.HasGlob() && len(mk.Edges) == 0 { return true diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 97a2c5f424..631a409f6a 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -3576,6 +3576,40 @@ steps: { `, `d2/testdata/d2compiler/TestCompile2/boards/errs/duplicate_board.d2:9:2: board name one already used by another board`) }, }, + { + name: "style-nested-boards", + run: func(t *testing.T) { + g, _ := assertCompile(t, `**.style.stroke: black + +scenarios: { + a: { + x + } + b: { + x + } +} +steps: { + c: { + x + } + d: { + x + } +} +layers: { + e: { + x + } +} +`, ``) + assert.Equal(t, "black", g.Scenarios[0].Objects[0].Style.Stroke.Value) + assert.Equal(t, "black", g.Scenarios[1].Objects[0].Style.Stroke.Value) + assert.Equal(t, "black", g.Steps[0].Objects[0].Style.Stroke.Value) + assert.Equal(t, "black", g.Steps[1].Objects[0].Style.Stroke.Value) + assert.Equal(t, (*d2graph.Scalar)(nil), g.Layers[0].Objects[0].Style.Stroke) + }, + }, } for _, tc := range tca { diff --git a/d2ir/compile.go b/d2ir/compile.go index a85f9ddb28..b7e4778093 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -456,7 +456,7 @@ func (c *compiler) ampersandFilterMap(dst *Map, ast, scopeAST *d2ast.Map) bool { return false } var ks string - if gctx.refctx.Key.HasTripleGlob() { + if gctx.refctx.Key.HasMultiGlob() { ks = d2format.Format(d2ast.MakeKeyPath(IDA(dst))) } else { ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(dst))) @@ -488,7 +488,7 @@ func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) { // We don't want globs applied in a given scenario to affect future boards // Copying the applied fields and edges keeps the applications scoped to this board // Note that this is different from steps, where applications carry over - if !g.refctx.Key.HasTripleGlob() { + if !g.refctx.Key.HasMultiGlob() { // Triple globs already apply independently to each board g2.copyApplied(g) } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 823d77e8a4..ae7d35147c 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -784,7 +784,7 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext, create b filter := func(f *Field, passthrough bool) bool { if gctx != nil { var ks string - if refctx.Key.HasTripleGlob() { + if refctx.Key.HasMultiGlob() { ks = d2format.Format(d2ast.MakeKeyPath(IDA(f))) } else { ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(f))) @@ -937,7 +937,7 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext, create b } for _, grefctx := range c.globRefContextStack { var ks string - if grefctx.Key.HasTripleGlob() { + if grefctx.Key.HasMultiGlob() { ks = d2format.Format(d2ast.MakeKeyPath(IDA(f))) } else { ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(f))) @@ -1134,7 +1134,7 @@ func (m *Map) getEdges(eid *EdgeID, refctx *RefContext, gctx *globContext, ea *[ for _, e := range ea2 { if gctx != nil { var ks string - if refctx.Key.HasTripleGlob() { + if refctx.Key.HasMultiGlob() { ks = d2format.Format(d2ast.MakeKeyPath(IDA(e))) } else { ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(e))) @@ -1352,7 +1352,7 @@ func (m *Map) createEdge2(eid *EdgeID, refctx *RefContext, gctx *globContext, c e2 := e.Copy(e.Parent()).(*Edge) e2.ID = e2.ID.Copy() e2.ID.Index = nil - if refctx.Key.HasTripleGlob() { + if refctx.Key.HasMultiGlob() { ks = d2format.Format(d2ast.MakeKeyPath(IDA(e2))) } else { ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(e2))) diff --git a/testdata/d2compiler/TestCompile2/boards/style-nested-boards.exp.json b/testdata/d2compiler/TestCompile2/boards/style-nested-boards.exp.json new file mode 100644 index 0000000000..817cad6cff --- /dev/null +++ b/testdata/d2compiler/TestCompile2/boards/style-nested-boards.exp.json @@ -0,0 +1,1260 @@ +{ + "graph": { + "name": "", + "isFolderOnly": true, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:0:0-23:0:147", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:0:0-0:22:22", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:0:0-0:15:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:0:0-0:2:2", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:3:3-0:8:8", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:9:9-0:15:15", + "value": [ + { + "string": "stroke", + "raw_string": "stroke" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:17:17-0:22:22", + "value": [ + { + "string": "black", + "raw_string": "black" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,2:0:24-9:1:72", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,2:0:24-2:9:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,2:0:24-2:9:33", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,2:11:35-9:1:72", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,3:2:39-5:3:53", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,3:2:39-3:3:40", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,3:2:39-3:3:40", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,3:5:42-5:3:53", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,4:4:48-4:5:49", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,4:4:48-4:5:49", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,4:4:48-4:5:49", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,6:2:56-8:3:70", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,6:2:56-6:3:57", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,6:2:56-6:3:57", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,6:5:59-8:3:70", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,7:4:65-7:5:66", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,7:4:65-7:5:66", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,7:4:65-7:5:66", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,10:0:73-17:1:117", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,10:0:73-10:5:78", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,10:0:73-10:5:78", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,10:7:80-17:1:117", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,11:2:84-13:3:98", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,11:2:84-11:3:85", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,11:2:84-11:3:85", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,11:5:87-13:3:98", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,12:4:93-12:5:94", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,12:4:93-12:5:94", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,12:4:93-12:5:94", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,14:2:101-16:3:115", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,14:2:101-14:3:102", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,14:2:101-14:3:102", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,14:5:104-16:3:115", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,15:4:110-15:5:111", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,15:4:110-15:5:111", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,15:4:110-15:5:111", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,18:0:118-22:1:146", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,18:0:118-18:6:124", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,18:0:118-18:6:124", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,18:8:126-22:1:146", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,19:2:130-21:3:144", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,19:2:130-19:3:131", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,19:2:130-19:3:131", + "value": [ + { + "string": "e", + "raw_string": "e" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,19:5:133-21:3:144", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,20:4:139-20:5:140", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,20:4:139-20:5:140", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,20:4:139-20:5:140", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": null, + "layers": [ + { + "name": "e", + "isFolderOnly": false, + "ast": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,20:4:139-20:5:140", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,20:4:139-20:5:140", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ], + "scenarios": [ + { + "name": "a", + "isFolderOnly": false, + "ast": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "stroke" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:17:17-0:22:22", + "value": [ + { + "string": "black", + "raw_string": "black" + } + ] + } + }, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,4:4:48-4:5:49", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,4:4:48-4:5:49", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "stroke": { + "value": "black" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + { + "name": "b", + "isFolderOnly": false, + "ast": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "stroke" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:17:17-0:22:22", + "value": [ + { + "string": "black", + "raw_string": "black" + } + ] + } + }, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,7:4:65-7:5:66", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,7:4:65-7:5:66", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "stroke": { + "value": "black" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ], + "steps": [ + { + "name": "c", + "isFolderOnly": false, + "ast": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "stroke" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:17:17-0:22:22", + "value": [ + { + "string": "black", + "raw_string": "black" + } + ] + } + }, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,12:4:93-12:5:94", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,12:4:93-12:5:94", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "stroke": { + "value": "black" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + { + "name": "d", + "isFolderOnly": false, + "ast": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",0:0:0-1:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "stroke" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,0:17:17-0:22:22", + "value": [ + { + "string": "black", + "raw_string": "black" + } + ] + } + }, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,12:4:93-12:5:94", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,12:4:93-12:5:94", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,15:4:110-15:5:111", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/boards/style-nested-boards.d2,15:4:110-15:5:111", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "stroke": { + "value": "black" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": null +} diff --git a/testdata/d2ir/TestCompile/patterns/alixander-review/5.exp.json b/testdata/d2ir/TestCompile/patterns/alixander-review/5.exp.json index a23a2b1332..d7c15fa347 100644 --- a/testdata/d2ir/TestCompile/patterns/alixander-review/5.exp.json +++ b/testdata/d2ir/TestCompile/patterns/alixander-review/5.exp.json @@ -186,240 +186,6 @@ }, "due_to_glob": true, "due_to_lazy_glob": true - }, - { - "string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - }, - "key_path": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19", - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19", - "value": [ - { - "string": "red", - "raw_string": "red" - } - ] - } - } - } - }, - "due_to_glob": true, - "due_to_lazy_glob": true - }, - { - "string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - }, - "key_path": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19", - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19", - "value": [ - { - "string": "red", - "raw_string": "red" - } - ] - } - } - } - }, - "due_to_glob": true, - "due_to_lazy_glob": true } ] } @@ -1587,240 +1353,6 @@ }, "due_to_glob": true, "due_to_lazy_glob": true - }, - { - "string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - }, - "key_path": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19", - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19", - "value": [ - { - "string": "red", - "raw_string": "red" - } - ] - } - } - } - }, - "due_to_glob": true, - "due_to_lazy_glob": true - }, - { - "string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - }, - "key_path": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19", - "key": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3", - "value": [ - { - "string": "**", - "raw_string": "**" - } - ], - "pattern": [ - "*", - "", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19", - "value": [ - { - "string": "red", - "raw_string": "red" - } - ] - } - } - } - }, - "due_to_glob": true, - "due_to_lazy_glob": true } ] } diff --git a/testdata/d2ir/TestCompile/patterns/double-glob/defaults.exp.json b/testdata/d2ir/TestCompile/patterns/double-glob/defaults.exp.json index e0c116c327..1abe7f6431 100644 --- a/testdata/d2ir/TestCompile/patterns/double-glob/defaults.exp.json +++ b/testdata/d2ir/TestCompile/patterns/double-glob/defaults.exp.json @@ -594,6 +594,69 @@ } }, "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18", + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18", + "value": [ + { + "string": "page", + "raw_string": "page" + } + ] + } + } + } + }, + "due_to_glob": true, + "due_to_lazy_glob": true + }, { "string": { "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", @@ -736,6 +799,69 @@ } }, "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18", + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18", + "value": [ + { + "string": "page", + "raw_string": "page" + } + ] + } + } + } + }, + "due_to_glob": true, + "due_to_lazy_glob": true + }, { "string": { "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", @@ -878,6 +1004,69 @@ } }, "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18", + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18", + "value": [ + { + "string": "page", + "raw_string": "page" + } + ] + } + } + } + }, + "due_to_glob": true, + "due_to_lazy_glob": true + }, { "string": { "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", @@ -1020,6 +1209,69 @@ } }, "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18", + "key": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18", + "value": [ + { + "string": "page", + "raw_string": "page" + } + ] + } + } + } + }, + "due_to_glob": true, + "due_to_lazy_glob": true + }, { "string": { "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", @@ -1162,69 +1414,6 @@ } }, "references": [ - { - "string": { - "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - }, - "key_path": { - "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18", - "key": { - "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18", - "value": [ - { - "string": "page", - "raw_string": "page" - } - ] - } - } - } - }, - "due_to_glob": true, - "due_to_lazy_glob": true - }, { "string": { "range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",