From cbb54f06c0e34db23391b56d12e6b4335856e71c Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 12 Mar 2025 14:56:09 -0600 Subject: [PATCH] fix suspend --- d2compiler/compile_test.go | 38 ++ d2ir/compile.go | 2 - d2ir/d2ir.go | 36 +- .../TestCompile2/globs/suspend-shape.exp.json | 101 +++++ .../globs/unsuspend-edge-label.exp.json | 405 ++++++++++++++++++ .../globs/unsuspend-label.exp.json | 405 ++++++++++++++++++ .../globs/unsuspend-shape-label.exp.json | 178 ++++++++ 7 files changed, 1162 insertions(+), 3 deletions(-) create mode 100644 testdata/d2compiler/TestCompile2/globs/suspend-shape.exp.json create mode 100644 testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.exp.json create mode 100644 testdata/d2compiler/TestCompile2/globs/unsuspend-label.exp.json create mode 100644 testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.exp.json diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 00f3a24e4..39c0bb454 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -5617,6 +5617,44 @@ d -> d: "suspend" assert.Equal(t, 1, len(g.Edges)) }, }, + { + name: "unsuspend-edge-label", + run: func(t *testing.T) { + g, _ := assertCompile(t, ` +a -> b: hello +c +**: suspend +(** -> **)[*]: suspend + +(* -> *)[*]: unsuspend +`, ``) + assert.Equal(t, 2, len(g.Objects)) + assert.Equal(t, 1, len(g.Edges)) + assert.Equal(t, "hello", g.Edges[0].Label.Value) + }, + }, + { + name: "unsuspend-shape-label", + run: func(t *testing.T) { + g, _ := assertCompile(t, ` +a: hello +*: suspend +*: unsuspend +`, ``) + assert.Equal(t, 1, len(g.Objects)) + assert.Equal(t, "hello", g.Objects[0].Label.Value) + }, + }, + { + name: "suspend-shape", + run: func(t *testing.T) { + g, _ := assertCompile(t, ` +a: hello +*: suspend +`, ``) + assert.Equal(t, 0, len(g.Objects)) + }, + }, { name: "edge-glob-ampersand-filter/1", run: func(t *testing.T) { diff --git a/d2ir/compile.go b/d2ir/compile.go index 49e0cd740..db4984cd5 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -1285,12 +1285,10 @@ func (c *compiler) _compileEdges(refctx *RefContext) { // If we're unsuspending an edge, we should also unsuspend its src and dst objects if !suspensionValue { - // Find the source and destination objects srcPath, dstPath := e.ID.SrcPath, e.ID.DstPath srcObj := refctx.ScopeMap.GetField(srcPath...) dstObj := refctx.ScopeMap.GetField(dstPath...) - // Unsuspend the objects if srcObj != nil { srcObj.suspended = false } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 4ea360b92..e41edbb83 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -650,7 +650,41 @@ func (rc *RefContext) EdgeIndex() int { func (rc *RefContext) Equal(rc2 *RefContext) bool { // We intentionally ignore edges here because the same glob can produce multiple RefContexts that should be treated the same with only the edge as the difference. // Same with ScopeMap. - return rc.Key.Equals(rc2.Key) && rc.Scope == rc2.Scope && rc.ScopeAST == rc2.ScopeAST + if !(rc.Key.Equals(rc2.Key) && rc.Scope == rc2.Scope && rc.ScopeAST == rc2.ScopeAST) { + return false + } + + // Check if suspension values match for suspension operations + // We don't want these two to equal + // 1. *: suspend + // 2. *: unsuspend + hasSuspension1 := (rc.Key.Primary.Suspension != nil || rc.Key.Value.Suspension != nil) + hasSuspension2 := (rc2.Key.Primary.Suspension != nil || rc2.Key.Value.Suspension != nil) + + if hasSuspension1 || hasSuspension2 { + var val1, val2 bool + if rc.Key.Primary.Suspension != nil { + val1 = rc.Key.Primary.Suspension.Value + } else if rc.Key.Value.Suspension != nil { + val1 = rc.Key.Value.Suspension.Value + } + + if rc2.Key.Primary.Suspension != nil { + val2 = rc2.Key.Primary.Suspension.Value + } else if rc2.Key.Value.Suspension != nil { + val2 = rc2.Key.Value.Suspension.Value + } + + if hasSuspension1 && hasSuspension2 && val1 != val2 { + return false + } + + if hasSuspension1 != hasSuspension2 { + return false + } + } + + return true } func (m *Map) FieldCountRecursive() int { diff --git a/testdata/d2compiler/TestCompile2/globs/suspend-shape.exp.json b/testdata/d2compiler/TestCompile2/globs/suspend-shape.exp.json new file mode 100644 index 000000000..baf429ece --- /dev/null +++ b/testdata/d2compiler/TestCompile2/globs/suspend-shape.exp.json @@ -0,0 +1,101 @@ +{ + "graph": { + "name": "", + "isFolderOnly": true, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,0:0:0-3:0:21", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,1:0:1-1:8:9", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,1:3:4-1:8:9", + "value": [ + { + "string": "hello", + "raw_string": "hello" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,2:0:10-2:10:20", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,2:0:10-2:1:11", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,2:0:10-2:1:11", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/suspend-shape.d2,2:3:13-2:10:20", + "value": true + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": null + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.exp.json b/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.exp.json new file mode 100644 index 000000000..d33cb9b7c --- /dev/null +++ b/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.exp.json @@ -0,0 +1,405 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,0:0:0-7:0:76", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:0:1-1:13:14", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:8:9-1:13:14", + "value": [ + { + "string": "hello", + "raw_string": "hello" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,2:0:15-2:1:16", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,2:0:15-2:1:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,2:0:15-2:1:16", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,3:0:17-3:11:28", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,3:0:17-3:2:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,3:0:17-3:2:19", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,3:4:21-3:11:28", + "value": true + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:0:29-4:22:51", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:1:30-4:9:38", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:1:30-4:3:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:1:30-4:3:32", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:7:36-4:9:38", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:7:36-4:9:38", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:10:39-4:13:42", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,4:15:44-4:22:51", + "value": true + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:0:53-6:22:75", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:1:54-6:7:60", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:1:54-6:2:55", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:1:54-6:2:55", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:6:59-6:7:60", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:6:59-6:7:60", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:8:61-6:11:64", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,6:13:66-6:22:75", + "value": false + } + } + } + } + ] + }, + "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 + }, + { + "map_key_edge_index": 0 + }, + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "hello" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-edge-label.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "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/d2compiler/TestCompile2/globs/unsuspend-label.exp.json b/testdata/d2compiler/TestCompile2/globs/unsuspend-label.exp.json new file mode 100644 index 000000000..3a0edc892 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/globs/unsuspend-label.exp.json @@ -0,0 +1,405 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,0:0:0-7:0:76", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:0:1-1:13:14", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:8:9-1:13:14", + "value": [ + { + "string": "hello", + "raw_string": "hello" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,2:0:15-2:1:16", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,2:0:15-2:1:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,2:0:15-2:1:16", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,3:0:17-3:11:28", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,3:0:17-3:2:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,3:0:17-3:2:19", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,3:4:21-3:11:28", + "value": true + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:0:29-4:22:51", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:1:30-4:9:38", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:1:30-4:3:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:1:30-4:3:32", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:7:36-4:9:38", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:7:36-4:9:38", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:10:39-4:13:42", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,4:15:44-4:22:51", + "value": true + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:0:53-6:22:75", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:1:54-6:7:60", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:1:54-6:2:55", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:1:54-6:2:55", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:6:59-6:7:60", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:6:59-6:7:60", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:8:61-6:11:64", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,6:13:66-6:22:75", + "value": false + } + } + } + } + ] + }, + "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 + }, + { + "map_key_edge_index": 0 + }, + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "hello" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-label.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "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/d2compiler/TestCompile2/globs/unsuspend-shape-label.exp.json b/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.exp.json new file mode 100644 index 000000000..2ab9e4cfb --- /dev/null +++ b/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.exp.json @@ -0,0 +1,178 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,0:0:0-4:0:34", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,1:0:1-1:8:9", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,1:3:4-1:8:9", + "value": [ + { + "string": "hello", + "raw_string": "hello" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,2:0:10-2:10:20", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,2:0:10-2:1:11", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,2:0:10-2:1:11", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,2:3:13-2:10:20", + "value": true + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,3:0:21-3:12:33", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,3:0:21-3:1:22", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,3:0:21-3:1:22", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "primary": {}, + "value": { + "suspension": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,3:3:24-3:12:33", + "value": false + } + } + } + } + ] + }, + "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/TestCompile2/globs/unsuspend-shape-label.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/globs/unsuspend-shape-label.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "hello" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +}