diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go
index 90c2f26fba..df0ca4c456 100644
--- a/d2compiler/compile_test.go
+++ b/d2compiler/compile_test.go
@@ -2952,7 +2952,7 @@ layers: {
},
},
{
- name: "import-link-underscore",
+ name: "import-link-underscore-1",
text: `k
layers: {
@@ -2976,6 +2976,41 @@ layers: {
k: {
k
}
+}`,
+ },
+ assertions: func(t *testing.T, g *d2graph.Graph) {
+ tassert.Equal(t, "root.layers.x", g.Layers[0].Layers[0].Objects[0].Link.Value)
+ tassert.Equal(t, "root.layers.x.layers.b", g.Layers[0].Layers[0].Layers[0].Objects[0].Link.Value)
+ tassert.Equal(t, "root.layers.x", g.Layers[0].Layers[0].Layers[0].Objects[1].Link.Value)
+ tassert.Equal(t, "root.layers.x.layers.b", g.Layers[0].Layers[0].Layers[0].Objects[2].Link.Value)
+ tassert.Equal(t, "root.layers.x.layers.k", g.Layers[0].Layers[0].Objects[1].Link.Value)
+ },
+ },
+ {
+ name: "import-link-underscore-2",
+ text: `k
+
+layers: {
+ x: @x
+}`,
+ files: map[string]string{
+ "x.d2": `a
+layers: {
+ b: {
+ d.link: _
+ s.link: _.layers.k
+
+ layers: {
+ c: {
+ c.link: _
+ z.link: _._
+ f.link: _._.layers.b
+ }
+ }
+ }
+ k: {
+ k
+ }
}`,
},
assertions: func(t *testing.T, g *d2graph.Graph) {
diff --git a/d2ir/compile.go b/d2ir/compile.go
index fc8f558b9e..a4580716ee 100644
--- a/d2ir/compile.go
+++ b/d2ir/compile.go
@@ -819,7 +819,7 @@ func (c *compiler) _compileField(f *Field, refctx *RefContext) {
}
}
OverlayMap(f.Map(), n)
- c.updateLinks(f.Map())
+ c.extendLinks(f.Map(), f)
switch NodeBoardKind(f) {
case BoardScenario, BoardStep:
c.overlayClasses(f.Map())
@@ -883,74 +883,6 @@ func (c *compiler) extendLinks(m *Map, importF *Field) {
}
}
-func (c *compiler) updateLinks(m *Map) {
- nodeBoardKind := NodeBoardKind(m)
- for _, f := range m.Fields {
- if f.Name == "link" {
- if nodeBoardKind != "" {
- c.errorf(f.LastRef().AST(), "a board itself cannot be linked; only objects within a board can be linked")
- continue
- }
- val := f.Primary().Value.ScalarString()
- link, err := d2parser.ParseKey(val)
- if err != nil {
- continue
- }
-
- linkIDA := link.IDA()
- if len(linkIDA) == 0 {
- continue
- }
-
- // When updateLinks is called, all valid board links are already compiled and changed to the qualified path beginning with "root"
- if linkIDA[0] != "root" {
- continue
- }
- bida := BoardIDA(f)
- aida := IDA(f)
-
- if len(bida) != len(aida) {
- prependIDA := aida[:len(aida)-len(bida)]
- fullIDA := []string{"root"}
- // With nested imports, a value may already have been updated with part of the absolute path
- // E.g.,
- // The import prepends path a b c
- // The existing path is b c d
- // So the new path is
- // a b c
- // b c d
- // -------
- // a b c d
- OUTER:
- // Starts at 1 assuming 0 is "root" for both
- // +2 assuming layers/scenarios/steps is in between both
- for i := 1; i < len(prependIDA); i += 2 {
- for j := 0; i+j < len(prependIDA); j++ {
- if 1+j >= len(linkIDA) || prependIDA[i+j] != linkIDA[1+j] {
- break
- }
- // Reached the end and all common
- if i+j == len(prependIDA)-1 {
- break OUTER
- }
- }
- fullIDA = append(fullIDA, prependIDA[i])
- fullIDA = append(fullIDA, prependIDA[i+1])
- }
- // Chop off "root"
- fullIDA = append(fullIDA, linkIDA[1:]...)
-
- kp := d2ast.MakeKeyPath(fullIDA)
- s := d2format.Format(kp)
- f.Primary_.Value = d2ast.MakeValueBox(d2ast.FlatUnquotedString(s)).ScalarBox().Unbox()
- }
- }
- if f.Map() != nil {
- c.updateLinks(f.Map())
- }
- }
-}
-
func (c *compiler) compileLink(f *Field, refctx *RefContext) {
val := refctx.Key.Value.ScalarBox().Unbox().ScalarString()
link, err := d2parser.ParseKey(val)
diff --git a/e2etests-cli/testdata/TestCLI_E2E/layer-link/index.exp.svg b/e2etests-cli/testdata/TestCLI_E2E/layer-link/index.exp.svg
index 61f437fcce..d3ff3d0f7c 100644
--- a/e2etests-cli/testdata/TestCLI_E2E/layer-link/index.exp.svg
+++ b/e2etests-cli/testdata/TestCLI_E2E/layer-link/index.exp.svg
@@ -1,12 +1,12 @@
-
diff --git a/e2etests-cli/testdata/TestCLI_E2E/layer-link/test2.exp.svg b/e2etests-cli/testdata/TestCLI_E2E/layer-link/test2.exp.svg
index ed6391e77a..92db0723fc 100644
--- a/e2etests-cli/testdata/TestCLI_E2E/layer-link/test2.exp.svg
+++ b/e2etests-cli/testdata/TestCLI_E2E/layer-link/test2.exp.svg
@@ -1,13 +1,13 @@
-I'm a Mac
+ .d2-1391345131 .fill-N1{fill:#0A0F25;}
+ .d2-1391345131 .fill-N2{fill:#676C7E;}
+ .d2-1391345131 .fill-N3{fill:#9499AB;}
+ .d2-1391345131 .fill-N4{fill:#CFD2DD;}
+ .d2-1391345131 .fill-N5{fill:#DEE1EB;}
+ .d2-1391345131 .fill-N6{fill:#EEF1F8;}
+ .d2-1391345131 .fill-N7{fill:#FFFFFF;}
+ .d2-1391345131 .fill-B1{fill:#0D32B2;}
+ .d2-1391345131 .fill-B2{fill:#0D32B2;}
+ .d2-1391345131 .fill-B3{fill:#E3E9FD;}
+ .d2-1391345131 .fill-B4{fill:#E3E9FD;}
+ .d2-1391345131 .fill-B5{fill:#EDF0FD;}
+ .d2-1391345131 .fill-B6{fill:#F7F8FE;}
+ .d2-1391345131 .fill-AA2{fill:#4A6FF3;}
+ .d2-1391345131 .fill-AA4{fill:#EDF0FD;}
+ .d2-1391345131 .fill-AA5{fill:#F7F8FE;}
+ .d2-1391345131 .fill-AB4{fill:#EDF0FD;}
+ .d2-1391345131 .fill-AB5{fill:#F7F8FE;}
+ .d2-1391345131 .stroke-N1{stroke:#0A0F25;}
+ .d2-1391345131 .stroke-N2{stroke:#676C7E;}
+ .d2-1391345131 .stroke-N3{stroke:#9499AB;}
+ .d2-1391345131 .stroke-N4{stroke:#CFD2DD;}
+ .d2-1391345131 .stroke-N5{stroke:#DEE1EB;}
+ .d2-1391345131 .stroke-N6{stroke:#EEF1F8;}
+ .d2-1391345131 .stroke-N7{stroke:#FFFFFF;}
+ .d2-1391345131 .stroke-B1{stroke:#0D32B2;}
+ .d2-1391345131 .stroke-B2{stroke:#0D32B2;}
+ .d2-1391345131 .stroke-B3{stroke:#E3E9FD;}
+ .d2-1391345131 .stroke-B4{stroke:#E3E9FD;}
+ .d2-1391345131 .stroke-B5{stroke:#EDF0FD;}
+ .d2-1391345131 .stroke-B6{stroke:#F7F8FE;}
+ .d2-1391345131 .stroke-AA2{stroke:#4A6FF3;}
+ .d2-1391345131 .stroke-AA4{stroke:#EDF0FD;}
+ .d2-1391345131 .stroke-AA5{stroke:#F7F8FE;}
+ .d2-1391345131 .stroke-AB4{stroke:#EDF0FD;}
+ .d2-1391345131 .stroke-AB5{stroke:#F7F8FE;}
+ .d2-1391345131 .background-color-N1{background-color:#0A0F25;}
+ .d2-1391345131 .background-color-N2{background-color:#676C7E;}
+ .d2-1391345131 .background-color-N3{background-color:#9499AB;}
+ .d2-1391345131 .background-color-N4{background-color:#CFD2DD;}
+ .d2-1391345131 .background-color-N5{background-color:#DEE1EB;}
+ .d2-1391345131 .background-color-N6{background-color:#EEF1F8;}
+ .d2-1391345131 .background-color-N7{background-color:#FFFFFF;}
+ .d2-1391345131 .background-color-B1{background-color:#0D32B2;}
+ .d2-1391345131 .background-color-B2{background-color:#0D32B2;}
+ .d2-1391345131 .background-color-B3{background-color:#E3E9FD;}
+ .d2-1391345131 .background-color-B4{background-color:#E3E9FD;}
+ .d2-1391345131 .background-color-B5{background-color:#EDF0FD;}
+ .d2-1391345131 .background-color-B6{background-color:#F7F8FE;}
+ .d2-1391345131 .background-color-AA2{background-color:#4A6FF3;}
+ .d2-1391345131 .background-color-AA4{background-color:#EDF0FD;}
+ .d2-1391345131 .background-color-AA5{background-color:#F7F8FE;}
+ .d2-1391345131 .background-color-AB4{background-color:#EDF0FD;}
+ .d2-1391345131 .background-color-AB5{background-color:#F7F8FE;}
+ .d2-1391345131 .color-N1{color:#0A0F25;}
+ .d2-1391345131 .color-N2{color:#676C7E;}
+ .d2-1391345131 .color-N3{color:#9499AB;}
+ .d2-1391345131 .color-N4{color:#CFD2DD;}
+ .d2-1391345131 .color-N5{color:#DEE1EB;}
+ .d2-1391345131 .color-N6{color:#EEF1F8;}
+ .d2-1391345131 .color-N7{color:#FFFFFF;}
+ .d2-1391345131 .color-B1{color:#0D32B2;}
+ .d2-1391345131 .color-B2{color:#0D32B2;}
+ .d2-1391345131 .color-B3{color:#E3E9FD;}
+ .d2-1391345131 .color-B4{color:#E3E9FD;}
+ .d2-1391345131 .color-B5{color:#EDF0FD;}
+ .d2-1391345131 .color-B6{color:#F7F8FE;}
+ .d2-1391345131 .color-AA2{color:#4A6FF3;}
+ .d2-1391345131 .color-AA4{color:#EDF0FD;}
+ .d2-1391345131 .color-AA5{color:#F7F8FE;}
+ .d2-1391345131 .color-AB4{color:#EDF0FD;}
+ .d2-1391345131 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]>I'm a Mac
@@ -104,7 +104,7 @@
-
+
diff --git a/testdata/d2compiler/TestCompile/import-link-underscore-1.exp.json b/testdata/d2compiler/TestCompile/import-link-underscore-1.exp.json
new file mode 100644
index 0000000000..5feb61b1ab
--- /dev/null
+++ b/testdata/d2compiler/TestCompile/import-link-underscore-1.exp.json
@@ -0,0 +1,1744 @@
+{
+ "graph": {
+ "name": "",
+ "isFolderOnly": false,
+ "ast": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,0:0:0-4:1:27",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,0:0:0-0:1:1",
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "k",
+ "raw_string": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {}
+ }
+ },
+ {
+ "map_key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,2:0:3-4:1:27",
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,2:0:3-2:6:9",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,2:0:3-2:6:9",
+ "value": [
+ {
+ "string": "layers",
+ "raw_string": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,2:8:11-4:1:27",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,3:2:15-3:12:25",
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,3:2:15-3:3:16",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,3:2:15-3:3:16",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,3:5:18-3:12:25",
+ "nodes": [
+ {
+ "import": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,3:6:19-3:11:24",
+ "spread": true,
+ "pre": "",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,3:10:23-3:11:24",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "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": "k",
+ "id_val": "k",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-1.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "k",
+ "raw_string": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "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
+ }
+ ],
+ "layers": [
+ {
+ "name": "x",
+ "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": "a"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {}
+ }
+ },
+ {
+ "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": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "b"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "d"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "s"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.k"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "z"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "f"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "a",
+ "id_val": "a",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "a",
+ "raw_string": "a"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "a"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ }
+ ],
+ "layers": [
+ {
+ "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": "d"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "s"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.k"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "z"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "f"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "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": "d",
+ "id_val": "d",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,3:4:23-3:10:29",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,3:4:23-3:5:24",
+ "value": [
+ {
+ "string": "d",
+ "raw_string": "d"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,3:6:25-3:10:29",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "d"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ },
+ {
+ "id": "s",
+ "id_val": "s",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,4:2:35-4:8:41",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,4:2:35-4:3:36",
+ "value": [
+ {
+ "string": "s",
+ "raw_string": "s"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,4:4:37-4:8:41",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "s"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x.layers.k"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ }
+ ],
+ "layers": [
+ {
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "z"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "f"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "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": "c",
+ "id_val": "c",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,8:8:88-8:14:94",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,8:8:88-8:9:89",
+ "value": [
+ {
+ "string": "c",
+ "raw_string": "c"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,8:10:90-8:14:94",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "c"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x.layers.b"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ },
+ {
+ "id": "z",
+ "id_val": "z",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,9:4:102-9:10:108",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,9:4:102-9:5:103",
+ "value": [
+ {
+ "string": "z",
+ "raw_string": "z"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,9:6:104-9:10:108",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "z"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ },
+ {
+ "id": "f",
+ "id_val": "f",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,10:4:118-10:10:124",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,10:4:118-10:5:119",
+ "value": [
+ {
+ "string": "f",
+ "raw_string": "f"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,10:6:120-10:10:124",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "f"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x.layers.b"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "k",
+ "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": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "k",
+ "id_val": "k",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,15:4:168-15:5:169",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,15:4:168-15:5:169",
+ "value": [
+ {
+ "string": "k",
+ "raw_string": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "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
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "err": null
+}
diff --git a/testdata/d2compiler/TestCompile/import-link-underscore-2.exp.json b/testdata/d2compiler/TestCompile/import-link-underscore-2.exp.json
new file mode 100644
index 0000000000..ee11e5deb4
--- /dev/null
+++ b/testdata/d2compiler/TestCompile/import-link-underscore-2.exp.json
@@ -0,0 +1,1762 @@
+{
+ "graph": {
+ "name": "",
+ "isFolderOnly": false,
+ "ast": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,0:0:0-4:1:22",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,0:0:0-0:1:1",
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "k",
+ "raw_string": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {}
+ }
+ },
+ {
+ "map_key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,2:0:3-4:1:22",
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,2:0:3-2:6:9",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,2:0:3-2:6:9",
+ "value": [
+ {
+ "string": "layers",
+ "raw_string": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,2:8:11-4:1:22",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,3:2:15-3:7:20",
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,3:2:15-3:3:16",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,3:2:15-3:3:16",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": ",1:0:0-1:0:0",
+ "nodes": [
+ {
+ "import": {
+ "range": ",1:0:0-1:0:0",
+ "spread": true,
+ "pre": "",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,3:6:19-3:7:20",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "import": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,3:5:18-3:7:20",
+ "spread": false,
+ "pre": "",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,3:6:19-3:7:20",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "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": "k",
+ "id_val": "k",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/import-link-underscore-2.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "k",
+ "raw_string": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "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
+ }
+ ],
+ "layers": [
+ {
+ "name": "x",
+ "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": "a"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {}
+ }
+ },
+ {
+ "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": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "b"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "d"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "s"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.k"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "z"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "f"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "a",
+ "id_val": "a",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "a",
+ "raw_string": "a"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "a"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ }
+ ],
+ "layers": [
+ {
+ "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": "d"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "s"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.k"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "layers"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "z"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "f"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "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": "d",
+ "id_val": "d",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,3:4:23-3:10:29",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,3:4:23-3:5:24",
+ "value": [
+ {
+ "string": "d",
+ "raw_string": "d"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,3:6:25-3:10:29",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "d"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ },
+ {
+ "id": "s",
+ "id_val": "s",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,4:2:35-4:8:41",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,4:2:35-4:3:36",
+ "value": [
+ {
+ "string": "s",
+ "raw_string": "s"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,4:4:37-4:8:41",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "s"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x.layers.k"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ }
+ ],
+ "layers": [
+ {
+ "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": "c"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "z"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x"
+ }
+ ]
+ }
+ },
+ "value": {}
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "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": "f"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {
+ "unquoted_string": {
+ "range": ",0:0:0-0:0:0",
+ "value": [
+ {
+ "string": "root.layers.x.layers.b"
+ }
+ ]
+ }
+ },
+ "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": "c",
+ "id_val": "c",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,8:8:88-8:14:94",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,8:8:88-8:9:89",
+ "value": [
+ {
+ "string": "c",
+ "raw_string": "c"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,8:10:90-8:14:94",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "c"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x.layers.b"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ },
+ {
+ "id": "z",
+ "id_val": "z",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,9:4:102-9:10:108",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,9:4:102-9:5:103",
+ "value": [
+ {
+ "string": "z",
+ "raw_string": "z"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,9:6:104-9:10:108",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "z"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ },
+ {
+ "id": "f",
+ "id_val": "f",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,10:4:118-10:10:124",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,10:4:118-10:5:119",
+ "value": [
+ {
+ "string": "f",
+ "raw_string": "f"
+ }
+ ]
+ }
+ },
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,10:6:120-10:10:124",
+ "value": [
+ {
+ "string": "link",
+ "raw_string": "link"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "f"
+ },
+ "labelDimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "style": {},
+ "link": {
+ "value": "root.layers.x.layers.b"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": null
+ },
+ "zIndex": 0
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "k",
+ "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": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "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": "k",
+ "id_val": "k",
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,15:4:168-15:5:169",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2compiler/TestCompile/x.d2,15:4:168-15:5:169",
+ "value": [
+ {
+ "string": "k",
+ "raw_string": "k"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "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
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "err": null
+}