diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 3094e0819..fdb24e551 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -340,9 +340,6 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) { scalar := f.Primary().Value switch scalar := scalar.(type) { - case *d2ast.Null: - // TODO: Delete instead. - attrs.Label.Value = scalar.ScalarString() case *d2ast.BlockString: if strings.TrimSpace(scalar.ScalarString()) == "" { c.errorf(f.LastPrimaryKey(), "block string cannot be empty") diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index c6cea1b2f..a283166be 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -2743,6 +2743,7 @@ func TestCompile2(t *testing.T) { t.Run("boards", testBoards) t.Run("seqdiagrams", testSeqDiagrams) + t.Run("nulls", testNulls) } func testBoards(t *testing.T) { @@ -2923,6 +2924,237 @@ Office chatter: { }) } +func testNulls(t *testing.T) { + t.Parallel() + + t.Run("basic", func(t *testing.T) { + t.Parallel() + + tca := []struct { + name string + skip bool + run func(t *testing.T) + }{ + { + name: "shape", + run: func(t *testing.T) { + g := assertCompile(t, ` +a +a: null +`, "") + assert.Equal(t, 0, len(g.Objects)) + }, + }, + { + name: "edge", + run: func(t *testing.T) { + g := assertCompile(t, ` +a -> b +(a -> b)[0]: null +`, "") + assert.Equal(t, 2, len(g.Objects)) + assert.Equal(t, 0, len(g.Edges)) + }, + }, + { + name: "attribute", + run: func(t *testing.T) { + g := assertCompile(t, ` +a.style.opacity: 0.2 +a.style.opacity: null + `, "") + assert.Equal(t, (*d2graph.Scalar)(nil), g.Objects[0].Attributes.Style.Opacity) + }, + }, + } + + for _, tc := range tca { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + if tc.skip { + t.SkipNow() + } + tc.run(t) + }) + } + }) + + t.Run("reappear", func(t *testing.T) { + t.Parallel() + + tca := []struct { + name string + skip bool + run func(t *testing.T) + }{ + { + name: "shape", + run: func(t *testing.T) { + g := assertCompile(t, ` +a +a: null +a +`, "") + assert.Equal(t, 1, len(g.Objects)) + }, + }, + { + name: "edge", + run: func(t *testing.T) { + g := assertCompile(t, ` +a -> b +(a -> b)[0]: null +a -> b +`, "") + assert.Equal(t, 2, len(g.Objects)) + assert.Equal(t, 1, len(g.Edges)) + }, + }, + { + name: "attribute-reset", + run: func(t *testing.T) { + g := assertCompile(t, ` +a.style.opacity: 0.2 +a: null +a +`, "") + assert.Equal(t, 1, len(g.Objects)) + assert.Equal(t, (*d2graph.Scalar)(nil), g.Objects[0].Attributes.Style.Opacity) + }, + }, + { + name: "edge-reset", + run: func(t *testing.T) { + g := assertCompile(t, ` +a -> b +a: null +a +`, "") + assert.Equal(t, 2, len(g.Objects)) + assert.Equal(t, 0, len(g.Edges)) + }, + }, + { + name: "children-reset", + run: func(t *testing.T) { + g := assertCompile(t, ` +a.b.c +a.b: null +a.b +`, "") + assert.Equal(t, 2, len(g.Objects)) + }, + }, + } + + for _, tc := range tca { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + if tc.skip { + t.SkipNow() + } + tc.run(t) + }) + } + }) + + t.Run("implicit", func(t *testing.T) { + t.Parallel() + + tca := []struct { + name string + skip bool + run func(t *testing.T) + }{ + { + name: "delete-connection", + run: func(t *testing.T) { + g := assertCompile(t, ` +x -> y +y: null +`, "") + assert.Equal(t, 1, len(g.Objects)) + assert.Equal(t, 0, len(g.Edges)) + }, + }, + { + name: "no-delete-connection", + run: func(t *testing.T) { + g := assertCompile(t, ` +y: null +x -> y +`, "") + assert.Equal(t, 2, len(g.Objects)) + assert.Equal(t, 1, len(g.Edges)) + }, + }, + { + name: "delete-children", + run: func(t *testing.T) { + g := assertCompile(t, ` +x.y.z +a.b.c + +x: null +a.b: null +`, "") + assert.Equal(t, 1, len(g.Objects)) + }, + }, + } + + for _, tc := range tca { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + if tc.skip { + t.SkipNow() + } + tc.run(t) + }) + } + }) + + t.Run("multiboard", func(t *testing.T) { + t.Parallel() + + tca := []struct { + name string + skip bool + run func(t *testing.T) + }{ + { + name: "scenario", + run: func(t *testing.T) { + g := assertCompile(t, ` +x + +scenarios: { + a: { + x: null + } +} +`, "") + assert.Equal(t, 0, len(g.Scenarios[0].Objects)) + }, + }, + } + + for _, tc := range tca { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + if tc.skip { + t.SkipNow() + } + tc.run(t) + }) + } + }) +} + func assertCompile(t *testing.T, text string, expErr string) *d2graph.Graph { d2Path := fmt.Sprintf("d2/testdata/d2compiler/%v.d2", t.Name()) g, err := d2compiler.Compile(d2Path, strings.NewReader(text), nil) diff --git a/d2ir/compile.go b/d2ir/compile.go index 20a03b103..f5d92d043 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -150,6 +150,10 @@ func (c *compiler) compileKey(refctx *RefContext) { } func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) { + if refctx.Key != nil && len(refctx.Key.Edges) == 0 && refctx.Key.Value.Null != nil { + dst.DeleteField(kp.IDA()...) + return + } f, err := dst.EnsureField(kp, refctx) if err != nil { c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) @@ -353,6 +357,11 @@ func (c *compiler) compileEdges(refctx *RefContext) { eida := NewEdgeIDs(refctx.Key) for i, eid := range eida { + if refctx.Key != nil && refctx.Key.Value.Null != nil { + refctx.ScopeMap.DeleteEdge(eid) + continue + } + refctx = refctx.Copy() refctx.Edge = refctx.Key.Edges[i] diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 516c42be4..ab7173c8e 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -190,11 +190,7 @@ func testCompileFields(t *testing.T) { m, err := compile(t, `pq: pq pq: null`) assert.Success(t, err) - assertQuery(t, m, 1, 0, nil, "") - // null doesn't delete pq from *Map so that for language tooling - // we maintain the references. - // Instead d2compiler will ensure it doesn't get rendered. - assertQuery(t, m, 0, 0, nil, "pq") + assertQuery(t, m, 0, 0, nil, "") }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 7234256f7..dc239975a 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -738,6 +738,20 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, return f.Map().ensureField(i+1, kp, refctx) } +func (m *Map) DeleteEdge(eid *EdgeID) *Edge { + if eid == nil { + return nil + } + + for i, e := range m.Edges { + if e.ID.Match(eid) { + m.Edges = append(m.Edges[:i], m.Edges[i+1:]...) + return e + } + } + return nil +} + func (m *Map) DeleteField(ida ...string) *Field { if len(ida) == 0 { return nil @@ -751,7 +765,33 @@ func (m *Map) DeleteField(ida ...string) *Field { continue } if len(rest) == 0 { + for _, fr := range f.References { + for i, e := range m.Edges { + for _, er := range e.References { + if er.Context == fr.Context { + m.DeleteEdge(e.ID) + i-- + break + } + } + } + } m.Fields = append(m.Fields[:i], m.Fields[i+1:]...) + + // If a field was deleted from a keyword-holder keyword and that holder is empty, + // then that holder becomes meaningless and should be deleted too + parent := ParentField(f) + for keyword := range d2graph.ReservedKeywordHolders { + if parent != nil && parent.Name == keyword && len(parent.Map().Fields) == 0 { + styleParentMap := ParentMap(parent) + for i, f := range styleParentMap.Fields { + if f.Name == keyword { + styleParentMap.Fields = append(styleParentMap.Fields[:i], styleParentMap.Fields[i+1:]...) + break + } + } + } + } return f } if f.Map() != nil { diff --git a/testdata/d2compiler/TestCompile2/nulls/basic/attribute.exp.json b/testdata/d2compiler/TestCompile2/nulls/basic/attribute.exp.json new file mode 100644 index 000000000..8b29a9497 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/basic/attribute.exp.json @@ -0,0 +1,205 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,0:0:0-3:3:47", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:0:1-1:20:21", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:0:1-1:15:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:2:3-1:7:8", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:8:9-1:15:16", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:17:18-1:20:21", + "raw": "0.2", + "value": "1/5" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,2:0:22-2:21:43", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,2:0:22-2:15:37", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,2:0:22-2:1:23", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,2:2:24-2:7:29", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,2:8:30-2:15:37", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,2:17:39-2:21:43" + } + } + } + } + ] + }, + "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/nulls/basic/attribute.d2,1:0:1-1:15:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:2:3-1:7:8", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/attribute.d2,1:8:9-1:15:16", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "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 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/nulls/basic/edge.exp.json b/testdata/d2compiler/TestCompile2/nulls/basic/edge.exp.json new file mode 100644 index 000000000..66e103bb6 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/basic/edge.exp.json @@ -0,0 +1,229 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,0:0:0-3:0:26", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,1:0:1-1:6:7", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:0:8-2:17:25", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:1:9-2:7:15", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:1:9-2:2:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:1:9-2:2:10", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:6:14-2:7:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:6:14-2:7:15", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:8:16-2:11:19", + "int": 0, + "glob": false + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.d2,2:13:21-2:17:25" + } + } + } + } + ] + }, + "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/nulls/basic/edge.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.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/nulls/basic/edge.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/edge.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/nulls/basic/shape.exp.json b/testdata/d2compiler/TestCompile2/nulls/basic/shape.exp.json new file mode 100644 index 000000000..4f2c2fd5c --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/basic/shape.exp.json @@ -0,0 +1,87 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,0:0:0-3:0:11", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,1:0:1-1:1:2", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,2:0:3-2:7:10", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,2:0:3-2:1:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,2:0:3-2:1:4", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/basic/shape.d2,2:3:6-2:7:10" + } + } + } + } + ] + }, + "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/nulls/implicit/connection.exp.json b/testdata/d2compiler/TestCompile2/nulls/implicit/connection.exp.json new file mode 100644 index 000000000..bfead385b --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/implicit/connection.exp.json @@ -0,0 +1,156 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,0:0:0-3:0:16", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:0:1-1:6:7", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:0:1-1:1:2", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:5:6-1:6:7", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,2:0:8-2:7:15", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,2:0:8-2:1:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,2:0:8-2:1:9", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,2:3:11-2:7:15" + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/connection.d2,1:0:1-1:1:2", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "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/nulls/implicit/delete-children.exp.json b/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.exp.json new file mode 100644 index 000000000..7d93bdeea --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.exp.json @@ -0,0 +1,260 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,0:0:0-6:0:32", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,1:0:1-1:5:6", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,1:0:1-1:5:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,1:0:1-1:1:2", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,1:2:3-1:3:4", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,1:4:5-1:5:6", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:0:7-2:5:12", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:0:7-2:5:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:0:7-2:1:8", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:2:9-2:3:10", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:4:11-2:5:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,4:0:14-4:7:21", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,4:0:14-4:1:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,4:0:14-4:1:15", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,4:3:17-4:7:21" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,5:0:22-5:9:31", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,5:0:22-5:3:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,5:0:22-5:1:23", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,5:2:24-5:3:25", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,5:5:27-5:9:31" + } + } + } + } + ] + }, + "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/nulls/implicit/delete-children.d2,2:0:7-2:5:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:0:7-2:1:8", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:2:9-2:3:10", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-children.d2,2:4:11-2:5:12", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "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 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.exp.json b/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.exp.json new file mode 100644 index 000000000..62151696b --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.exp.json @@ -0,0 +1,156 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,0:0:0-3:0:16", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:0:1-1:6:7", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:0:1-1:1:2", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:5:6-1:6:7", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,2:0:8-2:7:15", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,2:0:8-2:1:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,2:0:8-2:1:9", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,2:3:11-2:7:15" + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/delete-connection.d2,1:0:1-1:1:2", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "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/nulls/implicit/no-delete-connection.exp.json b/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.exp.json new file mode 100644 index 000000000..c0b0e4fc1 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.exp.json @@ -0,0 +1,232 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,0:0:0-3:0:16", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,1:0:1-1:7:8", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,1:0:1-1:1:2", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,1:3:4-1:7:8" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:0:9-2:6:15", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:0:9-2:6:15", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:0:9-2:1:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:0:9-2:1:10", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:5:14-2:6:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:5:14-2:6:15", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "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": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:0:9-2:1:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:0:9-2:1:10", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:5:14-2:6:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/implicit/no-delete-connection.d2,2:5:14-2:6:15", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "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/nulls/multiboard/scenario.exp.json b/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.exp.json new file mode 100644 index 000000000..9a3a10c59 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.exp.json @@ -0,0 +1,226 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,0:0:0-8:0:42", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,1:0:1-1:1:2", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,1:0:1-1:1:2", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,3:0:4-7:1:41", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,3:0:4-3:9:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,3:0:4-3:9:13", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,3:11:15-7:1:41", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,4:2:19-6:3:39", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,4:2:19-4:3:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,4:2:19-4:3:20", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,4:5:22-6:3:39", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,5:4:28-5:11:35", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,5:4:28-5:5:29", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,5:4:28-5:5:29", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,5:7:31-5:11:35" + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/multiboard/scenario.d2,1:0:1-1:1:2", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "scenarios": [ + { + "name": "a", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": null + }, + "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/nulls/null/basic-shape.exp.json b/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.exp.json new file mode 100644 index 000000000..f7b872984 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.exp.json @@ -0,0 +1,153 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,0:0:0-3:0:11", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,1:0:1-1:1:2", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,2:0:3-2:7:10", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,2:0:3-2:1:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,2:0:3-2:1:4", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,2:3:6-2:7:10" + } + } + } + } + ] + }, + "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/nulls/null/basic-shape.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,2:0:3-2:1:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/null/basic-shape.d2,2:0:3-2:1:4", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "" + }, + "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/nulls/reappear/attribute-reset.exp.json b/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.exp.json new file mode 100644 index 000000000..92f2e464a --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.exp.json @@ -0,0 +1,184 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,0:0:0-4:0:32", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,1:0:1-1:20:21", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,1:0:1-1:15:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,1:2:3-1:7:8", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,1:8:9-1:15:16", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,1:17:18-1:20:21", + "raw": "0.2", + "value": "1/5" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,2:0:22-2:7:29", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,2:0:22-2:1:23", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,2:0:22-2:1:23", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,2:3:25-2:7:29" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,3:0:30-3:1:31", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,3:0:30-3:1:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,3:0:30-3:1:31", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "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/TestCompile2/nulls/reappear/attribute-reset.d2,3:0:30-3:1:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/attribute-reset.d2,3:0:30-3:1:31", + "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 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.exp.json b/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.exp.json new file mode 100644 index 000000000..3e297fcec --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.exp.json @@ -0,0 +1,309 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,0:0:0-4:0:21", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:0:1-1:5:6", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:0:1-1:5:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:2:3-1:3:4", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:4:5-1:5:6", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,2:0:7-2:9:16", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,2:0:7-2:3:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,2:0:7-2:1:8", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,2:2:9-2:3:10", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,2:5:12-2:9:16" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:0:17-3:3:20", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:0:17-3:3:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:0:17-3:1:18", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:2:19-3:3:20", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "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/TestCompile2/nulls/reappear/children-reset.d2,1:0:1-1:5:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:2:3-1:3:4", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,1:4:5-1:5:6", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:0:17-3:3:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:0:17-3:1:18", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:2:19-3:3:20", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:0:17-3:3:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:0:17-3:1:18", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/children-reset.d2,3:2:19-3:3:20", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.exp.json b/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.exp.json new file mode 100644 index 000000000..d6e3860e1 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.exp.json @@ -0,0 +1,224 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,0:0:0-4:0:18", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,1:0:1-1:6:7", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,2:0:8-2:7:15", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,2:0:8-2:1:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,2:0:8-2:1:9", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,2:3:11-2:7:15" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,3:0:16-3:1:17", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,3:0:16-3:1:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,3:0:16-3:1:17", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "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": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.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 + }, + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,3:0:16-3:1:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge-reset.d2,3:0:16-3:1:17", + "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 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/nulls/reappear/edge.exp.json b/testdata/d2compiler/TestCompile2/nulls/reappear/edge.exp.json new file mode 100644 index 000000000..f22a53468 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/reappear/edge.exp.json @@ -0,0 +1,346 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,0:0:0-4:0:33", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:0:1-1:6:7", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:0:1-1:6:7", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:0:8-2:17:25", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:1:9-2:7:15", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:1:9-2:2:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:1:9-2:2:10", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:6:14-2:7:15", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:6:14-2:7:15", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:8:16-2:11:19", + "int": 0, + "glob": false + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,2:13:21-2:17:25" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:0:26-3:6:32", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:0:26-3:6:32", + "src": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:0:26-3:1:27", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:0:26-3:1:27", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:5:31-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:5:31-3:6:32", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "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": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:0:26-3:1:27", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:0:26-3:1:27", + "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/nulls/reappear/edge.d2,1:5:6-1:6:7", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,1:5:6-1:6:7", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:5:31-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/edge.d2,3:5:31-3:6:32", + "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/nulls/reappear/reset.exp.json b/testdata/d2compiler/TestCompile2/nulls/reappear/reset.exp.json new file mode 100644 index 000000000..cc7592209 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/reappear/reset.exp.json @@ -0,0 +1,184 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,0:0:0-4:0:32", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,1:0:1-1:20:21", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,1:0:1-1:15:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,1:2:3-1:7:8", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,1:8:9-1:15:16", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,1:17:18-1:20:21", + "raw": "0.2", + "value": "1/5" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,2:0:22-2:7:29", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,2:0:22-2:1:23", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,2:0:22-2:1:23", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,2:3:25-2:7:29" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,3:0:30-3:1:31", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,3:0:30-3:1:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,3:0:30-3:1:31", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "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/TestCompile2/nulls/reappear/reset.d2,3:0:30-3:1:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/reset.d2,3:0:30-3:1:31", + "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 + } + ] + }, + "err": null +} diff --git a/testdata/d2compiler/TestCompile2/nulls/reappear/shape.exp.json b/testdata/d2compiler/TestCompile2/nulls/reappear/shape.exp.json new file mode 100644 index 000000000..744b757f3 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/nulls/reappear/shape.exp.json @@ -0,0 +1,156 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,0:0:0-4:0:13", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,1:0:1-1:1:2", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,1:0:1-1:1:2", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,1:0:1-1:1:2", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,2:0:3-2:7:10", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,2:0:3-2:1:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,2:0:3-2:1:4", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,2:3:6-2:7:10" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,3:0:11-3:1:12", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,3:0:11-3:1:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,3:0:11-3:1:12", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "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/TestCompile2/nulls/reappear/shape.d2,3:0:11-3:1:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,3:0:11-3:1:12", + "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 + } + ] + }, + "err": null +} diff --git a/testdata/d2ir/TestCompile/fields/null.exp.json b/testdata/d2ir/TestCompile/fields/null.exp.json index 022cb550c..e7db96e23 100644 --- a/testdata/d2ir/TestCompile/fields/null.exp.json +++ b/testdata/d2ir/TestCompile/fields/null.exp.json @@ -1,131 +1,4 @@ { - "fields": [ - { - "name": "pq", - "primary": { - "value": { - "range": "TestCompile/fields/null.d2,1:4:11-1:8:15" - } - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", - "value": [ - { - "string": "pq", - "raw_string": "pq" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", - "value": [ - { - "string": "pq", - "raw_string": "pq" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/fields/null.d2,0:0:0-0:6:6", - "key": { - "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", - "value": [ - { - "string": "pq", - "raw_string": "pq" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/null.d2,0:4:4-0:6:6", - "value": [ - { - "string": "pq", - "raw_string": "pq" - } - ] - } - } - } - } - }, - { - "string": { - "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", - "value": [ - { - "string": "pq", - "raw_string": "pq" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", - "value": [ - { - "string": "pq", - "raw_string": "pq" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/fields/null.d2,1:0:7-1:8:15", - "key": { - "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", - "value": [ - { - "string": "pq", - "raw_string": "pq" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "null": { - "range": "TestCompile/fields/null.d2,1:4:11-1:8:15" - } - } - } - } - } - ] - } - ], + "fields": [], "edges": null }