diff --git a/d2compiler/compile.go b/d2compiler/compile.go index df750cc7a..3094e0819 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -726,6 +726,7 @@ func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { MapKey: er.Context.Key, MapKeyEdgeIndex: er.Context.EdgeIndex(), Scope: er.Context.Scope, + ScopeAST: er.Context.ScopeAST, } if er.Context.ScopeMap != nil { scopeObjIDA := d2graphIDA(d2ir.BoardIDA(er.Context.ScopeMap)) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index b65270ffe..eb47de274 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1117,6 +1117,7 @@ type EdgeReference struct { MapKeyEdgeIndex int `json:"map_key_edge_index"` Scope *d2ast.Map `json:"-"` ScopeObj *Object `json:"-"` + ScopeAST *d2ast.Map `json:"-"` } func (e *Edge) GetAstEdge() *d2ast.Edge { diff --git a/d2oracle/edit.go b/d2oracle/edit.go index 5ca66601d..3bf8ec541 100644 --- a/d2oracle/edit.go +++ b/d2oracle/edit.go @@ -115,7 +115,7 @@ func Set(g *d2graph.Graph, boardPath []string, key string, tag, value *string) ( return recompile(g.AST) } -func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ *d2graph.Graph, err error) { +func ReconnectEdge(g *d2graph.Graph, boardPath []string, edgeKey string, srcKey, dstKey *string) (_ *d2graph.Graph, err error) { mk, err := d2parser.ParseMapKey(edgeKey) if err != nil { return nil, err @@ -130,10 +130,24 @@ func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ } edgeTrimCommon(mk) - obj := g.Root + + boardG := g + baseAST := g.AST + + if len(boardPath) > 0 { + // When compiling a nested board, we can read from boardG but only write to baseBoardG + boardG = GetBoardGraph(g, boardPath) + if boardG == nil { + return nil, fmt.Errorf("board %v not found", boardPath) + } + // TODO beter name + baseAST = boardG.BaseAST + } + + obj := boardG.Root if mk.Key != nil { var ok bool - obj, ok = g.Root.HasChild(d2graph.Key(mk.Key)) + obj, ok = boardG.Root.HasChild(d2graph.Key(mk.Key)) if !ok { return nil, errors.New("edge not found") } @@ -167,7 +181,7 @@ func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ if err != nil { return nil, err } - src, ok = g.Root.HasChild(d2graph.Key(srcmk.Key)) + src, ok = boardG.Root.HasChild(d2graph.Key(srcmk.Key)) if !ok { return nil, errors.New("newSrc not found") } @@ -177,18 +191,26 @@ func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ if err != nil { return nil, err } - dst, ok = g.Root.HasChild(d2graph.Key(dstmk.Key)) + dst, ok = boardG.Root.HasChild(d2graph.Key(dstmk.Key)) if !ok { return nil, errors.New("newDst not found") } } - ref := edge.References[0] + refs := edge.References + if baseAST != g.AST { + refs = getWriteableEdgeRefs(edge, baseAST) + if len(refs) == 0 || refs[0].ScopeAST != baseAST { + // TODO null + return nil, OutsideScopeError{} + } + } + ref := refs[0] // for loops where only one end is changing, node is always ensured if edge.Src != edge.Dst && (srcKey == nil || dstKey == nil) { var refEdges []*d2ast.Edge - for _, ref := range edge.References { + for _, ref := range refs { refEdges = append(refEdges, ref.Edge) } @@ -200,8 +222,8 @@ func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ } } - for i := range edge.References { - ref := edge.References[i] + for i := range refs { + ref := refs[i] // it's a chain if len(ref.MapKey.Edges) > 1 && ref.MapKey.EdgeIndex == nil { splitChain := true @@ -232,7 +254,7 @@ func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ if src != nil { srcmk, _ := d2parser.ParseMapKey(*srcKey) ref.Edge.Src = srcmk.Key - newPath, err := pathFromScopeObj(g, srcmk, ref.ScopeObj) + newPath, err := pathFromScopeObj(boardG, srcmk, ref.ScopeObj) if err != nil { return nil, err } @@ -241,7 +263,7 @@ func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ if dst != nil { dstmk, _ := d2parser.ParseMapKey(*dstKey) ref.Edge.Dst = dstmk.Key - newPath, err := pathFromScopeObj(g, dstmk, ref.ScopeObj) + newPath, err := pathFromScopeObj(boardG, dstmk, ref.ScopeObj) if err != nil { return nil, err } @@ -445,14 +467,20 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string) if !ok { return errors.New("edge not found") } + refs := edge.References + if baseAST != g.AST { + refs = getWriteableEdgeRefs(edge, baseAST) + } onlyInChain := true - for _, ref := range edge.References { + for _, ref := range refs { // TODO merge flat edgekeys // E.g. this can group into a map // (y -> z)[0].style.opacity: 0.4 // (y -> z)[0].style.animated: true - if len(ref.MapKey.Edges) == 1 && ref.MapKey.EdgeIndex == nil { - onlyInChain = false + if len(ref.MapKey.Edges) == 1 { + if ref.MapKey.EdgeIndex == nil || ref.MapKey.Value.Map != nil { + onlyInChain = false + } } // If a ref has an exact match on this key, just change the value tmp1 := *ref.MapKey @@ -485,7 +513,7 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string) } foundMap := false - for _, ref := range edge.References { + for _, ref := range refs { // TODO get the most nested one if ref.MapKey.Value.Map != nil { foundMap = true @@ -1374,6 +1402,7 @@ func deleteEdge(g *d2graph.Graph, scope *d2ast.Map, mk *d2ast.Key, i int) { } } +// ensureNode ensures that `k` exists in `scope` if `excludedEdges` were removed func ensureNode(g *d2graph.Graph, excludedEdges []*d2ast.Edge, scopeObj *d2graph.Object, scope *d2ast.Map, cursor *d2ast.Key, k *d2ast.KeyPath, before bool) { if k == nil || len(k.Path) == 0 { return @@ -1421,7 +1450,7 @@ func ensureNode(g *d2graph.Graph, excludedEdges []*d2ast.Edge, scopeObj *d2graph } } -func Rename(g *d2graph.Graph, key, newName string) (_ *d2graph.Graph, newKey string, err error) { +func Rename(g *d2graph.Graph, boardPath []string, key, newName string) (_ *d2graph.Graph, newKey string, err error) { defer xdefer.Errorf(&err, "failed to rename %#v to %#v", key, newName) mk, err := d2parser.ParseMapKey(key) @@ -1429,6 +1458,15 @@ func Rename(g *d2graph.Graph, key, newName string) (_ *d2graph.Graph, newKey str return nil, "", err } + boardG := g + + if len(boardPath) > 0 { + boardG = GetBoardGraph(g, boardPath) + if boardG == nil { + return nil, "", fmt.Errorf("board %v not found", boardPath) + } + } + if len(mk.Edges) > 0 && mk.EdgeKey == nil { // TODO: Not a fan of this dual interpretation depending on mk.Edges. // Maybe we remove Rename and just have Move. @@ -1445,12 +1483,12 @@ func Rename(g *d2graph.Graph, key, newName string) (_ *d2graph.Graph, newKey str return nil, "", fmt.Errorf("cannot rename to reserved keyword: %#v", newName) } if mk.Key != nil { - obj, ok := g.Root.HasChild(d2graph.Key(mk.Key)) + obj, ok := boardG.Root.HasChild(d2graph.Key(mk.Key)) if !ok { return nil, "", fmt.Errorf("key does not exist") } // If attempt to name something "x", but "x" already exists, rename it "x 2" instead - generatedName, _, err := generateUniqueKey(g, newName, obj, nil) + generatedName, _, err := generateUniqueKey(boardG, newName, obj, nil) if err == nil { newName = generatedName } @@ -1459,8 +1497,7 @@ func Rename(g *d2graph.Graph, key, newName string) (_ *d2graph.Graph, newKey str mk.Key.Path[len(mk.Key.Path)-1] = d2ast.MakeValueBox(d2ast.RawString(newName, true)).StringBox() } - // TODO - g, err = move(g, nil, key, d2format.Format(mk), false) + g, err = move(g, boardPath, key, d2format.Format(mk), false) return g, newName, err } @@ -2188,7 +2225,7 @@ func ReparentIDDelta(g *d2graph.Graph, key, parentKey string) (string, error) { return id, nil } -func ReconnectEdgeIDDeltas(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (deltas map[string]string, err error) { +func ReconnectEdgeIDDeltas(g *d2graph.Graph, boardPath []string, edgeKey string, srcKey, dstKey *string) (deltas map[string]string, err error) { defer xdefer.Errorf(&err, "failed to get deltas for reconnect edge %#v", edgeKey) deltas = make(map[string]string) // Reconnection: nothing is created or destroyed, the edge just gets a new ID @@ -2214,10 +2251,21 @@ func ReconnectEdgeIDDeltas(g *d2graph.Graph, edgeKey string, srcKey, dstKey *str } edgeTrimCommon(mk) - obj := g.Root + + boardG := g + + if len(boardPath) > 0 { + // When compiling a nested board, we can read from boardG but only write to baseBoardG + boardG = GetBoardGraph(g, boardPath) + if boardG == nil { + return nil, fmt.Errorf("board %v not found", boardPath) + } + } + + obj := boardG.Root if mk.Key != nil { var ok bool - obj, ok = g.Root.HasChild(d2graph.Key(mk.Key)) + obj, ok = boardG.Root.HasChild(d2graph.Key(mk.Key)) if !ok { return nil, errors.New("edge not found") } @@ -2252,7 +2300,7 @@ func ReconnectEdgeIDDeltas(g *d2graph.Graph, edgeKey string, srcKey, dstKey *str if err != nil { return nil, err } - src, ok = g.Root.HasChild(d2graph.Key(srcmk.Key)) + src, ok = boardG.Root.HasChild(d2graph.Key(srcmk.Key)) if !ok { return nil, errors.New("newSrc not found") } @@ -2263,7 +2311,7 @@ func ReconnectEdgeIDDeltas(g *d2graph.Graph, edgeKey string, srcKey, dstKey *str if err != nil { return nil, err } - dst, ok = g.Root.HasChild(d2graph.Key(dstmk.Key)) + dst, ok = boardG.Root.HasChild(d2graph.Key(dstmk.Key)) if !ok { return nil, errors.New("newDst not found") } @@ -2276,7 +2324,7 @@ func ReconnectEdgeIDDeltas(g *d2graph.Graph, edgeKey string, srcKey, dstKey *str newIndex := 0 // For the edge's own delta, it just needs to know how many edges came before it with the same src and dst - for _, otherEdge := range g.Edges { + for _, otherEdge := range boardG.Edges { if otherEdge.Src == newSrc && otherEdge.Dst == newDst { firstRef := otherEdge.References[0] if firstRef.MapKey.Range.Start.Line <= line { @@ -2827,7 +2875,7 @@ func DeleteIDDeltas(g *d2graph.Graph, key string) (deltas map[string]string, err return deltas, nil } -func RenameIDDeltas(g *d2graph.Graph, key, newName string) (deltas map[string]string, err error) { +func RenameIDDeltas(g *d2graph.Graph, boardPath []string, key, newName string) (deltas map[string]string, err error) { defer xdefer.Errorf(&err, "failed to get deltas for renaming of %#v to %#v", key, newName) deltas = make(map[string]string) @@ -2836,11 +2884,19 @@ func RenameIDDeltas(g *d2graph.Graph, key, newName string) (deltas map[string]st return nil, err } + boardG := g + if len(boardPath) > 0 { + boardG = GetBoardGraph(g, boardPath) + if boardG == nil { + return nil, fmt.Errorf("board %v not found", boardPath) + } + } + edgeTrimCommon(mk) - obj := g.Root + obj := boardG.Root if mk.Key != nil { var ok bool - obj, ok = g.Root.HasChild(d2graph.Key(mk.Key)) + obj, ok = boardG.Root.HasChild(d2graph.Key(mk.Key)) if !ok { return nil, nil } @@ -2878,7 +2934,7 @@ func RenameIDDeltas(g *d2graph.Graph, key, newName string) (deltas map[string]st } mk.Key.Path[len(mk.Key.Path)-1].Unbox().SetString(newName) - uniqueKeyStr, _, err := generateUniqueKey(g, strings.Join(d2graph.Key(mk.Key), "."), obj, nil) + uniqueKeyStr, _, err := generateUniqueKey(boardG, strings.Join(d2graph.Key(mk.Key), "."), obj, nil) if err != nil { return nil, err } @@ -3001,3 +3057,12 @@ func getWriteableRefs(obj *d2graph.Object, writeableAST *d2ast.Map) (out []d2gra } return } + +func getWriteableEdgeRefs(edge *d2graph.Edge, writeableAST *d2ast.Map) (out []d2graph.EdgeReference) { + for i, ref := range edge.References { + if ref.ScopeAST == writeableAST { + out = append(out, edge.References[i]) + } + } + return +} diff --git a/d2oracle/edit_test.go b/d2oracle/edit_test.go index aece05656..bf4d864a1 100644 --- a/d2oracle/edit_test.go +++ b/d2oracle/edit_test.go @@ -1897,6 +1897,93 @@ scenarios: { a: b } } +`, + }, + { + name: "scenarios-edge-set", + + text: `a -> b + +scenarios: { + x: { + c + } +} +`, + key: `(a -> b)[0].style.opacity`, + value: go2.Pointer(`0.2`), + boardPath: []string{"x"}, + + exp: `a -> b + +scenarios: { + x: { + c + (a -> b)[0].style.opacity: 0.2 + } +} +`, + }, + { + name: "scenarios-existing-edge-set", + + text: `a -> b + +scenarios: { + x: { + a -> b + c + } +} +`, + key: `(a -> b)[1].style.opacity`, + value: go2.Pointer(`0.2`), + boardPath: []string{"x"}, + + exp: `a -> b + +scenarios: { + x: { + a -> b: {style.opacity: 0.2} + c + } +} +`, + }, + { + name: "scenarios-arrowhead", + + text: `a -> b: { + target-arrowhead.shape: triangle +} +x -> y + +scenarios: { + x: { + (a -> b)[0]: { + target-arrowhead.shape: circle + } + c -> d + } +} +`, + key: `(a -> b)[0].target-arrowhead.shape`, + value: go2.Pointer(`diamond`), + boardPath: []string{"x"}, + + exp: `a -> b: { + target-arrowhead.shape: triangle +} +x -> y + +scenarios: { + x: { + (a -> b)[0]: { + target-arrowhead.shape: diamond + } + c -> d + } +} `, }, } @@ -1925,11 +2012,12 @@ func TestReconnectEdge(t *testing.T) { t.Parallel() testCases := []struct { - name string - text string - edgeKey string - newSrc string - newDst string + name string + boardPath []string + text string + edgeKey string + newSrc string + newDst string expErr string exp string @@ -2196,6 +2284,96 @@ x newDst: "x", expErr: "newDst not found", }, + { + name: "layers-basic", + text: `a + +layers: { + x: { + b + c + a -> b + } +} +`, + boardPath: []string{"x"}, + edgeKey: `(a -> b)[0]`, + newDst: "c", + exp: `a + +layers: { + x: { + b + c + a -> c + } +} +`, + }, + { + name: "scenarios-basic", + text: `a + +scenarios: { + x: { + b + c + a -> b + } +} +`, + boardPath: []string{"x"}, + edgeKey: `(a -> b)[0]`, + newDst: "c", + exp: `a + +scenarios: { + x: { + b + c + a -> c + } +} +`, + }, + { + name: "scenarios-outer-scope", + text: `a + +scenarios: { + x: { + d -> b + } +} +`, + boardPath: []string{"x"}, + edgeKey: `(d -> b)[0]`, + newDst: "a", + exp: `a + +scenarios: { + x: { + d -> a + b + } +} +`, + }, + { + name: "scenarios-chain", + text: `a -> b -> c + +scenarios: { + x: { + d + } +} +`, + boardPath: []string{"x"}, + edgeKey: `(a -> b)[0]`, + newDst: "d", + expErr: `operation would modify AST outside of given scope`, + }, } for _, tc := range testCases { @@ -2214,7 +2392,7 @@ x if tc.newDst != "" { newDst = &tc.newDst } - return d2oracle.ReconnectEdge(g, tc.edgeKey, newSrc, newDst) + return d2oracle.ReconnectEdge(g, tc.boardPath, tc.edgeKey, newSrc, newDst) }, exp: tc.exp, @@ -2230,7 +2408,8 @@ func TestRename(t *testing.T) { t.Parallel() testCases := []struct { - name string + name string + boardPath []string text string key string @@ -2646,6 +2825,95 @@ more.(ok.q.z -> p.k): "furbling, v.:" newName: "near", expErr: `failed to rename "x.icon" to "near": cannot rename to reserved keyword: "near"`, }, + { + name: "layers-basic", + + text: `x + +layers: { + y: { + a + } +} +`, + boardPath: []string{"y"}, + key: "a", + newName: "b", + + exp: `x + +layers: { + y: { + b + } +} +`, + }, + { + name: "scenarios-basic", + + text: `x + +scenarios: { + y: { + a + } +} +`, + boardPath: []string{"y"}, + key: "a", + newName: "b", + + exp: `x + +scenarios: { + y: { + b + } +} +`, + }, + { + name: "scenarios-conflict", + + text: `x + +scenarios: { + y: { + a + } +} +`, + boardPath: []string{"y"}, + key: "a", + newName: "x", + + exp: `x + +scenarios: { + y: { + x 2 + } +} +`, + }, + { + name: "scenarios-scope-err", + + text: `x + +scenarios: { + y: { + a + } +} +`, + boardPath: []string{"y"}, + key: "x", + newName: "b", + + expErr: `failed to rename "x" to "b": operation would modify AST outside of given scope`, + }, } for _, tc := range testCases { @@ -2658,7 +2926,7 @@ more.(ok.q.z -> p.k): "furbling, v.:" testFunc: func(g *d2graph.Graph) (*d2graph.Graph, error) { objectsBefore := len(g.Objects) var err error - g, _, err = d2oracle.Rename(g, tc.key, tc.newName) + g, _, err = d2oracle.Rename(g, tc.boardPath, tc.key, tc.newName) if err == nil { objectsAfter := len(g.Objects) if objectsBefore != objectsAfter { @@ -6753,10 +7021,11 @@ func TestReconnectEdgeIDDeltas(t *testing.T) { testCases := []struct { name string - text string - edge string - newSrc string - newDst string + boardPath []string + text string + edge string + newSrc string + newDst string exp string expErr string @@ -6913,6 +7182,42 @@ b exp: `{ "(a -> c)[0]": "(a -> b)[0]", "(a -> c)[1]": "(a -> c)[0]" +}`, + }, + { + name: "scenarios-outer-scope", + text: `a + +scenarios: { + x: { + d -> b + } +} +`, + boardPath: []string{"x"}, + edge: `(d -> b)[0]`, + newDst: "a", + exp: `{ + "(d -> b)[0]": "(d -> a)[0]" +}`, + }, + { + name: "scenarios-second", + text: `g +a -> b +d + +scenarios: { + x: { + d -> b + } +} +`, + boardPath: []string{"x"}, + edge: `(d -> b)[0]`, + newSrc: "a", + exp: `{ + "(d -> b)[0]": "(a -> b)[1]" }`, }, } @@ -6937,7 +7242,7 @@ b newDst = &tc.newDst } - deltas, err := d2oracle.ReconnectEdgeIDDeltas(g, tc.edge, newSrc, newDst) + deltas, err := d2oracle.ReconnectEdgeIDDeltas(g, tc.boardPath, tc.edge, newSrc, newDst) if tc.expErr != "" { if err == nil { t.Fatalf("expected error with: %q", tc.expErr) @@ -7756,9 +8061,10 @@ func TestRenameIDDeltas(t *testing.T) { testCases := []struct { name string - text string - key string - newName string + boardPath []string + text string + key string + newName string exp string expErr string @@ -7884,6 +8190,44 @@ x.y.z.w.e.p.l -> x.y.z.1.2.3.4 exp: `{ "x.y.z.(w.e.p.l -> 1.2.3.4)[1]": "x.y.z.(w.e.p.l <-> 1.2.3.4)[1]" +}`, + }, + { + name: "layers-basic", + + text: `x + +layers: { + y: { + a + } +} +`, + boardPath: []string{"y"}, + key: "a", + newName: "b", + + exp: `{ + "a": "b" +}`, + }, + { + name: "scenarios-conflict", + + text: `x + +scenarios: { + y: { + a + } +} +`, + boardPath: []string{"y"}, + key: "a", + newName: "x", + + exp: `{ + "a": "x 2" }`, }, } @@ -7899,7 +8243,7 @@ x.y.z.w.e.p.l -> x.y.z.1.2.3.4 t.Fatal(err) } - deltas, err := d2oracle.RenameIDDeltas(g, tc.key, tc.newName) + deltas, err := d2oracle.RenameIDDeltas(g, tc.boardPath, tc.key, tc.newName) if tc.expErr != "" { if err == nil { t.Fatalf("expected error with: %q", tc.expErr) diff --git a/testdata/d2oracle/TestReconnectEdge/layers-basic.exp.json b/testdata/d2oracle/TestReconnectEdge/layers-basic.exp.json new file mode 100644 index 000000000..6e537fb03 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/layers-basic.exp.json @@ -0,0 +1,589 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,0:0:0-9:0:49", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,2:0:3-8:1:48", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,2:8:11-8:1:48", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,3:2:15-7:3:46", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,3:2:15-3:3:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,3:5:18-7:3:46", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,4:4:24-4:5:25", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,4:4:24-4:5:25", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,5:4:30-5:5:31", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,5:4:30-5:5:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,5:4:30-5:5:31", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:4:36-6:10:42", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:4:36-6:10:42", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:4:36-6:5:37", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:4:36-6:5:37", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:9:41-6:10:42", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:9:41-6:10:42", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "layers": [ + { + "name": "x", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "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": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,4:4:24-4:5:25", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,5:4:30-5:5:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,5:4:30-5:5:31", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:9:41-6:10:42", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:9:41-6:10:42", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:4:36-6:5:37", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/layers-basic.d2,6:4:36-6:5:37", + "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 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/scenarios-basic.exp.json b/testdata/d2oracle/TestReconnectEdge/scenarios-basic.exp.json new file mode 100644 index 000000000..983bd873c --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/scenarios-basic.exp.json @@ -0,0 +1,609 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-9:0:52", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,2:0:3-8:1:51", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,2:0:3-2:9:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,2:0:3-2:9:12", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,2:11:14-8:1:51", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,3:2:18-7:3:49", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,3:2:18-3:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,3:2:18-3:3:19", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,3:5:21-7:3:49", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,4:4:27-4:5:28", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,4:4:27-4:5:28", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,5:4:33-5:5:34", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,5:4:33-5:5:34", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,5:4:33-5:5:34", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:4:39-6:10:45", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:4:39-6:10:45", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:4:39-6:5:40", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:4:39-6:5:40", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:9:44-6:10:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:9:44-6:10:45", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "scenarios": [ + { + "name": "x", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "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/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:4:39-6:5:40", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:4:39-6:5:40", + "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/d2oracle/TestReconnectEdge/scenarios-basic.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,4:4:27-4:5:28", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,5:4:33-5:5:34", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,5:4:33-5:5:34", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:9:44-6:10:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-basic.d2,6:9:44-6:10:45", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestReconnectEdge/scenarios-chain.exp.json b/testdata/d2oracle/TestReconnectEdge/scenarios-chain.exp.json new file mode 100644 index 000000000..b9a53f907 --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/scenarios-chain.exp.json @@ -0,0 +1,4 @@ +{ + "graph": null, + "err": "d2oracle.OutsideScopeError{}" +} diff --git a/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.exp.json b/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.exp.json new file mode 100644 index 000000000..0f368f97c --- /dev/null +++ b/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.exp.json @@ -0,0 +1,566 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-8:0:46", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,2:0:3-7:1:45", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,2:0:3-2:9:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,2:0:3-2:9:12", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,2:11:14-7:1:45", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,3:2:18-6:3:43", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,3:2:18-3:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,3:2:18-3:3:19", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,3:5:21-6:3:43", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:4:27-4:10:33", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:4:27-4:10:33", + "src": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:4:27-4:5:28", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:9:32-4:10:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:9:32-4:10:33", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,5:4:38-5:5:39", + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,5:4:38-5:5:39", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,5:4:38-5:5:39", + "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/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "scenarios": [ + { + "name": "x", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "d" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "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/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:9:32-4:10:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:9:32-4:10:33", + "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": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,4:4:27-4:5:28", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,5:4:38-5:5:39", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestReconnectEdge/scenarios-outer-scope.d2,5:4:38-5:5:39", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestRename/layers-basic.exp.json b/testdata/d2oracle/TestRename/layers-basic.exp.json new file mode 100644 index 000000000..043603d54 --- /dev/null +++ b/testdata/d2oracle/TestRename/layers-basic.exp.json @@ -0,0 +1,291 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,0:0:0-7:0:32", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,2:0:3-6:1:31", + "key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,2:8:11-6:1:31", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,3:2:15-5:3:29", + "key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,3:2:15-3:3:16", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,3:5:18-5:3:29", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,4:4:24-4:5:25", + "key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,4:4:24-4:5:25", + "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": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,0:0:0-0:1:1", + "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 + } + ], + "layers": [ + { + "name": "y", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "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/d2oracle/TestRename/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/layers-basic.d2,4:4:24-4:5:25", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestRename/scenarios-basic.exp.json b/testdata/d2oracle/TestRename/scenarios-basic.exp.json new file mode 100644 index 000000000..6e32f9fd3 --- /dev/null +++ b/testdata/d2oracle/TestRename/scenarios-basic.exp.json @@ -0,0 +1,358 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-7:0:35", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,2:0:3-6:1:34", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,2:0:3-2:9:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,2:0:3-2:9:12", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,2:11:14-6:1:34", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,3:2:18-5:3:32", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,3:2:18-3:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,3:2:18-3:3:19", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,3:5:21-5:3:32", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,4:4:27-4:5:28", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,4:4:27-4:5:28", + "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": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-0:1:1", + "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": "y", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "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": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,0:0:0-0:1:1", + "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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-basic.d2,4:4:27-4:5:28", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestRename/scenarios-conflict.exp.json b/testdata/d2oracle/TestRename/scenarios-conflict.exp.json new file mode 100644 index 000000000..3d7328605 --- /dev/null +++ b/testdata/d2oracle/TestRename/scenarios-conflict.exp.json @@ -0,0 +1,358 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-7:0:37", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,2:0:3-6:1:36", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,2:0:3-2:9:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,2:0:3-2:9:12", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,2:11:14-6:1:36", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,3:2:18-5:3:34", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,3:2:18-3:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,3:2:18-3:3:19", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,3:5:21-5:3:34", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,4:4:27-4:7:30", + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,4:4:27-4:7:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,4:4:27-4:7:30", + "value": [ + { + "string": "x 2", + "raw_string": "x 2" + } + ] + } + } + ] + }, + "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": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-0:1:1", + "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": "y", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x 2" + } + ] + } + } + ] + }, + "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": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,0:0:0-0:1:1", + "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 + }, + { + "id": "x 2", + "id_val": "x 2", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,4:4:27-4:7:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestRename/scenarios-conflict.d2,4:4:27-4:7:30", + "value": [ + { + "string": "x 2", + "raw_string": "x 2" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x 2" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestRename/scenarios-scope-err.exp.json b/testdata/d2oracle/TestRename/scenarios-scope-err.exp.json new file mode 100644 index 000000000..ec0686ae6 --- /dev/null +++ b/testdata/d2oracle/TestRename/scenarios-scope-err.exp.json @@ -0,0 +1,4 @@ +{ + "graph": null, + "err": "failed to rename \"x\" to \"b\": operation would modify AST outside of given scope" +} diff --git a/testdata/d2oracle/TestSet/scenarios-arrowhead.exp.json b/testdata/d2oracle/TestSet/scenarios-arrowhead.exp.json new file mode 100644 index 000000000..168961d59 --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-arrowhead.exp.json @@ -0,0 +1,1433 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-13:0:155", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-2:1:46", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:8:8-2:1:46", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,1:2:12-1:34:44", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,1:2:12-1:24:34", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,1:2:12-1:18:28", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,1:19:29-1:24:34", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,1:26:36-1:34:44", + "value": [ + { + "string": "triangle", + "raw_string": "triangle" + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:6:53", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:6:53", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:1:48", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:1:48", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:5:52-3:6:53", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:5:52-3:6:53", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,5:0:55-12:1:154", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,5:0:55-5:9:64", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,5:0:55-5:9:64", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,5:11:66-12:1:154", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,6:2:70-11:3:152", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,6:2:70-6:3:71", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,6:2:70-6:3:71", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,6:5:73-11:3:152", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:4:79-9:5:137", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:5:80-7:11:86", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:5:80-7:6:81", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:5:80-7:6:81", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:10:85-7:11:86", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:10:85-7:11:86", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:12:87-7:15:90", + "int": 0, + "glob": false + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:17:92-9:5:137", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,8:6:100-8:37:131", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,8:6:100-8:28:122", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,8:6:100-8:22:116", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,8:23:117-8:28:122", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,8:30:124-8:37:131", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:4:142-10:10:148", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:4:142-10:10:148", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:4:142-10:5:143", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:4:142-10:5:143", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:9:147-10:10:148", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:9:147-10:10:148", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "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, + "dstArrowhead": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "triangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-0:1:1", + "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/d2oracle/TestSet/scenarios-arrowhead.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:5:5-0:6:6", + "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": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:1:48", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:1:48", + "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/d2oracle/TestSet/scenarios-arrowhead.d2,3:5:52-3:6:53", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:5:52-3:6:53", + "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 + } + ], + "scenarios": [ + { + "name": "x", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "target-arrowhead" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "shape" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,8:30:124-8:37:131", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + }, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "d" + } + ] + } + } + ] + }, + "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, + "dstArrowhead": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "diamond" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "references": [ + { + "map_key_edge_index": 0 + }, + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "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/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:5:80-7:6:81", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:5:80-7:6:81", + "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/d2oracle/TestSet/scenarios-arrowhead.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:10:85-7:11:86", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,7:10:85-7:11:86", + "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": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:1:48", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:0:47-3:1:48", + "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/d2oracle/TestSet/scenarios-arrowhead.d2,3:5:52-3:6:53", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,3:5:52-3:6:53", + "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 + }, + { + "id": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:4:142-10:5:143", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:4:142-10:5:143", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:9:147-10:10:148", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-arrowhead.d2,10:9:147-10:10:148", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/scenarios-edge-set.exp.json b/testdata/d2oracle/TestSet/scenarios-edge-set.exp.json new file mode 100644 index 000000000..8ea7ca279 --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-edge-set.exp.json @@ -0,0 +1,792 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-8:0:75", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,2:0:8-7:1:74", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,2:0:8-2:9:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,2:0:8-2:9:17", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,2:11:19-7:1:74", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,3:2:23-6:3:72", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,3:2:23-3:3:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,3:2:23-3:3:24", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,3:5:26-6:3:72", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,4:4:32-4:5:33", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,4:4:32-4:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,4:4:32-4:5:33", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:4:38-5:34:68", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:5:39-5:11:45", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:5:39-5:6:40", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:5:39-5:6:40", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:10:44-5:11:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:10:44-5:11:45", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:12:46-5:15:49", + "int": 0, + "glob": false + }, + "edge_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:16:50-5:29:63", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:16:50-5:21:55", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:22:56-5:29:63", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:31:65-5:34:68", + "raw": "0.2", + "value": "1/5" + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "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/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:1:1", + "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/d2oracle/TestSet/scenarios-edge-set.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:5:5-0:6:6", + "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 + } + ], + "scenarios": [ + { + "name": "x", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "opacity" + } + ] + } + } + ] + }, + "primary": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:31:65-5:34:68", + "raw": "0.2", + "value": "1/5" + } + }, + "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 + }, + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.2" + } + }, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:5:39-5:6:40", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:5:39-5:6:40", + "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/d2oracle/TestSet/scenarios-edge-set.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:10:44-5:11:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,5:10:44-5:11:45", + "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": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,4:4:32-4:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-edge-set.d2,4:4:32-4:5:33", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/scenarios-existing-edge-set.exp.json b/testdata/d2oracle/TestSet/scenarios-existing-edge-set.exp.json new file mode 100644 index 000000000..0294a412c --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-existing-edge-set.exp.json @@ -0,0 +1,871 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-8:0:73", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,2:0:8-7:1:72", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,2:0:8-2:9:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,2:0:8-2:9:17", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,2:11:19-7:1:72", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,3:2:23-6:3:70", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,3:2:23-3:3:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,3:2:23-3:3:24", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,3:5:26-6:3:70", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:4:32-4:32:60", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:4:32-4:10:38", + "src": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:4:32-4:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:4:32-4:5:33", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:9:37-4:10:38", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:9:37-4:10:38", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:12:40-4:32:60", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:13:41-4:31:59", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:13:41-4:26:54", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:13:41-4:18:46", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:19:47-4:26:54", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:28:56-4:31:59", + "raw": "0.2", + "value": "1/5" + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,5:4:65-5:5:66", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,5:4:65-5:5:66", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,5:4:65-5:5:66", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "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/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:1:1", + "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/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:5:5-0:6:6", + "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 + } + ], + "scenarios": [ + { + "name": "x", + "isFolderOnly": false, + "ast": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": ",0:0:0-0:0:0", + "edges": [ + { + "range": ",0:0:0-0:0:0", + "src": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": ",1:0:0-2:0:0", + "nodes": [ + { + "map_key": { + "range": ",0:0:0-0:0:0", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "opacity" + } + ] + } + } + ] + }, + "primary": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:28:56-4:31:59", + "raw": "0.2", + "value": "1/5" + } + }, + "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 + }, + { + "index": 1, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.2" + } + }, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:4:32-4:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:4:32-4:5:33", + "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/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:9:37-4:10:38", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,4:9:37-4:10:38", + "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": "c", + "id_val": "c", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,5:4:65-5:5:66", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-existing-edge-set.d2,5:4:65-5:5:66", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "c" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +}