diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 442b2fe74..f3ee2da8a 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -31,7 +31,9 @@ - Formatter: - fixes substitutions in quotes surrounded by text [#2462](https://github.com/terrastruct/d2/pull/2462) - CLI: fetch and render remote images of mimetype octet-stream correctly [#2370](https://github.com/terrastruct/d2/pull/2370) -- Composition: spread importing scenarios/steps was not inheriting correctly [#2460](https://github.com/terrastruct/d2/pull/2460) +- Composition: + - spread importing scenarios/steps was not inheriting correctly [#2460](https://github.com/terrastruct/d2/pull/2460) + - imported fields were not merging with current fields/edges [#2464](https://github.com/terrastruct/d2/pull/2464) - Markdown: fixes nested var substitutions not working [#2456](https://github.com/terrastruct/d2/pull/2456) - d2js: handle unicode characters [#2393](https://github.com/terrastruct/d2/pull/2393) diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index bb939a807..e373a4cd9 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -1714,6 +1714,59 @@ steps: { assert.Equal(t, 1, len(g.Layers[0].Steps)) }, }, + { + name: "import-connections", + + text: `b.c -> b.d + +b: @imp +`, + files: map[string]string{ + "imp.d2": ` +c +d +d -> c +`, + }, + assertions: func(t *testing.T, g *d2graph.Graph) { + assert.Equal(t, 2, len(g.Edges)) + }, + }, + { + name: "import-style-1", + + text: `b.c.style.fill: red + +b: @imp +`, + files: map[string]string{ + "imp.d2": `c`, + }, + assertions: func(t *testing.T, g *d2graph.Graph) { + assert.Equal(t, 2, len(g.Objects)) + assert.Equal(t, "c", g.Objects[1].Label.Value) + assert.Equal(t, "red", g.Objects[1].Style.Fill.Value) + }, + }, + { + name: "import-style-2", + + text: `b.k.c.style.fill: red + +b: @imp +`, + files: map[string]string{ + "imp.d2": ` +k: { + c +} +`, + }, + assertions: func(t *testing.T, g *d2graph.Graph) { + assert.Equal(t, "c", g.Objects[2].Label.Value) + assert.Equal(t, "red", g.Objects[2].Style.Fill.Value) + }, + }, { name: "import-scenario", diff --git a/d2ir/compile.go b/d2ir/compile.go index c7bf15e9d..45672d4bb 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -1098,6 +1098,11 @@ func (c *compiler) _compileField(f *Field, refctx *RefContext) { return } n.(Importable).SetImportAST(refctx.Key.Value.Import) + var existingEdges []*Edge + if f.Map() != nil { + existingEdges = f.Map().Edges + } + originalF := f.Copy(refctx.ScopeMap).(*Field) switch n := n.(type) { case *Field: if n.Primary_ != nil { @@ -1134,6 +1139,22 @@ func (c *compiler) _compileField(f *Field, refctx *RefContext) { c.overlayClasses(f.Map()) } } + OverlayField(f, originalF) + if existingEdges != nil && f.Map() != nil { + for _, edge := range existingEdges { + exists := false + for _, currentEdge := range f.Map().Edges { + if currentEdge.ID.Match(edge.ID) { + exists = true + break + } + } + if !exists { + f.Map().Edges = append(f.Map().Edges, edge) + } + } + } + } else if refctx.Key.Value.ScalarBox().Unbox() != nil { if c.ignoreLazyGlob(f) { return diff --git a/testdata/d2compiler/TestCompile/import-connections.exp.json b/testdata/d2compiler/TestCompile/import-connections.exp.json new file mode 100644 index 000000000..6433fd184 --- /dev/null +++ b/testdata/d2compiler/TestCompile/import-connections.exp.json @@ -0,0 +1,590 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-3:0:20", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:10:10", + "src": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:8:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:9:9-0:10:10", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:7:19", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:3:15-2:7:19", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:4:16-2:7:19", + "value": [ + { + "string": "imp", + "raw_string": "imp" + } + ] + } + } + ] + } + } + } + } + ] + }, + "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": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:8:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:9:9-0:10:10", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:8:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:9:9-0:10:10", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,1:0:1-1:1:2", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,3:5:10-3:6:11", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,3:5:10-3:6:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,2:0:3-2:1:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,2:0:3-2:1:4", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,3:0:5-3:1:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,3:0:5-3:1:6", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:8:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:9:9-0:10:10", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile/import-icon-near.exp.json b/testdata/d2compiler/TestCompile/import-icon-near.exp.json index ae9301419..5b95fd136 100644 --- a/testdata/d2compiler/TestCompile/import-icon-near.exp.json +++ b/testdata/d2compiler/TestCompile/import-icon-near.exp.json @@ -78,6 +78,26 @@ "id": "y", "id_val": "y", "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:1:1", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, { "key": { "range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:1:1", diff --git a/testdata/d2compiler/TestCompile/import-style-1.exp.json b/testdata/d2compiler/TestCompile/import-style-1.exp.json new file mode 100644 index 000000000..7a15621be --- /dev/null +++ b/testdata/d2compiler/TestCompile/import-style-1.exp.json @@ -0,0 +1,419 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-3:0:29", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:19:19", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:16:16-0:19:19", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:7:28", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:3:24-2:7:28", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:4:25-2:7:28", + "value": [ + { + "string": "imp", + "raw_string": "imp" + } + ] + } + } + ] + } + } + } + } + ] + }, + "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": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,0:0:0-0:1:1", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile/import-style-2.exp.json b/testdata/d2compiler/TestCompile/import-style-2.exp.json new file mode 100644 index 000000000..5c61b5d52 --- /dev/null +++ b/testdata/d2compiler/TestCompile/import-style-2.exp.json @@ -0,0 +1,572 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-3:0:31", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:21:21", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:2:2-0:3:3", + "value": [ + { + "string": "k", + "raw_string": "k" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:4:4-0:5:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:12:12-0:16:16", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:18:18-0:21:21", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:0:23-2:7:30", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:0:23-2:1:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:0:23-2:1:24", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:3:26-2:7:30", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:4:27-2:7:30", + "value": [ + { + "string": "imp", + "raw_string": "imp" + } + ] + } + } + ] + } + } + } + } + ] + }, + "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": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:2:2-0:3:3", + "value": [ + { + "string": "k", + "raw_string": "k" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:4:4-0:5:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:12:12-0:16:16", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:0:23-2:1:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:0:23-2:1:24", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:2:2-0:3:3", + "value": [ + { + "string": "k", + "raw_string": "k" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:4:4-0:5:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:12:12-0:16:16", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:0:23-2:1:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,2:0:23-2:1:24", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "k", + "id_val": "k", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,1:0:1-1:1:2", + "value": [ + { + "string": "k", + "raw_string": "k" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:2:2-0:3:3", + "value": [ + { + "string": "k", + "raw_string": "k" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:4:4-0:5:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:12:12-0:16:16", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "k" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,2:2:8-2:3:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,2:2:8-2:3:9", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:0:0-0:1:1", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:2:2-0:3:3", + "value": [ + { + "string": "k", + "raw_string": "k" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:4:4-0:5:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style-2.d2,0:12:12-0:16:16", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 2, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile/import-style.exp.json b/testdata/d2compiler/TestCompile/import-style.exp.json new file mode 100644 index 000000000..0bea509e5 --- /dev/null +++ b/testdata/d2compiler/TestCompile/import-style.exp.json @@ -0,0 +1,342 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-3:0:27", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-0:17:17", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:2:2-0:7:7", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:8:8-0:12:12", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:14:14-0:17:17", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,2:0:19-2:7:26", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,2:0:19-2:1:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,2:0:19-2:1:20", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,2:3:22-2:7:26", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,2:4:23-2:7:26", + "value": [ + { + "string": "imp", + "raw_string": "imp" + } + ] + } + } + ] + } + } + } + } + ] + }, + "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": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:2:2-0:7:7", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:8:8-0:12:12", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/imp.d2,1:0:1-1:1:2", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:2:2-0:7:7", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,0:8:8-0:12:12", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "red" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,2:0:19-2:1:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/import-style.d2,2:0:19-2:1:20", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2ir/TestCompile/imports/boards-deep.exp.json b/testdata/d2ir/TestCompile/imports/boards-deep.exp.json index 892926586..2ea3a94a1 100644 --- a/testdata/d2ir/TestCompile/imports/boards-deep.exp.json +++ b/testdata/d2ir/TestCompile/imports/boards-deep.exp.json @@ -775,6 +775,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "c.d2,0:28:28-0:29:29", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + }, + "key_path": { + "range": "c.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "c.d2,0:28:28-0:29:29", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "c.d2,0:28:28-0:34:34", + "key": { + "range": "c.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "c.d2,0:28:28-0:29:29", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "c.d2,0:31:31-0:34:34", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "c.d2,0:32:32-0:33:33", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "c.d2,0:28:28-0:29:29", @@ -960,6 +1032,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "b.d2,0:28:28-0:29:29", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + }, + "key_path": { + "range": "b.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "b.d2,0:28:28-0:29:29", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "b.d2,0:28:28-0:34:34", + "key": { + "range": "b.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "b.d2,0:28:28-0:29:29", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "b.d2,0:31:31-0:34:34", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "b.d2,0:32:32-0:33:33", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "b.d2,0:28:28-0:29:29", @@ -1145,6 +1289,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:28:28-0:29:29", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + }, + "key_path": { + "range": "index.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:28:28-0:29:29", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:28:28-0:34:34", + "key": { + "range": "index.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:28:28-0:29:29", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:31:31-0:34:34", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:32:32-0:33:33", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:28:28-0:29:29", diff --git a/testdata/d2ir/TestCompile/imports/boards.exp.json b/testdata/d2ir/TestCompile/imports/boards.exp.json index c2e7e9a19..e2cd8d6b4 100644 --- a/testdata/d2ir/TestCompile/imports/boards.exp.json +++ b/testdata/d2ir/TestCompile/imports/boards.exp.json @@ -540,6 +540,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "x.d2,0:28:28-0:29:29", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "x.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "x.d2,0:28:28-0:29:29", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "x.d2,0:28:28-0:34:34", + "key": { + "range": "x.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "x.d2,0:28:28-0:29:29", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "x.d2,0:31:31-0:34:34", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "x.d2,0:32:32-0:33:33", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "x.d2,0:28:28-0:29:29", @@ -725,6 +797,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:28:28-0:29:29", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "index.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:28:28-0:29:29", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:28:28-0:34:34", + "key": { + "range": "index.d2,0:28:28-0:29:29", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:28:28-0:29:29", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:31:31-0:34:34", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:32:32-0:33:33", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:28:28-0:29:29", diff --git a/testdata/d2ir/TestCompile/imports/nested/array.exp.json b/testdata/d2ir/TestCompile/imports/nested/array.exp.json index 7081d05e0..e06ff2377 100644 --- a/testdata/d2ir/TestCompile/imports/nested/array.exp.json +++ b/testdata/d2ir/TestCompile/imports/nested/array.exp.json @@ -26,6 +26,89 @@ ] }, "references": [ + { + "string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:0:0-0:7:7", + "key": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:3:3-0:7:7", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:4:4-0:5:5", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "index.d2,0:6:6-0:7:7", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:0:0-0:1:1", diff --git a/testdata/d2ir/TestCompile/imports/nested/map.exp.json b/testdata/d2ir/TestCompile/imports/nested/map.exp.json index 39559df56..6efbc25c3 100644 --- a/testdata/d2ir/TestCompile/imports/nested/map.exp.json +++ b/testdata/d2ir/TestCompile/imports/nested/map.exp.json @@ -190,6 +190,89 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:0:0-0:7:7", + "key": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:3:3-0:7:7", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:4:4-0:5:5", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "index.d2,0:6:6-0:7:7", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:0:0-0:1:1", diff --git a/testdata/d2ir/TestCompile/imports/nested/scalar.exp.json b/testdata/d2ir/TestCompile/imports/nested/scalar.exp.json index 76558fb51..0d42ee494 100644 --- a/testdata/d2ir/TestCompile/imports/nested/scalar.exp.json +++ b/testdata/d2ir/TestCompile/imports/nested/scalar.exp.json @@ -22,6 +22,89 @@ } }, "references": [ + { + "string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:0:0-0:7:7", + "key": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:3:3-0:7:7", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:4:4-0:5:5", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "index.d2,0:6:6-0:7:7", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:0:0-0:1:1", diff --git a/testdata/d2ir/TestCompile/imports/pattern-value.exp.json b/testdata/d2ir/TestCompile/imports/pattern-value.exp.json index 8e8653a31..a40689479 100644 --- a/testdata/d2ir/TestCompile/imports/pattern-value.exp.json +++ b/testdata/d2ir/TestCompile/imports/pattern-value.exp.json @@ -190,6 +190,59 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:0:0-0:11:11", + "value": [ + { + "string": "userWebsite", + "raw_string": "userWebsite" + } + ] + }, + "key_path": { + "range": "index.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:11:11", + "value": [ + { + "string": "userWebsite", + "raw_string": "userWebsite" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:0:0-0:11:11", + "key": { + "range": "index.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:11:11", + "value": [ + { + "string": "userWebsite", + "raw_string": "userWebsite" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:0:0-0:11:11", @@ -435,6 +488,59 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,1:0:12-1:10:22", + "value": [ + { + "string": "userMobile", + "raw_string": "userMobile" + } + ] + }, + "key_path": { + "range": "index.d2,1:0:12-1:10:22", + "path": [ + { + "unquoted_string": { + "range": "index.d2,1:0:12-1:10:22", + "value": [ + { + "string": "userMobile", + "raw_string": "userMobile" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,1:0:12-1:10:22", + "key": { + "range": "index.d2,1:0:12-1:10:22", + "path": [ + { + "unquoted_string": { + "range": "index.d2,1:0:12-1:10:22", + "value": [ + { + "string": "userMobile", + "raw_string": "userMobile" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,1:0:12-1:10:22", diff --git a/testdata/d2ir/TestCompile/imports/steps-inheritence.exp.json b/testdata/d2ir/TestCompile/imports/steps-inheritence.exp.json index 12e600fb8..3f542c369 100644 --- a/testdata/d2ir/TestCompile/imports/steps-inheritence.exp.json +++ b/testdata/d2ir/TestCompile/imports/steps-inheritence.exp.json @@ -226,6 +226,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:41:41-0:42:42", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "index.d2,0:41:41-0:42:42", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:41:41-0:42:42", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:41:41-0:46:46", + "key": { + "range": "index.d2,0:41:41-0:42:42", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:41:41-0:42:42", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:44:44-0:46:46", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:45:45-0:46:46", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:41:41-0:42:42", @@ -448,6 +520,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:48:48-0:49:49", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "index.d2,0:48:48-0:49:49", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:48:48-0:49:49", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:48:48-0:54:54", + "key": { + "range": "index.d2,0:48:48-0:49:49", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:48:48-0:49:49", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:51:51-0:54:54", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:52:52-0:53:53", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:48:48-0:49:49", @@ -831,6 +975,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:12:12-0:13:13", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + }, + "key_path": { + "range": "index.d2,0:12:12-0:13:13", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:12:12-0:13:13", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:12:12-0:17:17", + "key": { + "range": "index.d2,0:12:12-0:13:13", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:12:12-0:13:13", + "value": [ + { + "string": "1", + "raw_string": "1" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:15:15-0:17:17", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:16:16-0:17:17", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:12:12-0:13:13", @@ -1119,6 +1335,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:19:19-0:20:20", + "value": [ + { + "string": "2", + "raw_string": "2" + } + ] + }, + "key_path": { + "range": "index.d2,0:19:19-0:20:20", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:19:19-0:20:20", + "value": [ + { + "string": "2", + "raw_string": "2" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:19:19-0:25:25", + "key": { + "range": "index.d2,0:19:19-0:20:20", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:19:19-0:20:20", + "value": [ + { + "string": "2", + "raw_string": "2" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:22:22-0:25:25", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:23:23-0:24:24", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:19:19-0:20:20", diff --git a/testdata/d2ir/TestCompile/imports/value.exp.json b/testdata/d2ir/TestCompile/imports/value.exp.json index 64186e6af..fa8af8371 100644 --- a/testdata/d2ir/TestCompile/imports/value.exp.json +++ b/testdata/d2ir/TestCompile/imports/value.exp.json @@ -190,6 +190,78 @@ "edges": null }, "references": [ + { + "string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "index.d2,0:0:0-0:8:8", + "key": { + "range": "index.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "import": { + "range": "index.d2,0:3:3-0:8:8", + "spread": false, + "pre": "", + "path": [ + { + "unquoted_string": { + "range": "index.d2,0:4:4-0:5:5", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + } + }, + "due_to_glob": false, + "due_to_lazy_glob": false + }, { "string": { "range": "index.d2,0:0:0-0:1:1", diff --git a/testdata/d2oracle/TestSet/import/6.exp.json b/testdata/d2oracle/TestSet/import/6.exp.json index 7c2f2b3e6..9b0e876c3 100644 --- a/testdata/d2oracle/TestSet/import/6.exp.json +++ b/testdata/d2oracle/TestSet/import/6.exp.json @@ -334,6 +334,26 @@ "key_path_index": 0, "map_key_edge_index": -1 }, + { + "key": { + "range": "index.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "index.d2,1:0:2-1:1:3", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, { "key": { "range": "index.d2,2:0:9-2:14:23",