diff --git a/d2chaos/d2chaos.go b/d2chaos/d2chaos.go index 910c99935..96f9cd906 100644 --- a/d2chaos/d2chaos.go +++ b/d2chaos/d2chaos.go @@ -73,7 +73,7 @@ func (gs *dslGenState) genNode(containerID string) (string, error) { nodeID = containerID + "." + nodeID } var err error - gs.g, nodeID, err = d2oracle.Create(gs.g, nodeID) + gs.g, nodeID, err = d2oracle.Create(gs.g, nil, nodeID) if err != nil { return "", err } @@ -105,7 +105,7 @@ func (gs *dslGenState) node() error { if complexIDs { maxLen = 256 } - gs.g, err = d2oracle.Set(gs.g, nodeID, nil, go2.Pointer(gs.randStr(maxLen, false))) + gs.g, err = d2oracle.Set(gs.g, nil, nodeID, nil, go2.Pointer(gs.randStr(maxLen, false))) if err != nil { return err } @@ -114,7 +114,7 @@ func (gs *dslGenState) node() error { if gs.roll(25, 75) == 1 { // 75% chance of adding a shape. randShape := gs.randShape() - gs.g, err = d2oracle.Set(gs.g, nodeID+".shape", nil, go2.Pointer(randShape)) + gs.g, err = d2oracle.Set(gs.g, nil, nodeID+".shape", nil, go2.Pointer(randShape)) if err != nil { return err } @@ -159,7 +159,7 @@ func (gs *dslGenState) edge() error { } key := fmt.Sprintf("%s %s%s %s", src, srcArrow, dstArrow, dst) - gs.g, key, err = d2oracle.Create(gs.g, key) + gs.g, key, err = d2oracle.Create(gs.g, nil, key) if err != nil { return err } @@ -168,7 +168,7 @@ func (gs *dslGenState) edge() error { if complexIDs { maxLen = 128 } - gs.g, err = d2oracle.Set(gs.g, key, nil, go2.Pointer(gs.randStr(maxLen, false))) + gs.g, err = d2oracle.Set(gs.g, nil, key, nil, go2.Pointer(gs.randStr(maxLen, false))) if err != nil { return err } diff --git a/d2compiler/compile.go b/d2compiler/compile.go index b8579ffe3..d99f7994c 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -111,6 +111,7 @@ func (c *compiler) compileBoardsField(g *d2graph.Graph, ir *d2ir.Map, fieldName g2 := d2graph.NewGraph() g2.Parent = g g2.AST = f.Map().AST().(*d2ast.Map) + g2.BaseAST = findFieldAST(g.AST, f) c.compileBoard(g2, f.Map()) g2.Name = f.Name switch fieldName { @@ -124,6 +125,48 @@ func (c *compiler) compileBoardsField(g *d2graph.Graph, ir *d2ir.Map, fieldName } } +func findFieldAST(ast *d2ast.Map, f *d2ir.Field) *d2ast.Map { + path := []string{} + var curr *d2ir.Field = f + for { + path = append([]string{curr.Name}, path...) + boardKind := d2ir.NodeBoardKind(curr) + if boardKind == "" { + break + } + curr = d2ir.ParentField(curr) + } + + currAST := ast + for len(path) > 0 { + head := path[0] + found := false + for _, n := range currAST.Nodes { + if n.MapKey == nil { + continue + } + if n.MapKey.Key == nil { + continue + } + if len(n.MapKey.Key.Path) != 1 { + continue + } + head2 := n.MapKey.Key.Path[0].Unbox().ScalarString() + if head == head2 { + currAST = n.MapKey.Value.Map + found = true + break + } + } + if !found { + return nil + } + path = path[1:] + } + + return currAST +} + type compiler struct { err *d2parser.ParseError } @@ -284,6 +327,7 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { MapKey: fr.Context.Key, MapKeyEdgeIndex: fr.Context.EdgeIndex(), Scope: fr.Context.Scope, + ScopeAST: fr.Context.ScopeAST, } if fr.Context.ScopeMap != nil { scopeObjIDA := d2graphIDA(d2ir.BoardIDA(fr.Context.ScopeMap)) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index a91c95e12..d3afb199f 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -42,6 +42,8 @@ type Graph struct { // the board tree. IsFolderOnly bool `json:"isFolderOnly"` AST *d2ast.Map `json:"ast"` + // BaseAST is the AST of the original graph without inherited fields and edges + BaseAST *d2ast.Map `json:"-"` Root *Object `json:"root"` Edges []*Edge `json:"edges"` @@ -177,7 +179,6 @@ func (a *Attributes) ToArrowhead() d2target.Arrowhead { return d2target.ToArrowhead(a.Shape.Value, filled) } -// TODO references at the root scope should have their Scope set to root graph AST type Reference struct { Key *d2ast.KeyPath `json:"key"` KeyPathIndex int `json:"key_path_index"` @@ -186,6 +187,7 @@ type Reference struct { MapKeyEdgeIndex int `json:"map_key_edge_index"` Scope *d2ast.Map `json:"-"` ScopeObj *Object `json:"-"` + ScopeAST *d2ast.Map `json:"-"` } func (r Reference) MapKeyEdgeDest() bool { diff --git a/d2ir/compile.go b/d2ir/compile.go index 2c4022edc..20a03b103 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -44,13 +44,14 @@ func Compile(ast *d2ast.Map, opts *CompileOptions) (*Map, error) { m := &Map{} m.initRoot() m.parent.(*Field).References[0].Context.Scope = ast + m.parent.(*Field).References[0].Context.ScopeAST = ast c.pushImportStack(&d2ast.Import{ Path: []*d2ast.StringBox{d2ast.RawStringBox(ast.GetRange().Path, true)}, }) defer c.popImportStack() - c.compileMap(m, ast) + c.compileMap(m, ast, ast) c.compileClasses(m) if !c.err.Empty() { return nil, c.err @@ -105,7 +106,7 @@ func (c *compiler) overlay(base *Map, f *Field) { f.Composite = base } -func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { +func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) { for _, n := range ast.Nodes { switch { case n.MapKey != nil: @@ -113,6 +114,7 @@ func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { Key: n.MapKey, Scope: ast, ScopeMap: dst, + ScopeAST: scopeAST, }) case n.Import != nil: impn, ok := c._import(n.Import) @@ -164,7 +166,7 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) a := &Array{ parent: f, } - c.compileArray(a, refctx.Key.Value.Array) + c.compileArray(a, refctx.Key.Value.Array, refctx.ScopeAST) f.Composite = a } else if refctx.Key.Value.Map != nil { if f.Map() == nil { @@ -172,6 +174,7 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) parent: f, } } + scopeAST := refctx.Key.Value.Map switch NodeBoardKind(f) { case BoardScenario: c.overlay(ParentBoard(f).Map(), f) @@ -187,8 +190,12 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) break } } + case BoardLayer: + default: + // If new board type, use that as the new scope AST, otherwise, carry on + scopeAST = refctx.ScopeAST } - c.compileMap(f.Map(), refctx.Key.Value.Map) + c.compileMap(f.Map(), refctx.Key.Value.Map, scopeAST) switch NodeBoardKind(f) { case BoardScenario, BoardStep: c.compileClasses(f.Map()) @@ -404,7 +411,7 @@ func (c *compiler) compileEdges(refctx *RefContext) { parent: e, } } - c.compileMap(e.Map_, refctx.Key.Value.Map) + c.compileMap(e.Map_, refctx.Key.Value.Map, refctx.ScopeAST) } else if refctx.Key.Value.ScalarBox().Unbox() != nil { e.Primary_ = &Scalar{ parent: e, @@ -415,7 +422,7 @@ func (c *compiler) compileEdges(refctx *RefContext) { } } -func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { +func (c *compiler) compileArray(dst *Array, a *d2ast.Array, scopeAST *d2ast.Map) { for _, an := range a.Nodes { var irv Value switch v := an.Unbox().(type) { @@ -423,13 +430,13 @@ func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { ira := &Array{ parent: dst, } - c.compileArray(ira, v) + c.compileArray(ira, v, scopeAST) irv = ira case *d2ast.Map: irm := &Map{ parent: dst, } - c.compileMap(irm, v) + c.compileMap(irm, v, scopeAST) irv = irm case d2ast.Scalar: irv = &Scalar{ diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 47651fdc6..7234256f7 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -196,6 +196,7 @@ func (m *Map) CopyBase(newParent Node) *Map { layers := m.DeleteField("layers") scenarios := m.DeleteField("scenarios") steps := m.DeleteField("steps") + m2 := m.Copy(newParent).(*Map) if layers != nil { m.Fields = append(m.Fields, layers) @@ -549,6 +550,7 @@ type RefContext struct { Key *d2ast.Key `json:"key"` Scope *d2ast.Map `json:"-"` ScopeMap *Map `json:"-"` + ScopeAST *d2ast.Map `json:"-"` } func (rc *RefContext) Copy() *RefContext { diff --git a/d2ir/import.go b/d2ir/import.go index aaad0d035..147130071 100644 --- a/d2ir/import.go +++ b/d2ir/import.go @@ -111,7 +111,7 @@ func (c *compiler) __import(imp *d2ast.Import) (*Map, bool) { ir.initRoot() ir.parent.(*Field).References[0].Context.Scope = ast - c.compileMap(ir, ast) + c.compileMap(ir, ast, ast) c.importCache[impPath] = ir diff --git a/d2oracle/edit.go b/d2oracle/edit.go index 165d6886c..5ca66601d 100644 --- a/d2oracle/edit.go +++ b/d2oracle/edit.go @@ -22,23 +22,50 @@ import ( "oss.terrastruct.com/d2/d2target" ) -func Create(g *d2graph.Graph, key string) (_ *d2graph.Graph, newKey string, err error) { +type OutsideScopeError struct{} + +func (e OutsideScopeError) Error() string { + return "operation would modify AST outside of given scope" +} + +func Create(g *d2graph.Graph, boardPath []string, key string) (_ *d2graph.Graph, newKey string, err error) { defer xdefer.Errorf(&err, "failed to create %#v", key) - newKey, edge, err := generateUniqueKey(g, key, nil, nil) + 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 + } + + newKey, edge, err := generateUniqueKey(boardG, key, nil, nil) if err != nil { return nil, "", err } if edge { - err = _set(g, key, nil, nil) + err = _set(boardG, baseAST, key, nil, nil) } else { - err = _set(g, newKey, nil, nil) + err = _set(boardG, baseAST, newKey, nil, nil) } + + if len(boardPath) > 0 { + replaced := ReplaceBoardNode(g.AST, baseAST, boardPath) + if !replaced { + return nil, "", fmt.Errorf("board %v AST not found", boardPath) + } + } + if err != nil { return nil, "", err } - g, err = recompile(g) + g, err = recompile(g.AST) if err != nil { return nil, "", err } @@ -47,7 +74,7 @@ func Create(g *d2graph.Graph, key string) (_ *d2graph.Graph, newKey string, err // TODO: update graph in place when compiler can accept single modifications // TODO: go through all references to decide best spot to insert something -func Set(g *d2graph.Graph, key string, tag, value *string) (_ *d2graph.Graph, err error) { +func Set(g *d2graph.Graph, boardPath []string, key string, tag, value *string) (_ *d2graph.Graph, err error) { var valueHelp string if value == nil { valueHelp = fmt.Sprintf("%#v", value) @@ -60,12 +87,32 @@ func Set(g *d2graph.Graph, key string, tag, value *string) (_ *d2graph.Graph, er defer xdefer.Errorf(&err, "failed to set %#v to %#v", key, valueHelp) } - err = _set(g, key, tag, value) + 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 + } + + err = _set(boardG, baseAST, key, tag, value) if err != nil { return nil, err } - return recompile(g) + if len(boardPath) > 0 { + replaced := ReplaceBoardNode(g.AST, baseAST, boardPath) + if !replaced { + return nil, fmt.Errorf("board %v AST not found", boardPath) + } + } + + return recompile(g.AST) } func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ *d2graph.Graph, err error) { @@ -202,7 +249,7 @@ func ReconnectEdge(g *d2graph.Graph, edgeKey string, srcKey, dstKey *string) (_ } } - return recompile(g) + return recompile(g.AST) } func pathFromScopeKey(g *d2graph.Graph, key *d2ast.Key, scopeak []string) ([]*d2ast.StringBox, error) { @@ -234,9 +281,9 @@ func pathFromScopeObj(g *d2graph.Graph, key *d2ast.Key, fromScope *d2graph.Objec return pathFromScopeKey(g, key, scopeak) } -func recompile(g *d2graph.Graph) (*d2graph.Graph, error) { - s := d2format.Format(g.AST) - g, err := d2compiler.Compile(g.AST.Range.Path, strings.NewReader(s), nil) +func recompile(ast *d2ast.Map) (*d2graph.Graph, error) { + s := d2format.Format(ast) + g, err := d2compiler.Compile(ast.Range.Path, strings.NewReader(s), nil) if err != nil { return nil, fmt.Errorf("failed to recompile:\n%s\n%w", s, err) } @@ -244,7 +291,7 @@ func recompile(g *d2graph.Graph) (*d2graph.Graph, error) { } // TODO merge flat styles -func _set(g *d2graph.Graph, key string, tag, value *string) error { +func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string) error { if tag != nil { if hasSpace(*tag) { return fmt.Errorf("spaces are not allowed in blockstring tags") @@ -272,7 +319,7 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error { }) } - scope := g.AST + scope := baseAST edgeTrimCommon(mk) obj := g.Root toSkip := 1 @@ -312,13 +359,25 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error { } obj = o - if obj.Map == nil { + var maybeNewScope *d2ast.Map + if baseAST != g.AST { + writeableRefs := getWriteableRefs(obj, baseAST) + for _, ref := range writeableRefs { + if ref.MapKey != nil && ref.MapKey.Value.Map != nil { + maybeNewScope = ref.MapKey.Value.Map + } + } + } else { + maybeNewScope = obj.Map + } + + if maybeNewScope == nil { // If we find a deeper obj.Map we need to skip this key too. toSkip++ continue } - scope = obj.Map + scope = maybeNewScope mk.Key.Path = mk.Key.Path[toSkip:] toSkip = 1 if len(mk.Key.Path) == 0 { @@ -326,13 +385,37 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error { } } - if obj.Label.MapKey != nil && obj.Map == nil && (!found || reserved || len(mk.Edges) > 0) { - obj.Map = &d2ast.Map{ + var objK *d2ast.Key + if baseAST != g.AST { + writeableRefs := getWriteableRefs(obj, baseAST) + if len(writeableRefs) > 0 { + objK = writeableRefs[0].MapKey + } + if objK == nil { + appendMapKey(scope, mk) + return nil + } + } + var m *d2ast.Map + if objK != nil { + m = objK.Value.Map + } else { + m = obj.Map + } + + if obj.Label.MapKey != nil && m == nil && (!found || reserved || len(mk.Edges) > 0) { + m2 := &d2ast.Map{ Range: d2ast.MakeRange(",1:0:0-1:0:0"), } - obj.Label.MapKey.Primary = obj.Label.MapKey.Value.ScalarBox() - obj.Label.MapKey.Value = d2ast.MakeValueBox(obj.Map) - scope = obj.Map + if objK == nil { + obj.Map = m2 + objK = obj.Label.MapKey + } else { + objK.Value.Map = m2 + } + objK.Primary = objK.Value.ScalarBox() + objK.Value = d2ast.MakeValueBox(m2) + scope = m2 mk.Key.Path = mk.Key.Path[toSkip-1:] toSkip = 1 @@ -346,7 +429,6 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error { return nil } } - ir, err := d2ir.Compile(g.AST, nil) if err != nil { return err @@ -687,7 +769,7 @@ func appendMapKey(m *d2ast.Map, mk *d2ast.Key) { } } -func Delete(g *d2graph.Graph, key string) (_ *d2graph.Graph, err error) { +func Delete(g *d2graph.Graph, boardPath []string, key string) (_ *d2graph.Graph, err error) { defer xdefer.Errorf(&err, "failed to delete %#v", key) mk, err := d2parser.ParseMapKey(key) @@ -703,6 +785,19 @@ func Delete(g *d2graph.Graph, key string) (_ *d2graph.Graph, err error) { edgeTrimCommon(mk) } + 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 + } + g2, err := deleteReserved(g, mk) if err != nil { return nil, err @@ -752,31 +847,47 @@ func Delete(g *d2graph.Graph, key string) (_ *d2graph.Graph, err error) { } } } - return recompile(g) + return recompile(g.AST) } - prevG, _ := recompile(g) + prevG, _ := recompile(boardG.AST) - g, err = renameConflictsToParent(g, mk.Key) + boardG, err = renameConflictsToParent(boardG, mk.Key) if err != nil { return nil, err } - obj, ok := g.Root.HasChild(d2graph.Key(mk.Key)) + obj, ok := boardG.Root.HasChild(d2graph.Key(mk.Key)) if !ok { return g, nil } - g, err = deleteObject(g, mk.Key, obj) + if len(boardPath) > 0 { + // TODO null + writeableRefs := getWriteableRefs(obj, baseAST) + if len(writeableRefs) != len(obj.References) { + return nil, OutsideScopeError{} + } + } + + boardG, err = deleteObject(boardG, baseAST, mk.Key, obj) if err != nil { return nil, err } - if err := updateNear(prevG, g, &key, nil, false); err != nil { + if err := updateNear(prevG, boardG, &key, nil, false); err != nil { return nil, err } - return recompile(g) + if len(boardPath) > 0 { + replaced := ReplaceBoardNode(g.AST, baseAST, boardPath) + if !replaced { + return nil, fmt.Errorf("board %v AST not found", boardPath) + } + return recompile(g.AST) + } + + return recompile(boardG.AST) } func bumpChildrenUnderscores(m *d2ast.Map) { @@ -975,7 +1086,8 @@ func renameConflictsToParent(g *d2graph.Graph, key *d2ast.KeyPath) (*d2graph.Gra } for _, k := range renameOrder { var err error - g, err = move(g, k, renames[k], false) + // TODO boardPath + g, err = move(g, nil, k, renames[k], false) if err != nil { return nil, err } @@ -1015,7 +1127,7 @@ func deleteReserved(g *d2graph.Graph, mk *d2ast.Key) (*d2graph.Graph, error) { if err := deleteEdgeField(g, e, targetKey.Path[len(targetKey.Path)-1].Unbox().ScalarString()); err != nil { return nil, err } - return recompile(g) + return recompile(g.AST) } isStyleKey := false @@ -1054,7 +1166,7 @@ func deleteReserved(g *d2graph.Graph, mk *d2ast.Key) (*d2graph.Graph, error) { } } - return recompile(g) + return recompile(g.AST) } func deleteMapField(m *d2ast.Map, field string) { @@ -1118,7 +1230,7 @@ func deleteObjField(g *d2graph.Graph, obj *d2graph.Object, field string) error { copy(tmpNodes, ref.Scope.Nodes) // If I delete this, will the object still exist? deleteFromMap(ref.Scope, ref.MapKey) - g2, err := recompile(g) + g2, err := recompile(g.AST) if err != nil { return err } @@ -1134,7 +1246,7 @@ func deleteObjField(g *d2graph.Graph, obj *d2graph.Object, field string) error { return nil } -func deleteObject(g *d2graph.Graph, key *d2ast.KeyPath, obj *d2graph.Object) (*d2graph.Graph, error) { +func deleteObject(g *d2graph.Graph, baseAST *d2ast.Map, key *d2ast.KeyPath, obj *d2graph.Object) (*d2graph.Graph, error) { var refEdges []*d2ast.Edge for _, ref := range obj.References { if ref.InEdge() { @@ -1347,7 +1459,8 @@ 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() } - g, err = move(g, key, d2format.Format(mk), false) + // TODO + g, err = move(g, nil, key, d2format.Format(mk), false) return g, newName, err } @@ -1361,16 +1474,30 @@ func trimReservedSuffix(path []*d2ast.StringBox) []*d2ast.StringBox { } // Does not handle edge keys, on account of edge keys can only be reserved, e.g. (a->b).style.color: red -func Move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (_ *d2graph.Graph, err error) { +func Move(g *d2graph.Graph, boardPath []string, key, newKey string, includeDescendants bool) (_ *d2graph.Graph, err error) { defer xdefer.Errorf(&err, "failed to move: %#v to %#v", key, newKey) - return move(g, key, newKey, includeDescendants) + return move(g, boardPath, key, newKey, includeDescendants) } -func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2graph.Graph, error) { +func move(g *d2graph.Graph, boardPath []string, key, newKey string, includeDescendants bool) (*d2graph.Graph, error) { if key == newKey { return g, nil } - newKey, _, err := generateUniqueKey(g, newKey, nil, nil) + + 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 + } + + newKey, _, err := generateUniqueKey(boardG, newKey, nil, nil) if err != nil { return nil, err } @@ -1386,6 +1513,7 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra } edgeTrimCommon(mk) edgeTrimCommon(mk2) + if len(mk.Edges) > 0 && mk.EdgeKey == nil { if d2format.Format(mk.Key) != d2format.Format(mk2.Key) { // TODO just prevent moving edges at all @@ -1413,10 +1541,10 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra ref.MapKey.Edges[ref.MapKeyEdgeIndex].SrcArrow = mk2.Edges[0].SrcArrow ref.MapKey.Edges[ref.MapKeyEdgeIndex].DstArrow = mk2.Edges[0].DstArrow } - return recompile(g) + return recompile(g.AST) } - prevG, _ := recompile(g) + prevG, _ := recompile(boardG.AST) ak := d2graph.Key(mk.Key) ak2 := d2graph.Key(mk2.Key) @@ -1424,20 +1552,27 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra isCrossScope := strings.Join(ak[:len(ak)-1], ".") != strings.Join(ak2[:len(ak2)-1], ".") if isCrossScope && !includeDescendants { - g, err = renameConflictsToParent(g, mk.Key) + boardG, err = renameConflictsToParent(boardG, mk.Key) if err != nil { return nil, err } } - obj, ok := g.Root.HasChild(ak) + obj, ok := boardG.Root.HasChild(ak) if !ok { return nil, fmt.Errorf("key referenced by from does not exist") } - toParent := g.Root + if len(boardPath) > 0 { + writeableRefs := getWriteableRefs(obj, baseAST) + if len(writeableRefs) != len(obj.References) { + return nil, OutsideScopeError{} + } + } + + toParent := boardG.Root if isCrossScope && len(ak2) > 1 { - toParent, ok = g.Root.HasChild(ak2[:len(ak2)-1]) + toParent, ok = boardG.Root.HasChild(ak2[:len(ak2)-1]) if !ok { return nil, fmt.Errorf("key referenced by to parent does not exist") } @@ -1507,7 +1642,7 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra // 2. Ensure parent node Key has a map to accept moved node. // This map will be what MOVE will append the new key to - toScope := g.AST + toScope := boardG.AST if isCrossScope && len(ak2) > 1 && needsLandingMap { mostNestedParentRefs := getMostNestedRefs(toParent) mapExists := false @@ -1599,7 +1734,7 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra } absKey.Path = append(absKey.Path, ref.Key.Path...) if !includeDescendants { - hoistRefChildren(g, absKey, ref) + hoistRefChildren(boardG, absKey, ref) } deleteFromMap(ref.Scope, ref.MapKey) detachedMK := &d2ast.Key{Primary: ref.MapKey.Primary, Key: cloneKey(ref.MapKey.Key)} @@ -1641,7 +1776,7 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra return nil, err } - newPath, err := pathFromScopeKey(g, &d2ast.Key{Key: d2ast.MakeKeyPath(append(resolvedParent.AbsIDArray(), resolvedScopeKey...))}, ak2) + newPath, err := pathFromScopeKey(boardG, &d2ast.Key{Key: d2ast.MakeKeyPath(append(resolvedParent.AbsIDArray(), resolvedScopeKey...))}, ak2) if err != nil { return nil, err } @@ -1655,7 +1790,7 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra return nil, err } - newPath, err := pathFromScopeKey(g, &d2ast.Key{Key: d2ast.MakeKeyPath(append(resolvedParent.AbsIDArray(), resolvedScopeKey...))}, ak2) + newPath, err := pathFromScopeKey(boardG, &d2ast.Key{Key: d2ast.MakeKeyPath(append(resolvedParent.AbsIDArray(), resolvedScopeKey...))}, ak2) if err != nil { return nil, err } @@ -1667,7 +1802,7 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra return nil, err } - newPath, err := pathFromScopeKey(g, &d2ast.Key{Key: d2ast.MakeKeyPath(append(resolvedParent.AbsIDArray(), resolvedScopeKey...))}, ak2) + newPath, err := pathFromScopeKey(boardG, &d2ast.Key{Key: d2ast.MakeKeyPath(append(resolvedParent.AbsIDArray(), resolvedScopeKey...))}, ak2) if err != nil { return nil, err } @@ -1765,11 +1900,11 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra detachedMK := &d2ast.Key{ Key: cloneKey(ref.Key), } - oldPath, err := pathFromScopeObj(g, mk, ref.ScopeObj) + oldPath, err := pathFromScopeObj(boardG, mk, ref.ScopeObj) if err != nil { return nil, err } - newPath, err := pathFromScopeObj(g, mk2, ref.ScopeObj) + newPath, err := pathFromScopeObj(boardG, mk2, ref.ScopeObj) if err != nil { return nil, err } @@ -1800,14 +1935,14 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra // When moving a node connected to an edge, we have to ensure parents continue to exist // e.g. the `c` out of `a.b.c -> ...` // `a.b` needs to exist - newPath, err := pathFromScopeObj(g, mk2, ref.ScopeObj) + newPath, err := pathFromScopeObj(boardG, mk2, ref.ScopeObj) if err != nil { return nil, err } if len(go2.Filter(ref.Key.Path, func(x *d2ast.StringBox) bool { return x.Unbox().ScalarString() != "_" })) > 1 { detachedK := cloneKey(ref.Key) detachedK.Path = detachedK.Path[:len(detachedK.Path)-1] - ensureNode(g, refEdges, ref.ScopeObj, ref.Scope, ref.MapKey, detachedK, false) + ensureNode(boardG, refEdges, ref.ScopeObj, ref.Scope, ref.MapKey, detachedK, false) } if includeDescendants { @@ -1818,11 +1953,19 @@ func move(g *d2graph.Graph, key, newKey string, includeDescendants bool) (*d2gra } } - if err := updateNear(prevG, g, &key, &newKey, includeDescendants); err != nil { + if err := updateNear(prevG, boardG, &key, &newKey, includeDescendants); err != nil { return nil, err } - return recompile(g) + if len(boardPath) > 0 { + replaced := ReplaceBoardNode(g.AST, baseAST, boardPath) + if !replaced { + return nil, fmt.Errorf("board %v AST not found", boardPath) + } + return recompile(g.AST) + } + + return recompile(boardG.AST) } // filterReserved takes a Value and splits it into 2 @@ -1934,7 +2077,7 @@ func updateNear(prevG, g *d2graph.Graph, from, to *string, includeDescendants bo if err != nil { return err } - tmpG, _ := recompile(prevG) + tmpG, _ := recompile(prevG.AST) appendMapKey(tmpG.AST, valueMK) if to == nil { deltas, err := DeleteIDDeltas(tmpG, *from) @@ -1979,7 +2122,7 @@ func updateNear(prevG, g *d2graph.Graph, from, to *string, includeDescendants bo if err != nil { return err } - tmpG, _ := recompile(prevG) + tmpG, _ := recompile(prevG.AST) appendMapKey(tmpG.AST, valueMK) if to == nil { deltas, err := DeleteIDDeltas(tmpG, *from) @@ -2849,3 +2992,12 @@ func filterReservedPath(path []*d2ast.StringBox) (filtered []*d2ast.StringBox) { } return } + +func getWriteableRefs(obj *d2graph.Object, writeableAST *d2ast.Map) (out []d2graph.Reference) { + for i, ref := range obj.References { + if ref.ScopeAST == writeableAST { + out = append(out, obj.References[i]) + } + } + return +} diff --git a/d2oracle/edit_test.go b/d2oracle/edit_test.go index a48bcc0d1..472e07d0c 100644 --- a/d2oracle/edit_test.go +++ b/d2oracle/edit_test.go @@ -26,9 +26,10 @@ func TestCreate(t *testing.T) { t.Parallel() testCases := []struct { - name string - text string - key string + boardPath []string + name string + text string + key string expKey string expErr string @@ -455,6 +456,241 @@ rawr: { } after +`, + }, + { + name: "layers-basic", + + text: `a + +layers: { + x: { + a + } +} +`, + key: `b`, + boardPath: []string{"root", "layers", "x"}, + + expKey: `b`, + exp: `a + +layers: { + x: { + a + b + } +} +`, + }, + { + name: "layers-edge", + + text: `a + +layers: { + x: { + a + } +} +`, + key: `a -> b`, + boardPath: []string{"root", "layers", "x"}, + + expKey: `(a -> b)[0]`, + exp: `a + +layers: { + x: { + a + a -> b + } +} +`, + }, + { + name: "layers-edge-duplicate", + + text: `a -> b + +layers: { + x: { + a -> b + } +} +`, + key: `a -> b`, + boardPath: []string{"root", "layers", "x"}, + + expKey: `(a -> b)[1]`, + exp: `a -> b + +layers: { + x: { + a -> b + a -> b + } +} +`, + }, + { + name: "scenarios-basic", + + text: `a +b + +scenarios: { + x: { + a + } +} +`, + key: `c`, + boardPath: []string{"root", "scenarios", "x"}, + + expKey: `c`, + exp: `a +b + +scenarios: { + x: { + a + c + } +} +`, + }, + { + name: "scenarios-edge", + + text: `a +b + +scenarios: { + x: { + a + } +} +`, + key: `a -> b`, + boardPath: []string{"root", "scenarios", "x"}, + + expKey: `(a -> b)[0]`, + exp: `a +b + +scenarios: { + x: { + a + a -> b + } +} +`, + }, + { + name: "scenarios-edge-inherited", + + text: `a -> b + +scenarios: { + x: { + a + } +} +`, + key: `a -> b`, + boardPath: []string{"root", "scenarios", "x"}, + + expKey: `(a -> b)[1]`, + exp: `a -> b + +scenarios: { + x: { + a + a -> b + } +} +`, + }, + { + name: "steps-basic", + + text: `a +d + +steps: { + x: { + b + } +} +`, + key: `c`, + boardPath: []string{"root", "steps", "x"}, + + expKey: `c`, + exp: `a +d + +steps: { + x: { + b + c + } +} +`, + }, + { + name: "steps-edge", + + text: `a +d + +steps: { + x: { + b + } +} +`, + key: `d -> b`, + boardPath: []string{"root", "steps", "x"}, + + expKey: `(d -> b)[0]`, + exp: `a +d + +steps: { + x: { + b + d -> b + } +} +`, + }, + { + name: "steps-conflict", + + text: `a +d + +steps: { + x: { + b + } +} +`, + key: `d`, + boardPath: []string{"root", "steps", "x"}, + + expKey: `d 2`, + exp: `a +d + +steps: { + x: { + b + d 2 + } +} `, }, } @@ -469,7 +705,7 @@ after text: tc.text, testFunc: func(g *d2graph.Graph) (*d2graph.Graph, error) { var err error - g, newKey, err = d2oracle.Create(g, tc.key) + g, newKey, err = d2oracle.Create(g, tc.boardPath, tc.key) return g, err }, @@ -493,11 +729,12 @@ func TestSet(t *testing.T) { t.Parallel() testCases := []struct { - name string - text string - key string - tag *string - value *string + boardPath []string + name string + text string + key string + tag *string + value *string expErr string exp string @@ -1471,6 +1708,197 @@ six expErr: `failed to set "x.icon" to "one two" "\"three\\nfour\\nfive\\nsix\\n\"": spaces are not allowed in blockstring tags`, }, + { + name: "layers-usable-ref-style", + + text: `a + +layers: { + x: { + a + } +} +`, + key: `a.style.opacity`, + value: go2.Pointer(`0.2`), + boardPath: []string{"root", "layers", "x"}, + + exp: `a + +layers: { + x: { + a: {style.opacity: 0.2} + } +} +`, + }, + { + name: "layers-unusable-ref-style", + + text: `a + +layers: { + x: { + b + } +} +`, + key: `a.style.opacity`, + value: go2.Pointer(`0.2`), + boardPath: []string{"root", "layers", "x"}, + + exp: `a + +layers: { + x: { + b + a.style.opacity: 0.2 + } +} +`, + }, + { + name: "scenarios-usable-ref-style", + + text: `a: outer + +scenarios: { + x: { + a: inner + } +} +`, + key: `a.style.opacity`, + value: go2.Pointer(`0.2`), + boardPath: []string{"root", "scenarios", "x"}, + + exp: `a: outer + +scenarios: { + x: { + a: inner {style.opacity: 0.2} + } +} +`, + }, + { + name: "scenarios-nested-usable-ref-style", + + text: `a: { + b: outer +} + +scenarios: { + x: { + a: { + b: inner + } + } +} +`, + key: `a.b.style.opacity`, + value: go2.Pointer(`0.2`), + boardPath: []string{"root", "scenarios", "x"}, + + exp: `a: { + b: outer +} + +scenarios: { + x: { + a: { + b: inner {style.opacity: 0.2} + } + } +} +`, + }, + { + name: "scenarios-unusable-ref-style", + + text: `a + +scenarios: { + x: { + b + } +} +`, + key: `a.style.opacity`, + value: go2.Pointer(`0.2`), + boardPath: []string{"root", "scenarios", "x"}, + + exp: `a + +scenarios: { + x: { + b + a.style.opacity: 0.2 + } +} +`, + }, + { + name: "scenarios-label-primary", + + text: `a: { + style.opacity: 0.2 +} + +scenarios: { + x: { + a: { + style.opacity: 0.3 + } + } +} +`, + key: `a`, + value: go2.Pointer(`b`), + boardPath: []string{"root", "scenarios", "x"}, + + exp: `a: { + style.opacity: 0.2 +} + +scenarios: { + x: { + a: b { + style.opacity: 0.3 + } + } +} +`, + }, + { + name: "scenarios-label-primary-missing", + + text: `a: { + style.opacity: 0.2 +} + +scenarios: { + x: { + b + } +} +`, + key: `a`, + value: go2.Pointer(`b`), + boardPath: []string{"root", "scenarios", "x"}, + + exp: `a: { + style.opacity: 0.2 +} + +scenarios: { + x: { + b + a: b + } +} +`, + }, } for _, tc := range testCases { @@ -1481,7 +1909,7 @@ six et := editTest{ text: tc.text, testFunc: func(g *d2graph.Graph) (*d2graph.Graph, error) { - return d2oracle.Set(g, tc.key, tc.tag, tc.value) + return d2oracle.Set(g, tc.boardPath, tc.key, tc.tag, tc.value) }, exp: tc.exp, @@ -2255,8 +2683,9 @@ func TestMove(t *testing.T) { t.Parallel() testCases := []struct { - skip bool - name string + skip bool + name string + boardPath []string text string key string @@ -4437,6 +4866,51 @@ a } `, }, + { + name: "layers-basic", + + text: `a + +layers: { + x: { + b + c + } +} +`, + key: `c`, + newKey: `b.c`, + boardPath: []string{"root", "layers", "x"}, + + exp: `a + +layers: { + x: { + b: { + c + } + } +} +`, + }, + { + name: "scenarios-out-of-scope", + + text: `a + +scenarios: { + x: { + b + c + } +} +`, + key: `a`, + newKey: `b.a`, + boardPath: []string{"root", "scenarios", "x"}, + + expErr: `failed to move: "a" to "b.a": operation would modify AST outside of given scope`, + }, } for _, tc := range testCases { @@ -4452,7 +4926,7 @@ a testFunc: func(g *d2graph.Graph) (*d2graph.Graph, error) { objectsBefore := len(g.Objects) var err error - g, err = d2oracle.Move(g, tc.key, tc.newKey, tc.includeDescendants) + g, err = d2oracle.Move(g, tc.boardPath, tc.key, tc.newKey, tc.includeDescendants) if err == nil { objectsAfter := len(g.Objects) if objectsBefore != objectsAfter { @@ -4476,7 +4950,8 @@ func TestDelete(t *testing.T) { t.Parallel() testCases := []struct { - name string + name string + boardPath []string text string key string @@ -6124,6 +6599,71 @@ cdpdxz cm `, }, + { + name: "layers-basic", + + text: `a + +layers: { + x: { + b + c + } +} +`, + key: `c`, + boardPath: []string{"root", "layers", "x"}, + + exp: `a + +layers: { + x: { + b + } +} +`, + }, + { + name: "scenarios-basic", + + text: `a + +scenarios: { + x: { + b + c + } +} +`, + key: `c`, + boardPath: []string{"root", "scenarios", "x"}, + + exp: `a + +scenarios: { + x: { + b + } +} +`, + }, + { + name: "scenarios-inherited", + + text: `a + +scenarios: { + x: { + b + c + } +} +`, + key: `a`, + boardPath: []string{"root", "scenarios", "x"}, + + expErr: `failed to delete "a": operation would modify AST outside of given scope`, + }, } for _, tc := range testCases { @@ -6134,7 +6674,7 @@ cm et := editTest{ text: tc.text, testFunc: func(g *d2graph.Graph) (*d2graph.Graph, error) { - return d2oracle.Delete(g, tc.key) + return d2oracle.Delete(g, tc.boardPath, tc.key) }, exp: tc.exp, diff --git a/d2oracle/get.go b/d2oracle/get.go index f24178efd..c17bbbb54 100644 --- a/d2oracle/get.go +++ b/d2oracle/get.go @@ -9,6 +9,97 @@ import ( "oss.terrastruct.com/d2/d2parser" ) +func GetBoardGraph(g *d2graph.Graph, boardPath []string) *d2graph.Graph { + if len(boardPath) == 0 { + return g + } + switch boardPath[0] { + case "root": + if g.Parent == nil { + return GetBoardGraph(g, boardPath[1:]) + } + return nil + case "layers": + if len(boardPath) < 2 { + return nil + } + for i, b := range g.Layers { + if b.Name == boardPath[1] { + return GetBoardGraph(g.Layers[i], boardPath[2:]) + } + } + case "scenarios": + if len(boardPath) < 2 { + return nil + } + for i, b := range g.Scenarios { + if b.Name == boardPath[1] { + return GetBoardGraph(g.Scenarios[i], boardPath[2:]) + } + } + case "steps": + if len(boardPath) < 2 { + return nil + } + for i, b := range g.Steps { + if b.Name == boardPath[1] { + return GetBoardGraph(g.Steps[i], boardPath[2:]) + } + } + } + + return nil +} + +func ReplaceBoardNode(ast, ast2 *d2ast.Map, boardPath []string) bool { + if len(boardPath) == 0 { + return false + } + switch boardPath[0] { + case "root": + return ReplaceBoardNode(ast, ast2, boardPath[1:]) + case "layers": + if len(boardPath) < 2 { + return false + } + for _, n := range ast.Nodes { + if n.MapKey != nil && n.MapKey.Key != nil && n.MapKey.Key.Path[0].Unbox().ScalarString() == "layers" { + return ReplaceBoardNode(n.MapKey.Value.Map, ast2, boardPath[1:]) + } + } + case "scenarios": + if len(boardPath) < 2 { + return false + } + for _, n := range ast.Nodes { + if n.MapKey != nil && n.MapKey.Key != nil && n.MapKey.Key.Path[0].Unbox().ScalarString() == "scenarios" { + return ReplaceBoardNode(n.MapKey.Value.Map, ast2, boardPath[1:]) + } + } + case "steps": + if len(boardPath) < 2 { + return false + } + for _, n := range ast.Nodes { + if n.MapKey != nil && n.MapKey.Key != nil && n.MapKey.Key.Path[0].Unbox().ScalarString() == "steps" { + return ReplaceBoardNode(n.MapKey.Value.Map, ast2, boardPath[1:]) + } + } + default: + for _, n := range ast.Nodes { + if n.MapKey != nil && n.MapKey.Key != nil && n.MapKey.Key.Path[0].Unbox().ScalarString() == boardPath[0] { + if len(boardPath) == 1 { + n.MapKey.Value.Map.Nodes = ast2.Nodes + return true + } + return ReplaceBoardNode(n.MapKey.Value.Map, ast2, boardPath[1:]) + } + } + } + + return false +} + func GetChildrenIDs(g *d2graph.Graph, absID string) (ids []string, _ error) { mk, err := d2parser.ParseMapKey(absID) if err != nil { diff --git a/docs/examples/lib/2-d2oracle/d2oracle.go b/docs/examples/lib/2-d2oracle/d2oracle.go index cb30cfa5a..8f37024e2 100644 --- a/docs/examples/lib/2-d2oracle/d2oracle.go +++ b/docs/examples/lib/2-d2oracle/d2oracle.go @@ -21,14 +21,14 @@ func main() { }) // Create a shape with the ID, "meow" - graph, _, _ = d2oracle.Create(graph, "meow") + graph, _, _ = d2oracle.Create(graph, nil, "meow") // Style the shape green color := "green" - graph, _ = d2oracle.Set(graph, "meow.style.fill", nil, &color) + graph, _ = d2oracle.Set(graph, nil, "meow.style.fill", nil, &color) // Create a shape with the ID, "cat" - graph, _, _ = d2oracle.Create(graph, "cat") + graph, _, _ = d2oracle.Create(graph, nil, "cat") // Move the shape "meow" inside the container "cat" - graph, _ = d2oracle.Move(graph, "meow", "cat.meow", false) + graph, _ = d2oracle.Move(graph, nil, "meow", "cat.meow", false) // Prints formatted D2 script fmt.Print(d2format.Format(graph.AST)) } diff --git a/testdata/d2oracle/TestCreate/edge-dupe.exp.json b/testdata/d2oracle/TestCreate/edge-dupe.exp.json new file mode 100644 index 000000000..444e8a838 --- /dev/null +++ b/testdata/d2oracle/TestCreate/edge-dupe.exp.json @@ -0,0 +1,205 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:0:0-1:0:7", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "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/TestCreate/edge-dupe.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/edge-dupe.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestCreate/layers-basic.exp.json b/testdata/d2oracle/TestCreate/layers-basic.exp.json new file mode 100644 index 000000000..202a1fdf8 --- /dev/null +++ b/testdata/d2oracle/TestCreate/layers-basic.exp.json @@ -0,0 +1,381 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,0:0:0-8:0:38", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,2:0:3-7:1:37", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,2:8:11-7:1:37", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,3:2:15-6:3:35", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,3:2:15-3:3:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,3:5:18-6:3:35", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,4:4:24-4:5:25", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,4:4:24-4:5:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,5:4:30-5:5:31", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,5:4:30-5:5:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,5:4:30-5:5:31", + "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/TestCreate/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/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": "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": {} + } + } + ] + }, + "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/TestCreate/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,4:4:24-4:5:25", + "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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,5:4:30-5:5:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-basic.d2,5:4:30-5:5:31", + "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/TestCreate/layers-edge-duplicate.exp.json b/testdata/d2oracle/TestCreate/layers-edge-duplicate.exp.json new file mode 100644 index 000000000..6ed250186 --- /dev/null +++ b/testdata/d2oracle/TestCreate/layers-edge-duplicate.exp.json @@ -0,0 +1,715 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:0:0-8:0:53", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,2:0:8-7:1:52", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,2:0:8-2:6:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,2:0:8-2:6:14", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,2:8:16-7:1:52", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,3:2:20-6:3:50", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,3:2:20-3:3:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,3:2:20-3:3:21", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,3:5:23-6:3:50", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:4:29-4:10:35", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:4:29-4:10:35", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:4:29-4:5:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:4:29-4:5:30", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:9:34-4:10:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:9:34-4:10:35", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:4:40-5:10:46", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:4:40-5:10:46", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:4:40-5:5:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:4:40-5:5:41", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:9:45-5:10:46", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:9:45-5:10:46", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.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/TestCreate/layers-edge-duplicate.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.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 + } + ], + "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": "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", + "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": {} + } + } + ] + }, + "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": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:4:29-4:5:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:4:29-4:5:30", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:4:40-5:5:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:4:40-5:5:41", + "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/TestCreate/layers-edge-duplicate.d2,4:9:34-4:10:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,4:9:34-4:10:35", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:9:45-5:10:46", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge-duplicate.d2,5:9:45-5:10:46", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestCreate/layers-edge.exp.json b/testdata/d2oracle/TestCreate/layers-edge.exp.json new file mode 100644 index 000000000..71fd6031a --- /dev/null +++ b/testdata/d2oracle/TestCreate/layers-edge.exp.json @@ -0,0 +1,499 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,0:0:0-8:0:43", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,2:0:3-7:1:42", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,2:8:11-7:1:42", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,3:2:15-6:3:40", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,3:2:15-3:3:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,3:5:18-6:3:40", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,4:4:24-4:5:25", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,4:4:24-4:5:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:4:30-5:10:36", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:4:30-5:10:36", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:4:30-5:5:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:4:30-5:5:31", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:9:35-5:10:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:9:35-5:10:36", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.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": "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", + "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": {} + } + } + ] + }, + "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/TestCreate/layers-edge.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,4:4:24-4:5:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:4:30-5:5:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:4:30-5:5:31", + "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/TestCreate/layers-edge.d2,5:9:35-5:10:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/layers-edge.d2,5:9:35-5:10:36", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestCreate/scenarios-basic.exp.json b/testdata/d2oracle/TestCreate/scenarios-basic.exp.json new file mode 100644 index 000000000..44f44d42a --- /dev/null +++ b/testdata/d2oracle/TestCreate/scenarios-basic.exp.json @@ -0,0 +1,536 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,0:0:0-9:0:43", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,3:0:5-8:1:42", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,3:0:5-3:9:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,3:0:5-3:9:14", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,3:11:16-8:1:42", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,4:2:20-7:3:40", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,4:2:20-4:3:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,4:2:20-4:3:21", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,4:5:23-7:3:40", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,5:4:29-5:5:30", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,5:4:29-5:5:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,5:4:29-5:5:30", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,6:4:35-6:5:36", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,6:4:35-6:5:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,6:4:35-6:5:36", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,1:0:2-1:1:3", + "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 + } + ], + "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": {} + } + } + ] + }, + "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/TestCreate/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/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/TestCreate/scenarios-basic.d2,5:4:29-5:5:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,5:4:29-5:5:30", + "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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,1:0:2-1:1:3", + "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/TestCreate/scenarios-basic.d2,6:4:35-6:5:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-basic.d2,6:4:35-6:5:36", + "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/TestCreate/scenarios-edge-inherited.exp.json b/testdata/d2oracle/TestCreate/scenarios-edge-inherited.exp.json new file mode 100644 index 000000000..7d4a47a62 --- /dev/null +++ b/testdata/d2oracle/TestCreate/scenarios-edge-inherited.exp.json @@ -0,0 +1,712 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:0:0-8:0:51", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:0:0-0:6:6", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,2:0:8-7:1:50", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,2:0:8-2:9:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,2:0:8-2:9:17", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,2:11:19-7:1:50", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,3:2:23-6:3:48", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,3:2:23-3:3:24", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,3:2:23-3:3:24", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,3:5:26-6:3:48", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,4:4:32-4:5:33", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,4:4:32-4:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,4:4:32-4:5:33", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:4:38-5:10:44", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:4:38-5:10:44", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:4:38-5:5:39", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:4:38-5:5:39", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:9:43-5:10:44", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:9:43-5:10:44", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.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/TestCreate/scenarios-edge-inherited.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.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", + "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": {} + } + } + ] + }, + "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": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.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/TestCreate/scenarios-edge-inherited.d2,4:4:32-4:5:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,4:4:32-4:5:33", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:4:38-5:5:39", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:4:38-5:5:39", + "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/TestCreate/scenarios-edge-inherited.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.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/TestCreate/scenarios-edge-inherited.d2,5:9:43-5:10:44", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge-inherited.d2,5:9:43-5:10:44", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestCreate/scenarios-edge.exp.json b/testdata/d2oracle/TestCreate/scenarios-edge.exp.json new file mode 100644 index 000000000..ed4cf7c75 --- /dev/null +++ b/testdata/d2oracle/TestCreate/scenarios-edge.exp.json @@ -0,0 +1,607 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,0:0:0-9:0:48", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,3:0:5-8:1:47", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,3:0:5-3:9:14", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,3:0:5-3:9:14", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,3:11:16-8:1:47", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,4:2:20-7:3:45", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,4:2:20-4:3:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,4:2:20-4:3:21", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,4:5:23-7:3:45", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,5:4:29-5:5:30", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,5:4:29-5:5:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,5:4:29-5:5:30", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:4:35-6:10:41", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:4:35-6:10:41", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:4:35-6:5:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:4:35-6:5:36", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:9:40-6:10:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:9:40-6:10:41", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,1:0:2-1:1:3", + "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 + } + ], + "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", + "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": {} + } + } + ] + }, + "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/TestCreate/scenarios-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.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/TestCreate/scenarios-edge.d2,5:4:29-5:5:30", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,5:4:29-5:5:30", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:4:35-6:5:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:4:35-6:5:36", + "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/TestCreate/scenarios-edge.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:9:40-6:10:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/scenarios-edge.d2,6:9:40-6:10:41", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestCreate/steps-basic.exp.json b/testdata/d2oracle/TestCreate/steps-basic.exp.json new file mode 100644 index 000000000..1d1ef21ff --- /dev/null +++ b/testdata/d2oracle/TestCreate/steps-basic.exp.json @@ -0,0 +1,583 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,0:0:0-9:0:39", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,3:0:5-8:1:38", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,3:0:5-3:5:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,3:0:5-3:5:10", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,3:7:12-8:1:38", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,4:2:16-7:3:36", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,4:2:16-4:3:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,4:2:16-4:3:17", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,4:5:19-7:3:36", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,5:4:25-5:5:26", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,5:4:25-5:5:26", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,5:4:25-5:5:26", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,6:4:31-6:5:32", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,6:4:31-6:5:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,6:4:31-6:5:32", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-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 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "steps": [ + { + "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", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-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 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "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/TestCreate/steps-basic.d2,5:4:25-5:5:26", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,5:4:25-5:5:26", + "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/TestCreate/steps-basic.d2,6:4:31-6:5:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-basic.d2,6:4:31-6:5:32", + "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/TestCreate/steps-conflict.exp.json b/testdata/d2oracle/TestCreate/steps-conflict.exp.json new file mode 100644 index 000000000..5f561da19 --- /dev/null +++ b/testdata/d2oracle/TestCreate/steps-conflict.exp.json @@ -0,0 +1,583 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,0:0:0-9:0:41", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,3:0:5-8:1:40", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,3:0:5-3:5:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,3:0:5-3:5:10", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,3:7:12-8:1:40", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,4:2:16-7:3:38", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,4:2:16-4:3:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,4:2:16-4:3:17", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,4:5:19-7:3:38", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,5:4:25-5:5:26", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,5:4:25-5:5:26", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,5:4:25-5:5:26", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,6:4:31-6:7:34", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,6:4:31-6:7:34", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,6:4:31-6:7:34", + "value": [ + { + "string": "d 2", + "raw_string": "d 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": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.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 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "steps": [ + { + "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", + "key": { + "range": ",0:0:0-0:0:0", + "path": [ + { + "unquoted_string": { + "range": ",0:0:0-0:0:0", + "value": [ + { + "string": "d 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": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.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 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "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/TestCreate/steps-conflict.d2,5:4:25-5:5:26", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,5:4:25-5:5:26", + "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": "d 2", + "id_val": "d 2", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,6:4:31-6:7:34", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-conflict.d2,6:4:31-6:7:34", + "value": [ + { + "string": "d 2", + "raw_string": "d 2" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "d 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/TestCreate/steps-edge.exp.json b/testdata/d2oracle/TestCreate/steps-edge.exp.json new file mode 100644 index 000000000..d97d8265a --- /dev/null +++ b/testdata/d2oracle/TestCreate/steps-edge.exp.json @@ -0,0 +1,654 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,0:0:0-9:0:44", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,1:0:2-1:1:3", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,3:0:5-8:1:43", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,3:0:5-3:5:10", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,3:0:5-3:5:10", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,3:7:12-8:1:43", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,4:2:16-7:3:41", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,4:2:16-4:3:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,4:2:16-4:3:17", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,4:5:19-7:3:41", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,5:4:25-5:5:26", + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,5:4:25-5:5:26", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,5:4:25-5:5:26", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:4:31-6:10:37", + "edges": [ + { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:4:31-6:10:37", + "src": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:4:31-6:5:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:4:31-6:5:32", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:9:36-6:10:37", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:9:36-6:10:37", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.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 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "d" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "steps": [ + { + "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": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.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 + }, + { + "id": "d", + "id_val": "d", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,1:0:2-1:1:3", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:4:31-6:5:32", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:4:31-6:5:32", + "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/TestCreate/steps-edge.d2,5:4:25-5:5:26", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,5:4:25-5:5:26", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:9:36-6:10:37", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestCreate/steps-edge.d2,6:9:36-6:10:37", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestDelete/layers-basic.exp.json b/testdata/d2oracle/TestDelete/layers-basic.exp.json new file mode 100644 index 000000000..9278c3367 --- /dev/null +++ b/testdata/d2oracle/TestDelete/layers-basic.exp.json @@ -0,0 +1,291 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,0:0:0-7:0:32", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,2:0:3-6:1:31", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,2:8:11-6:1:31", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,3:2:15-5:3:29", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,3:2:15-3:3:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,3:5:18-5:3:29", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,4:4:24-4:5:25", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/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": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/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": {} + } + } + ] + }, + "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/TestDelete/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/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/TestDelete/scenarios-basic.exp.json b/testdata/d2oracle/TestDelete/scenarios-basic.exp.json new file mode 100644 index 000000000..987593d7c --- /dev/null +++ b/testdata/d2oracle/TestDelete/scenarios-basic.exp.json @@ -0,0 +1,358 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,0:0:0-7:0:35", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,2:0:3-6:1:34", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,2:0:3-2:9:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,2:0:3-2:9:12", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,2:11:14-6:1:34", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,3:2:18-5:3:32", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,3:2:18-3:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,3:2:18-3:3:19", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,3:5:21-5:3:32", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,4:4:27-4:5:28", + "key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/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": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/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": {} + } + } + ] + }, + "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/TestDelete/scenarios-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestDelete/scenarios-basic.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestDelete/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/TestDelete/scenarios-inherited.exp.json b/testdata/d2oracle/TestDelete/scenarios-inherited.exp.json new file mode 100644 index 000000000..85a38a782 --- /dev/null +++ b/testdata/d2oracle/TestDelete/scenarios-inherited.exp.json @@ -0,0 +1,4 @@ +{ + "graph": null, + "err": "failed to delete \"a\": operation would modify AST outside of given scope" +} diff --git a/testdata/d2oracle/TestMove/layers-basic.exp.json b/testdata/d2oracle/TestMove/layers-basic.exp.json new file mode 100644 index 000000000..bf5bea56b --- /dev/null +++ b/testdata/d2oracle/TestMove/layers-basic.exp.json @@ -0,0 +1,393 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,0:0:0-9:0:49", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,2:0:3-8:1:48", + "key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,2:8:11-8:1:48", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,3:2:15-7:3:46", + "key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,3:2:15-3:3:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,3:5:18-7:3:46", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,4:4:24-6:5:42", + "key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,4:4:24-4:5:25", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,4:7:27-6:5:42", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,5:6:35-5:7:36", + "key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,5:6:35-5:7:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,5:6:35-5:7:36", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/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": { + "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": "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": null, + "objects": [ + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/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/TestMove/layers-basic.d2,5:6:35-5:7:36", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestMove/layers-basic.d2,5:6:35-5:7:36", + "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/TestMove/scenarios-out-of-scope.exp.json b/testdata/d2oracle/TestMove/scenarios-out-of-scope.exp.json new file mode 100644 index 000000000..8b6a3a125 --- /dev/null +++ b/testdata/d2oracle/TestMove/scenarios-out-of-scope.exp.json @@ -0,0 +1,4 @@ +{ + "graph": null, + "err": "failed to move: \"a\" to \"b.a\": operation would modify AST outside of given scope" +} diff --git a/testdata/d2oracle/TestSet/layers-unusable-ref-style.exp.json b/testdata/d2oracle/TestSet/layers-unusable-ref-style.exp.json new file mode 100644 index 000000000..b6e8eafa6 --- /dev/null +++ b/testdata/d2oracle/TestSet/layers-unusable-ref-style.exp.json @@ -0,0 +1,497 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,0:0:0-8:0:57", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,2:0:3-7:1:56", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,2:8:11-7:1:56", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,3:2:15-6:3:54", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,3:2:15-3:3:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,3:5:18-6:3:54", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,4:4:24-4:5:25", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,4:4:24-4:5:25", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:4:30-5:24:50", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:4:30-5:19:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:4:30-5:5:31", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:6:32-5:11:37", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:12:38-5:19:45", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:21:47-5:24:50", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.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": "a" + } + ] + } + } + ] + }, + "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/layers-unusable-ref-style.d2,5:21:47-5:24:50", + "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": null, + "objects": [ + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.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": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:4:30-5:19:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:4:30-5:5:31", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:6:32-5:11:37", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-unusable-ref-style.d2,5:12:38-5:19:45", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.2" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/layers-usable-ref-style.exp.json b/testdata/d2oracle/TestSet/layers-usable-ref-style.exp.json new file mode 100644 index 000000000..fc68d6cdf --- /dev/null +++ b/testdata/d2oracle/TestSet/layers-usable-ref-style.exp.json @@ -0,0 +1,403 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,0:0:0-7:0:54", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,2:0:3-6:1:53", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,2:0:3-2:6:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,2:0:3-2:6:9", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,2:8:11-6:1:53", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,3:2:15-5:3:51", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,3:2:15-3:3:16", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,3:2:15-3:3:16", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,3:5:18-5:3:51", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:4:24-4:27:47", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:4:24-4:5:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:7:27-4:27:47", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:8:28-4:26:46", + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:8:28-4:21:41", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:8:28-4:13:33", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:14:34-4:21:41", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:23:43-4:26:46", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.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": "a" + } + ] + } + } + ] + }, + "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/layers-usable-ref-style.d2,4:23:43-4:26:46", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:4:24-4:5:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/layers-usable-ref-style.d2,4:4:24-4:5:25", + "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": { + "opacity": { + "value": "0.2" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/scenarios-label-primary-missing.exp.json b/testdata/d2oracle/TestSet/scenarios-label-primary-missing.exp.json new file mode 100644 index 000000000..9dd6fd8f1 --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-label-primary-missing.exp.json @@ -0,0 +1,537 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,0:0:0-10:0:70", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,0:0:0-2:1:27", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,0:3:3-2:1:27", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,1:2:7-1:20:25", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,1:2:7-1:15:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,1:2:7-1:7:12", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,1:8:13-1:15:20", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,1:17:22-1:20:25", + "raw": "0.2", + "value": "1/5" + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,4:0:29-9:1:69", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,4:0:29-4:9:38", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,4:0:29-4:9:38", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,4:11:40-9:1:69", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,5:2:44-8:3:67", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,5:2:44-5:3:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,5:2:44-5:3:45", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,5:5:47-8:3:67", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,6:4:53-6:5:54", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,6:4:53-6:5:54", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,6:4:53-6:5:54", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,7:4:59-7:8:63", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,7:4:59-7:5:60", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,7:4:59-7:5:60", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,7:7:62-7:8:63", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "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/TestSet/scenarios-label-primary-missing.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.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": { + "opacity": { + "value": "0.2" + } + }, + "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": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,7:7:62-7:8:63", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + "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-label-primary-missing.d2,1:17:22-1:20:25", + "raw": "0.2", + "value": "1/5" + } + }, + "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": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.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/TestSet/scenarios-label-primary-missing.d2,7:4:59-7:5:60", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,7:4:59-7:5:60", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.2" + } + }, + "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-label-primary-missing.d2,6:4:53-6:5:54", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary-missing.d2,6:4:53-6:5:54", + "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/TestSet/scenarios-label-primary.exp.json b/testdata/d2oracle/TestSet/scenarios-label-primary.exp.json new file mode 100644 index 000000000..8399c247e --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-label-primary.exp.json @@ -0,0 +1,493 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,0:0:0-11:0:97", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,0:0:0-2:1:27", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,0:3:3-2:1:27", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,1:2:7-1:20:25", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,1:2:7-1:15:20", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,1:2:7-1:7:12", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,1:8:13-1:15:20", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,1:17:22-1:20:25", + "raw": "0.2", + "value": "1/5" + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,4:0:29-10:1:96", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,4:0:29-4:9:38", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,4:0:29-4:9:38", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,4:11:40-10:1:96", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,5:2:44-9:3:94", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,5:2:44-5:3:45", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,5:2:44-5:3:45", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,5:5:47-9:3:94", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,6:4:53-8:5:90", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,6:4:53-6:5:54", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,6:4:53-6:5:54", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,6:7:56-6:8:57", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,6:9:58-8:5:90", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,7:6:66-7:24:84", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,7:6:66-7:19:79", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,7:6:66-7:11:71", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,7:12:72-7:19:79", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,7:21:81-7:24:84", + "raw": "0.3", + "value": "3/10" + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.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": { + "opacity": { + "value": "0.2" + } + }, + "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": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,6:7:56-6:8:57", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + }, + "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-label-primary.d2,7:21:81-7:24:84", + "raw": "0.3", + "value": "3/10" + } + }, + "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/TestSet/scenarios-label-primary.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.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/TestSet/scenarios-label-primary.d2,6:4:53-6:5:54", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-label-primary.d2,6:4:53-6:5:54", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.3" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.exp.json b/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.exp.json new file mode 100644 index 000000000..10d0c34ab --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.exp.json @@ -0,0 +1,649 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,0:0:0-11:0:96", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,0:0:0-2:1:17", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,0:3:3-2:1:17", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:2:7-1:10:15", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:2:7-1:3:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:2:7-1:3:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:5:10-1:10:15", + "value": [ + { + "string": "outer", + "raw_string": "outer" + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,4:0:19-10:1:95", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,4:0:19-4:9:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,4:0:19-4:9:28", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,4:11:30-10:1:95", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,5:2:34-9:3:93", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,5:2:34-5:3:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,5:2:34-5:3:35", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,5:5:37-9:3:93", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,6:4:43-8:5:89", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,6:4:43-6:5:44", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,6:4:43-6:5:44", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,6:7:46-8:5:89", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:6:54-7:35:83", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:6:54-7:7:55", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:6:54-7:7:55", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:9:57-7:14:62", + "value": [ + { + "string": "inner", + "raw_string": "inner" + } + ] + } + }, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:15:63-7:35:83", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:16:64-7:34:82", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:16:64-7:29:77", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:16:64-7:21:69", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:22:70-7:29:77", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:31:79-7:34:82", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:2:7-1:3:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:2:7-1:3:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "outer" + }, + "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": { + "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": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:9:57-7:14:62", + "value": [ + { + "string": "inner", + "raw_string": "inner" + } + ] + } + }, + "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-nested-usable-ref-style.d2,7:31:79-7:34:82", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.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/TestSet/scenarios-nested-usable-ref-style.d2,6:4:43-6:5:44", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,6:4:43-6:5:44", + "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 + }, + { + "id": "b", + "id_val": "b", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:2:7-1:3:8", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,1:2:7-1:3:8", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:6:54-7:7:55", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-nested-usable-ref-style.d2,7:6:54-7:7:55", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "inner" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.2" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +} diff --git a/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.exp.json b/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.exp.json new file mode 100644 index 000000000..1b3c4bce4 --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.exp.json @@ -0,0 +1,517 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,0:0:0-8:0:60", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,0:0:0-0:1:1", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,2:0:3-7:1:59", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,2:0:3-2:9:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,2:0:3-2:9:12", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,2:11:14-7:1:59", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,3:2:18-6:3:57", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,3:2:18-3:3:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,3:2:18-3:3:19", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,3:5:21-6:3:57", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,4:4:27-4:5:28", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,4:4:27-4:5:28", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:4:33-5:24:53", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:4:33-5:19:48", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:4:33-5:5:34", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:6:35-5:11:40", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:12:41-5:19:48", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:21:50-5:24:53", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.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": { + "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-unusable-ref-style.d2,5:21:50-5:24:53", + "raw": "0.2", + "value": "1/5" + } + }, + "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": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.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/TestSet/scenarios-unusable-ref-style.d2,5:4:33-5:19:48", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:4:33-5:5:34", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:6:35-5:11:40", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.d2,5:12:41-5:19:48", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.2" + } + }, + "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-unusable-ref-style.d2,4:4:27-4:5:28", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-unusable-ref-style.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/TestSet/scenarios-usable-ref-style.exp.json b/testdata/d2oracle/TestSet/scenarios-usable-ref-style.exp.json new file mode 100644 index 000000000..446504d3b --- /dev/null +++ b/testdata/d2oracle/TestSet/scenarios-usable-ref-style.exp.json @@ -0,0 +1,453 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,0:0:0-7:0:70", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,0:0:0-0:8:8", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,0:3:3-0:8:8", + "value": [ + { + "string": "outer", + "raw_string": "outer" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,2:0:10-6:1:69", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,2:0:10-2:9:19", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,2:0:10-2:9:19", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,2:11:21-6:1:69", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,3:2:25-5:3:67", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,3:2:25-3:3:26", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,3:2:25-3:3:26", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,3:5:28-5:3:67", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:4:34-4:33:63", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:4:34-4:5:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:4:34-4:5:35", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:7:37-4:12:42", + "value": [ + { + "string": "inner", + "raw_string": "inner" + } + ] + } + }, + "value": { + "map": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:13:43-4:33:63", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:14:44-4:32:62", + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:14:44-4:27:57", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:14:44-4:19:49", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:20:50-4:27:57", + "value": [ + { + "string": "opacity", + "raw_string": "opacity" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:29:59-4:32:62", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.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": "outer" + }, + "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": { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:7:37-4:12:42", + "value": [ + { + "string": "inner", + "raw_string": "inner" + } + ] + } + }, + "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-usable-ref-style.d2,4:29:59-4:32:62", + "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": null, + "objects": [ + { + "id": "a", + "id_val": "a", + "references": [ + { + "key": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.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/TestSet/scenarios-usable-ref-style.d2,4:4:34-4:5:35", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2oracle/TestSet/scenarios-usable-ref-style.d2,4:4:34-4:5:35", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "inner" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "opacity": { + "value": "0.2" + } + }, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + } + ] + }, + "err": "" +}