From aff6723d38fa22a0092eb70d6b01fdfd71cad3c2 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 20 Feb 2023 14:15:47 -0800 Subject: [PATCH] replace link and tooltip --- d2compiler/compile.go | 8 +- d2graph/d2graph.go | 8 +- d2oracle/edit.go | 29 +- d2oracle/edit_test.go | 94 +++++ .../d2oracle/TestDelete/arrowhead.exp.json | 214 +++++++++++ .../TestDelete/arrowhead_shape.exp.json | 214 +++++++++++ .../d2oracle/TestDelete/delete_icon.exp.json | 4 +- .../TestDelete/edge-only-style.exp.json | 214 +++++++++++ .../TestSet/edge_replace_arrowhead.exp.json | 280 ++++++++++++++ .../edge_replace_arrowhead_indexed.exp.json | 361 ++++++++++++++++++ .../TestSet/edge_replace_style.exp.json | 280 ++++++++++++++ .../TestSet/edge_set_arrowhead.exp.json | 280 ++++++++++++++ .../d2oracle/TestSet/replace_link.exp.json | 151 ++++++++ .../d2oracle/TestSet/replace_tooltip.exp.json | 151 ++++++++ 14 files changed, 2280 insertions(+), 8 deletions(-) create mode 100644 testdata/d2oracle/TestDelete/arrowhead.exp.json create mode 100644 testdata/d2oracle/TestDelete/arrowhead_shape.exp.json create mode 100644 testdata/d2oracle/TestDelete/edge-only-style.exp.json create mode 100644 testdata/d2oracle/TestSet/edge_replace_arrowhead.exp.json create mode 100644 testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.exp.json create mode 100644 testdata/d2oracle/TestSet/edge_replace_style.exp.json create mode 100644 testdata/d2oracle/TestSet/edge_set_arrowhead.exp.json create mode 100644 testdata/d2oracle/TestSet/replace_link.exp.json create mode 100644 testdata/d2oracle/TestSet/replace_tooltip.exp.json diff --git a/d2compiler/compile.go b/d2compiler/compile.go index b2df640da..2a2e3becd 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -266,7 +266,9 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { nearKey.Range = scalar.GetRange() attrs.NearKey = nearKey case "tooltip": - attrs.Tooltip = scalar.ScalarString() + attrs.Tooltip = &d2graph.Scalar{} + attrs.Tooltip.Value = scalar.ScalarString() + attrs.Tooltip.MapKey = f.LastPrimaryKey() case "width": _, err := strconv.Atoi(scalar.ScalarString()) if err != nil { @@ -304,7 +306,9 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { attrs.Left.Value = scalar.ScalarString() attrs.Left.MapKey = f.LastPrimaryKey() case "link": - attrs.Link = scalar.ScalarString() + attrs.Link = &d2graph.Scalar{} + attrs.Link.Value = scalar.ScalarString() + attrs.Link.MapKey = f.LastPrimaryKey() case "direction": dirs := []string{"up", "down", "right", "left"} if !go2.Contains(dirs, scalar.ScalarString()) { diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 30bdedcbf..385a6b2ed 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -95,8 +95,8 @@ type Attributes struct { Label Scalar `json:"label"` Style Style `json:"style"` Icon *url.URL `json:"icon,omitempty"` - Tooltip string `json:"tooltip,omitempty"` - Link string `json:"link,omitempty"` + Tooltip *Scalar `json:"tooltip,omitempty"` + Link *Scalar `json:"link,omitempty"` Width *Scalar `json:"width,omitempty"` Height *Scalar `json:"height,omitempty"` @@ -1313,10 +1313,10 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler switch shapeType { case shape.TABLE_TYPE, shape.CLASS_TYPE, shape.CODE_TYPE, shape.IMAGE_TYPE: default: - if obj.Attributes.Link != "" { + if obj.Attributes.Link != nil { paddingX += 32 } - if obj.Attributes.Tooltip != "" { + if obj.Attributes.Tooltip != nil { paddingX += 32 } } diff --git a/d2oracle/edit.go b/d2oracle/edit.go index 8813755bf..669443541 100644 --- a/d2oracle/edit.go +++ b/d2oracle/edit.go @@ -37,6 +37,7 @@ func Create(g *d2graph.Graph, key string) (_ *d2graph.Graph, newKey string, err if err != nil { return nil, "", err } + g, err = recompile(g) if err != nil { return nil, "", err @@ -195,6 +196,20 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error { reserved = true toSkip = 1 + if len(mk.EdgeKey.Path) > 1 { + switch mk.EdgeKey.Path[len(mk.EdgeKey.Path)-2].Unbox().ScalarString() { + case "source-arrowhead": + if edge.SrcArrowhead != nil { + toSkip++ + attrs = edge.SrcArrowhead + } + case "target-arrowhead": + if edge.DstArrowhead != nil { + toSkip++ + attrs = edge.DstArrowhead + } + } + } mk = &d2ast.Key{ Key: cloneKey(mk.EdgeKey), Value: mk.Value, @@ -234,6 +249,16 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error { attrs.Shape.MapKey.SetScalar(mk.Value.ScalarBox()) return nil } + case "link": + if attrs.Link.MapKey != nil { + attrs.Link.MapKey.SetScalar(mk.Value.ScalarBox()) + return nil + } + case "tooltip": + if attrs.Tooltip.MapKey != nil { + attrs.Tooltip.MapKey.SetScalar(mk.Value.ScalarBox()) + return nil + } case "width": if attrs.Width != nil && attrs.Width.MapKey != nil { attrs.Width.MapKey.SetScalar(mk.Value.ScalarBox()) @@ -714,7 +739,9 @@ func deleteMapField(m *d2ast.Map, field string) { if n.MapKey != nil && n.MapKey.Key != nil { if n.MapKey.Key.Path[0].Unbox().ScalarString() == field { deleteFromMap(m, n.MapKey) - } else if n.MapKey.Key.Path[0].Unbox().ScalarString() == "style" { + } else if n.MapKey.Key.Path[0].Unbox().ScalarString() == "style" || + n.MapKey.Key.Path[0].Unbox().ScalarString() == "source-arrowhead" || + n.MapKey.Key.Path[0].Unbox().ScalarString() == "target-arrowhead" { if n.MapKey.Value.Map != nil { deleteMapField(n.MapKey.Value.Map, field) if len(n.MapKey.Value.Map.Nodes) == 0 { diff --git a/d2oracle/edit_test.go b/d2oracle/edit_test.go index f6dc0cf3a..c5116b925 100644 --- a/d2oracle/edit_test.go +++ b/d2oracle/edit_test.go @@ -741,6 +741,32 @@ square.style.opacity: 0.2 exp: `square: { width: 200 } +`, + }, + { + name: "replace_tooltip", + text: `square: { + tooltip: x +} +`, + key: `square.tooltip`, + value: go2.Pointer(`y`), + exp: `square: { + tooltip: y +} +`, + }, + { + name: "replace_link", + text: `square: { + link: https://google.com +} +`, + key: `square.link`, + value: go2.Pointer(`https://apple.com`), + exp: `square: { + link: https://apple.com +} `, }, { @@ -1072,6 +1098,38 @@ a.b -> a.c: {style.animated: true} value: go2.Pointer(`true`), exp: `x -> y: {style.animated: true} +`, + }, + { + name: "edge_set_arrowhead", + text: `x -> y +`, + key: `(x -> y)[0].target-arrowhead.shape`, + value: go2.Pointer(`diamond`), + + exp: `x -> y: {target-arrowhead.shape: diamond} +`, + }, + { + name: "edge_replace_arrowhead", + text: `x -> y: {target-arrowhead.shape: circle} +`, + key: `(x -> y)[0].target-arrowhead.shape`, + value: go2.Pointer(`diamond`), + + exp: `x -> y: {target-arrowhead.shape: diamond} +`, + }, + { + name: "edge_replace_arrowhead_indexed", + text: `x -> y +(x -> y)[0].target-arrowhead.shape: circle +`, + key: `(x -> y)[0].target-arrowhead.shape`, + value: go2.Pointer(`diamond`), + + exp: `x -> y +(x -> y)[0].target-arrowhead.shape: diamond `, }, { @@ -3459,6 +3517,42 @@ x key: `x`, exp: `y +`, + }, + { + name: "arrowhead", + + text: `x -> y: { + target-arrowhead.shape: diamond +} +`, + key: `(x -> y)[0].target-arrowhead`, + + exp: `x -> y +`, + }, + { + name: "arrowhead_shape", + + text: `x -> y: { + target-arrowhead.shape: diamond +} +`, + key: `(x -> y)[0].target-arrowhead.shape`, + + exp: `x -> y +`, + }, + { + name: "edge-only-style", + + text: `x -> y: { + style.stroke: red +} +`, + key: `(x -> y)[0].style.stroke`, + + exp: `x -> y `, }, { diff --git a/testdata/d2oracle/TestDelete/arrowhead.exp.json b/testdata/d2oracle/TestDelete/arrowhead.exp.json new file mode 100644 index 000000000..eb4cd6ebb --- /dev/null +++ b/testdata/d2oracle/TestDelete/arrowhead.exp.json @@ -0,0 +1,214 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-1:0:7", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestDelete/arrowhead_shape.exp.json b/testdata/d2oracle/TestDelete/arrowhead_shape.exp.json new file mode 100644 index 000000000..6ad6f3824 --- /dev/null +++ b/testdata/d2oracle/TestDelete/arrowhead_shape.exp.json @@ -0,0 +1,214 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-1:0:7", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestDelete/delete_icon.exp.json b/testdata/d2oracle/TestDelete/delete_icon.exp.json index 374b88cb2..66fcdfb72 100644 --- a/testdata/d2oracle/TestDelete/delete_icon.exp.json +++ b/testdata/d2oracle/TestDelete/delete_icon.exp.json @@ -209,7 +209,9 @@ "value": "x" }, "style": {}, - "link": "https://google.com", + "link": { + "value": "https://google.com" + }, "near_key": null, "shape": { "value": "rectangle" diff --git a/testdata/d2oracle/TestDelete/edge-only-style.exp.json b/testdata/d2oracle/TestDelete/edge-only-style.exp.json new file mode 100644 index 000000000..50846ea3b --- /dev/null +++ b/testdata/d2oracle/TestDelete/edge-only-style.exp.json @@ -0,0 +1,214 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-1:0:7", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/edge_replace_arrowhead.exp.json b/testdata/d2oracle/TestSet/edge_replace_arrowhead.exp.json new file mode 100644 index 000000000..2099babb4 --- /dev/null +++ b/testdata/d2oracle/TestSet/edge_replace_arrowhead.exp.json @@ -0,0 +1,280 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-1:0:42", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:41:41", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:8:8-0:40:40", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:9:9-0:40:40", + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:9:9-0:31:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:9:9-0:25:25", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:26:26-0:31:31", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:33:33-0:40:40", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "dstArrowhead": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "diamond" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.exp.json b/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.exp.json new file mode 100644 index 000000000..17bc34333 --- /dev/null +++ b/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.exp.json @@ -0,0 +1,361 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-2:0:51", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:0:7-1:43:50", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:7:14", + "src": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:3:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:2:9", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:5:12-1:7:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:6:13-1:7:14", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:8:15-1:11:18", + "int": 0, + "glob": false + }, + "edge_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:12:19-1:34:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:12:19-1:28:35", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:29:36-1:34:41", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:36:43-1:43:50", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "dstArrowhead": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "diamond" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "references": [ + { + "map_key_edge_index": 0 + }, + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:3:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:2:9", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:5:12-1:7:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:6:13-1:7:14", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/edge_replace_style.exp.json b/testdata/d2oracle/TestSet/edge_replace_style.exp.json new file mode 100644 index 000000000..f15dc4109 --- /dev/null +++ b/testdata/d2oracle/TestSet/edge_replace_style.exp.json @@ -0,0 +1,280 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-1:0:42", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:41:41", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:8:8-0:40:40", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:9:9-0:40:40", + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:9:9-0:31:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:9:9-0:25:25", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:26:26-0:31:31", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:33:33-0:40:40", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "dstArrowhead": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "diamond" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/edge_set_arrowhead.exp.json b/testdata/d2oracle/TestSet/edge_set_arrowhead.exp.json new file mode 100644 index 000000000..0c3855cc9 --- /dev/null +++ b/testdata/d2oracle/TestSet/edge_set_arrowhead.exp.json @@ -0,0 +1,280 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-1:0:42", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:41:41", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:8:8-0:40:40", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:9:9-0:40:40", + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:9:9-0:31:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:9:9-0:25:25", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:26:26-0:31:31", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:33:33-0:40:40", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "dstArrowhead": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "diamond" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/replace_link.exp.json b/testdata/d2oracle/TestSet/replace_link.exp.json new file mode 100644 index 000000000..a6ad42efe --- /dev/null +++ b/testdata/d2oracle/TestSet/replace_link.exp.json @@ -0,0 +1,151 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-3:0:38", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-2:1:37", + "key": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-0:6:6", + "value": [ + { + "string": "square", + "raw_string": "square" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:8:8-2:0:36", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:2:12-1:25:35", + "key": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:2:12-1:6:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:2:12-1:6:16", + "value": [ + { + "string": "link", + "raw_string": "link" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:8:18-1:25:35", + "value": [ + { + "string": "https://apple.com", + "raw_string": "https://apple.com" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "square", + "id_val": "square", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-0:6:6", + "value": [ + { + "string": "square", + "raw_string": "square" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "square" + }, + "style": {}, + "link": { + "value": "https://apple.com" + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/replace_tooltip.exp.json b/testdata/d2oracle/TestSet/replace_tooltip.exp.json new file mode 100644 index 000000000..7aab2f7e2 --- /dev/null +++ b/testdata/d2oracle/TestSet/replace_tooltip.exp.json @@ -0,0 +1,151 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-3:0:25", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-2:1:24", + "key": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-0:6:6", + "value": [ + { + "string": "square", + "raw_string": "square" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:8:8-2:0:23", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:2:12-1:12:22", + "key": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:2:12-1:9:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:2:12-1:9:19", + "value": [ + { + "string": "tooltip", + "raw_string": "tooltip" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:11:21-1:12:22", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "square", + "id_val": "square", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-0:6:6", + "value": [ + { + "string": "square", + "raw_string": "square" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "square" + }, + "style": {}, + "tooltip": { + "value": "y" + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": "" +}