From 49428367a5538e59f69262d4a92a2dc75d568e9b Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 2 Jan 2023 18:13:44 -0800 Subject: [PATCH 01/60] d2compiler: Remove old TODO --- d2compiler/compile.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index c89a4853e..6b60e61d8 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -17,8 +17,6 @@ import ( "oss.terrastruct.com/d2/d2target" ) -// TODO: should Parse even be exported? guess not. IR should contain list of files and -// their AST. type CompileOptions struct { UTF16 bool } From ecd61cdb49a13a7062aab25b6505c48800757de8 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 2 Jan 2023 18:14:09 -0800 Subject: [PATCH 02/60] d2compiler: Remove another old now irrelevant TODO --- d2compiler/compile.go | 1 - 1 file changed, 1 deletion(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 6b60e61d8..089d01550 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -53,7 +53,6 @@ func compileAST(path string, pe d2parser.ParseError, ast *d2ast.Map) (*d2graph.G c.validateKeys(g.Root, ast) } c.compileEdges(g.Root, ast) - // TODO: simplify removeContainer by running before compileEdges c.compileShapes(g.Root) c.validateNear(g) From 8ea2c71b99193ba28d25ca81b49741dfac046fbf Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 3 Jan 2023 02:47:03 -0800 Subject: [PATCH 03/60] d2graph: Remove TODO --- d2graph/d2graph.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 28ea03ef9..016c21ee4 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -24,9 +24,6 @@ import ( const INNER_LABEL_PADDING int = 5 const DEFAULT_SHAPE_PADDING = 100. -// TODO: Refactor with a light abstract layer on top of AST implementing scenarios, -// variables, imports, substitutions and then a final set of structures representing -// a final graph. type Graph struct { AST *d2ast.Map `json:"ast"` From c9ef6ab9c995b8acc95ec7657035bc4fc7431562 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 3 Jan 2023 17:50:27 -0800 Subject: [PATCH 04/60] d2graph: Implement deep copying a graph --- ci/sub | 2 +- d2compiler/compile.go | 21 +- d2compiler/compile_test.go | 71 ++- d2graph/copy.go | 176 +++++++ d2graph/copy_test.go | 86 ++++ d2graph/d2graph.go | 22 +- d2graph/seqdiagram.go | 2 +- d2layouts/d2sequence/layout_test.go | 18 +- d2layouts/d2sequence/sequence_diagram.go | 2 +- d2target/class.go | 10 + d2target/sqltable.go | 9 + go.mod | 42 +- go.sum | 271 ++--------- out/.gitignore | 0 .../TestCompile2/scenarios/one.exp.json | 455 ++++++++++++++++++ 15 files changed, 913 insertions(+), 274 deletions(-) create mode 100644 d2graph/copy.go create mode 100644 d2graph/copy_test.go delete mode 100644 out/.gitignore create mode 100644 testdata/d2compiler/TestCompile2/scenarios/one.exp.json diff --git a/ci/sub b/ci/sub index 23984e4d7..b1ec0a8d4 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 23984e4d743dd9977b513c0fd850a4996c9198a5 +Subproject commit b1ec0a8d430a62b7556211ed8bcd7b6e41e2362c diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 089d01550..773cbae08 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -148,7 +148,8 @@ func (c *compiler) compileArrowheads(edge *d2graph.Edge, m *d2ast.Map, mk *d2ast return false } fakeParent := &d2graph.Object{ - Children: make(map[string]*d2graph.Object), + Children: make(map[string]*d2graph.Object), + Attributes: &d2graph.Attributes{}, } detachedMK := &d2ast.Key{ Key: arrowheadKey, @@ -262,8 +263,8 @@ func (c *compiler) compileKey(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) }, unresolvedObj) } else if obj.Parent == nil { // Top level reserved key set on root. - c.compileAttributes(&obj.Attributes, mk) - c.applyScalar(&obj.Attributes, reserved, mk.Value.ScalarBox()) + c.compileAttributes(obj.Attributes, mk) + c.applyScalar(obj.Attributes, reserved, mk.Value.ScalarBox()) return } @@ -271,13 +272,13 @@ func (c *compiler) compileKey(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) return } - c.compileAttributes(&obj.Attributes, mk) + c.compileAttributes(obj.Attributes, mk) if obj.Attributes.Style.Animated != nil { c.errorf(mk.Range.Start, mk.Range.End, `key "animated" can only be applied to edges`) return } - c.applyScalar(&obj.Attributes, reserved, mk.Value.ScalarBox()) + c.applyScalar(obj.Attributes, reserved, mk.Value.ScalarBox()) if mk.Value.Map != nil { if reserved != "" { c.errorf(mk.Range.Start, mk.Range.End, "cannot set reserved key %q to a map", reserved) @@ -287,7 +288,7 @@ func (c *compiler) compileKey(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) c.compileKeys(obj, mk.Value.Map) } - c.applyScalar(&obj.Attributes, reserved, mk.Primary) + c.applyScalar(obj.Attributes, reserved, mk.Primary) } func (c *compiler) applyScalar(attrs *d2graph.Attributes, reserved string, box d2ast.ScalarBox) { @@ -438,8 +439,8 @@ func (c *compiler) compileEdge(edge *d2graph.Edge, m *d2ast.Map, mk *d2ast.Key) if len(mk.Edges) == 1 { edge.Attributes.Label.MapKey = mk } - c.applyScalar(&edge.Attributes, "", mk.Value.ScalarBox()) - c.applyScalar(&edge.Attributes, "", mk.Primary) + c.applyScalar(edge.Attributes, "", mk.Value.ScalarBox()) + c.applyScalar(edge.Attributes, "", mk.Primary) } else { c.compileEdgeKey(edge, m, mk) } @@ -487,8 +488,8 @@ func (c *compiler) compileEdgeKey(edge *d2graph.Edge, m *d2ast.Map, mk *d2ast.Ke if ok { return } - c.compileAttributes(&edge.Attributes, mk) - c.applyScalar(&edge.Attributes, r, mk.Value.ScalarBox()) + c.compileAttributes(edge.Attributes, mk) + c.applyScalar(edge.Attributes, r, mk.Value.ScalarBox()) if mk.Value.Map != nil { for _, n := range mk.Value.Map.Nodes { if n.MapKey != nil { diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index a432f078e..926dbeb2a 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -8,12 +8,13 @@ import ( tassert "github.com/stretchr/testify/assert" + "oss.terrastruct.com/util-go/assert" + "oss.terrastruct.com/util-go/diff" + "oss.terrastruct.com/d2/d2compiler" "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2target" - "oss.terrastruct.com/util-go/assert" - "oss.terrastruct.com/util-go/diff" ) func TestCompile(t *testing.T) { @@ -1939,3 +1940,69 @@ Chinchillas_Collectibles.chinchilla -> Chinchillas.id`, }) } } + +func TestCompile2(t *testing.T) { + t.Parallel() + + t.Run("scenarios", testScenarios) +} + +func testScenarios(t *testing.T) { + t.Parallel() + + tca := []struct { + name string + run func(t *testing.T) + }{ + { + name: "one", + run: func(t *testing.T) { + g := assertCompile(t, `base + +layers: { + one: { + santa + } + two: { + clause + } +} +`, "") + assert.JSON(t, 2, len(g.Layers)) + assert.JSON(t, "one", g.Layers[0].Root.ID) + assert.JSON(t, "two", g.Layers[1].Root.ID) + }, + }, + } + + for _, tc := range tca { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + tc.run(t) + }) + } +} + +func assertCompile(t *testing.T, text string, expErr string) *d2graph.Graph { + d2Path := fmt.Sprintf("d2/testdata/d2compiler/%v.d2", t.Name()) + g, err := d2compiler.Compile(d2Path, strings.NewReader(text), nil) + if expErr != "" { + assert.Error(t, err) + assert.ErrorString(t, err, expErr) + } else { + assert.Success(t, err) + } + + got := struct { + Graph *d2graph.Graph `json:"graph"` + Err error `json:"err"` + }{ + Graph: g, + Err: err, + } + + err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2compiler", t.Name()), got) + assert.Success(t, err) + return g +} diff --git a/d2graph/copy.go b/d2graph/copy.go new file mode 100644 index 000000000..b6d1828c4 --- /dev/null +++ b/d2graph/copy.go @@ -0,0 +1,176 @@ +package d2graph + +func (s *Scalar) Copy() *Scalar { + if s == nil { + return nil + } + tmp := *s + return &tmp +} + +func (s Style) Copy() Style { + return Style{ + Opacity: s.Opacity.Copy(), + Stroke: s.Stroke.Copy(), + Fill: s.Fill.Copy(), + StrokeWidth: s.StrokeWidth.Copy(), + StrokeDash: s.StrokeDash.Copy(), + BorderRadius: s.BorderRadius.Copy(), + Shadow: s.Shadow.Copy(), + ThreeDee: s.ThreeDee.Copy(), + Multiple: s.Multiple.Copy(), + Font: s.Font.Copy(), + FontSize: s.FontSize.Copy(), + FontColor: s.FontColor.Copy(), + Animated: s.Animated.Copy(), + Bold: s.Bold.Copy(), + Italic: s.Italic.Copy(), + Underline: s.Underline.Copy(), + Filled: s.Filled.Copy(), + } +} + +func (attrs *Attributes) Copy() *Attributes { + if attrs == nil { + return nil + } + return &Attributes{ + Label: attrs.Label, + Style: attrs.Style.Copy(), + Icon: attrs.Icon, + Tooltip: attrs.Tooltip, + Link: attrs.Link, + + Width: attrs.Width.Copy(), + Height: attrs.Height.Copy(), + + NearKey: attrs.NearKey, + Language: attrs.Language, + Shape: attrs.Shape, + + Direction: attrs.Shape, + } +} + +func (o *Object) Copy() *Object { + return &Object{ + Graph: o.Graph, + Parent: o.Parent, + + ID: o.ID, + IDVal: o.IDVal, + Map: o.Map, + LabelDimensions: o.LabelDimensions, + References: append([]Reference(nil), o.References...), + + Box: o.Box.Copy(), + LabelPosition: o.LabelPosition, + LabelWidth: o.LabelHeight, + LabelHeight: o.LabelHeight, + IconPosition: o.IconPosition, + + Class: o.Class.Copy(), + SQLTable: o.SQLTable.Copy(), + + Children: copyChildrenMap(o.Children), + ChildrenArray: append([]*Object(nil), o.ChildrenArray...), + + Attributes: o.Attributes.Copy(), + + ZIndex: o.ZIndex, + } +} + +func copyChildrenMap(children map[string]*Object) map[string]*Object { + children2 := make(map[string]*Object, len(children)) + for id, ch := range children { + children2[id] = ch + } + return children2 +} + +func (e *Edge) Copy() *Edge { + return &Edge{ + Index: e.Index, + + MinWidth: e.MinWidth, + MinHeight: e.MinHeight, + + SrcTableColumnIndex: e.SrcTableColumnIndex, + DstTableColumnIndex: e.DstTableColumnIndex, + + LabelDimensions: e.LabelDimensions, + LabelPosition: e.LabelPosition, + LabelPercentage: e.LabelPercentage, + + IsCurve: e.IsCurve, + Route: e.Route, + + Src: e.Src, + SrcArrow: e.SrcArrow, + SrcArrowhead: e.SrcArrowhead.Copy(), + Dst: e.Dst, + DstArrow: e.DstArrow, + DstArrowhead: e.DstArrowhead.Copy(), + + References: append([]EdgeReference(nil), e.References...), + Attributes: e.Attributes.Copy(), + + ZIndex: e.ZIndex, + } +} + +// Copy copies for use as the base of a step or scenario. +func (g *Graph) Copy() *Graph { + g2 := &Graph{ + AST: g.AST, + + Root: g.Root.Copy(), + } + + absIDMap := make(map[string]*Object, len(g.Objects)) + for _, o := range g.Objects { + o2 := o.Copy() + g2.Objects = append(g2.Objects, o2) + absIDMap[o.AbsID()] = o2 + } + + updateObjectPointers := func(o2 *Object) { + o2.Graph = g2 + if o2.Parent != nil { + if o2.Parent.Parent == nil { + o2.Parent = g2.Root + } else { + o2.Parent = absIDMap[o2.Parent.AbsID()] + } + } + + for i, ref := range o2.References { + o2.References[i].ScopeObj = absIDMap[ref.ScopeObj.AbsID()] + } + for id, ch := range o2.Children { + o2.Children[id] = absIDMap[ch.AbsID()] + } + for i, ch := range o2.ChildrenArray { + o2.ChildrenArray[i] = absIDMap[ch.AbsID()] + } + } + updateObjectPointers(g2.Root) + for _, o2 := range g2.Objects { + updateObjectPointers(o2) + } + + for _, e := range g.Edges { + g2.Edges = append(g2.Edges, e.Copy()) + } + for _, e2 := range g2.Edges { + e2.Src = absIDMap[e2.Src.AbsID()] + e2.Dst = absIDMap[e2.Dst.AbsID()] + + for i, ref := range e2.References { + e2.References[i].ScopeObj = absIDMap[ref.ScopeObj.AbsID()] + } + } + + return g2 +} diff --git a/d2graph/copy_test.go b/d2graph/copy_test.go new file mode 100644 index 000000000..78b1c3e32 --- /dev/null +++ b/d2graph/copy_test.go @@ -0,0 +1,86 @@ +package d2graph_test + +import ( + "strings" + "testing" + + "oss.terrastruct.com/util-go/assert" + + "oss.terrastruct.com/d2/d2compiler" + "oss.terrastruct.com/d2/d2graph" +) + +func TestCopy(t *testing.T) { + t.Parallel() + + tca := []struct { + name string + d2str string + assert func(t *testing.T, g, g2 *d2graph.Graph) + }{ + { + name: `objects`, + d2str: `a +b +c +d`, + assert: func(t *testing.T, g, g2 *d2graph.Graph) { + g2.Root.IDVal = `jingleberry` + assert.String(t, ``, g.Root.IDVal) + g2.Root.ChildrenArray[0].IDVal = `saltedmeat` + assert.String(t, `a`, g.Root.ChildrenArray[0].IDVal) + assert.NotEqual(t, + g.Root.ChildrenArray[0].References[0].ScopeObj, + g2.Root.ChildrenArray[0].References[0].ScopeObj, + ) + }, + }, + { + name: `edges`, + d2str: `a -> b +b -> c +c -> d +d -> a`, + assert: func(t *testing.T, g, g2 *d2graph.Graph) { + g2.Edges[0].DstArrow = false + assert.Equal(t, true, g.Edges[0].DstArrow) + assert.NotEqual(t, + g.Edges[0].References[0].ScopeObj, + g2.Edges[0].References[0].ScopeObj, + ) + }, + }, + { + name: `nested`, + d2str: `a.b -> c.d`, + assert: func(t *testing.T, g, g2 *d2graph.Graph) { + g2.Root.ChildrenArray[0].ChildrenArray[0].IDVal = `saltedmeat` + assert.String(t, `b`, g.Root.ChildrenArray[0].ChildrenArray[0].IDVal) + assert.NotEqual(t, + g.Root.ChildrenArray[0].ChildrenArray[0].References[0].ScopeObj, + g2.Root.ChildrenArray[0].ChildrenArray[0].References[0].ScopeObj, + ) + + g2.Edges[0].DstArrow = false + assert.Equal(t, true, g.Edges[0].DstArrow) + assert.NotEqual(t, + g.Edges[0].References[0].ScopeObj, + g2.Edges[0].References[0].ScopeObj, + ) + }, + }, + } + + for _, tc := range tca { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + g, err := d2compiler.Compile("", strings.NewReader(tc.d2str), nil) + assert.Success(t, err) + + g2 := g.Copy() + tc.assert(t, g, g2) + }) + } +} diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 016c21ee4..3822299e2 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -30,6 +30,10 @@ type Graph struct { Root *Object `json:"root"` Edges []*Edge `json:"edges"` Objects []*Object `json:"objects"` + + Layers []*Graph `json:"layers,omitempty"` + Scenarios []*Graph `json:"scenarios,omitempty"` + Steps []*Graph `json:"steps,omitempty"` } func NewGraph(ast *d2ast.Map) *Graph { @@ -37,9 +41,10 @@ func NewGraph(ast *d2ast.Map) *Graph { AST: ast, } d.Root = &Object{ - Graph: d, - Parent: nil, - Children: make(map[string]*Object), + Graph: d, + Parent: nil, + Children: make(map[string]*Object), + Attributes: &Attributes{}, } return d } @@ -52,6 +57,7 @@ type Scalar struct { } // TODO maybe rename to Shape +// reminder: When adding new fields remember to update copy.go type Object struct { Graph *Graph `json:"-"` Parent *Object `json:"-"` @@ -79,11 +85,12 @@ type Object struct { Children map[string]*Object `json:"-"` ChildrenArray []*Object `json:"-"` - Attributes Attributes `json:"attributes"` + Attributes *Attributes `json:"attributes,omitempty"` ZIndex int `json:"zIndex"` } +// reminder: When adding new fields remember to update copy.go type Attributes struct { Label Scalar `json:"label"` Style Style `json:"style"` @@ -126,6 +133,7 @@ func (r Reference) InEdge() bool { return r.Key != r.MapKey.Key } +// reminder: When adding new fields remember to update copy.go type Style struct { Opacity *Scalar `json:"opacity,omitempty"` Stroke *Scalar `json:"stroke,omitempty"` @@ -487,7 +495,7 @@ func (obj *Object) newObject(id string) *Object { child := &Object{ ID: id, IDVal: idval, - Attributes: Attributes{ + Attributes: &Attributes{ Label: Scalar{ Value: idval, }, @@ -850,7 +858,7 @@ type Edge struct { DstArrowhead *Attributes `json:"dstArrowhead,omitempty"` References []EdgeReference `json:"references,omitempty"` - Attributes Attributes `json:"attributes"` + Attributes *Attributes `json:"attributes,omitempty"` ZIndex int `json:"zIndex"` } @@ -947,7 +955,7 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label } edge := &Edge{ - Attributes: Attributes{ + Attributes: &Attributes{ Label: Scalar{ Value: label, }, diff --git a/d2graph/seqdiagram.go b/d2graph/seqdiagram.go index a92cc8924..0f6567596 100644 --- a/d2graph/seqdiagram.go +++ b/d2graph/seqdiagram.go @@ -3,7 +3,7 @@ package d2graph import "oss.terrastruct.com/d2/d2target" func (obj *Object) IsSequenceDiagram() bool { - return obj != nil && obj.Attributes.Shape.Value == d2target.ShapeSequenceDiagram + return obj != nil && obj.Attributes != nil && obj.Attributes.Shape.Value == d2target.ShapeSequenceDiagram } func (obj *Object) OuterSequenceDiagram() *Object { diff --git a/d2layouts/d2sequence/layout_test.go b/d2layouts/d2sequence/layout_test.go index 50c1e3ffe..77767f852 100644 --- a/d2layouts/d2sequence/layout_test.go +++ b/d2layouts/d2sequence/layout_test.go @@ -387,7 +387,7 @@ func TestSelfEdges(t *testing.T) { Src: n1, Dst: n1, Index: 0, - Attributes: d2graph.Attributes{ + Attributes: &d2graph.Attributes{ Label: d2graph.Scalar{Value: "left to right"}, }, }, @@ -417,7 +417,7 @@ func TestSequenceToDescendant(t *testing.T) { g.Root.Attributes.Shape = d2graph.Scalar{Value: d2target.ShapeSequenceDiagram} a := g.Root.EnsureChild([]string{"a"}) a.Box = geo.NewBox(nil, 100, 100) - a.Attributes = d2graph.Attributes{ + a.Attributes = &d2graph.Attributes{ Shape: d2graph.Scalar{Value: shape.PERSON_TYPE}, } a_t1 := a.EnsureChild([]string{"t1"}) @@ -425,13 +425,15 @@ func TestSequenceToDescendant(t *testing.T) { g.Edges = []*d2graph.Edge{ { - Src: a, - Dst: a_t1, - Index: 0, + Src: a, + Dst: a_t1, + Index: 0, + Attributes: &d2graph.Attributes{}, }, { - Src: a_t1, - Dst: a, - Index: 0, + Src: a_t1, + Dst: a, + Index: 0, + Attributes: &d2graph.Attributes{}, }, } diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 053694d1a..1da928656 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -324,7 +324,7 @@ func (sd *sequenceDiagram) addLifelineEdges() { actorLifelineEnd := actor.Center() actorLifelineEnd.Y = endY sd.lifelines = append(sd.lifelines, &d2graph.Edge{ - Attributes: d2graph.Attributes{ + Attributes: &d2graph.Attributes{ Style: d2graph.Style{ StrokeDash: &d2graph.Scalar{Value: fmt.Sprintf("%d", LIFELINE_STROKE_DASH)}, StrokeWidth: &d2graph.Scalar{Value: fmt.Sprintf("%d", LIFELINE_STROKE_WIDTH)}, diff --git a/d2target/class.go b/d2target/class.go index f62a3ea43..3a2d2c5e0 100644 --- a/d2target/class.go +++ b/d2target/class.go @@ -69,3 +69,13 @@ func (cm ClassMethod) VisibilityToken() string { return "+" } } + +func (c *Class) Copy() *Class { + if c == nil { + return nil + } + return &Class{ + Fields: append([]ClassField(nil), c.Fields...), + Methods: append([]ClassMethod(nil), c.Methods...), + } +} diff --git a/d2target/sqltable.go b/d2target/sqltable.go index 8332a34c8..64ee34d58 100644 --- a/d2target/sqltable.go +++ b/d2target/sqltable.go @@ -50,3 +50,12 @@ func (c SQLColumn) ConstraintAbbr() string { return "" } } + +func (st *SQLTable) Copy() *SQLTable { + if st == nil { + return nil + } + return &SQLTable{ + Columns: append([]SQLColumn(nil), st.Columns...), + } +} diff --git a/go.mod b/go.mod index be4afe5ac..71db602d4 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module oss.terrastruct.com/d2 go 1.18 require ( - cdr.dev/slog v1.4.2-0.20221206192828-e4803b10ae17 + cdr.dev/slog v1.4.1 github.com/PuerkitoBio/goquery v1.8.0 github.com/alecthomas/chroma v0.10.0 - github.com/dop251/goja v0.0.0-20221118162653-d4bf6fde1b86 + github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 github.com/fsnotify/fsnotify v1.6.0 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/lucasb-eyer/go-colorful v1.2.0 @@ -15,46 +15,36 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.1 github.com/yuin/goldmark v1.5.3 - go.uber.org/multierr v1.8.0 - golang.org/x/image v0.1.0 - golang.org/x/net v0.2.0 + go.uber.org/multierr v1.9.0 + golang.org/x/image v0.3.0 + golang.org/x/net v0.5.0 golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 gonum.org/v1/plot v0.12.0 nhooyr.io/websocket v1.8.7 - oss.terrastruct.com/util-go v0.0.0-20230118143836-0960f48cae9f + oss.terrastruct.com/util-go v0.0.0-20230123214952-834a0f3992d1 ) require ( - cloud.google.com/go/compute v1.7.0 // indirect github.com/andybalholm/cascadia v1.3.1 // indirect github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.7.0 // indirect - github.com/fatih/color v1.13.0 // indirect - github.com/gin-gonic/gin v1.7.7 // indirect - github.com/go-playground/validator/v10 v10.10.0 // indirect + github.com/fatih/color v1.12.0 // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/go-stack/stack v1.8.1 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.13.6 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/klauspost/compress v1.10.3 // indirect + github.com/mattn/go-colorable v0.1.8 // indirect + github.com/mattn/go-isatty v0.0.12 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.8.0 // indirect - github.com/ugorji/go/codec v1.2.6 // indirect - go.opencensus.io v0.24.0 // indirect + go.opencensus.io v0.23.0 // indirect go.uber.org/atomic v1.7.0 // indirect - golang.org/x/crypto v0.3.0 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect - golang.org/x/sys v0.2.0 // indirect - golang.org/x/term v0.2.0 // indirect - golang.org/x/text v0.4.0 // indirect - google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect - google.golang.org/protobuf v1.28.1 // indirect + golang.org/x/sys v0.4.0 // indirect + golang.org/x/term v0.4.0 // indirect + golang.org/x/text v0.6.0 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 4648445e7..4b91ebd5b 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -cdr.dev/slog v1.4.2-0.20221206192828-e4803b10ae17 h1:Jf+VOk2lif79HeTlnLaZ70zYTsuVSUEu/47U9VaG2Rw= -cdr.dev/slog v1.4.2-0.20221206192828-e4803b10ae17/go.mod h1:YPVZsUbRMaLaPgme0RzlPWlC7fI7YmDj/j/kZLuvICs= +cdr.dev/slog v1.4.1 h1:Q8+X63m8/WB4geelMTDO8t4CTwVh1f7+5Cxi7kS/SZg= +cdr.dev/slog v1.4.1/go.mod h1:O76C6gZJxa5HK1SXMrjd48V2kJxYZKFRTcFfn/V9OhA= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -20,32 +20,16 @@ cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmW cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0 h1:bAMqZidYkmIsUqe6PtkEPT7Q+vfizScn+jfNA6jwK9c= cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0 h1:v/k9Eueb8aAJ0vZuxKMrgm6kPhCLZU9HxFU+AFDs9Uk= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -55,23 +39,23 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= git.sr.ht/~sbinet/gg v0.3.1 h1:LNhjNn8DerC8f9DHLz6lS0YYul/b602DUxDgGkd/Aik= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U= github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= +github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= +github.com/alecthomas/chroma v0.9.1/go.mod h1:eMuEnpA18XbG/WhOWtCzJHS7WqEtDAI+HxdwoW0nVSk= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= +github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= +github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= +github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -79,12 +63,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= @@ -97,8 +75,8 @@ github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwu github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20221118162653-d4bf6fde1b86 h1:E2wycakfddWJ26v+ZyEY91Lb/HEZyaiZhbMX+KQcdmc= -github.com/dop251/goja v0.0.0-20221118162653-d4bf6fde1b86/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= +github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 h1:kgvzE5wLsLa7XKfV85VZl40QXaMCaeFtHpPwJ8fhotY= +github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -107,20 +85,15 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= +github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= -github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= github.com/go-fonts/liberation v0.2.0 h1:jAkAWJP4S+OsrPLZM4/eC9iW7CtHy+HBXrEwZXWo5VM= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -128,16 +101,12 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81 h1:6zl3BbBhdnMkpSj2YY30qV3gDcVBGtFgVsV3+/i+mKQ= github.com/go-pdf/fpdf v0.6.0 h1:MlgtGIfsdMEEQJr2le6b/HNr1ZlQwxyWr77r2aj2U/8= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0= -github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= @@ -153,9 +122,8 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -164,7 +132,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -198,9 +165,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -218,37 +183,25 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/h2non/filetype v1.1.1/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -257,45 +210,40 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mazznoer/csscolorparser v0.1.3 h1:vug4zh6loQxAUxfU1DZEu70gTPufDPspamZlHAkKcxE= github.com/mazznoer/csscolorparser v0.1.3/go.mod h1:Aj22+L/rYN/Y6bj3bYqO3N6g1dtdHtGfQ32xZ5PJQic= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/playwright-community/playwright-go v0.2000.1 h1:2JViSHpJQ/UL/PO1Gg6gXV5IcXAAsoBJ3KG9L3wKXto= github.com/playwright-community/playwright-go v0.2000.1/go.mod h1:1y9cM9b9dVHnuRWzED1KLM7FtbwTJC8ibDjI6MNqewU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= -github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -305,11 +253,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= -github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -324,23 +271,19 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= -go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -355,8 +298,8 @@ golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7 golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.1.0 h1:r8Oj8ZA2Xy12/b5KZYj3tuv7NG/fBz3TwQVvpJ9l8Rk= -golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c= +golang.org/x/image v0.3.0 h1:HTDXbdK9bjfSWkPzDJIw89W8CAtfFGduujWs33NLLsg= +golang.org/x/image v0.3.0/go.mod h1:fXd9211C/0VTlYuAcOhW8dY/RtEJqODXOWBDpmYBf+A= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -417,15 +360,9 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -438,14 +375,6 @@ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -457,7 +386,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -480,6 +408,7 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -499,35 +428,17 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg= +golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -537,8 +448,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -590,17 +501,11 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/plot v0.12.0 h1:y1ZNmfz/xHuHvtgFe8USZVyykQo5ERXPnspQNVK15Og= @@ -627,23 +532,6 @@ google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjR google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -674,7 +562,6 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= @@ -690,47 +577,10 @@ google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc h1:Nf+EdcTLHR8qDNN/KfkQL0u0ssxt9OhbaWCl5C0ucEI= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -744,7 +594,6 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= @@ -752,17 +601,8 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -775,11 +615,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -788,12 +625,10 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -805,8 +640,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -oss.terrastruct.com/util-go v0.0.0-20230118143836-0960f48cae9f h1:+VLjmVHPpFbsovhDyXOX7xRa8bM6tQ2821jsviq57PY= -oss.terrastruct.com/util-go v0.0.0-20230118143836-0960f48cae9f/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= +oss.terrastruct.com/util-go v0.0.0-20230123214952-834a0f3992d1 h1:mhZsCUUqGInjqOsxF0TlP1TVwpBC+O2CUgKs9Xw2ViU= +oss.terrastruct.com/util-go v0.0.0-20230123214952-834a0f3992d1/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/out/.gitignore b/out/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/testdata/d2compiler/TestCompile2/scenarios/one.exp.json b/testdata/d2compiler/TestCompile2/scenarios/one.exp.json new file mode 100644 index 000000000..34e4b7447 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/scenarios/one.exp.json @@ -0,0 +1,455 @@ +{ + "graph": { + "ast": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,0:0:0-10:0:65", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,0:0:0-0:4:4", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,0:0:0-0:4:4", + "value": [ + { + "string": "base", + "raw_string": "base" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,2:0:6-9:1:64", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,2:0:6-2:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,2:0:6-2:6:12", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,2:8:14-9:0:63", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,3:2:18-5:3:38", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,3:2:18-3:5:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,3:2:18-3:5:21", + "value": [ + { + "string": "one", + "raw_string": "one" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,3:7:23-5:2:37", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,4:4:29-4:9:34", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,4:4:29-4:9:34", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,4:4:29-4:9:34", + "value": [ + { + "string": "santa", + "raw_string": "santa" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,6:2:41-8:3:62", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,6:2:41-6:5:44", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,6:2:41-6:5:44", + "value": [ + { + "string": "two", + "raw_string": "two" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,6:7:46-8:2:61", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,7:4:52-7:10:58", + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,7:4:52-7:10:58", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,7:4:52-7:10:58", + "value": [ + { + "string": "clause", + "raw_string": "clause" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "base", + "id_val": "base", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,0:0:0-0:4:4", + "value": [ + { + "string": "base", + "raw_string": "base" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "base" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "layers", + "id_val": "layers", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,2:0:6-2:6:12", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,2:0:6-2:6:12", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "layers" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "one", + "id_val": "one", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,3:2:18-3:5:21", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,3:2:18-3:5:21", + "value": [ + { + "string": "one", + "raw_string": "one" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "one" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "santa", + "id_val": "santa", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,4:4:29-4:9:34", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,4:4:29-4:9:34", + "value": [ + { + "string": "santa", + "raw_string": "santa" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "santa" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "two", + "id_val": "two", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,6:2:41-6:5:44", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,6:2:41-6:5:44", + "value": [ + { + "string": "two", + "raw_string": "two" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "two" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "clause", + "id_val": "clause", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,7:4:52-7:10:58", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/one.d2,7:4:52-7:10:58", + "value": [ + { + "string": "clause", + "raw_string": "clause" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "clause" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": null +} From ef0e197a63cd33b129a3a6e9cf60d4e37ac26ba1 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 8 Jan 2023 09:02:21 -0800 Subject: [PATCH 05/60] ci/cov.sh: Add --- .gitignore | 1 + ci/cov.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 ci/cov.sh diff --git a/.gitignore b/.gitignore index 7af7b3572..e9e020ff5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *.got.svg e2e_report.html bin +out diff --git a/ci/cov.sh b/ci/cov.sh new file mode 100755 index 000000000..63d5bb812 --- /dev/null +++ b/ci/cov.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -eu +cd -- "$(dirname "$0")/.." +. ./ci/sub/lib.sh + +main() { + if [ "$*" = "" ]; then + set ./... + fi + + mkdir -p out + capcode ./ci/test.sh -covermode=atomic -coverprofile=out/cov.prof "$@" + go tool cover -html=out/cov.prof -o=out/cov.html + go tool cover -func=out/cov.prof | grep '^total:' \ + | sed 's#^total:.*(statements)[[:space:]]*\([0-9.%]*\)#TOTAL:\t\1#' + return "$code" +} + +main "$@" From a277d10dda6fabbdbbe1961dd628e5131bc3e7a2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 9 Jan 2023 13:26:11 -0800 Subject: [PATCH 06/60] d2ir: Import and cleanup Test files still need cleanup. --- d2ir/apply.go | 57 +++++++ d2ir/apply_test.go | 199 +++++++++++++++++++++++ d2ir/d2ir.go | 386 +++++++++++++++++++++++++++++++++++++++++++++ d2ir/d2ir_test.go | 77 +++++++++ 4 files changed, 719 insertions(+) create mode 100644 d2ir/apply.go create mode 100644 d2ir/apply_test.go create mode 100644 d2ir/d2ir.go create mode 100644 d2ir/d2ir_test.go diff --git a/d2ir/apply.go b/d2ir/apply.go new file mode 100644 index 000000000..893bda82a --- /dev/null +++ b/d2ir/apply.go @@ -0,0 +1,57 @@ +package d2ir + +import ( + "fmt" + + "oss.terrastruct.com/d2/d2ast" + "oss.terrastruct.com/d2/d2graph" + "oss.terrastruct.com/d2/d2parser" +) + +type compiler struct { + err d2parser.ParseError +} + +func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { + f = "%v: " + f + v = append([]interface{}{n.GetRange()}, v...) + c.err.Errors = append(c.err.Errors, d2ast.Error{ + Range: n.GetRange(), + Message: fmt.Sprintf(f, v...), + }) +} + +func Apply(dst *Map, ast *d2ast.Map) error { + var c compiler + c.apply(dst, ast) + return c.err +} + +func (c *compiler) apply(dst *Map, ast *d2ast.Map) { + for _, n := range ast.Nodes { + if n.MapKey == nil { + continue + } + + c.applyKey(dst, n.MapKey) + } +} + +func (c *compiler) applyKey(dst *Map, k *d2ast.Key) { + if k.Key != nil && len(k.Key.Path) > 0 { + f, ok := dst.Ensure(d2graph.Key(k.Key)) + if !ok { + c.errorf(k.Key, "cannot index into array") + return + } + + if len(k.Edges) == 0 { + if k.Primary.Unbox() != nil { + f.Primary = &Scalar{ + parent: f, + Value: k.Primary.Unbox(), + } + } + } + } +} diff --git a/d2ir/apply_test.go b/d2ir/apply_test.go new file mode 100644 index 000000000..5787e882f --- /dev/null +++ b/d2ir/apply_test.go @@ -0,0 +1,199 @@ +package d2ir_test + +import ( + "fmt" + "math/big" + "path/filepath" + "strings" + "testing" + + "oss.terrastruct.com/util-go/diff" + + "oss.terrastruct.com/d2/d2ast" + "oss.terrastruct.com/d2/d2ir" + "oss.terrastruct.com/d2/d2parser" + "oss.terrastruct.com/d2/internal/assert" +) + +type testCase struct { + name string + text string + base *d2ir.Map + + exp func(testing.TB, *d2ir.Map, error) +} + +func TestApply(t *testing.T) { + t.Parallel() + + t.Run("simple", testApplySimple) +} + +func testApplySimple(t *testing.T) { + tcs := []testCase{ + { + name: "one", + text: `x`, + + exp: func(t testing.TB, m *d2ir.Map, err error) { + assert.Success(t, err) + assertField(t, m, 1, 0, nil) + + assertField(t, m, 0, 0, nil, "x") + }, + }, + { + name: "nested", + text: `x.y -> z.p`, + + exp: func(t testing.TB, m *d2ir.Map, err error) { + assert.Success(t, err) + assertField(t, m, 4, 1, nil) + + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, nil, "x", "y") + + assertField(t, m, 1, 0, nil, "z") + assertField(t, m, 0, 0, nil, "z", "p") + + assertEdge(t, m, 0, nil, &d2ir.EdgeID{ + []string{"x", "y"}, false, + []string{"z", "p"}, true, + -1, + }) + }, + }, + { + name: "underscore_parent", + text: `x._ -> z`, + + exp: func(t testing.TB, m *d2ir.Map, err error) { + assert.Success(t, err) + assertField(t, m, 2, 1, nil) + + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "z") + + assertEdge(t, m, 0, nil, &d2ir.EdgeID{ + []string{"x"}, false, + []string{"z"}, true, + -1, + }) + }, + }, + } + + runa(t, tcs) +} + +func runa(t *testing.T, tcs []testCase) { + for _, tc := range tcs { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + run(t, tc) + }) + } +} + +func run(t testing.TB, tc testCase) { + d2Path := fmt.Sprintf("d2/testdata/d2ir/%v.d2", t.Name()) + ast, err := d2parser.Parse(d2Path, strings.NewReader(tc.text), nil) + if err != nil { + tc.exp(t, nil, err) + t.FailNow() + return + } + + dst := tc.base.Copy(nil).(*d2ir.Map) + err = d2ir.Apply(dst, ast) + tc.exp(t, dst, err) + + err = diff.Testdata(filepath.Join("..", "testdata", "d2ir", t.Name()), dst) + if err != nil { + tc.exp(t, nil, err) + t.FailNow() + return + } +} + +func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { + t.Helper() + + m := d2ir.NodeToMap(n) + p := d2ir.NodeToPrimary(n) + + var f *d2ir.Field + if len(ida) > 0 { + f = m.Get(ida) + if f == nil { + t.Fatalf("expected field %#v in map %#v but not found", ida, m) + } + p = f.Primary + m = d2ir.NodeToMap(f) + } + + if m.FieldCount() != nfields { + t.Fatalf("expected %d fields but got %d", nfields, m.FieldCount()) + } + if m.EdgeCount() != nedges { + t.Fatalf("expected %d edges but got %d", nedges, m.EdgeCount()) + } + if !p.Equal(makeScalar(primary)) { + t.Fatalf("expected primary %#v but %#v", primary, p) + } + + return f +} + +func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid *d2ir.EdgeID) *d2ir.Edge { + t.Helper() + + m := d2ir.NodeToMap(n) + + e := m.GetEdge(eid) + if e == nil { + t.Fatalf("expected edge %#v in map %#v but not found", eid, m) + } + + if e.Map.FieldCount() != nfields { + t.Fatalf("expected %d fields but got %d", nfields, e.Map.FieldCount()) + } + if e.Map.EdgeCount() != 0 { + t.Fatalf("expected %d edges but got %d", 0, e.Map.EdgeCount()) + } + if !e.Primary.Equal(makeScalar(primary)) { + t.Fatalf("expected primary %#v but %#v", primary, e.Primary) + } + + return e +} + +func makeScalar(v interface{}) *d2ir.Scalar { + s := &d2ir.Scalar{} + switch v := v.(type) { + case bool: + s.Value = &d2ast.Boolean{ + Value: v, + } + case float64: + bv := &big.Rat{} + bv.SetFloat64(v) + s.Value = &d2ast.Number{ + Value: bv, + } + case int: + s.Value = &d2ast.Number{ + Value: big.NewRat(int64(v), 1), + } + case string: + s.Value = d2ast.FlatDoubleQuotedString(v) + default: + if v != nil { + panic(fmt.Sprintf("d2ir: unexpected type to makeScalar: %#v", v)) + } + s.Value = &d2ast.Null{} + } + return s +} diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go new file mode 100644 index 000000000..20ecdd08e --- /dev/null +++ b/d2ir/d2ir.go @@ -0,0 +1,386 @@ +package d2ir + +import ( + "strings" + + "oss.terrastruct.com/d2/d2ast" +) + +type Node interface { + node() + Copy(newp Parent) Node +} + +var _ Node = &Scalar{} +var _ Node = &Field{} +var _ Node = &Edge{} +var _ Node = &Array{} +var _ Node = &Map{} + +type Parent interface { + Node + Parent() Parent +} + +var _ Parent = &Field{} +var _ Parent = &Edge{} +var _ Parent = &Array{} +var _ Parent = &Map{} + +type Value interface { + Node + value() +} + +var _ Value = &Scalar{} +var _ Value = &Array{} +var _ Value = &Map{} + +type Composite interface { + Node + Value + composite() +} + +var _ Composite = &Array{} +var _ Composite = &Map{} + +func (n *Scalar) node() {} +func (n *Field) node() {} +func (n *Edge) node() {} +func (n *Array) node() {} +func (n *Map) node() {} + +func (n *Field) Parent() Parent { return n.parent } +func (n *Edge) Parent() Parent { return n.parent } +func (n *Array) Parent() Parent { return n.parent } +func (n *Map) Parent() Parent { return n.parent } + +func (n *Scalar) value() {} +func (n *Array) value() {} +func (n *Map) value() {} + +func (n *Array) composite() {} +func (n *Map) composite() {} + +type Scalar struct { + parent Parent + Value d2ast.Scalar `json:"value"` +} + +func (s *Scalar) Copy(newp Parent) Node { + tmp := *s + s = &tmp + + s.parent = newp + return s +} + +func (s *Scalar) Equal(s2 *Scalar) bool { + return s.Value.ScalarString() == s2.Value.ScalarString() && s.Value.Type() == s2.Value.Type() +} + +type Map struct { + parent Parent + Fields []*Field `json:"fields"` + Edges []*Edge `json:"edges"` +} + +func (m *Map) Copy(newp Parent) Node { + tmp := *m + m = &tmp + + m.parent = newp + m.Fields = append([]*Field(nil), m.Fields...) + for i := range m.Fields { + m.Fields[i] = m.Fields[i].Copy(m).(*Field) + } + m.Edges = append([]*Edge(nil), m.Edges...) + for i := range m.Edges { + m.Edges[i] = m.Edges[i].Copy(m).(*Edge) + } + return m +} + +// Root reports whether the Map is the root of the D2 tree. +// The root map has no parent. +func (m *Map) Root() bool { + return m.parent == nil +} + +type Field struct { + parent *Map + + Name string `json:"name"` + + Primary *Scalar `json:"primary"` + Composite Composite `json:"composite"` + + Refs []KeyReference `json:"refs"` +} + +func (f *Field) Copy(newp Parent) Node { + tmp := *f + f = &tmp + + f.parent = newp.(*Map) + f.Refs = append([]KeyReference(nil), f.Refs...) + if f.Primary != nil { + f.Primary = f.Primary.Copy(f).(*Scalar) + } + if f.Composite != nil { + f.Composite = f.Composite.Copy(f).(Composite) + } + return f +} + +type EdgeID struct { + SrcPath []string `json:"src_path"` + SrcArrow bool `json:"src_arrow"` + + DstPath []string `json:"dst_path"` + DstArrow bool `json:"dst_arrow"` + + Index int `json:"index"` +} + +func (eid *EdgeID) Copy() *EdgeID { + tmp := *eid + eid = &tmp + + eid.SrcPath = append([]string(nil), eid.SrcPath...) + eid.DstPath = append([]string(nil), eid.DstPath...) + return eid +} + +func (eid *EdgeID) Equal(eid2 *EdgeID) bool { + if eid.Index != eid2.Index { + return false + } + + if len(eid.SrcPath) != len(eid2.SrcPath) { + return false + } + if eid.SrcArrow != eid2.SrcArrow { + return false + } + for i, s := range eid.SrcPath { + if !strings.EqualFold(s, eid2.SrcPath[i]) { + return false + } + } + + if len(eid.DstPath) != len(eid2.DstPath) { + return false + } + if eid.DstArrow != eid2.DstArrow { + return false + } + for i, s := range eid.DstPath { + if !strings.EqualFold(s, eid2.DstPath[i]) { + return false + } + } + + return true +} + +func (eid *EdgeID) trimCommon() (common []string, _ *EdgeID) { + eid = eid.Copy() + for len(eid.SrcPath) > 1 && len(eid.DstPath) > 1 { + if !strings.EqualFold(eid.SrcPath[0], eid.DstPath[0]) { + return common, eid + } + common = append(common, eid.SrcPath[0]) + eid.SrcPath = eid.SrcPath[1:] + eid.DstPath = eid.DstPath[1:] + } + return common, eid +} + +type Edge struct { + parent *Map + + ID *EdgeID `json:"edge_id"` + + Primary *Scalar `json:"primary"` + Map *Map `json:"map"` + + Refs []EdgeReference `json:"refs"` +} + +func (e *Edge) Copy(newp Parent) Node { + tmp := *e + e = &tmp + + e.parent = newp.(*Map) + e.Refs = append([]EdgeReference(nil), e.Refs...) + if e.Primary != nil { + e.Primary = e.Primary.Copy(e).(*Scalar) + } + if e.Map != nil { + e.Map = e.Map.Copy(e).(*Map) + } + return e +} + +type Array struct { + parent Parent + Values []Value `json:"values"` +} + +func (a *Array) Copy(newp Parent) Node { + tmp := *a + a = &tmp + + a.parent = newp + a.Values = append([]Value(nil), a.Values...) + for i := range a.Values { + a.Values[i] = a.Values[i].Copy(a).(Value) + } + return a +} + +type KeyReference struct { + String *d2ast.StringBox `json:"string"` + KeyPath *d2ast.KeyPath `json:"key_path"` + + RefCtx *RefContext `json:"ref_ctx"` +} + +type EdgeReference struct { + RefCtx *RefContext `json:"ref_ctx"` +} + +type RefContext struct { + Key *d2ast.Key `json:"-"` + Edge *d2ast.Edge `json:"-"` + Scope *d2ast.Map `json:"-"` +} + +func (m *Map) FieldCount() int { + acc := len(m.Fields) + for _, f := range m.Fields { + if f_m, ok := f.Composite.(*Map); ok { + acc += f_m.FieldCount() + } + } + return acc +} + +func (m *Map) EdgeCount() int { + acc := len(m.Edges) + for _, e := range m.Edges { + if e.Map != nil { + acc += e.Map.EdgeCount() + } + } + return acc +} + +func (m *Map) Get(ida []string) (*Field, bool) { + if len(ida) == 0 { + return nil, false + } + + s := ida[0] + rest := ida[1:] + + for _, f := range m.Fields { + if !strings.EqualFold(f.Name, s) { + continue + } + if len(rest) == 0 { + return f, true + } + if f_m, ok := f.Composite.(*Map); ok { + return f_m.Get(rest) + } + } + return nil, false +} + +func (m *Map) Ensure(ida []string) (*Field, bool) { + if len(ida) == 0 { + return nil, false + } + + s := ida[0] + rest := ida[1:] + + for _, f := range m.Fields { + if !strings.EqualFold(f.Name, s) { + continue + } + if len(rest) == 0 { + return f, true + } + switch fc := f.Composite.(type) { + case *Map: + return fc.Ensure(rest) + case *Array: + return nil, false + } + f.Composite = &Map{ + parent: f, + } + return f.Composite.(*Map).Ensure(rest) + } + + f := &Field{ + parent: m, + Name: s, + } + m.Fields = append(m.Fields, f) + if len(rest) == 0 { + return f, true + } + f.Composite = &Map{ + parent: f, + } + return f.Composite.(*Map).Ensure(rest) +} + +func (m *Map) Delete(ida []string) bool { + if len(ida) == 0 { + return false + } + + s := ida[0] + rest := ida[1:] + + for i, f := range m.Fields { + if !strings.EqualFold(f.Name, s) { + continue + } + if len(rest) == 0 { + copy(m.Fields[i:], m.Fields[i+1:]) + return true + } + if f_m, ok := f.Composite.(*Map); ok { + return f_m.Delete(rest) + } + } + return false +} + +func (m *Map) GetEdge(eid *EdgeID) (*Edge, bool) { + common, eid := eid.trimCommon() + if len(common) > 0 { + f, ok := m.Get(common) + if !ok { + return nil, false + } + if f_m, ok := f.Composite.(*Map); ok { + return f_m.GetEdge(eid) + } + return nil, false + } + + for _, e := range m.Edges { + if e.ID.Equal(eid) { + return e, true + } + } + return nil, false +} diff --git a/d2ir/d2ir_test.go b/d2ir/d2ir_test.go new file mode 100644 index 000000000..9fab4f612 --- /dev/null +++ b/d2ir/d2ir_test.go @@ -0,0 +1,77 @@ +package d2ir_test + +import ( + "testing" + + "oss.terrastruct.com/d2/d2ast" + "oss.terrastruct.com/d2/d2ir" + "oss.terrastruct.com/d2/internal/assert" +) + +func TestCopy(t *testing.T) { + t.Parallel() + + const scalStr = `Those who claim the dead never return to life haven't ever been around.` + s := &d2ir.Scalar{ + parent: nil, + Value: d2ast.FlatUnquotedString(scalStr), + } + a := &d2ir.Array{ + Parent: nil, + Values: []d2ir.Value{ + &d2ir.Scalar{ + parent: nil, + Value: &d2ast.Boolean{ + Value: true, + }, + }, + }, + } + m2 := &d2ir.Map{ + Parent: nil, + Fields: []*d2ir.Field{ + {Primary: s}, + }, + } + + const keyStr = `Absence makes the heart grow frantic.` + f := &d2ir.Field{ + Parent: nil, + Name: keyStr, + + Primary: s, + Composite: a, + } + e := &d2ir.Edge{ + Parent: nil, + + Primary: s, + Map: m2, + } + m := &d2ir.Map{ + Parent: nil, + + Fields: []*d2ir.Field{f}, + Edges: []*d2ir.Edge{e}, + } + + m = m.Copy(nil).(*d2ir.Map) + f.Name = `Many a wife thinks her husband is the world's greatest lover.` + + assert.Equal(t, m, m.Fields[0].Parent) + assert.Equal(t, keyStr, m.Fields[0].Name) + assert.Equal(t, m.Fields[0], m.Fields[0].Primary.parent) + assert.Equal(t, m.Fields[0], m.Fields[0].Composite.(*d2ir.Array).Parent) + + assert.Equal(t, + m.Fields[0].Composite, + m.Fields[0].Composite.(*d2ir.Array).Values[0].(*d2ir.Scalar).parent, + ) + + assert.Equal(t, m, m.Edges[0].Parent) + assert.Equal(t, m.Edges[0], m.Edges[0].Primary.parent) + assert.Equal(t, m.Edges[0], m.Edges[0].Map.Parent) + + assert.Equal(t, m.Edges[0].Map, m.Edges[0].Map.Fields[0].Parent) + assert.Equal(t, m.Edges[0].Map.Fields[0], m.Edges[0].Map.Fields[0].Primary.parent) +} From 4b50748dd0b5fe8b91102457df48d3d5cd9c3b64 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 9 Jan 2023 13:31:27 -0800 Subject: [PATCH 07/60] d2ir: Final PR imports https://github.com/terrastruct/terrastruct-backend/pull/975/files#diff-1b00307a7a2bd1ffc68527a7df7c9c83327d8cd2dd00f4741ec6bd0b96605cd4 --- d2ast/d2ast.go | 2 ++ lib/env/env.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 2ffb448f1..d824ef367 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -1,3 +1,5 @@ +// TODO: Remove boxes and cleanup like d2ir +// // d2ast implements the d2 language's abstract syntax tree. // // Special characters to think about in parser: diff --git a/lib/env/env.go b/lib/env/env.go index eee0ddc65..07ba22eef 100644 --- a/lib/env/env.go +++ b/lib/env/env.go @@ -23,5 +23,5 @@ func DevOnly() bool { } func SkipGraphDiffTests() bool { - return os.Getenv("SKIP_GRAPH_DIFF_TESTS") == "on" + return os.Getenv("SKIP_GRAPH_DIFF_TESTS") != "" } From 83ef53dc408578f9088ec2e93851fca367247b39 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 11 Jan 2023 11:05:50 -0800 Subject: [PATCH 08/60] d2ir: wip --- d2ir/apply.go | 5 +- d2ir/apply_test.go | 129 ++++++++++-------- d2ir/d2ir.go | 34 ++++- d2ir/d2ir_test.go | 32 ++--- d2parser/parse.go | 10 +- .../d2ir/TestApply/simple/nested.exp.json | 4 + testdata/d2ir/TestApply/simple/one.exp.json | 8 ++ .../simple/underscore_parent.exp.json | 4 + 8 files changed, 139 insertions(+), 87 deletions(-) create mode 100644 testdata/d2ir/TestApply/simple/nested.exp.json create mode 100644 testdata/d2ir/TestApply/simple/one.exp.json create mode 100644 testdata/d2ir/TestApply/simple/underscore_parent.exp.json diff --git a/d2ir/apply.go b/d2ir/apply.go index 893bda82a..9fd025578 100644 --- a/d2ir/apply.go +++ b/d2ir/apply.go @@ -24,7 +24,10 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { func Apply(dst *Map, ast *d2ast.Map) error { var c compiler c.apply(dst, ast) - return c.err + if !c.err.Empty() { + return c.err + } + return nil } func (c *compiler) apply(dst *Map, ast *d2ast.Map) { diff --git a/d2ir/apply_test.go b/d2ir/apply_test.go index 5787e882f..32ac9281d 100644 --- a/d2ir/apply_test.go +++ b/d2ir/apply_test.go @@ -7,20 +7,17 @@ import ( "strings" "testing" + "oss.terrastruct.com/util-go/assert" "oss.terrastruct.com/util-go/diff" "oss.terrastruct.com/d2/d2ast" "oss.terrastruct.com/d2/d2ir" "oss.terrastruct.com/d2/d2parser" - "oss.terrastruct.com/d2/internal/assert" ) type testCase struct { name string - text string - base *d2ir.Map - - exp func(testing.TB, *d2ir.Map, error) + run func(testing.TB, *d2ir.Map) } func TestApply(t *testing.T) { @@ -30,12 +27,13 @@ func TestApply(t *testing.T) { } func testApplySimple(t *testing.T) { - tcs := []testCase{ + t.Parallel() + + tca := []testCase{ { name: "one", - text: `x`, - - exp: func(t testing.TB, m *d2ir.Map, err error) { + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x`) assert.Success(t, err) assertField(t, m, 1, 0, nil) @@ -44,9 +42,8 @@ func testApplySimple(t *testing.T) { }, { name: "nested", - text: `x.y -> z.p`, - - exp: func(t testing.TB, m *d2ir.Map, err error) { + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x.y -> z.p`) assert.Success(t, err) assertField(t, m, 4, 1, nil) @@ -65,9 +62,8 @@ func testApplySimple(t *testing.T) { }, { name: "underscore_parent", - text: `x._ -> z`, - - exp: func(t testing.TB, m *d2ir.Map, err error) { + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x._ -> z`) assert.Success(t, err) assertField(t, m, 2, 1, nil) @@ -83,63 +79,76 @@ func testApplySimple(t *testing.T) { }, } - runa(t, tcs) + runa(t, tca) } -func runa(t *testing.T, tcs []testCase) { - for _, tc := range tcs { +func runa(t *testing.T, tca []testCase) { + for _, tc := range tca { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() - - run(t, tc) + m := &d2ir.Map{} + tc.run(t, m) }) } } -func run(t testing.TB, tc testCase) { +func parse(t testing.TB, dst *d2ir.Map, text string) error { + t.Helper() + d2Path := fmt.Sprintf("d2/testdata/d2ir/%v.d2", t.Name()) - ast, err := d2parser.Parse(d2Path, strings.NewReader(tc.text), nil) - if err != nil { - tc.exp(t, nil, err) - t.FailNow() - return - } + ast, err := d2parser.Parse(d2Path, strings.NewReader(text), nil) + assert.Success(t, err) - dst := tc.base.Copy(nil).(*d2ir.Map) err = d2ir.Apply(dst, ast) - tc.exp(t, dst, err) - - err = diff.Testdata(filepath.Join("..", "testdata", "d2ir", t.Name()), dst) if err != nil { - tc.exp(t, nil, err) - t.FailNow() - return + return err } + + err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), dst) + return err } func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { t.Helper() - m := d2ir.NodeToMap(n) - p := d2ir.NodeToPrimary(n) + var m *d2ir.Map + p := &d2ir.Scalar{ + Value: &d2ast.Null{}, + } + switch n := n.(type) { + case *d2ir.Field: + mm, ok := n.Composite.(*d2ir.Map) + if ok { + m = mm + } else { + t.Fatalf("unexpected d2ir.Field.Composite %T", n.Composite) + } + p = n.Primary + case *d2ir.Map: + m = n + p.Value = &d2ast.Null{} + default: + t.Fatalf("unexpected d2ir.Node %T", n) + } var f *d2ir.Field + var ok bool if len(ida) > 0 { - f = m.Get(ida) - if f == nil { - t.Fatalf("expected field %#v in map %#v but not found", ida, m) + f, ok = m.Get(ida) + if !ok { + t.Fatalf("expected field %v in map %s", ida, m) } p = f.Primary - m = d2ir.NodeToMap(f) + if f_m, ok := f.Composite.(*d2ir.Map); ok { + m = f_m + } else { + m = &d2ir.Map{} + } } - if m.FieldCount() != nfields { - t.Fatalf("expected %d fields but got %d", nfields, m.FieldCount()) - } - if m.EdgeCount() != nedges { - t.Fatalf("expected %d edges but got %d", nedges, m.EdgeCount()) - } + assert.Equal(t, nfields, m.FieldCount()) + assert.Equal(t, nedges, m.EdgeCount()) if !p.Equal(makeScalar(primary)) { t.Fatalf("expected primary %#v but %#v", primary, p) } @@ -150,19 +159,27 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid *d2ir.EdgeID) *d2ir.Edge { t.Helper() - m := d2ir.NodeToMap(n) - - e := m.GetEdge(eid) - if e == nil { - t.Fatalf("expected edge %#v in map %#v but not found", eid, m) + var m *d2ir.Map + switch n := n.(type) { + case *d2ir.Field: + mm, ok := n.Composite.(*d2ir.Map) + if ok { + m = mm + } else { + t.Fatalf("unexpected d2ir.Field.Composite %T", n.Composite) + } + case *d2ir.Map: + m = n + default: + t.Fatalf("unexpected d2ir.Node %T", n) } - if e.Map.FieldCount() != nfields { - t.Fatalf("expected %d fields but got %d", nfields, e.Map.FieldCount()) - } - if e.Map.EdgeCount() != 0 { - t.Fatalf("expected %d edges but got %d", 0, e.Map.EdgeCount()) + e, ok := m.GetEdge(eid) + if !ok { + t.Fatalf("expected edge %v in map %s but not found", eid, m) } + + assert.Equal(t, nfields, e.Map.FieldCount()) if !e.Primary.Equal(makeScalar(primary)) { t.Fatalf("expected primary %#v but %#v", primary, e.Primary) } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 20ecdd08e..8facce8b4 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -1,6 +1,8 @@ package d2ir import ( + "encoding/json" + "fmt" "strings" "oss.terrastruct.com/d2/d2ast" @@ -51,6 +53,7 @@ func (n *Edge) node() {} func (n *Array) node() {} func (n *Map) node() {} +func (n *Scalar) Parent() Parent { return n.parent } func (n *Field) Parent() Parent { return n.parent } func (n *Edge) Parent() Parent { return n.parent } func (n *Array) Parent() Parent { return n.parent } @@ -77,6 +80,17 @@ func (s *Scalar) Copy(newp Parent) Node { } func (s *Scalar) Equal(s2 *Scalar) bool { + if s == nil { + if s2 == nil { + return true + } + _, ok := s2.Value.(*d2ast.Null) + return ok + } + if s2 == nil { + _, ok := s.Value.(*d2ast.Null) + return ok + } return s.Value.ScalarString() == s2.Value.ScalarString() && s.Value.Type() == s2.Value.Type() } @@ -113,10 +127,10 @@ type Field struct { Name string `json:"name"` - Primary *Scalar `json:"primary"` - Composite Composite `json:"composite"` + Primary *Scalar `json:"primary,omitempty"` + Composite Composite `json:"composite,omitempty"` - Refs []KeyReference `json:"refs"` + Refs []KeyReference `json:"refs,omitempty"` } func (f *Field) Copy(newp Parent) Node { @@ -203,10 +217,10 @@ type Edge struct { ID *EdgeID `json:"edge_id"` - Primary *Scalar `json:"primary"` - Map *Map `json:"map"` + Primary *Scalar `json:"primary,omitempty"` + Map *Map `json:"map,omitempty"` - Refs []EdgeReference `json:"refs"` + Refs []EdgeReference `json:"refs,omitempty"` } func (e *Edge) Copy(newp Parent) Node { @@ -384,3 +398,11 @@ func (m *Map) GetEdge(eid *EdgeID) (*Edge, bool) { } return nil, false } + +func (m *Map) String() string { + b, err := json.Marshal(m) + if err != nil { + panic(fmt.Sprintf("d2ir: failed to marshal d2ir.Map: %v", err)) + } + return string(b) +} diff --git a/d2ir/d2ir_test.go b/d2ir/d2ir_test.go index 9fab4f612..52cae5aad 100644 --- a/d2ir/d2ir_test.go +++ b/d2ir/d2ir_test.go @@ -3,9 +3,10 @@ package d2ir_test import ( "testing" + "oss.terrastruct.com/util-go/assert" + "oss.terrastruct.com/d2/d2ast" "oss.terrastruct.com/d2/d2ir" - "oss.terrastruct.com/d2/internal/assert" ) func TestCopy(t *testing.T) { @@ -13,14 +14,11 @@ func TestCopy(t *testing.T) { const scalStr = `Those who claim the dead never return to life haven't ever been around.` s := &d2ir.Scalar{ - parent: nil, - Value: d2ast.FlatUnquotedString(scalStr), + Value: d2ast.FlatUnquotedString(scalStr), } a := &d2ir.Array{ - Parent: nil, Values: []d2ir.Value{ &d2ir.Scalar{ - parent: nil, Value: &d2ast.Boolean{ Value: true, }, @@ -28,7 +26,6 @@ func TestCopy(t *testing.T) { }, } m2 := &d2ir.Map{ - Parent: nil, Fields: []*d2ir.Field{ {Primary: s}, }, @@ -36,20 +33,17 @@ func TestCopy(t *testing.T) { const keyStr = `Absence makes the heart grow frantic.` f := &d2ir.Field{ - Parent: nil, - Name: keyStr, + Name: keyStr, Primary: s, Composite: a, } e := &d2ir.Edge{ - Parent: nil, Primary: s, Map: m2, } m := &d2ir.Map{ - Parent: nil, Fields: []*d2ir.Field{f}, Edges: []*d2ir.Edge{e}, @@ -58,20 +52,20 @@ func TestCopy(t *testing.T) { m = m.Copy(nil).(*d2ir.Map) f.Name = `Many a wife thinks her husband is the world's greatest lover.` - assert.Equal(t, m, m.Fields[0].Parent) + assert.Equal(t, m, m.Fields[0].Parent()) assert.Equal(t, keyStr, m.Fields[0].Name) - assert.Equal(t, m.Fields[0], m.Fields[0].Primary.parent) - assert.Equal(t, m.Fields[0], m.Fields[0].Composite.(*d2ir.Array).Parent) + assert.Equal(t, m.Fields[0], m.Fields[0].Primary.Parent()) + assert.Equal(t, m.Fields[0], m.Fields[0].Composite.(*d2ir.Array).Parent()) assert.Equal(t, m.Fields[0].Composite, - m.Fields[0].Composite.(*d2ir.Array).Values[0].(*d2ir.Scalar).parent, + m.Fields[0].Composite.(*d2ir.Array).Values[0].(*d2ir.Scalar).Parent(), ) - assert.Equal(t, m, m.Edges[0].Parent) - assert.Equal(t, m.Edges[0], m.Edges[0].Primary.parent) - assert.Equal(t, m.Edges[0], m.Edges[0].Map.Parent) + assert.Equal(t, m, m.Edges[0].Parent()) + assert.Equal(t, m.Edges[0], m.Edges[0].Primary.Parent()) + assert.Equal(t, m.Edges[0], m.Edges[0].Map.Parent()) - assert.Equal(t, m.Edges[0].Map, m.Edges[0].Map.Fields[0].Parent) - assert.Equal(t, m.Edges[0].Map.Fields[0], m.Edges[0].Map.Fields[0].Primary.parent) + assert.Equal(t, m.Edges[0].Map, m.Edges[0].Map.Fields[0].Parent()) + assert.Equal(t, m.Edges[0].Map.Fields[0], m.Edges[0].Map.Fields[0].Primary.Parent()) } diff --git a/d2parser/parse.go b/d2parser/parse.go index d8351dcbc..0e7e5eefc 100644 --- a/d2parser/parse.go +++ b/d2parser/parse.go @@ -45,7 +45,7 @@ func Parse(path string, r io.RuneReader, opts *ParseOptions) (*d2ast.Map, error) } m := p.parseMap(true) - if !p.err.empty() { + if !p.err.Empty() { return m, p.err } return m, nil @@ -57,7 +57,7 @@ func ParseKey(key string) (*d2ast.KeyPath, error) { } k := p.parseKey() - if !p.err.empty() { + if !p.err.Empty() { return nil, fmt.Errorf("failed to parse key %q: %w", key, p.err) } if k == nil { @@ -72,7 +72,7 @@ func ParseMapKey(mapKey string) (*d2ast.Key, error) { } mk := p.parseMapKey() - if !p.err.empty() { + if !p.err.Empty() { return nil, fmt.Errorf("failed to parse map key %q: %w", mapKey, p.err) } if mk == nil { @@ -87,7 +87,7 @@ func ParseValue(value string) (d2ast.Value, error) { } v := p.parseValue() - if !p.err.empty() { + if !p.err.Empty() { return nil, fmt.Errorf("failed to parse value %q: %w", value, p.err) } if v.Unbox() == nil { @@ -130,7 +130,7 @@ type ParseError struct { Errors []d2ast.Error `json:"errs"` } -func (pe ParseError) empty() bool { +func (pe ParseError) Empty() bool { return pe.IOError == nil && len(pe.Errors) == 0 } diff --git a/testdata/d2ir/TestApply/simple/nested.exp.json b/testdata/d2ir/TestApply/simple/nested.exp.json new file mode 100644 index 000000000..fbfc21849 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/nested.exp.json @@ -0,0 +1,4 @@ +{ + "fields": null, + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/one.exp.json b/testdata/d2ir/TestApply/simple/one.exp.json new file mode 100644 index 000000000..2dcf9ab44 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/one.exp.json @@ -0,0 +1,8 @@ +{ + "fields": [ + { + "name": "x" + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/underscore_parent.exp.json b/testdata/d2ir/TestApply/simple/underscore_parent.exp.json new file mode 100644 index 000000000..fbfc21849 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/underscore_parent.exp.json @@ -0,0 +1,4 @@ +{ + "fields": null, + "edges": null +} From fd241e442588d073eff5d3be5e8905a597027001 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 11 Jan 2023 13:20:05 -0800 Subject: [PATCH 09/60] d2ir: wip --- d2ir/apply_test.go | 10 ++++++++-- d2ir/d2ir.go | 11 ----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/d2ir/apply_test.go b/d2ir/apply_test.go index 32ac9281d..5c44020cf 100644 --- a/d2ir/apply_test.go +++ b/d2ir/apply_test.go @@ -149,7 +149,7 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa assert.Equal(t, nfields, m.FieldCount()) assert.Equal(t, nedges, m.EdgeCount()) - if !p.Equal(makeScalar(primary)) { + if !makeScalar(p).Equal(makeScalar(primary)) { t.Fatalf("expected primary %#v but %#v", primary, p) } @@ -180,7 +180,7 @@ func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid } assert.Equal(t, nfields, e.Map.FieldCount()) - if !e.Primary.Equal(makeScalar(primary)) { + if !makeScalar(e.Primary).Equal(makeScalar(primary)) { t.Fatalf("expected primary %#v but %#v", primary, e.Primary) } @@ -190,6 +190,12 @@ func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid func makeScalar(v interface{}) *d2ir.Scalar { s := &d2ir.Scalar{} switch v := v.(type) { + case *d2ir.Scalar: + if v == nil { + s.Value = &d2ast.Null{} + return s + } + return v case bool: s.Value = &d2ast.Boolean{ Value: v, diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 8facce8b4..07ceccc98 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -80,17 +80,6 @@ func (s *Scalar) Copy(newp Parent) Node { } func (s *Scalar) Equal(s2 *Scalar) bool { - if s == nil { - if s2 == nil { - return true - } - _, ok := s2.Value.(*d2ast.Null) - return ok - } - if s2 == nil { - _, ok := s.Value.(*d2ast.Null) - return ok - } return s.Value.ScalarString() == s2.Value.ScalarString() && s.Value.Type() == s2.Value.Type() } From 989fdb0fe570de972870c163f3ed12fe108841f4 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 11 Jan 2023 15:50:49 -0800 Subject: [PATCH 10/60] d2ir: wip --- d2format/format.go | 13 +++ d2graph/d2graph.go | 11 +-- d2ir/apply.go | 43 +++++++-- d2ir/apply_test.go | 93 ++++++++++++++++--- d2ir/d2ir.go | 21 ++++- testdata/d2ir/TestApply/simple/edge.exp.json | 4 + testdata/d2ir/TestApply/simple/field.exp.json | 8 ++ .../TestApply/simple/field/label.exp.json | 19 ++++ .../simple/field/label/nested.exp.json | 27 ++++++ testdata/d2ir/TestApply/simple/label.exp.json | 19 ++++ .../d2ir/TestApply/simple/primary#01.exp.json | 27 ++++++ .../d2ir/TestApply/simple/primary.exp.json | 27 ++++++ .../TestApply/simple/primary/nested.exp.json | 35 +++++++ 13 files changed, 308 insertions(+), 39 deletions(-) create mode 100644 testdata/d2ir/TestApply/simple/edge.exp.json create mode 100644 testdata/d2ir/TestApply/simple/field.exp.json create mode 100644 testdata/d2ir/TestApply/simple/field/label.exp.json create mode 100644 testdata/d2ir/TestApply/simple/field/label/nested.exp.json create mode 100644 testdata/d2ir/TestApply/simple/label.exp.json create mode 100644 testdata/d2ir/TestApply/simple/primary#01.exp.json create mode 100644 testdata/d2ir/TestApply/simple/primary.exp.json create mode 100644 testdata/d2ir/TestApply/simple/primary/nested.exp.json diff --git a/d2format/format.go b/d2format/format.go index a45d55f63..b7eca3bca 100644 --- a/d2format/format.go +++ b/d2format/format.go @@ -397,3 +397,16 @@ func (p *printer) edgeIndex(ei *d2ast.EdgeIndex) { } p.sb.WriteByte(']') } + +func KeyPath(kp *d2ast.KeyPath) []string { + var ids []string + for _, s := range kp.Path { + // We format each string of the key to ensure the resulting strings can be parsed + // correctly. + n := &d2ast.KeyPath{ + Path: []*d2ast.StringBox{d2ast.MakeValueBox(d2ast.RawString(s.Unbox().ScalarString(), true)).StringBox()}, + } + ids = append(ids, Format(n)) + } + return ids +} diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 3822299e2..aa0c78ab7 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1238,16 +1238,7 @@ func (g *Graph) Texts() []*d2target.MText { } func Key(k *d2ast.KeyPath) []string { - var ids []string - for _, s := range k.Path { - // We format each string of the key to ensure the resulting strings can be parsed - // correctly. - n := &d2ast.KeyPath{ - Path: []*d2ast.StringBox{d2ast.MakeValueBox(d2ast.RawString(s.Unbox().ScalarString(), true)).StringBox()}, - } - ids = append(ids, d2format.Format(n)) - } - return ids + return d2format.KeyPath(k) } var ReservedKeywords = map[string]struct{}{ diff --git a/d2ir/apply.go b/d2ir/apply.go index 9fd025578..462c2cc88 100644 --- a/d2ir/apply.go +++ b/d2ir/apply.go @@ -4,7 +4,7 @@ import ( "fmt" "oss.terrastruct.com/d2/d2ast" - "oss.terrastruct.com/d2/d2graph" + "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2parser" ) @@ -23,28 +23,29 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { func Apply(dst *Map, ast *d2ast.Map) error { var c compiler - c.apply(dst, ast) + c.compileMap(dst, ast) if !c.err.Empty() { return c.err } return nil } -func (c *compiler) apply(dst *Map, ast *d2ast.Map) { +func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { for _, n := range ast.Nodes { - if n.MapKey == nil { - continue + switch { + case n.MapKey != nil: + c.compileField(dst, n.MapKey) + case n.Substitution != nil: + panic("TODO") } - - c.applyKey(dst, n.MapKey) } } -func (c *compiler) applyKey(dst *Map, k *d2ast.Key) { +func (c *compiler) compileField(dst *Map, k *d2ast.Key) { if k.Key != nil && len(k.Key.Path) > 0 { - f, ok := dst.Ensure(d2graph.Key(k.Key)) + f, ok := dst.Ensure(d2format.KeyPath(k.Key)) if !ok { - c.errorf(k.Key, "cannot index into array") + c.errorf(k, "cannot index into array") return } @@ -55,6 +56,28 @@ func (c *compiler) applyKey(dst *Map, k *d2ast.Key) { Value: k.Primary.Unbox(), } } + if k.Value.Array != nil { + a := &Array{ + parent: f, + } + c.compileArray(a, k.Value.Array) + f.Composite = a + } else if k.Value.Map != nil { + m := &Map{ + parent: f, + } + c.compileMap(m, k.Value.Map) + f.Composite = m + } else if k.Value.ScalarBox().Unbox() != nil { + f.Primary = &Scalar{ + parent: f, + Value: k.Value.ScalarBox().Unbox(), + } + } } } } + +func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { + panic(fmt.Sprintf("TODO")) +} diff --git a/d2ir/apply_test.go b/d2ir/apply_test.go index 5c44020cf..9e53f0a40 100644 --- a/d2ir/apply_test.go +++ b/d2ir/apply_test.go @@ -11,6 +11,7 @@ import ( "oss.terrastruct.com/util-go/diff" "oss.terrastruct.com/d2/d2ast" + "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2ir" "oss.terrastruct.com/d2/d2parser" ) @@ -31,7 +32,7 @@ func testApplySimple(t *testing.T) { tca := []testCase{ { - name: "one", + name: "field", run: func(t testing.TB, m *d2ir.Map) { err := parse(t, m, `x`) assert.Success(t, err) @@ -40,6 +41,62 @@ func testApplySimple(t *testing.T) { assertField(t, m, 0, 0, nil, "x") }, }, + { + name: "field/label", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x: yes`) + assert.Success(t, err) + assertField(t, m, 1, 0, nil) + + assertField(t, m, 0, 0, "yes", "x") + }, + }, + { + name: "field/label/nested", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x.y: yes`) + assert.Success(t, err) + assertField(t, m, 2, 0, nil) + + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, "yes", "x", "y") + }, + }, + { + name: "primary", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x: yes { pqrs }`) + assert.Success(t, err) + assertField(t, m, 2, 0, nil) + + assertField(t, m, 1, 0, "yes", "x") + assertField(t, m, 0, 0, nil, "x", "pqrs") + }, + }, + { + name: "primary/nested", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x.y: yes { pqrs }`) + assert.Success(t, err) + assertField(t, m, 3, 0, nil) + + assertField(t, m, 2, 0, nil, "x") + assertField(t, m, 1, 0, "yes", "x", "y") + assertField(t, m, 0, 0, nil, "x", "y", "pqrs") + }, + }, + { + name: "edge", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x -> y`) + assert.Success(t, err) + assertField(t, m, 2, 1, nil) + assertEdge(t, m, 0, nil, `(x -> y)[0]`) + + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "y") + }, + }, { name: "nested", run: func(t testing.TB, m *d2ir.Map) { @@ -53,11 +110,7 @@ func testApplySimple(t *testing.T) { assertField(t, m, 1, 0, nil, "z") assertField(t, m, 0, 0, nil, "z", "p") - assertEdge(t, m, 0, nil, &d2ir.EdgeID{ - []string{"x", "y"}, false, - []string{"z", "p"}, true, - -1, - }) + assertEdge(t, m, 0, nil, "(x.y -> z.p)[0]") }, }, { @@ -70,11 +123,7 @@ func testApplySimple(t *testing.T) { assertField(t, m, 0, 0, nil, "x") assertField(t, m, 0, 0, nil, "z") - assertEdge(t, m, 0, nil, &d2ir.EdgeID{ - []string{"x"}, false, - []string{"z"}, true, - -1, - }) + assertEdge(t, m, 0, nil, "(x -> z)[0]") }, }, } @@ -150,14 +199,30 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa assert.Equal(t, nfields, m.FieldCount()) assert.Equal(t, nedges, m.EdgeCount()) if !makeScalar(p).Equal(makeScalar(primary)) { - t.Fatalf("expected primary %#v but %#v", primary, p) + t.Fatalf("expected primary %#v but got %s", primary, p) } return f } -func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid *d2ir.EdgeID) *d2ir.Edge { +func parseEdgeID(t testing.TB, eids string) *d2ir.EdgeID { t.Helper() + k, err := d2parser.ParseMapKey(eids) + assert.Success(t, err) + + return &d2ir.EdgeID{ + SrcPath: d2format.KeyPath(k.Edges[0].Src), + SrcArrow: k.Edges[0].SrcArrow == "<", + DstPath: d2format.KeyPath(k.Edges[0].Dst), + DstArrow: k.Edges[0].DstArrow == ">", + Index: *k.EdgeIndex.Int, + } +} + +func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eids string) *d2ir.Edge { + t.Helper() + + eid := parseEdgeID(t, eids) var m *d2ir.Map switch n := n.(type) { @@ -181,7 +246,7 @@ func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid assert.Equal(t, nfields, e.Map.FieldCount()) if !makeScalar(e.Primary).Equal(makeScalar(primary)) { - t.Fatalf("expected primary %#v but %#v", primary, e.Primary) + t.Fatalf("expected primary %#v but %s", primary, e.Primary) } return e diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 07ceccc98..c44c3430a 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -6,6 +6,7 @@ import ( "strings" "oss.terrastruct.com/d2/d2ast" + "oss.terrastruct.com/d2/d2format" ) type Node interface { @@ -54,10 +55,10 @@ func (n *Array) node() {} func (n *Map) node() {} func (n *Scalar) Parent() Parent { return n.parent } -func (n *Field) Parent() Parent { return n.parent } -func (n *Edge) Parent() Parent { return n.parent } -func (n *Array) Parent() Parent { return n.parent } -func (n *Map) Parent() Parent { return n.parent } +func (n *Field) Parent() Parent { return n.parent } +func (n *Edge) Parent() Parent { return n.parent } +func (n *Array) Parent() Parent { return n.parent } +func (n *Map) Parent() Parent { return n.parent } func (n *Scalar) value() {} func (n *Array) value() {} @@ -80,7 +81,17 @@ func (s *Scalar) Copy(newp Parent) Node { } func (s *Scalar) Equal(s2 *Scalar) bool { - return s.Value.ScalarString() == s2.Value.ScalarString() && s.Value.Type() == s2.Value.Type() + if _, ok := s.Value.(d2ast.String); ok { + if _, ok = s2.Value.(d2ast.String); ok { + return s.Value.ScalarString() == s2.Value.ScalarString() + } + } + return s.Value.Type() == s2.Value.Type() && s.Value.ScalarString() == s2.Value.ScalarString() + +} + +func (s *Scalar) String() string { + return d2format.Format(s.Value) } type Map struct { diff --git a/testdata/d2ir/TestApply/simple/edge.exp.json b/testdata/d2ir/TestApply/simple/edge.exp.json new file mode 100644 index 000000000..fbfc21849 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/edge.exp.json @@ -0,0 +1,4 @@ +{ + "fields": null, + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/field.exp.json b/testdata/d2ir/TestApply/simple/field.exp.json new file mode 100644 index 000000000..2dcf9ab44 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/field.exp.json @@ -0,0 +1,8 @@ +{ + "fields": [ + { + "name": "x" + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/field/label.exp.json b/testdata/d2ir/TestApply/simple/field/label.exp.json new file mode 100644 index 000000000..0e70b7b57 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/field/label.exp.json @@ -0,0 +1,19 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestApply/simple/field/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/field/label/nested.exp.json b/testdata/d2ir/TestApply/simple/field/label/nested.exp.json new file mode 100644 index 000000000..fec6ca0c6 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/field/label/nested.exp.json @@ -0,0 +1,27 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestApply/simple/field/label/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/label.exp.json b/testdata/d2ir/TestApply/simple/label.exp.json new file mode 100644 index 000000000..fd2267e5a --- /dev/null +++ b/testdata/d2ir/TestApply/simple/label.exp.json @@ -0,0 +1,19 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestApply/simple/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/primary#01.exp.json b/testdata/d2ir/TestApply/simple/primary#01.exp.json new file mode 100644 index 000000000..c1e536d08 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/primary#01.exp.json @@ -0,0 +1,27 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestApply/simple/primary#01.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/primary.exp.json b/testdata/d2ir/TestApply/simple/primary.exp.json new file mode 100644 index 000000000..8f512307c --- /dev/null +++ b/testdata/d2ir/TestApply/simple/primary.exp.json @@ -0,0 +1,27 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestApply/simple/primary.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/primary/nested.exp.json b/testdata/d2ir/TestApply/simple/primary/nested.exp.json new file mode 100644 index 000000000..ba3dcf560 --- /dev/null +++ b/testdata/d2ir/TestApply/simple/primary/nested.exp.json @@ -0,0 +1,35 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestApply/simple/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null + } + } + ], + "edges": null +} From 61aef74975aca06502f8e28932591df555a03242 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 16 Jan 2023 03:52:37 -0800 Subject: [PATCH 11/60] d2ir: wip --- d2ir/apply.go | 83 --------- d2ir/compile.go | 171 ++++++++++++++++++ d2ir/{apply_test.go => compile_test.go} | 48 ++--- d2ir/d2ir.go | 115 +++++++++--- testdata/d2ir/TestCompile/roots/edge.exp.json | 25 +++ .../d2ir/TestCompile/roots/field.exp.json | 8 + .../TestCompile/roots/field/label.exp.json | 19 ++ .../roots/field/label/nested.exp.json | 27 +++ .../d2ir/TestCompile/roots/nested.exp.json | 43 +++++ .../d2ir/TestCompile/roots/primary.exp.json | 27 +++ .../TestCompile/roots/primary/nested.exp.json | 35 ++++ .../roots/underscore_parent.exp.json | 34 ++++ .../d2ir/TestCompile/simple/edge.exp.json | 4 + .../d2ir/TestCompile/simple/field.exp.json | 8 + .../TestCompile/simple/field/label.exp.json | 19 ++ .../simple/field/label/nested.exp.json | 27 +++ .../d2ir/TestCompile/simple/nested.exp.json | 4 + .../d2ir/TestCompile/simple/primary.exp.json | 27 +++ .../simple/primary/nested.exp.json | 35 ++++ .../simple/underscore_parent.exp.json | 4 + 20 files changed, 624 insertions(+), 139 deletions(-) delete mode 100644 d2ir/apply.go create mode 100644 d2ir/compile.go rename d2ir/{apply_test.go => compile_test.go} (86%) create mode 100644 testdata/d2ir/TestCompile/roots/edge.exp.json create mode 100644 testdata/d2ir/TestCompile/roots/field.exp.json create mode 100644 testdata/d2ir/TestCompile/roots/field/label.exp.json create mode 100644 testdata/d2ir/TestCompile/roots/field/label/nested.exp.json create mode 100644 testdata/d2ir/TestCompile/roots/nested.exp.json create mode 100644 testdata/d2ir/TestCompile/roots/primary.exp.json create mode 100644 testdata/d2ir/TestCompile/roots/primary/nested.exp.json create mode 100644 testdata/d2ir/TestCompile/roots/underscore_parent.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/edge.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/field.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/field/label.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/field/label/nested.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/nested.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/primary.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/primary/nested.exp.json create mode 100644 testdata/d2ir/TestCompile/simple/underscore_parent.exp.json diff --git a/d2ir/apply.go b/d2ir/apply.go deleted file mode 100644 index 462c2cc88..000000000 --- a/d2ir/apply.go +++ /dev/null @@ -1,83 +0,0 @@ -package d2ir - -import ( - "fmt" - - "oss.terrastruct.com/d2/d2ast" - "oss.terrastruct.com/d2/d2format" - "oss.terrastruct.com/d2/d2parser" -) - -type compiler struct { - err d2parser.ParseError -} - -func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { - f = "%v: " + f - v = append([]interface{}{n.GetRange()}, v...) - c.err.Errors = append(c.err.Errors, d2ast.Error{ - Range: n.GetRange(), - Message: fmt.Sprintf(f, v...), - }) -} - -func Apply(dst *Map, ast *d2ast.Map) error { - var c compiler - c.compileMap(dst, ast) - if !c.err.Empty() { - return c.err - } - return nil -} - -func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { - for _, n := range ast.Nodes { - switch { - case n.MapKey != nil: - c.compileField(dst, n.MapKey) - case n.Substitution != nil: - panic("TODO") - } - } -} - -func (c *compiler) compileField(dst *Map, k *d2ast.Key) { - if k.Key != nil && len(k.Key.Path) > 0 { - f, ok := dst.Ensure(d2format.KeyPath(k.Key)) - if !ok { - c.errorf(k, "cannot index into array") - return - } - - if len(k.Edges) == 0 { - if k.Primary.Unbox() != nil { - f.Primary = &Scalar{ - parent: f, - Value: k.Primary.Unbox(), - } - } - if k.Value.Array != nil { - a := &Array{ - parent: f, - } - c.compileArray(a, k.Value.Array) - f.Composite = a - } else if k.Value.Map != nil { - m := &Map{ - parent: f, - } - c.compileMap(m, k.Value.Map) - f.Composite = m - } else if k.Value.ScalarBox().Unbox() != nil { - f.Primary = &Scalar{ - parent: f, - Value: k.Value.ScalarBox().Unbox(), - } - } - } - } -} - -func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { - panic(fmt.Sprintf("TODO")) -} diff --git a/d2ir/compile.go b/d2ir/compile.go new file mode 100644 index 000000000..0f9587eed --- /dev/null +++ b/d2ir/compile.go @@ -0,0 +1,171 @@ +package d2ir + +import ( + "fmt" + + "oss.terrastruct.com/d2/d2ast" + "oss.terrastruct.com/d2/d2format" + "oss.terrastruct.com/d2/d2parser" +) + +type compiler struct { + err d2parser.ParseError +} + +func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { + f = "%v: " + f + v = append([]interface{}{n.GetRange()}, v...) + c.err.Errors = append(c.err.Errors, d2ast.Error{ + Range: n.GetRange(), + Message: fmt.Sprintf(f, v...), + }) +} + +func Compile(dst *Map, ast *d2ast.Map) error { + var c compiler + c.compileMap(dst, ast) + if !c.err.Empty() { + return c.err + } + return nil +} + +func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { + for _, n := range ast.Nodes { + switch { + case n.MapKey != nil: + c.compileKey(dst, n.MapKey) + case n.Substitution != nil: + panic("TODO") + } + } +} + +func (c *compiler) compileKey(dst *Map, k *d2ast.Key) { + if len(k.Edges) == 0 { + c.compileField(dst, k) + } else { + c.compileEdges(dst, k) + } +} + +func (c *compiler) compileField(dst *Map, k *d2ast.Key) { + f, err := dst.Ensure(d2format.KeyPath(k.Key)) + if err != nil { + c.errorf(k, err.Error()) + return + } + + if k.Primary.Unbox() != nil { + f.Primary = &Scalar{ + parent: f, + Value: k.Primary.Unbox(), + } + } + if k.Value.Array != nil { + a := &Array{ + parent: f, + } + c.compileArray(a, k.Value.Array) + f.Composite = a + } else if k.Value.Map != nil { + if f_m, ok := f.Composite.(*Map); ok { + c.compileMap(f_m, k.Value.Map) + } else { + m := &Map{ + parent: f, + } + c.compileMap(m, k.Value.Map) + f.Composite = m + } + } else if k.Value.ScalarBox().Unbox() != nil { + f.Primary = &Scalar{ + parent: f, + Value: k.Value.ScalarBox().Unbox(), + } + } +} + +func (c *compiler) compileEdges(dst *Map, k *d2ast.Key) { + if k.Key != nil && len(k.Key.Path) > 0 { + f, err := dst.Ensure(d2format.KeyPath(k.Key)) + if err != nil { + c.errorf(k, err.Error()) + return + } + if f_m, ok := f.Composite.(*Map); ok { + dst = f_m + } else { + m := &Map{ + parent: f, + } + f.Composite = m + dst = m + } + } + + eida := NewEdgeIDs(k) + for i, eid := range eida { + var e *Edge + if eid.Index != nil { + ea := dst.GetEdges(eid) + if len(ea) == 0 { + c.errorf(k.Edges[i], "indexed edge does not exist") + continue + } + e = ea[0] + } else { + var err error + e, err = dst.EnsureEdge(eid) + if err != nil { + c.errorf(k.Edges[i], err.Error()) + continue + } + } + + _, err := dst.Ensure(eid.SrcPath) + if err != nil { + c.errorf(k.Edges[i].Src, err.Error()) + continue + } + _, err = dst.Ensure(eid.DstPath) + if err != nil { + c.errorf(k.Edges[i].Dst, err.Error()) + continue + } + + if k.EdgeKey != nil { + if e.Map == nil { + e.Map = &Map{ + parent: e, + } + } + tmpk := &d2ast.Key{ + Range: k.EdgeKey.Range, + Key: k.EdgeKey, + } + c.compileField(e.Map, tmpk) + } else { + if k.Primary.Unbox() != nil { + e.Primary = &Scalar{ + parent: e, + Value: k.Primary.Unbox(), + } + } else if k.Value.Map != nil { + if e.Map == nil { + e.Map = &Map{ + parent: e, + } + } + c.compileMap(e.Map, k.Value.Map) + } else if k.Value.Unbox() != nil { + c.errorf(k.Value.Unbox(), "edges cannot be assigned arrays") + continue + } + } + } +} + +func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { + panic(fmt.Sprintf("TODO")) +} diff --git a/d2ir/apply_test.go b/d2ir/compile_test.go similarity index 86% rename from d2ir/apply_test.go rename to d2ir/compile_test.go index 9e53f0a40..7cb3d1df4 100644 --- a/d2ir/apply_test.go +++ b/d2ir/compile_test.go @@ -11,7 +11,6 @@ import ( "oss.terrastruct.com/util-go/diff" "oss.terrastruct.com/d2/d2ast" - "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2ir" "oss.terrastruct.com/d2/d2parser" ) @@ -21,13 +20,13 @@ type testCase struct { run func(testing.TB, *d2ir.Map) } -func TestApply(t *testing.T) { +func TestCompile(t *testing.T) { t.Parallel() - t.Run("simple", testApplySimple) + t.Run("roots", testCompileRoots) } -func testApplySimple(t *testing.T) { +func testCompileRoots(t *testing.T) { t.Parallel() tca := []testCase{ @@ -118,7 +117,7 @@ func testApplySimple(t *testing.T) { run: func(t testing.TB, m *d2ir.Map) { err := parse(t, m, `x._ -> z`) assert.Success(t, err) - assertField(t, m, 2, 1, nil) + assertField(t, m, 3, 1, nil) assertField(t, m, 0, 0, nil, "x") assertField(t, m, 0, 0, nil, "z") @@ -149,7 +148,7 @@ func parse(t testing.TB, dst *d2ir.Map, text string) error { ast, err := d2parser.Parse(d2Path, strings.NewReader(text), nil) assert.Success(t, err) - err = d2ir.Apply(dst, ast) + err = d2ir.Compile(dst, ast) if err != nil { return err } @@ -182,10 +181,9 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa } var f *d2ir.Field - var ok bool if len(ida) > 0 { - f, ok = m.Get(ida) - if !ok { + f = m.Get(ida) + if f == nil { t.Fatalf("expected field %v in map %s", ida, m) } p = f.Primary @@ -196,8 +194,8 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa } } - assert.Equal(t, nfields, m.FieldCount()) - assert.Equal(t, nedges, m.EdgeCount()) + assert.Equal(t, nfields, m.FieldCountRecursive()) + assert.Equal(t, nedges, m.EdgeCountRecursive()) if !makeScalar(p).Equal(makeScalar(primary)) { t.Fatalf("expected primary %#v but got %s", primary, p) } @@ -205,24 +203,13 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa return f } -func parseEdgeID(t testing.TB, eids string) *d2ir.EdgeID { - t.Helper() - k, err := d2parser.ParseMapKey(eids) - assert.Success(t, err) - - return &d2ir.EdgeID{ - SrcPath: d2format.KeyPath(k.Edges[0].Src), - SrcArrow: k.Edges[0].SrcArrow == "<", - DstPath: d2format.KeyPath(k.Edges[0].Dst), - DstArrow: k.Edges[0].DstArrow == ">", - Index: *k.EdgeIndex.Int, - } -} - func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eids string) *d2ir.Edge { t.Helper() - eid := parseEdgeID(t, eids) + k, err := d2parser.ParseMapKey(eids) + assert.Success(t, err) + + eid := d2ir.NewEdgeIDs(k)[0] var m *d2ir.Map switch n := n.(type) { @@ -239,12 +226,13 @@ func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid t.Fatalf("unexpected d2ir.Node %T", n) } - e, ok := m.GetEdge(eid) - if !ok { - t.Fatalf("expected edge %v in map %s but not found", eid, m) + ea := m.GetEdges(eid) + if len(ea) != 1 { + t.Fatalf("expected single edge %v in map %s but not found", eid, m) } + e := ea[0] - assert.Equal(t, nfields, e.Map.FieldCount()) + assert.Equal(t, nfields, e.Map.FieldCountRecursive()) if !makeScalar(e.Primary).Equal(makeScalar(primary)) { t.Fatalf("expected primary %#v but %s", primary, e.Primary) } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index c44c3430a..3bb9154fd 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -2,6 +2,7 @@ package d2ir import ( "encoding/json" + "errors" "fmt" "strings" @@ -155,7 +156,8 @@ type EdgeID struct { DstPath []string `json:"dst_path"` DstArrow bool `json:"dst_arrow"` - Index int `json:"index"` + // If nil, then any EdgeID with equal src/dst/arrows matches. + Index *int `json:"index"` } func (eid *EdgeID) Copy() *EdgeID { @@ -167,9 +169,11 @@ func (eid *EdgeID) Copy() *EdgeID { return eid } -func (eid *EdgeID) Equal(eid2 *EdgeID) bool { - if eid.Index != eid2.Index { - return false +func (eid *EdgeID) Match(eid2 *EdgeID) bool { + if eid.Index != nil && eid2.Index != nil { + if *eid.Index != *eid2.Index { + return false + } } if len(eid.SrcPath) != len(eid2.SrcPath) { @@ -272,29 +276,40 @@ type RefContext struct { Scope *d2ast.Map `json:"-"` } -func (m *Map) FieldCount() int { +func (m *Map) FieldCountRecursive() int { + if m == nil { + return 0 + } acc := len(m.Fields) for _, f := range m.Fields { if f_m, ok := f.Composite.(*Map); ok { - acc += f_m.FieldCount() + acc += f_m.FieldCountRecursive() + } + } + for _, e := range m.Edges { + if e.Map != nil { + acc += e.Map.FieldCountRecursive() } } return acc } -func (m *Map) EdgeCount() int { +func (m *Map) EdgeCountRecursive() int { + if m == nil { + return 0 + } acc := len(m.Edges) for _, e := range m.Edges { if e.Map != nil { - acc += e.Map.EdgeCount() + acc += e.Map.EdgeCountRecursive() } } return acc } -func (m *Map) Get(ida []string) (*Field, bool) { +func (m *Map) Get(ida []string) *Field { if len(ida) == 0 { - return nil, false + return nil } s := ida[0] @@ -305,18 +320,18 @@ func (m *Map) Get(ida []string) (*Field, bool) { continue } if len(rest) == 0 { - return f, true + return f } if f_m, ok := f.Composite.(*Map); ok { return f_m.Get(rest) } } - return nil, false + return nil } -func (m *Map) Ensure(ida []string) (*Field, bool) { +func (m *Map) Ensure(ida []string) (*Field, error) { if len(ida) == 0 { - return nil, false + return nil, errors.New("empty ida") } s := ida[0] @@ -327,13 +342,13 @@ func (m *Map) Ensure(ida []string) (*Field, bool) { continue } if len(rest) == 0 { - return f, true + return f, nil } switch fc := f.Composite.(type) { case *Map: return fc.Ensure(rest) case *Array: - return nil, false + return nil, errors.New("cannot index into array") } f.Composite = &Map{ parent: f, @@ -347,7 +362,7 @@ func (m *Map) Ensure(ida []string) (*Field, bool) { } m.Fields = append(m.Fields, f) if len(rest) == 0 { - return f, true + return f, nil } f.Composite = &Map{ parent: f, @@ -378,25 +393,58 @@ func (m *Map) Delete(ida []string) bool { return false } -func (m *Map) GetEdge(eid *EdgeID) (*Edge, bool) { +func (m *Map) GetEdges(eid *EdgeID) []*Edge { common, eid := eid.trimCommon() if len(common) > 0 { - f, ok := m.Get(common) - if !ok { - return nil, false + f := m.Get(common) + if f == nil { + return nil } if f_m, ok := f.Composite.(*Map); ok { - return f_m.GetEdge(eid) + return f_m.GetEdges(eid) } - return nil, false + return nil } + var ea []*Edge for _, e := range m.Edges { - if e.ID.Equal(eid) { - return e, true + if e.ID.Match(eid) { + ea = append(ea, e) } } - return nil, false + return ea +} + +func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { + common, eid := eid.trimCommon() + if len(common) > 0 { + f, err := m.Ensure(common) + if err != nil { + return nil, err + } + switch fc := f.Composite.(type) { + case *Map: + return fc.EnsureEdge(eid) + case *Array: + return nil, errors.New("cannot index into array") + } + f.Composite = &Map{ + parent: f, + } + return f.Composite.(*Map).EnsureEdge(eid) + } + + eid.Index = nil + ea := m.GetEdges(eid) + index := len(ea) + eid.Index = &index + e := &Edge{ + parent: m, + ID: eid, + } + m.Edges = append(m.Edges, e) + + return e, nil } func (m *Map) String() string { @@ -406,3 +454,18 @@ func (m *Map) String() string { } return string(b) } + +func NewEdgeIDs(k *d2ast.Key) (eida []*EdgeID) { + for _, ke := range k.Edges { + eida = append(eida, &EdgeID{ + SrcPath: d2format.KeyPath(ke.Src), + SrcArrow: ke.SrcArrow == "<", + DstPath: d2format.KeyPath(ke.Dst), + DstArrow: ke.DstArrow == ">", + }) + } + if k.EdgeIndex != nil && k.EdgeIndex.Int != nil { + eida[0].Index = k.EdgeIndex.Int + } + return eida +} diff --git a/testdata/d2ir/TestCompile/roots/edge.exp.json b/testdata/d2ir/TestCompile/roots/edge.exp.json new file mode 100644 index 000000000..67dbe62d8 --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/edge.exp.json @@ -0,0 +1,25 @@ +{ + "fields": [ + { + "name": "x" + }, + { + "name": "y" + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + } + } + ] +} diff --git a/testdata/d2ir/TestCompile/roots/field.exp.json b/testdata/d2ir/TestCompile/roots/field.exp.json new file mode 100644 index 000000000..2dcf9ab44 --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/field.exp.json @@ -0,0 +1,8 @@ +{ + "fields": [ + { + "name": "x" + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/roots/field/label.exp.json b/testdata/d2ir/TestCompile/roots/field/label.exp.json new file mode 100644 index 000000000..723e59be4 --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/field/label.exp.json @@ -0,0 +1,19 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/roots/field/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/roots/field/label/nested.exp.json b/testdata/d2ir/TestCompile/roots/field/label/nested.exp.json new file mode 100644 index 000000000..ce902b9a6 --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/field/label/nested.exp.json @@ -0,0 +1,27 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/roots/field/label/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/roots/nested.exp.json b/testdata/d2ir/TestCompile/roots/nested.exp.json new file mode 100644 index 000000000..8f8b60261 --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/nested.exp.json @@ -0,0 +1,43 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y" + } + ], + "edges": null + } + }, + { + "name": "z", + "composite": { + "fields": [ + { + "name": "p" + } + ], + "edges": null + } + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x", + "y" + ], + "src_arrow": false, + "dst_path": [ + "z", + "p" + ], + "dst_arrow": true, + "index": 0 + } + } + ] +} diff --git a/testdata/d2ir/TestCompile/roots/primary.exp.json b/testdata/d2ir/TestCompile/roots/primary.exp.json new file mode 100644 index 000000000..4e3e9b221 --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/primary.exp.json @@ -0,0 +1,27 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/roots/primary.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/roots/primary/nested.exp.json b/testdata/d2ir/TestCompile/roots/primary/nested.exp.json new file mode 100644 index 000000000..8ae714eba --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/primary/nested.exp.json @@ -0,0 +1,35 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/roots/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/roots/underscore_parent.exp.json b/testdata/d2ir/TestCompile/roots/underscore_parent.exp.json new file mode 100644 index 000000000..0a718ea3d --- /dev/null +++ b/testdata/d2ir/TestCompile/roots/underscore_parent.exp.json @@ -0,0 +1,34 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "_" + } + ], + "edges": null + } + }, + { + "name": "z" + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x", + "_" + ], + "src_arrow": false, + "dst_path": [ + "z" + ], + "dst_arrow": true, + "index": 0 + } + } + ] +} diff --git a/testdata/d2ir/TestCompile/simple/edge.exp.json b/testdata/d2ir/TestCompile/simple/edge.exp.json new file mode 100644 index 000000000..fbfc21849 --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/edge.exp.json @@ -0,0 +1,4 @@ +{ + "fields": null, + "edges": null +} diff --git a/testdata/d2ir/TestCompile/simple/field.exp.json b/testdata/d2ir/TestCompile/simple/field.exp.json new file mode 100644 index 000000000..2dcf9ab44 --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/field.exp.json @@ -0,0 +1,8 @@ +{ + "fields": [ + { + "name": "x" + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/simple/field/label.exp.json b/testdata/d2ir/TestCompile/simple/field/label.exp.json new file mode 100644 index 000000000..17ebacf95 --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/field/label.exp.json @@ -0,0 +1,19 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/simple/field/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/simple/field/label/nested.exp.json b/testdata/d2ir/TestCompile/simple/field/label/nested.exp.json new file mode 100644 index 000000000..520e48db0 --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/field/label/nested.exp.json @@ -0,0 +1,27 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/simple/field/label/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/simple/nested.exp.json b/testdata/d2ir/TestCompile/simple/nested.exp.json new file mode 100644 index 000000000..fbfc21849 --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/nested.exp.json @@ -0,0 +1,4 @@ +{ + "fields": null, + "edges": null +} diff --git a/testdata/d2ir/TestCompile/simple/primary.exp.json b/testdata/d2ir/TestCompile/simple/primary.exp.json new file mode 100644 index 000000000..d104b375d --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/primary.exp.json @@ -0,0 +1,27 @@ +{ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/simple/primary.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/simple/primary/nested.exp.json b/testdata/d2ir/TestCompile/simple/primary/nested.exp.json new file mode 100644 index 000000000..ebac9bea8 --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/primary/nested.exp.json @@ -0,0 +1,35 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "d2/testdata/d2ir/TestCompile/simple/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/simple/underscore_parent.exp.json b/testdata/d2ir/TestCompile/simple/underscore_parent.exp.json new file mode 100644 index 000000000..fbfc21849 --- /dev/null +++ b/testdata/d2ir/TestCompile/simple/underscore_parent.exp.json @@ -0,0 +1,4 @@ +{ + "fields": null, + "edges": null +} From 91149543f5b71e94eebee348f8ad7018e7221667 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 16 Jan 2023 04:48:45 -0800 Subject: [PATCH 12/60] d2ir: wip --- d2ir/compile.go | 25 +- d2ir/compile_test.go | 246 ++++++++++-------- testdata/d2ir/TestApply/simple/edge.exp.json | 4 - .../TestApply/simple/field/label.exp.json | 19 -- .../d2ir/TestApply/simple/nested.exp.json | 4 - testdata/d2ir/TestApply/simple/one.exp.json | 8 - .../d2ir/TestApply/simple/primary.exp.json | 27 -- .../TestApply/simple/primary/nested.exp.json | 35 --- .../simple/underscore_parent.exp.json | 4 - .../TestCompile/{roots => edge}/edge.exp.json | 0 .../{roots => edge}/nested.exp.json | 0 .../underscore.exp.json} | 0 .../d2ir/TestCompile/field/array.exp.json | 40 +++ .../field}/label.exp.json | 2 +- .../field}/nested.exp.json | 2 +- .../{roots => field}/primary/nested.exp.json | 2 +- .../field/primary/root.exp.json} | 2 +- .../field/root.exp.json} | 0 .../d2ir/TestCompile/roots/field.exp.json | 8 - .../TestCompile/roots/field/label.exp.json | 19 -- .../roots/field/label/nested.exp.json | 27 -- .../d2ir/TestCompile/roots/primary.exp.json | 27 -- .../d2ir/TestCompile/simple/edge.exp.json | 4 - .../d2ir/TestCompile/simple/field.exp.json | 8 - .../TestCompile/simple/field/label.exp.json | 19 -- .../simple/field/label/nested.exp.json | 27 -- .../d2ir/TestCompile/simple/nested.exp.json | 4 - .../d2ir/TestCompile/simple/primary.exp.json | 27 -- .../simple/primary/nested.exp.json | 35 --- .../simple/underscore_parent.exp.json | 4 - 30 files changed, 206 insertions(+), 423 deletions(-) delete mode 100644 testdata/d2ir/TestApply/simple/edge.exp.json delete mode 100644 testdata/d2ir/TestApply/simple/field/label.exp.json delete mode 100644 testdata/d2ir/TestApply/simple/nested.exp.json delete mode 100644 testdata/d2ir/TestApply/simple/one.exp.json delete mode 100644 testdata/d2ir/TestApply/simple/primary.exp.json delete mode 100644 testdata/d2ir/TestApply/simple/primary/nested.exp.json delete mode 100644 testdata/d2ir/TestApply/simple/underscore_parent.exp.json rename testdata/d2ir/TestCompile/{roots => edge}/edge.exp.json (100%) rename testdata/d2ir/TestCompile/{roots => edge}/nested.exp.json (100%) rename testdata/d2ir/TestCompile/{roots/underscore_parent.exp.json => edge/underscore.exp.json} (100%) create mode 100644 testdata/d2ir/TestCompile/field/array.exp.json rename testdata/d2ir/{TestApply/simple => TestCompile/field}/label.exp.json (76%) rename testdata/d2ir/{TestApply/simple/field/label => TestCompile/field}/nested.exp.json (82%) rename testdata/d2ir/TestCompile/{roots => field}/primary/nested.exp.json (91%) rename testdata/d2ir/{TestApply/simple/primary#01.exp.json => TestCompile/field/primary/root.exp.json} (81%) rename testdata/d2ir/{TestApply/simple/field.exp.json => TestCompile/field/root.exp.json} (100%) delete mode 100644 testdata/d2ir/TestCompile/roots/field.exp.json delete mode 100644 testdata/d2ir/TestCompile/roots/field/label.exp.json delete mode 100644 testdata/d2ir/TestCompile/roots/field/label/nested.exp.json delete mode 100644 testdata/d2ir/TestCompile/roots/primary.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/edge.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/field.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/field/label.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/field/label/nested.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/nested.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/primary.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/primary/nested.exp.json delete mode 100644 testdata/d2ir/TestCompile/simple/underscore_parent.exp.json diff --git a/d2ir/compile.go b/d2ir/compile.go index 0f9587eed..358c4ba93 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -167,5 +167,28 @@ func (c *compiler) compileEdges(dst *Map, k *d2ast.Key) { } func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { - panic(fmt.Sprintf("TODO")) + for _, an := range a.Nodes { + var irv Value + switch v := an.Unbox().(type) { + case *d2ast.Array: + ira := &Array{ + parent: dst, + } + c.compileArray(ira, v) + irv = ira + case *d2ast.Map: + irm := &Map{ + parent: dst, + } + c.compileMap(irm, v) + irv = irm + case d2ast.Scalar: + irv = &Scalar{ + parent: dst, + Value: v, + } + } + + dst.Values = append(dst.Values, irv) + } } diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 7cb3d1df4..e1174d46c 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -15,119 +15,16 @@ import ( "oss.terrastruct.com/d2/d2parser" ) -type testCase struct { - name string - run func(testing.TB, *d2ir.Map) -} - func TestCompile(t *testing.T) { t.Parallel() - t.Run("roots", testCompileRoots) + t.Run("field", testCompileField) + t.Run("edge", testCompileEdge) } -func testCompileRoots(t *testing.T) { - t.Parallel() - - tca := []testCase{ - { - name: "field", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x`) - assert.Success(t, err) - assertField(t, m, 1, 0, nil) - - assertField(t, m, 0, 0, nil, "x") - }, - }, - { - name: "field/label", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x: yes`) - assert.Success(t, err) - assertField(t, m, 1, 0, nil) - - assertField(t, m, 0, 0, "yes", "x") - }, - }, - { - name: "field/label/nested", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x.y: yes`) - assert.Success(t, err) - assertField(t, m, 2, 0, nil) - - assertField(t, m, 1, 0, nil, "x") - assertField(t, m, 0, 0, "yes", "x", "y") - }, - }, - { - name: "primary", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x: yes { pqrs }`) - assert.Success(t, err) - assertField(t, m, 2, 0, nil) - - assertField(t, m, 1, 0, "yes", "x") - assertField(t, m, 0, 0, nil, "x", "pqrs") - }, - }, - { - name: "primary/nested", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x.y: yes { pqrs }`) - assert.Success(t, err) - assertField(t, m, 3, 0, nil) - - assertField(t, m, 2, 0, nil, "x") - assertField(t, m, 1, 0, "yes", "x", "y") - assertField(t, m, 0, 0, nil, "x", "y", "pqrs") - }, - }, - { - name: "edge", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x -> y`) - assert.Success(t, err) - assertField(t, m, 2, 1, nil) - assertEdge(t, m, 0, nil, `(x -> y)[0]`) - - assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 0, 0, nil, "y") - }, - }, - { - name: "nested", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x.y -> z.p`) - assert.Success(t, err) - assertField(t, m, 4, 1, nil) - - assertField(t, m, 1, 0, nil, "x") - assertField(t, m, 0, 0, nil, "x", "y") - - assertField(t, m, 1, 0, nil, "z") - assertField(t, m, 0, 0, nil, "z", "p") - - assertEdge(t, m, 0, nil, "(x.y -> z.p)[0]") - }, - }, - { - name: "underscore_parent", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x._ -> z`) - assert.Success(t, err) - assertField(t, m, 3, 1, nil) - - assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 0, 0, nil, "z") - - assertEdge(t, m, 0, nil, "(x -> z)[0]") - }, - }, - } - - runa(t, tca) +type testCase struct { + name string + run func(testing.TB, *d2ir.Map) } func runa(t *testing.T, tca []testCase) { @@ -273,3 +170,136 @@ func makeScalar(v interface{}) *d2ir.Scalar { } return s } + +func testCompileField(t *testing.T) { + t.Parallel() + t.Run("primary", testCompileFieldPrimary) + tca := []testCase{ + { + name: "root", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x`) + assert.Success(t, err) + assertField(t, m, 1, 0, nil) + + assertField(t, m, 0, 0, nil, "x") + }, + }, + { + name: "label", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x: yes`) + assert.Success(t, err) + assertField(t, m, 1, 0, nil) + + assertField(t, m, 0, 0, "yes", "x") + }, + }, + { + name: "nested", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x.y: yes`) + assert.Success(t, err) + assertField(t, m, 2, 0, nil) + + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, "yes", "x", "y") + }, + }, + { + name: "array", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x: [1;2;3;4]`) + assert.Success(t, err) + assertField(t, m, 1, 0, nil) + + f := assertField(t, m, 0, 0, nil, "x") + f_a, ok := f.Composite.(*d2ir.Array) + if !ok { + t.Fatalf("unexpected type: %T", f.Composite) + } else { + assert.Equal(t, 4, len(f_a.Values)) + } + }, + }, + } + runa(t, tca) +} + +func testCompileFieldPrimary(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "root", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x: yes { pqrs }`) + assert.Success(t, err) + assertField(t, m, 2, 0, nil) + + assertField(t, m, 1, 0, "yes", "x") + assertField(t, m, 0, 0, nil, "x", "pqrs") + }, + }, + { + name: "nested", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x.y: yes { pqrs }`) + assert.Success(t, err) + assertField(t, m, 3, 0, nil) + + assertField(t, m, 2, 0, nil, "x") + assertField(t, m, 1, 0, "yes", "x", "y") + assertField(t, m, 0, 0, nil, "x", "y", "pqrs") + }, + }, + } + runa(t, tca) +} + +func testCompileEdge(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "edge", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x -> y`) + assert.Success(t, err) + assertField(t, m, 2, 1, nil) + assertEdge(t, m, 0, nil, `(x -> y)[0]`) + + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "y") + }, + }, + { + name: "nested", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x.y -> z.p`) + assert.Success(t, err) + assertField(t, m, 4, 1, nil) + + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, nil, "x", "y") + + assertField(t, m, 1, 0, nil, "z") + assertField(t, m, 0, 0, nil, "z", "p") + + assertEdge(t, m, 0, nil, "(x.y -> z.p)[0]") + }, + }, + { + name: "underscore", + run: func(t testing.TB, m *d2ir.Map) { + err := parse(t, m, `x._ -> z`) + assert.Success(t, err) + assertField(t, m, 3, 1, nil) + + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "z") + + assertEdge(t, m, 0, nil, "(x -> z)[0]") + }, + }, + } + runa(t, tca) +} diff --git a/testdata/d2ir/TestApply/simple/edge.exp.json b/testdata/d2ir/TestApply/simple/edge.exp.json deleted file mode 100644 index fbfc21849..000000000 --- a/testdata/d2ir/TestApply/simple/edge.exp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fields": null, - "edges": null -} diff --git a/testdata/d2ir/TestApply/simple/field/label.exp.json b/testdata/d2ir/TestApply/simple/field/label.exp.json deleted file mode 100644 index 0e70b7b57..000000000 --- a/testdata/d2ir/TestApply/simple/field/label.exp.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestApply/simple/field/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestApply/simple/nested.exp.json b/testdata/d2ir/TestApply/simple/nested.exp.json deleted file mode 100644 index fbfc21849..000000000 --- a/testdata/d2ir/TestApply/simple/nested.exp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fields": null, - "edges": null -} diff --git a/testdata/d2ir/TestApply/simple/one.exp.json b/testdata/d2ir/TestApply/simple/one.exp.json deleted file mode 100644 index 2dcf9ab44..000000000 --- a/testdata/d2ir/TestApply/simple/one.exp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "fields": [ - { - "name": "x" - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestApply/simple/primary.exp.json b/testdata/d2ir/TestApply/simple/primary.exp.json deleted file mode 100644 index 8f512307c..000000000 --- a/testdata/d2ir/TestApply/simple/primary.exp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestApply/simple/primary.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs" - } - ], - "edges": null - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestApply/simple/primary/nested.exp.json b/testdata/d2ir/TestApply/simple/primary/nested.exp.json deleted file mode 100644 index ba3dcf560..000000000 --- a/testdata/d2ir/TestApply/simple/primary/nested.exp.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestApply/simple/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs" - } - ], - "edges": null - } - } - ], - "edges": null - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestApply/simple/underscore_parent.exp.json b/testdata/d2ir/TestApply/simple/underscore_parent.exp.json deleted file mode 100644 index fbfc21849..000000000 --- a/testdata/d2ir/TestApply/simple/underscore_parent.exp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fields": null, - "edges": null -} diff --git a/testdata/d2ir/TestCompile/roots/edge.exp.json b/testdata/d2ir/TestCompile/edge/edge.exp.json similarity index 100% rename from testdata/d2ir/TestCompile/roots/edge.exp.json rename to testdata/d2ir/TestCompile/edge/edge.exp.json diff --git a/testdata/d2ir/TestCompile/roots/nested.exp.json b/testdata/d2ir/TestCompile/edge/nested.exp.json similarity index 100% rename from testdata/d2ir/TestCompile/roots/nested.exp.json rename to testdata/d2ir/TestCompile/edge/nested.exp.json diff --git a/testdata/d2ir/TestCompile/roots/underscore_parent.exp.json b/testdata/d2ir/TestCompile/edge/underscore.exp.json similarity index 100% rename from testdata/d2ir/TestCompile/roots/underscore_parent.exp.json rename to testdata/d2ir/TestCompile/edge/underscore.exp.json diff --git a/testdata/d2ir/TestCompile/field/array.exp.json b/testdata/d2ir/TestCompile/field/array.exp.json new file mode 100644 index 000000000..4f45a4827 --- /dev/null +++ b/testdata/d2ir/TestCompile/field/array.exp.json @@ -0,0 +1,40 @@ +{ + "fields": [ + { + "name": "x", + "composite": { + "values": [ + { + "value": { + "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "value": { + "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "value": { + "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "value": { + "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" + } + } + ] + } + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestApply/simple/label.exp.json b/testdata/d2ir/TestCompile/field/label.exp.json similarity index 76% rename from testdata/d2ir/TestApply/simple/label.exp.json rename to testdata/d2ir/TestCompile/field/label.exp.json index fd2267e5a..9378defd0 100644 --- a/testdata/d2ir/TestApply/simple/label.exp.json +++ b/testdata/d2ir/TestCompile/field/label.exp.json @@ -4,7 +4,7 @@ "name": "x", "primary": { "value": { - "range": "d2/testdata/d2ir/TestApply/simple/label.d2,0:3:3-0:6:6", + "range": "d2/testdata/d2ir/TestCompile/field/label.d2,0:3:3-0:6:6", "value": [ { "string": "yes", diff --git a/testdata/d2ir/TestApply/simple/field/label/nested.exp.json b/testdata/d2ir/TestCompile/field/nested.exp.json similarity index 82% rename from testdata/d2ir/TestApply/simple/field/label/nested.exp.json rename to testdata/d2ir/TestCompile/field/nested.exp.json index fec6ca0c6..638232665 100644 --- a/testdata/d2ir/TestApply/simple/field/label/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/nested.exp.json @@ -8,7 +8,7 @@ "name": "y", "primary": { "value": { - "range": "d2/testdata/d2ir/TestApply/simple/field/label/nested.d2,0:5:5-0:8:8", + "range": "d2/testdata/d2ir/TestCompile/field/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", diff --git a/testdata/d2ir/TestCompile/roots/primary/nested.exp.json b/testdata/d2ir/TestCompile/field/primary/nested.exp.json similarity index 91% rename from testdata/d2ir/TestCompile/roots/primary/nested.exp.json rename to testdata/d2ir/TestCompile/field/primary/nested.exp.json index 8ae714eba..79063ae09 100644 --- a/testdata/d2ir/TestCompile/roots/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/nested.exp.json @@ -8,7 +8,7 @@ "name": "y", "primary": { "value": { - "range": "d2/testdata/d2ir/TestCompile/roots/primary/nested.d2,0:5:5-0:8:8", + "range": "d2/testdata/d2ir/TestCompile/field/primary/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", diff --git a/testdata/d2ir/TestApply/simple/primary#01.exp.json b/testdata/d2ir/TestCompile/field/primary/root.exp.json similarity index 81% rename from testdata/d2ir/TestApply/simple/primary#01.exp.json rename to testdata/d2ir/TestCompile/field/primary/root.exp.json index c1e536d08..cd2bb026c 100644 --- a/testdata/d2ir/TestApply/simple/primary#01.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/root.exp.json @@ -4,7 +4,7 @@ "name": "x", "primary": { "value": { - "range": "d2/testdata/d2ir/TestApply/simple/primary#01.d2,0:3:3-0:6:6", + "range": "d2/testdata/d2ir/TestCompile/field/primary/root.d2,0:3:3-0:6:6", "value": [ { "string": "yes", diff --git a/testdata/d2ir/TestApply/simple/field.exp.json b/testdata/d2ir/TestCompile/field/root.exp.json similarity index 100% rename from testdata/d2ir/TestApply/simple/field.exp.json rename to testdata/d2ir/TestCompile/field/root.exp.json diff --git a/testdata/d2ir/TestCompile/roots/field.exp.json b/testdata/d2ir/TestCompile/roots/field.exp.json deleted file mode 100644 index 2dcf9ab44..000000000 --- a/testdata/d2ir/TestCompile/roots/field.exp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "fields": [ - { - "name": "x" - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/roots/field/label.exp.json b/testdata/d2ir/TestCompile/roots/field/label.exp.json deleted file mode 100644 index 723e59be4..000000000 --- a/testdata/d2ir/TestCompile/roots/field/label.exp.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/roots/field/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/roots/field/label/nested.exp.json b/testdata/d2ir/TestCompile/roots/field/label/nested.exp.json deleted file mode 100644 index ce902b9a6..000000000 --- a/testdata/d2ir/TestCompile/roots/field/label/nested.exp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/roots/field/label/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - ], - "edges": null - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/roots/primary.exp.json b/testdata/d2ir/TestCompile/roots/primary.exp.json deleted file mode 100644 index 4e3e9b221..000000000 --- a/testdata/d2ir/TestCompile/roots/primary.exp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/roots/primary.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs" - } - ], - "edges": null - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/edge.exp.json b/testdata/d2ir/TestCompile/simple/edge.exp.json deleted file mode 100644 index fbfc21849..000000000 --- a/testdata/d2ir/TestCompile/simple/edge.exp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fields": null, - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/field.exp.json b/testdata/d2ir/TestCompile/simple/field.exp.json deleted file mode 100644 index 2dcf9ab44..000000000 --- a/testdata/d2ir/TestCompile/simple/field.exp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "fields": [ - { - "name": "x" - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/field/label.exp.json b/testdata/d2ir/TestCompile/simple/field/label.exp.json deleted file mode 100644 index 17ebacf95..000000000 --- a/testdata/d2ir/TestCompile/simple/field/label.exp.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/simple/field/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/field/label/nested.exp.json b/testdata/d2ir/TestCompile/simple/field/label/nested.exp.json deleted file mode 100644 index 520e48db0..000000000 --- a/testdata/d2ir/TestCompile/simple/field/label/nested.exp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/simple/field/label/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - ], - "edges": null - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/nested.exp.json b/testdata/d2ir/TestCompile/simple/nested.exp.json deleted file mode 100644 index fbfc21849..000000000 --- a/testdata/d2ir/TestCompile/simple/nested.exp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fields": null, - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/primary.exp.json b/testdata/d2ir/TestCompile/simple/primary.exp.json deleted file mode 100644 index d104b375d..000000000 --- a/testdata/d2ir/TestCompile/simple/primary.exp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/simple/primary.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs" - } - ], - "edges": null - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/primary/nested.exp.json b/testdata/d2ir/TestCompile/simple/primary/nested.exp.json deleted file mode 100644 index ebac9bea8..000000000 --- a/testdata/d2ir/TestCompile/simple/primary/nested.exp.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/simple/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs" - } - ], - "edges": null - } - } - ], - "edges": null - } - } - ], - "edges": null -} diff --git a/testdata/d2ir/TestCompile/simple/underscore_parent.exp.json b/testdata/d2ir/TestCompile/simple/underscore_parent.exp.json deleted file mode 100644 index fbfc21849..000000000 --- a/testdata/d2ir/TestCompile/simple/underscore_parent.exp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fields": null, - "edges": null -} From 10ca5e2ce1953bcbe3fc2be67c028832fa1799ca Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 16 Jan 2023 05:31:18 -0800 Subject: [PATCH 13/60] d2ir: Add d2ir -> d2ast for stringifying the IR --- d2ast/d2ast.go | 39 +++++++++++++++ d2ir/compile_test.go | 7 +-- d2ir/d2ir.go | 116 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 134 insertions(+), 28 deletions(-) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index d824ef367..dbbee2ff8 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -650,6 +650,14 @@ type KeyPath struct { Path []*StringBox `json:"path"` } +func MakeKeyPath(a []string) *KeyPath { + var kp *KeyPath + for _, el := range a { + kp.Path = append(kp.Path, MakeValueBox(RawString(el, true)).StringBox()) + } + return kp +} + type Edge struct { Range Range `json:"range"` @@ -731,6 +739,37 @@ type ArrayNodeBox struct { Map *Map `json:"map,omitempty"` } +func MakeArrayNodeBox(an ArrayNode) ArrayNodeBox { + var ab ArrayNodeBox + switch an := an.(type) { + case *Comment: + ab.Comment = an + case *BlockComment: + ab.BlockComment = an + case *Substitution: + ab.Substitution = an + case *Null: + ab.Null = an + case *Boolean: + ab.Boolean = an + case *Number: + ab.Number = an + case *UnquotedString: + ab.UnquotedString = an + case *DoubleQuotedString: + ab.DoubleQuotedString = an + case *SingleQuotedString: + ab.SingleQuotedString = an + case *BlockString: + ab.BlockString = an + case *Array: + ab.Array = an + case *Map: + ab.Map = an + } + return ab +} + func (ab ArrayNodeBox) Unbox() ArrayNode { switch { case ab.Comment != nil: diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index e1174d46c..0d2c07e5b 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -214,12 +214,7 @@ func testCompileField(t *testing.T) { assertField(t, m, 1, 0, nil) f := assertField(t, m, 0, 0, nil, "x") - f_a, ok := f.Composite.(*d2ir.Array) - if !ok { - t.Fatalf("unexpected type: %T", f.Composite) - } else { - assert.Equal(t, 4, len(f_a.Values)) - } + assert.String(t, `[1; 2; 3; 4]`, f.Composite.String()) }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 3bb9154fd..783b1be9e 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -1,7 +1,6 @@ package d2ir import ( - "encoding/json" "errors" "fmt" "strings" @@ -12,7 +11,9 @@ import ( type Node interface { node() + ast() d2ast.Node Copy(newp Parent) Node + fmt.Stringer } var _ Node = &Scalar{} @@ -68,6 +69,12 @@ func (n *Map) value() {} func (n *Array) composite() {} func (n *Map) composite() {} +func (n *Scalar) String() string { return d2format.Format(n.ast()) } +func (n *Field) String() string { return d2format.Format(n.ast()) } +func (n *Edge) String() string { return d2format.Format(n.ast()) } +func (n *Array) String() string { return d2format.Format(n.ast()) } +func (n *Map) String() string { return d2format.Format(n.ast()) } + type Scalar struct { parent Parent Value d2ast.Scalar `json:"value"` @@ -91,10 +98,6 @@ func (s *Scalar) Equal(s2 *Scalar) bool { } -func (s *Scalar) String() string { - return d2format.Format(s.Value) -} - type Map struct { parent Parent Fields []*Field `json:"fields"` @@ -160,6 +163,21 @@ type EdgeID struct { Index *int `json:"index"` } +func NewEdgeIDs(k *d2ast.Key) (eida []*EdgeID) { + for _, ke := range k.Edges { + eida = append(eida, &EdgeID{ + SrcPath: d2format.KeyPath(ke.Src), + SrcArrow: ke.SrcArrow == "<", + DstPath: d2format.KeyPath(ke.Dst), + DstArrow: ke.DstArrow == ">", + }) + } + if k.EdgeIndex != nil && k.EdgeIndex.Int != nil { + eida[0].Index = k.EdgeIndex.Int + } + return eida +} + func (eid *EdgeID) Copy() *EdgeID { tmp := *eid eid = &tmp @@ -447,25 +465,79 @@ func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { return e, nil } -func (m *Map) String() string { - b, err := json.Marshal(m) - if err != nil { - panic(fmt.Sprintf("d2ir: failed to marshal d2ir.Map: %v", err)) - } - return string(b) +func (s *Scalar) ast() d2ast.Node { + return s.Value } -func NewEdgeIDs(k *d2ast.Key) (eida []*EdgeID) { - for _, ke := range k.Edges { - eida = append(eida, &EdgeID{ - SrcPath: d2format.KeyPath(ke.Src), - SrcArrow: ke.SrcArrow == "<", - DstPath: d2format.KeyPath(ke.Dst), - DstArrow: ke.DstArrow == ">", - }) +func (f *Field) ast() d2ast.Node { + k := &d2ast.Key{ + Key: &d2ast.KeyPath{ + Path: []*d2ast.StringBox{ + d2ast.MakeValueBox(d2ast.RawString(f.Name, true)).StringBox(), + }, + }, } - if k.EdgeIndex != nil && k.EdgeIndex.Int != nil { - eida[0].Index = k.EdgeIndex.Int + + if f.Primary != nil { + k.Primary = d2ast.MakeValueBox(f.Primary.ast().(d2ast.Value)).ScalarBox() } - return eida + if f.Composite != nil { + k.Value = d2ast.MakeValueBox(f.Composite.ast().(d2ast.Value)) + } + + return k +} + +func (e *Edge) ast() d2ast.Node { + astEdge := &d2ast.Edge{} + + astEdge.Src = d2ast.MakeKeyPath(e.ID.SrcPath) + if e.ID.SrcArrow { + astEdge.SrcArrow = "<" + } + astEdge.Dst = d2ast.MakeKeyPath(e.ID.DstPath) + if e.ID.DstArrow { + astEdge.DstArrow = ">" + } + + k := &d2ast.Key{ + Edges: []*d2ast.Edge{astEdge}, + } + + if e.Primary != nil { + k.Primary = d2ast.MakeValueBox(e.Primary.ast().(d2ast.Value)).ScalarBox() + } + if e.Map != nil { + k.Value = d2ast.MakeValueBox(e.Map.ast().(*d2ast.Map)) + } + + return k +} + +func (a *Array) ast() d2ast.Node { + if a == nil { + return nil + } + astArray := &d2ast.Array{} + for _, av := range a.Values { + astArray.Nodes = append(astArray.Nodes, d2ast.MakeArrayNodeBox(av.ast().(d2ast.ArrayNode))) + } + return astArray +} + +func (m *Map) ast() d2ast.Node { + if m == nil { + return nil + } + astMap := &d2ast.Map{} + if m.parent != nil { + astMap.Range = d2ast.MakeRange(",1:0:0-1:0:0") + } + for _, f := range m.Fields { + astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(f.ast().(d2ast.MapNode))) + } + for _, e := range m.Edges { + astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(e.ast().(d2ast.MapNode))) + } + return astMap } From 0a19aeb367f2b9c04b79791ddb0cab2e29e3c6a1 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 16 Jan 2023 07:45:13 -0800 Subject: [PATCH 14/60] d2ir: References wip --- d2ir/compile.go | 2 ++ d2ir/d2ir.go | 82 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 75 insertions(+), 9 deletions(-) diff --git a/d2ir/compile.go b/d2ir/compile.go index 358c4ba93..46c7e46b7 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -187,6 +187,8 @@ func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { parent: dst, Value: v, } + case *d2ast.Substitution: + panic("TODO") } dst.Values = append(dst.Values, irv) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 783b1be9e..0e10e1918 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -134,7 +134,7 @@ type Field struct { Primary *Scalar `json:"primary,omitempty"` Composite Composite `json:"composite,omitempty"` - Refs []KeyReference `json:"refs,omitempty"` + References []KeyReference `json:"references,omitempty"` } func (f *Field) Copy(newp Parent) Node { @@ -142,7 +142,7 @@ func (f *Field) Copy(newp Parent) Node { f = &tmp f.parent = newp.(*Map) - f.Refs = append([]KeyReference(nil), f.Refs...) + f.References = append([]KeyReference(nil), f.References...) if f.Primary != nil { f.Primary = f.Primary.Copy(f).(*Scalar) } @@ -242,7 +242,7 @@ type Edge struct { Primary *Scalar `json:"primary,omitempty"` Map *Map `json:"map,omitempty"` - Refs []EdgeReference `json:"refs,omitempty"` + References []EdgeReference `json:"references,omitempty"` } func (e *Edge) Copy(newp Parent) Node { @@ -250,7 +250,7 @@ func (e *Edge) Copy(newp Parent) Node { e = &tmp e.parent = newp.(*Map) - e.Refs = append([]EdgeReference(nil), e.Refs...) + e.References = append([]EdgeReference(nil), e.References...) if e.Primary != nil { e.Primary = e.Primary.Copy(e).(*Scalar) } @@ -281,17 +281,47 @@ type KeyReference struct { String *d2ast.StringBox `json:"string"` KeyPath *d2ast.KeyPath `json:"key_path"` - RefCtx *RefContext `json:"ref_ctx"` + Context *RefContext `json:"-"` +} + +func (kr KeyReference) KeyPathIndex() int { + for i, sb := range kr.KeyPath.Path { + if sb == kr.String { + return i + } + } + panic("d2ir.KeyReference.KeyPathIndex: String not in KeyPath?") +} + +func (kr KeyReference) EdgeDest() bool { + return kr.KeyPath == kr.Context.Edge.Dst +} + +func (kr KeyReference) InEdge() bool { + return kr.KeyPath != kr.Context.Key.Key } type EdgeReference struct { - RefCtx *RefContext `json:"ref_ctx"` + Context *RefContext `json:"-"` } type RefContext struct { - Key *d2ast.Key `json:"-"` - Edge *d2ast.Edge `json:"-"` - Scope *d2ast.Map `json:"-"` + Key *d2ast.Key + Edge *d2ast.Edge + Scope *d2ast.Map + + // UnresolvedScopeMap is prior to interpreting _ + ScopeMap *Map + UnresolvedScopeMap *Map +} + +func (rc RefContext) EdgeIndex() int { + for i, e := range rc.Context.Key.Edges { + if e == rc.Context.Edge { + return i + } + } + panic("d2ir.RefContext.EdgeIndex: Edge not in Key.Edges?") } func (m *Map) FieldCountRecursive() int { @@ -541,3 +571,37 @@ func (m *Map) ast() d2ast.Node { } return astMap } + +func (m *Map) appendKeyReferences(i int, kp *d2ast.KeyPath, refctx *RefContext) { + sb := kp.Path[i] + f := m.Get([]string{sb.Unbox().ScalarString()}) + if f == nil { + return + } + + f.References = append(f.References, KeyReference{ + String: sb, + KeyPath: kp, + Context: refctx, + }) + if f_m, ok := f.Composite.(*Map); ok { + f_m.appendReferences(i+1, kp, refctx) + } +} + +func (m *Map) appendEdgeReferences(e *Edge, refctx *RefContext) { + sb := kp.Path[i] + f := m.Get([]string{sb.Unbox().ScalarString()}) + if f == nil { + return + } + + f.References = append(f.References, KeyReference{ + String: sb, + KeyPath: kp, + Context: refctx, + }) + if f_m, ok := f.Composite.(*Map); ok { + f_m.appendReferences(i+1, kp, refctx) + } +} From 7721c8b2b46a0611f4ea631a14206c1d0e6a9403 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 17 Jan 2023 03:05:56 -0800 Subject: [PATCH 15/60] d2ir: References wip --- d2ir/d2ir.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 0e10e1918..14a39c127 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -316,8 +316,8 @@ type RefContext struct { } func (rc RefContext) EdgeIndex() int { - for i, e := range rc.Context.Key.Edges { - if e == rc.Context.Edge { + for i, e := range rc.Key.Edges { + if e == rc.Edge { return i } } @@ -584,24 +584,18 @@ func (m *Map) appendKeyReferences(i int, kp *d2ast.KeyPath, refctx *RefContext) KeyPath: kp, Context: refctx, }) + if i+1 == len(kp.Path) { + return + } if f_m, ok := f.Composite.(*Map); ok { - f_m.appendReferences(i+1, kp, refctx) + f_m.appendKeyReferences(i+1, kp, refctx) } } func (m *Map) appendEdgeReferences(e *Edge, refctx *RefContext) { - sb := kp.Path[i] - f := m.Get([]string{sb.Unbox().ScalarString()}) - if f == nil { - return - } - - f.References = append(f.References, KeyReference{ - String: sb, - KeyPath: kp, + e.References = append(e.References, EdgeReference{ Context: refctx, }) - if f_m, ok := f.Composite.(*Map); ok { - f_m.appendReferences(i+1, kp, refctx) - } + m.appendKeyReferences(0, refctx.Edge.Src, refctx) + m.appendKeyReferences(0, refctx.Edge.Dst, refctx) } From f69f401d23477e64abf745c8b994bc6df94ced99 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 17 Jan 2023 04:44:14 -0800 Subject: [PATCH 16/60] d2ir: References wip --- d2ast/d2ast.go | 2 +- d2ir/compile.go | 27 ++- d2ir/compile_test.go | 10 +- d2ir/d2ir.go | 190 +++++++++++++----- testdata/d2ir/TestCompile/edge/root.exp.json | 25 +++ .../d2ir/TestCompile/edge/underscore.exp.json | 10 +- 6 files changed, 190 insertions(+), 74 deletions(-) create mode 100644 testdata/d2ir/TestCompile/edge/root.exp.json diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index dbbee2ff8..37906a163 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -651,7 +651,7 @@ type KeyPath struct { } func MakeKeyPath(a []string) *KeyPath { - var kp *KeyPath + kp := &KeyPath{} for _, el := range a { kp.Path = append(kp.Path, MakeValueBox(RawString(el, true)).StringBox()) } diff --git a/d2ir/compile.go b/d2ir/compile.go index 46c7e46b7..0ceb42944 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -50,7 +50,7 @@ func (c *compiler) compileKey(dst *Map, k *d2ast.Key) { } func (c *compiler) compileField(dst *Map, k *d2ast.Key) { - f, err := dst.Ensure(d2format.KeyPath(k.Key)) + f, err := dst.EnsureField(d2format.KeyPath(k.Key)) if err != nil { c.errorf(k, err.Error()) return @@ -88,7 +88,7 @@ func (c *compiler) compileField(dst *Map, k *d2ast.Key) { func (c *compiler) compileEdges(dst *Map, k *d2ast.Key) { if k.Key != nil && len(k.Key.Path) > 0 { - f, err := dst.Ensure(d2format.KeyPath(k.Key)) + f, err := dst.EnsureField(d2format.KeyPath(k.Key)) if err != nil { c.errorf(k, err.Error()) return @@ -115,7 +115,17 @@ func (c *compiler) compileEdges(dst *Map, k *d2ast.Key) { } e = ea[0] } else { - var err error + _, err := dst.EnsureField(eid.SrcPath) + if err != nil { + c.errorf(k.Edges[i].Src, err.Error()) + continue + } + _, err = dst.EnsureField(eid.DstPath) + if err != nil { + c.errorf(k.Edges[i].Dst, err.Error()) + continue + } + e, err = dst.EnsureEdge(eid) if err != nil { c.errorf(k.Edges[i], err.Error()) @@ -123,17 +133,6 @@ func (c *compiler) compileEdges(dst *Map, k *d2ast.Key) { } } - _, err := dst.Ensure(eid.SrcPath) - if err != nil { - c.errorf(k.Edges[i].Src, err.Error()) - continue - } - _, err = dst.Ensure(eid.DstPath) - if err != nil { - c.errorf(k.Edges[i].Dst, err.Error()) - continue - } - if k.EdgeKey != nil { if e.Map == nil { e.Map = &Map{ diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 0d2c07e5b..11c882a95 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -79,7 +79,7 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa var f *d2ir.Field if len(ida) > 0 { - f = m.Get(ida) + f = m.GetField(ida) if f == nil { t.Fatalf("expected field %v in map %s", ida, m) } @@ -255,7 +255,7 @@ func testCompileEdge(t *testing.T) { t.Parallel() tca := []testCase{ { - name: "edge", + name: "root", run: func(t testing.TB, m *d2ir.Map) { err := parse(t, m, `x -> y`) assert.Success(t, err) @@ -285,14 +285,14 @@ func testCompileEdge(t *testing.T) { { name: "underscore", run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x._ -> z`) + err := parse(t, m, `p: { _.x -> z }`) assert.Success(t, err) assertField(t, m, 3, 1, nil) assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 0, 0, nil, "z") + assertField(t, m, 1, 0, nil, "p") - assertEdge(t, m, 0, nil, "(x -> z)[0]") + assertEdge(t, m, 0, nil, "(x -> p.z)[0]") }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 14a39c127..fc5d5930b 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -5,6 +5,8 @@ import ( "fmt" "strings" + "oss.terrastruct.com/util-go/go2" + "oss.terrastruct.com/d2/d2ast" "oss.terrastruct.com/d2/d2format" ) @@ -12,7 +14,9 @@ import ( type Node interface { node() ast() d2ast.Node - Copy(newp Parent) Node + Parent() Node + Copy(newp Node) Node + fmt.Stringer } @@ -22,16 +26,6 @@ var _ Node = &Edge{} var _ Node = &Array{} var _ Node = &Map{} -type Parent interface { - Node - Parent() Parent -} - -var _ Parent = &Field{} -var _ Parent = &Edge{} -var _ Parent = &Array{} -var _ Parent = &Map{} - type Value interface { Node value() @@ -56,11 +50,11 @@ func (n *Edge) node() {} func (n *Array) node() {} func (n *Map) node() {} -func (n *Scalar) Parent() Parent { return n.parent } -func (n *Field) Parent() Parent { return n.parent } -func (n *Edge) Parent() Parent { return n.parent } -func (n *Array) Parent() Parent { return n.parent } -func (n *Map) Parent() Parent { return n.parent } +func (n *Scalar) Parent() Node { return n.parent } +func (n *Field) Parent() Node { return n.parent } +func (n *Edge) Parent() Node { return n.parent } +func (n *Array) Parent() Node { return n.parent } +func (n *Map) Parent() Node { return n.parent } func (n *Scalar) value() {} func (n *Array) value() {} @@ -76,11 +70,11 @@ func (n *Array) String() string { return d2format.Format(n.ast()) } func (n *Map) String() string { return d2format.Format(n.ast()) } type Scalar struct { - parent Parent + parent Node Value d2ast.Scalar `json:"value"` } -func (s *Scalar) Copy(newp Parent) Node { +func (s *Scalar) Copy(newp Node) Node { tmp := *s s = &tmp @@ -99,12 +93,12 @@ func (s *Scalar) Equal(s2 *Scalar) bool { } type Map struct { - parent Parent + parent Node Fields []*Field `json:"fields"` Edges []*Edge `json:"edges"` } -func (m *Map) Copy(newp Parent) Node { +func (m *Map) Copy(newp Node) Node { tmp := *m m = &tmp @@ -134,15 +128,15 @@ type Field struct { Primary *Scalar `json:"primary,omitempty"` Composite Composite `json:"composite,omitempty"` - References []KeyReference `json:"references,omitempty"` + References []FieldReference `json:"references,omitempty"` } -func (f *Field) Copy(newp Parent) Node { +func (f *Field) Copy(newp Node) Node { tmp := *f f = &tmp f.parent = newp.(*Map) - f.References = append([]KeyReference(nil), f.References...) + f.References = append([]FieldReference(nil), f.References...) if f.Primary != nil { f.Primary = f.Primary.Copy(f).(*Scalar) } @@ -221,6 +215,30 @@ func (eid *EdgeID) Match(eid2 *EdgeID) bool { return true } +func (eid *EdgeID) resolveUnderscores(m *Map) (*EdgeID, *Map, error) { + eid = eid.Copy() + maxUnderscores := go2.Max(countUnderscores(eid.SrcPath), countUnderscores(eid.DstPath)) + for i := 0; i < maxUnderscores; i++ { + if eid.SrcPath[0] == "_" { + eid.SrcPath = eid.SrcPath[1:] + } else { + mf := parentField(m) + eid.SrcPath = append([]string{mf.Name}, eid.SrcPath...) + } + if eid.DstPath[0] == "_" { + eid.DstPath = eid.DstPath[1:] + } else { + mf := parentField(m) + eid.DstPath = append([]string{mf.Name}, eid.DstPath...) + } + m = parentMap(m) + if m == nil { + return nil, nil, errors.New("invalid underscore") + } + } + return eid, m, nil +} + func (eid *EdgeID) trimCommon() (common []string, _ *EdgeID) { eid = eid.Copy() for len(eid.SrcPath) > 1 && len(eid.DstPath) > 1 { @@ -245,7 +263,7 @@ type Edge struct { References []EdgeReference `json:"references,omitempty"` } -func (e *Edge) Copy(newp Parent) Node { +func (e *Edge) Copy(newp Node) Node { tmp := *e e = &tmp @@ -261,11 +279,11 @@ func (e *Edge) Copy(newp Parent) Node { } type Array struct { - parent Parent + parent Node Values []Value `json:"values"` } -func (a *Array) Copy(newp Parent) Node { +func (a *Array) Copy(newp Node) Node { tmp := *a a = &tmp @@ -277,14 +295,14 @@ func (a *Array) Copy(newp Parent) Node { return a } -type KeyReference struct { +type FieldReference struct { String *d2ast.StringBox `json:"string"` KeyPath *d2ast.KeyPath `json:"key_path"` Context *RefContext `json:"-"` } -func (kr KeyReference) KeyPathIndex() int { +func (kr FieldReference) KeyPathIndex() int { for i, sb := range kr.KeyPath.Path { if sb == kr.String { return i @@ -293,11 +311,11 @@ func (kr KeyReference) KeyPathIndex() int { panic("d2ir.KeyReference.KeyPathIndex: String not in KeyPath?") } -func (kr KeyReference) EdgeDest() bool { +func (kr FieldReference) EdgeDest() bool { return kr.KeyPath == kr.Context.Edge.Dst } -func (kr KeyReference) InEdge() bool { +func (kr FieldReference) InEdge() bool { return kr.KeyPath != kr.Context.Key.Key } @@ -311,7 +329,6 @@ type RefContext struct { Scope *d2ast.Map // UnresolvedScopeMap is prior to interpreting _ - ScopeMap *Map UnresolvedScopeMap *Map } @@ -347,6 +364,11 @@ func (m *Map) EdgeCountRecursive() int { return 0 } acc := len(m.Edges) + for _, f := range m.Fields { + if f_m, ok := f.Composite.(*Map); ok { + acc += f_m.EdgeCountRecursive() + } + } for _, e := range m.Edges { if e.Map != nil { acc += e.Map.EdgeCountRecursive() @@ -355,7 +377,17 @@ func (m *Map) EdgeCountRecursive() int { return acc } -func (m *Map) Get(ida []string) *Field { +func (m *Map) GetField(ida []string) *Field { + for len(ida) > 0 && ida[0] == "_" { + m = parentMap(m) + if m == nil { + return nil + } + } + return m.getField(ida) +} + +func (m *Map) getField(ida []string) *Field { if len(ida) == 0 { return nil } @@ -363,6 +395,10 @@ func (m *Map) Get(ida []string) *Field { s := ida[0] rest := ida[1:] + if s == "_" { + return nil + } + for _, f := range m.Fields { if !strings.EqualFold(f.Name, s) { continue @@ -371,20 +407,35 @@ func (m *Map) Get(ida []string) *Field { return f } if f_m, ok := f.Composite.(*Map); ok { - return f_m.Get(rest) + return f_m.getField(rest) } } return nil } -func (m *Map) Ensure(ida []string) (*Field, error) { +func (m *Map) EnsureField(ida []string) (*Field, error) { + for len(ida) > 0 && ida[0] == "_" { + m = parentMap(m) + if m == nil { + return nil, errors.New("invalid underscore") + } + ida = ida[1:] + } + return m.ensureField(ida) +} + +func (m *Map) ensureField(ida []string) (*Field, error) { if len(ida) == 0 { - return nil, errors.New("empty ida") + return nil, errors.New("invalid underscore") } s := ida[0] rest := ida[1:] + if s == "_" { + return nil, errors.New(`parent "_" can only be used in the beginning of paths, e.g. "_.x"`) + } + for _, f := range m.Fields { if !strings.EqualFold(f.Name, s) { continue @@ -394,14 +445,14 @@ func (m *Map) Ensure(ida []string) (*Field, error) { } switch fc := f.Composite.(type) { case *Map: - return fc.Ensure(rest) + return fc.ensureField(rest) case *Array: return nil, errors.New("cannot index into array") } f.Composite = &Map{ parent: f, } - return f.Composite.(*Map).Ensure(rest) + return f.Composite.(*Map).ensureField(rest) } f := &Field{ @@ -415,7 +466,7 @@ func (m *Map) Ensure(ida []string) (*Field, error) { f.Composite = &Map{ parent: f, } - return f.Composite.(*Map).Ensure(rest) + return f.Composite.(*Map).ensureField(rest) } func (m *Map) Delete(ida []string) bool { @@ -442,9 +493,13 @@ func (m *Map) Delete(ida []string) bool { } func (m *Map) GetEdges(eid *EdgeID) []*Edge { + eid, m, err := eid.resolveUnderscores(m) + if err != nil { + return nil + } common, eid := eid.trimCommon() if len(common) > 0 { - f := m.Get(common) + f := m.GetField(common) if f == nil { return nil } @@ -464,9 +519,13 @@ func (m *Map) GetEdges(eid *EdgeID) []*Edge { } func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { + eid, m, err := eid.resolveUnderscores(m) + if err != nil { + return nil, err + } common, eid := eid.trimCommon() if len(common) > 0 { - f, err := m.Ensure(common) + f, err := m.EnsureField(common) if err != nil { return nil, err } @@ -560,8 +619,10 @@ func (m *Map) ast() d2ast.Node { return nil } astMap := &d2ast.Map{} - if m.parent != nil { - astMap.Range = d2ast.MakeRange(",1:0:0-1:0:0") + if m.parent == nil { + astMap.Range = d2ast.MakeRange(",0:0:0-1:0:0") + } else { + astMap.Range = d2ast.MakeRange(",1:0:0-2:0:0") } for _, f := range m.Fields { astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(f.ast().(d2ast.MapNode))) @@ -572,15 +633,15 @@ func (m *Map) ast() d2ast.Node { return astMap } -func (m *Map) appendKeyReferences(i int, kp *d2ast.KeyPath, refctx *RefContext) { +func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext) { sb := kp.Path[i] - f := m.Get([]string{sb.Unbox().ScalarString()}) + f := m.GetField([]string{sb.Unbox().ScalarString()}) if f == nil { return } - f.References = append(f.References, KeyReference{ - String: sb, + f.References = append(f.References, FieldReference{ + String: sb, KeyPath: kp, Context: refctx, }) @@ -588,7 +649,7 @@ func (m *Map) appendKeyReferences(i int, kp *d2ast.KeyPath, refctx *RefContext) return } if f_m, ok := f.Composite.(*Map); ok { - f_m.appendKeyReferences(i+1, kp, refctx) + f_m.appendFieldReferences(i+1, kp, refctx) } } @@ -596,6 +657,37 @@ func (m *Map) appendEdgeReferences(e *Edge, refctx *RefContext) { e.References = append(e.References, EdgeReference{ Context: refctx, }) - m.appendKeyReferences(0, refctx.Edge.Src, refctx) - m.appendKeyReferences(0, refctx.Edge.Dst, refctx) + m.appendFieldReferences(0, refctx.Edge.Src, refctx) + m.appendFieldReferences(0, refctx.Edge.Dst, refctx) +} + +func parentMap(n Node) *Map { + for n.Parent() != nil { + n = n.Parent() + if n_m, ok := n.(*Map); ok { + return n_m + } + } + return nil +} + +func parentField(n Node) *Field { + for n.Parent() != nil { + n = n.Parent() + if n_f, ok := n.(*Field); ok { + return n_f + } + } + return nil +} + +func countUnderscores(p []string) int { + var count int + for _, el := range p { + if el != "_" { + break + } + count++ + } + return count } diff --git a/testdata/d2ir/TestCompile/edge/root.exp.json b/testdata/d2ir/TestCompile/edge/root.exp.json new file mode 100644 index 000000000..67dbe62d8 --- /dev/null +++ b/testdata/d2ir/TestCompile/edge/root.exp.json @@ -0,0 +1,25 @@ +{ + "fields": [ + { + "name": "x" + }, + { + "name": "y" + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + } + } + ] +} diff --git a/testdata/d2ir/TestCompile/edge/underscore.exp.json b/testdata/d2ir/TestCompile/edge/underscore.exp.json index 0a718ea3d..d4a50ab64 100644 --- a/testdata/d2ir/TestCompile/edge/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edge/underscore.exp.json @@ -1,29 +1,29 @@ { "fields": [ { - "name": "x", + "name": "p", "composite": { "fields": [ { - "name": "_" + "name": "z" } ], "edges": null } }, { - "name": "z" + "name": "x" } ], "edges": [ { "edge_id": { "src_path": [ - "x", - "_" + "x" ], "src_arrow": false, "dst_path": [ + "p", "z" ], "dst_arrow": true, From f7394133b957e0e668b77bcc26a7ea03c7e2b94a Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 17 Jan 2023 17:39:31 -0800 Subject: [PATCH 17/60] d2ir: IR Root wip --- d2ir/compile.go | 21 ++- d2ir/compile_test.go | 160 ++++++++---------- d2ir/d2ir.go | 105 ++++++++++-- testdata/d2ir/TestCompile/edge/edge.exp.json | 25 --- .../d2ir/TestCompile/edge/nested.exp.json | 151 ++++++++++++----- testdata/d2ir/TestCompile/edge/root.exp.json | 97 ++++++++--- .../d2ir/TestCompile/edge/underscore.exp.json | 151 +++++++++++++---- .../d2ir/TestCompile/field/array.exp.json | 132 +++++++++++---- .../d2ir/TestCompile/field/label.exp.json | 68 ++++++-- .../d2ir/TestCompile/field/nested.exp.json | 93 +++++++--- .../TestCompile/field/primary/nested.exp.json | 138 +++++++++++---- .../TestCompile/field/primary/root.exp.json | 113 ++++++++++--- testdata/d2ir/TestCompile/field/root.exp.json | 42 ++++- 13 files changed, 939 insertions(+), 357 deletions(-) delete mode 100644 testdata/d2ir/TestCompile/edge/edge.exp.json diff --git a/d2ir/compile.go b/d2ir/compile.go index 0ceb42944..ba3744d3f 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -21,13 +21,22 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { }) } -func Compile(dst *Map, ast *d2ast.Map) error { - var c compiler - c.compileMap(dst, ast) - if !c.err.Empty() { - return c.err +func Compile(ast *d2ast.Map) (*IR, error) { + ir := &IR{ + AST: ast, + Map: &Map{}, } - return nil + + c := &compiler{} + c.compile(ir) + if !c.err.Empty() { + return nil, c.err + } + return ir, nil +} + +func (c *compiler) compile(ir *IR) { + c.compileMap(ir.Map, ir.AST) } func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 11c882a95..043525cc3 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -24,7 +24,7 @@ func TestCompile(t *testing.T) { type testCase struct { name string - run func(testing.TB, *d2ir.Map) + run func(testing.TB) } func runa(t *testing.T, tca []testCase) { @@ -32,50 +32,38 @@ func runa(t *testing.T, tca []testCase) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() - m := &d2ir.Map{} - tc.run(t, m) + tc.run(t) }) } } -func parse(t testing.TB, dst *d2ir.Map, text string) error { +func compile(t testing.TB, text string) (*d2ir.IR, error) { t.Helper() - d2Path := fmt.Sprintf("d2/testdata/d2ir/%v.d2", t.Name()) + d2Path := fmt.Sprintf("%v.d2", t.Name()) ast, err := d2parser.Parse(d2Path, strings.NewReader(text), nil) assert.Success(t, err) - err = d2ir.Compile(dst, ast) + ir, err := d2ir.Compile(ast) if err != nil { - return err + return nil, err } - err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), dst) - return err + err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), ir) + if err != nil { + return nil, err + } + return ir ,nil } func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { t.Helper() - var m *d2ir.Map - p := &d2ir.Scalar{ - Value: &d2ast.Null{}, - } - switch n := n.(type) { - case *d2ir.Field: - mm, ok := n.Composite.(*d2ir.Map) - if ok { - m = mm - } else { - t.Fatalf("unexpected d2ir.Field.Composite %T", n.Composite) - } - p = n.Primary - case *d2ir.Map: - m = n - p.Value = &d2ast.Null{} - default: - t.Fatalf("unexpected d2ir.Node %T", n) + m := d2ir.ToMap(n) + if m == nil { + t.Fatalf("nil m from %T", n) } + p := d2ir.ToScalar(n) var f *d2ir.Field if len(ida) > 0 { @@ -84,11 +72,7 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa t.Fatalf("expected field %v in map %s", ida, m) } p = f.Primary - if f_m, ok := f.Composite.(*d2ir.Map); ok { - m = f_m - } else { - m = &d2ir.Map{} - } + m = d2ir.ToMap(f) } assert.Equal(t, nfields, m.FieldCountRecursive()) @@ -108,19 +92,9 @@ func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid eid := d2ir.NewEdgeIDs(k)[0] - var m *d2ir.Map - switch n := n.(type) { - case *d2ir.Field: - mm, ok := n.Composite.(*d2ir.Map) - if ok { - m = mm - } else { - t.Fatalf("unexpected d2ir.Field.Composite %T", n.Composite) - } - case *d2ir.Map: - m = n - default: - t.Fatalf("unexpected d2ir.Node %T", n) + m := d2ir.ToMap(n) + if m == nil { + t.Fatalf("nil m from %T", n) } ea := m.GetEdges(eid) @@ -177,43 +151,43 @@ func testCompileField(t *testing.T) { tca := []testCase{ { name: "root", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x`) + run: func(t testing.TB) { + ir, err := compile(t, `x`) assert.Success(t, err) - assertField(t, m, 1, 0, nil) + assertField(t, ir, 1, 0, nil) - assertField(t, m, 0, 0, nil, "x") + assertField(t, ir, 0, 0, nil, "x") }, }, { name: "label", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x: yes`) + run: func(t testing.TB) { + ir, err := compile(t, `x: yes`) assert.Success(t, err) - assertField(t, m, 1, 0, nil) + assertField(t, ir, 1, 0, nil) - assertField(t, m, 0, 0, "yes", "x") + assertField(t, ir, 0, 0, "yes", "x") }, }, { name: "nested", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x.y: yes`) + run: func(t testing.TB) { + ir, err := compile(t, `x.y: yes`) assert.Success(t, err) - assertField(t, m, 2, 0, nil) + assertField(t, ir, 2, 0, nil) - assertField(t, m, 1, 0, nil, "x") - assertField(t, m, 0, 0, "yes", "x", "y") + assertField(t, ir, 1, 0, nil, "x") + assertField(t, ir, 0, 0, "yes", "x", "y") }, }, { name: "array", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x: [1;2;3;4]`) + run: func(t testing.TB) { + ir, err := compile(t, `x: [1;2;3;4]`) assert.Success(t, err) - assertField(t, m, 1, 0, nil) + assertField(t, ir, 1, 0, nil) - f := assertField(t, m, 0, 0, nil, "x") + f := assertField(t, ir, 0, 0, nil, "x") assert.String(t, `[1; 2; 3; 4]`, f.Composite.String()) }, }, @@ -226,25 +200,25 @@ func testCompileFieldPrimary(t *testing.T) { tca := []testCase{ { name: "root", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x: yes { pqrs }`) + run: func(t testing.TB) { + ir, err := compile(t, `x: yes { pqrs }`) assert.Success(t, err) - assertField(t, m, 2, 0, nil) + assertField(t, ir, 2, 0, nil) - assertField(t, m, 1, 0, "yes", "x") - assertField(t, m, 0, 0, nil, "x", "pqrs") + assertField(t, ir, 1, 0, "yes", "x") + assertField(t, ir, 0, 0, nil, "x", "pqrs") }, }, { name: "nested", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x.y: yes { pqrs }`) + run: func(t testing.TB) { + ir, err := compile(t, `x.y: yes { pqrs }`) assert.Success(t, err) - assertField(t, m, 3, 0, nil) + assertField(t, ir, 3, 0, nil) - assertField(t, m, 2, 0, nil, "x") - assertField(t, m, 1, 0, "yes", "x", "y") - assertField(t, m, 0, 0, nil, "x", "y", "pqrs") + assertField(t, ir, 2, 0, nil, "x") + assertField(t, ir, 1, 0, "yes", "x", "y") + assertField(t, ir, 0, 0, nil, "x", "y", "pqrs") }, }, } @@ -256,43 +230,43 @@ func testCompileEdge(t *testing.T) { tca := []testCase{ { name: "root", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x -> y`) + run: func(t testing.TB) { + ir, err := compile(t, `x -> y`) assert.Success(t, err) - assertField(t, m, 2, 1, nil) - assertEdge(t, m, 0, nil, `(x -> y)[0]`) + assertField(t, ir, 2, 1, nil) + assertEdge(t, ir, 0, nil, `(x -> y)[0]`) - assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 0, 0, nil, "y") + assertField(t, ir, 0, 0, nil, "x") + assertField(t, ir, 0, 0, nil, "y") }, }, { name: "nested", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `x.y -> z.p`) + run: func(t testing.TB) { + ir, err := compile(t, `x.y -> z.p`) assert.Success(t, err) - assertField(t, m, 4, 1, nil) + assertField(t, ir, 4, 1, nil) - assertField(t, m, 1, 0, nil, "x") - assertField(t, m, 0, 0, nil, "x", "y") + assertField(t, ir, 1, 0, nil, "x") + assertField(t, ir, 0, 0, nil, "x", "y") - assertField(t, m, 1, 0, nil, "z") - assertField(t, m, 0, 0, nil, "z", "p") + assertField(t, ir, 1, 0, nil, "z") + assertField(t, ir, 0, 0, nil, "z", "p") - assertEdge(t, m, 0, nil, "(x.y -> z.p)[0]") + assertEdge(t, ir, 0, nil, "(x.y -> z.p)[0]") }, }, { name: "underscore", - run: func(t testing.TB, m *d2ir.Map) { - err := parse(t, m, `p: { _.x -> z }`) + run: func(t testing.TB) { + ir, err := compile(t, `p: { _.x -> z }`) assert.Success(t, err) - assertField(t, m, 3, 1, nil) + assertField(t, ir, 3, 1, nil) - assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 1, 0, nil, "p") + assertField(t, ir, 0, 0, nil, "x") + assertField(t, ir, 1, 0, nil, "p") - assertEdge(t, m, 0, nil, "(x -> p.z)[0]") + assertEdge(t, ir, 0, nil, "(x -> p.z)[0]") }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index fc5d5930b..80297328b 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -13,13 +13,14 @@ import ( type Node interface { node() - ast() d2ast.Node + Copy(parent Node) Node Parent() Node - Copy(newp Node) Node + ast() d2ast.Node fmt.Stringer } +var _ Node = &IR{} var _ Node = &Scalar{} var _ Node = &Field{} var _ Node = &Edge{} @@ -44,12 +45,14 @@ type Composite interface { var _ Composite = &Array{} var _ Composite = &Map{} +func (n *IR) node() {} func (n *Scalar) node() {} func (n *Field) node() {} func (n *Edge) node() {} func (n *Array) node() {} func (n *Map) node() {} +func (n *IR) Parent() Node { return n.parent } func (n *Scalar) Parent() Node { return n.parent } func (n *Field) Parent() Node { return n.parent } func (n *Edge) Parent() Node { return n.parent } @@ -59,16 +62,35 @@ func (n *Map) Parent() Node { return n.parent } func (n *Scalar) value() {} func (n *Array) value() {} func (n *Map) value() {} +func (n *IR) value() {} func (n *Array) composite() {} func (n *Map) composite() {} +func (n *IR) composite() {} +func (n *IR) String() string { return d2format.Format(n.ast()) } func (n *Scalar) String() string { return d2format.Format(n.ast()) } func (n *Field) String() string { return d2format.Format(n.ast()) } func (n *Edge) String() string { return d2format.Format(n.ast()) } func (n *Array) String() string { return d2format.Format(n.ast()) } func (n *Map) String() string { return d2format.Format(n.ast()) } +type IR struct { + parent Node + + AST *d2ast.Map `json:"ast"` + Map *Map `json:"base"` +} + +func (ir *IR) Copy(newp Node) Node { + tmp := *ir + ir = &tmp + + ir.parent = newp.(*IR) + ir.Map = ir.Map.Copy(ir).(*Map) + return ir +} + type Scalar struct { parent Node Value d2ast.Scalar `json:"value"` @@ -115,9 +137,9 @@ func (m *Map) Copy(newp Node) Node { } // Root reports whether the Map is the root of the D2 tree. -// The root map has no parent. func (m *Map) Root() bool { - return m.parent == nil + _, ok := m.parent.(*IR) + return ok } type Field struct { @@ -222,16 +244,16 @@ func (eid *EdgeID) resolveUnderscores(m *Map) (*EdgeID, *Map, error) { if eid.SrcPath[0] == "_" { eid.SrcPath = eid.SrcPath[1:] } else { - mf := parentField(m) + mf := ParentField(m) eid.SrcPath = append([]string{mf.Name}, eid.SrcPath...) } if eid.DstPath[0] == "_" { eid.DstPath = eid.DstPath[1:] } else { - mf := parentField(m) + mf := ParentField(m) eid.DstPath = append([]string{mf.Name}, eid.DstPath...) } - m = parentMap(m) + m = ParentMap(m) if m == nil { return nil, nil, errors.New("invalid underscore") } @@ -327,12 +349,29 @@ type RefContext struct { Key *d2ast.Key Edge *d2ast.Edge Scope *d2ast.Map - - // UnresolvedScopeMap is prior to interpreting _ - UnresolvedScopeMap *Map } -func (rc RefContext) EdgeIndex() int { +// UnresolvedScopeMap is scope prior to interpreting _ +// It does this by finding the referenced *Map of rc.Scope +func (rc *RefContext) UnresolvedScopeMap(m *Map) *Map { + for { + fm := ParentField(m) + if fm == nil { + return m + } + for _, ref := range fm.References { + if ref.KeyPath != ref.Context.Key.Key { + continue + } + if ref.Context.Key.Value.Unbox() == rc.Scope { + return m + } + } + m = ParentMap(m) + } +} + +func (rc *RefContext) EdgeIndex() int { for i, e := range rc.Key.Edges { if e == rc.Edge { return i @@ -379,7 +418,7 @@ func (m *Map) EdgeCountRecursive() int { func (m *Map) GetField(ida []string) *Field { for len(ida) > 0 && ida[0] == "_" { - m = parentMap(m) + m = ParentMap(m) if m == nil { return nil } @@ -415,7 +454,7 @@ func (m *Map) getField(ida []string) *Field { func (m *Map) EnsureField(ida []string) (*Field, error) { for len(ida) > 0 && ida[0] == "_" { - m = parentMap(m) + m = ParentMap(m) if m == nil { return nil, errors.New("invalid underscore") } @@ -469,7 +508,7 @@ func (m *Map) ensureField(ida []string) (*Field, error) { return f.Composite.(*Map).ensureField(rest) } -func (m *Map) Delete(ida []string) bool { +func (m *Map) DeleteField(ida []string) bool { if len(ida) == 0 { return false } @@ -486,7 +525,7 @@ func (m *Map) Delete(ida []string) bool { return true } if f_m, ok := f.Composite.(*Map); ok { - return f_m.Delete(rest) + return f_m.DeleteField(rest) } } return false @@ -554,6 +593,10 @@ func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { return e, nil } +func (ir *IR) ast() d2ast.Node { + return ir.Map.ast() +} + func (s *Scalar) ast() d2ast.Node { return s.Value } @@ -619,7 +662,7 @@ func (m *Map) ast() d2ast.Node { return nil } astMap := &d2ast.Map{} - if m.parent == nil { + if m.Root() { astMap.Range = d2ast.MakeRange(",0:0:0-1:0:0") } else { astMap.Range = d2ast.MakeRange(",1:0:0-2:0:0") @@ -661,7 +704,33 @@ func (m *Map) appendEdgeReferences(e *Edge, refctx *RefContext) { m.appendFieldReferences(0, refctx.Edge.Dst, refctx) } -func parentMap(n Node) *Map { +func ToMap(n Node) *Map { + switch n := n.(type) { + case *Map: + return n + case *IR: + return n.Map + case *Field: + return ToMap(n.Composite) + case *Edge: + return n.Map + default: + return nil + } +} + +func ToScalar(n Node) *Scalar { + switch n := n.(type) { + case *Field: + return n.Primary + case *Edge: + return n.Primary + default: + return nil + } +} + +func ParentMap(n Node) *Map { for n.Parent() != nil { n = n.Parent() if n_m, ok := n.(*Map); ok { @@ -671,7 +740,7 @@ func parentMap(n Node) *Map { return nil } -func parentField(n Node) *Field { +func ParentField(n Node) *Field { for n.Parent() != nil { n = n.Parent() if n_f, ok := n.(*Field); ok { diff --git a/testdata/d2ir/TestCompile/edge/edge.exp.json b/testdata/d2ir/TestCompile/edge/edge.exp.json deleted file mode 100644 index 67dbe62d8..000000000 --- a/testdata/d2ir/TestCompile/edge/edge.exp.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "fields": [ - { - "name": "x" - }, - { - "name": "y" - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "y" - ], - "dst_arrow": true, - "index": 0 - } - } - ] -} diff --git a/testdata/d2ir/TestCompile/edge/nested.exp.json b/testdata/d2ir/TestCompile/edge/nested.exp.json index 8f8b60261..171f32700 100644 --- a/testdata/d2ir/TestCompile/edge/nested.exp.json +++ b/testdata/d2ir/TestCompile/edge/nested.exp.json @@ -1,43 +1,118 @@ { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y" - } - ], - "edges": null + "ast": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } } - }, - { - "name": "z", - "composite": { - "fields": [ - { - "name": "p" - } - ], - "edges": null + ] + }, + "base": { + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y" + } + ], + "edges": null + } + }, + { + "name": "z", + "composite": { + "fields": [ + { + "name": "p" + } + ], + "edges": null + } } - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x", - "y" - ], - "src_arrow": false, - "dst_path": [ - "z", - "p" - ], - "dst_arrow": true, - "index": 0 + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x", + "y" + ], + "src_arrow": false, + "dst_path": [ + "z", + "p" + ], + "dst_arrow": true, + "index": 0 + } } - } - ] + ] + } } diff --git a/testdata/d2ir/TestCompile/edge/root.exp.json b/testdata/d2ir/TestCompile/edge/root.exp.json index 67dbe62d8..110559953 100644 --- a/testdata/d2ir/TestCompile/edge/root.exp.json +++ b/testdata/d2ir/TestCompile/edge/root.exp.json @@ -1,25 +1,78 @@ { - "fields": [ - { - "name": "x" - }, - { - "name": "y" - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "y" - ], - "dst_arrow": true, - "index": 0 + "ast": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } } - } - ] + ] + }, + "base": { + "fields": [ + { + "name": "x" + }, + { + "name": "y" + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + } + } + ] + } } diff --git a/testdata/d2ir/TestCompile/edge/underscore.exp.json b/testdata/d2ir/TestCompile/edge/underscore.exp.json index d4a50ab64..a1076d021 100644 --- a/testdata/d2ir/TestCompile/edge/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edge/underscore.exp.json @@ -1,34 +1,127 @@ { - "fields": [ - { - "name": "p", - "composite": { - "fields": [ - { - "name": "z" + "ast": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:15:15", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/edge/underscore.d2,0:3:3-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } } - ], - "edges": null + } } - }, - { - "name": "x" - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "p", - "z" - ], - "dst_arrow": true, - "index": 0 + ] + }, + "base": { + "fields": [ + { + "name": "p", + "composite": { + "fields": [ + { + "name": "z" + } + ], + "edges": null + } + }, + { + "name": "x" } - } - ] + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "p", + "z" + ], + "dst_arrow": true, + "index": 0 + } + } + ] + } } diff --git a/testdata/d2ir/TestCompile/field/array.exp.json b/testdata/d2ir/TestCompile/field/array.exp.json index 4f45a4827..cd5a6697e 100644 --- a/testdata/d2ir/TestCompile/field/array.exp.json +++ b/testdata/d2ir/TestCompile/field/array.exp.json @@ -1,40 +1,104 @@ { - "fields": [ - { - "name": "x", - "composite": { - "values": [ - { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:4:4-0:5:5", - "raw": "1", - "value": "1" - } + "ast": { + "range": "TestCompile/field/array.d2,0:0:0-0:12:12", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/array.d2,0:0:0-0:12:12", + "key": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] }, - { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:6:6-0:7:7", - "raw": "2", - "value": "2" - } - }, - { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:8:8-0:9:9", - "raw": "3", - "value": "3" - } - }, - { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/array.d2,0:10:10-0:11:11", - "raw": "4", - "value": "4" + "primary": {}, + "value": { + "array": { + "range": "TestCompile/field/array.d2,0:3:3-0:11:11", + "nodes": [ + { + "number": { + "range": "TestCompile/field/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" + } + } + ] } } - ] + } } - } - ], - "edges": null + ] + }, + "base": { + "fields": [ + { + "name": "x", + "composite": { + "values": [ + { + "value": { + "range": "TestCompile/field/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "value": { + "range": "TestCompile/field/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "value": { + "range": "TestCompile/field/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "value": { + "range": "TestCompile/field/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" + } + } + ] + } + } + ], + "edges": null + } } diff --git a/testdata/d2ir/TestCompile/field/label.exp.json b/testdata/d2ir/TestCompile/field/label.exp.json index 9378defd0..86d9d7079 100644 --- a/testdata/d2ir/TestCompile/field/label.exp.json +++ b/testdata/d2ir/TestCompile/field/label.exp.json @@ -1,19 +1,59 @@ { - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" + "ast": { + "range": "TestCompile/field/label.d2,0:0:0-0:6:6", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/label.d2,0:0:0-0:6:6", + "key": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] } - ] + } } } - } - ], - "edges": null + ] + }, + "base": { + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "TestCompile/field/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null + } } diff --git a/testdata/d2ir/TestCompile/field/nested.exp.json b/testdata/d2ir/TestCompile/field/nested.exp.json index 638232665..3c77060e2 100644 --- a/testdata/d2ir/TestCompile/field/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/nested.exp.json @@ -1,27 +1,78 @@ { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] + "ast": { + "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] } } - ], - "edges": null + } } - } - ], - "edges": null + ] + }, + "base": { + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + } + ], + "edges": null + } + } + ], + "edges": null + } } diff --git a/testdata/d2ir/TestCompile/field/primary/nested.exp.json b/testdata/d2ir/TestCompile/field/primary/nested.exp.json index 79063ae09..870609c5d 100644 --- a/testdata/d2ir/TestCompile/field/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/nested.exp.json @@ -1,35 +1,115 @@ { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs" + "ast": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } - ], - "edges": null + }, + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] } } - ], - "edges": null + } } - } - ], - "edges": null + ] + }, + "base": { + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null + } + } + ], + "edges": null + } } diff --git a/testdata/d2ir/TestCompile/field/primary/root.exp.json b/testdata/d2ir/TestCompile/field/primary/root.exp.json index cd2bb026c..69c46b633 100644 --- a/testdata/d2ir/TestCompile/field/primary/root.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/root.exp.json @@ -1,27 +1,96 @@ { - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "d2/testdata/d2ir/TestCompile/field/primary/root.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" + "ast": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:15:15", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/root.d2,0:7:7-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs" } - ], - "edges": null + } } - } - ], - "edges": null + ] + }, + "base": { + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "TestCompile/field/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs" + } + ], + "edges": null + } + } + ], + "edges": null + } } diff --git a/testdata/d2ir/TestCompile/field/root.exp.json b/testdata/d2ir/TestCompile/field/root.exp.json index 2dcf9ab44..c4ef7e3f4 100644 --- a/testdata/d2ir/TestCompile/field/root.exp.json +++ b/testdata/d2ir/TestCompile/field/root.exp.json @@ -1,8 +1,38 @@ { - "fields": [ - { - "name": "x" - } - ], - "edges": null + "ast": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "key": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + }, + "base": { + "fields": [ + { + "name": "x" + } + ], + "edges": null + } } From 25ea89fea35aae7dcf0b1512754cdb26e535736f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 17 Jan 2023 17:47:47 -0800 Subject: [PATCH 18/60] d2ir: IR Root wip --- d2ir/d2ir.go | 53 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 80297328b..66a566acd 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -386,7 +386,8 @@ func (m *Map) FieldCountRecursive() int { } acc := len(m.Fields) for _, f := range m.Fields { - if f_m, ok := f.Composite.(*Map); ok { + f_m := ToMap(f) + if f_m != nil { acc += f_m.FieldCountRecursive() } } @@ -404,7 +405,8 @@ func (m *Map) EdgeCountRecursive() int { } acc := len(m.Edges) for _, f := range m.Fields { - if f_m, ok := f.Composite.(*Map); ok { + f_m := ToMap(f) + if f_m != nil { acc += f_m.EdgeCountRecursive() } } @@ -445,7 +447,8 @@ func (m *Map) getField(ida []string) *Field { if len(rest) == 0 { return f } - if f_m, ok := f.Composite.(*Map); ok { + f_m := ToMap(f) + if f_m != nil { return f_m.getField(rest) } } @@ -482,16 +485,17 @@ func (m *Map) ensureField(ida []string) (*Field, error) { if len(rest) == 0 { return f, nil } - switch fc := f.Composite.(type) { - case *Map: - return fc.ensureField(rest) - case *Array: + if _, ok := f.Composite.(*Array); ok { return nil, errors.New("cannot index into array") } - f.Composite = &Map{ - parent: f, + f_m := ToMap(f) + if f_m == nil { + f_m = &Map{ + parent: f, + } + f.Composite = f_m } - return f.Composite.(*Map).ensureField(rest) + return f_m.ensureField(rest) } f := &Field{ @@ -502,10 +506,11 @@ func (m *Map) ensureField(ida []string) (*Field, error) { if len(rest) == 0 { return f, nil } - f.Composite = &Map{ + f_m := &Map{ parent: f, } - return f.Composite.(*Map).ensureField(rest) + f.Composite = f_m + return f_m.ensureField(rest) } func (m *Map) DeleteField(ida []string) bool { @@ -524,7 +529,8 @@ func (m *Map) DeleteField(ida []string) bool { copy(m.Fields[i:], m.Fields[i+1:]) return true } - if f_m, ok := f.Composite.(*Map); ok { + f_m := ToMap(f) + if f_m != nil { return f_m.DeleteField(rest) } } @@ -542,7 +548,8 @@ func (m *Map) GetEdges(eid *EdgeID) []*Edge { if f == nil { return nil } - if f_m, ok := f.Composite.(*Map); ok { + f_m := ToMap(f) + if f_m != nil { return f_m.GetEdges(eid) } return nil @@ -568,16 +575,17 @@ func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { if err != nil { return nil, err } - switch fc := f.Composite.(type) { - case *Map: - return fc.EnsureEdge(eid) - case *Array: + if _, ok := f.Composite.(*Array); ok { return nil, errors.New("cannot index into array") } - f.Composite = &Map{ - parent: f, + f_m := ToMap(f) + if f_m == nil { + f_m = &Map{ + parent: f, + } + f.Composite = f_m } - return f.Composite.(*Map).EnsureEdge(eid) + return f_m.EnsureEdge(eid) } eid.Index = nil @@ -691,7 +699,8 @@ func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext if i+1 == len(kp.Path) { return } - if f_m, ok := f.Composite.(*Map); ok { + f_m := ToMap(f) + if f_m != nil { f_m.appendFieldReferences(i+1, kp, refctx) } } From 5741e0a4f9cd03c67a8b7d950bf491f08f872a7d Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 17 Jan 2023 21:28:33 -0800 Subject: [PATCH 19/60] d2ir: IR Root wip --- d2ir/compile.go | 82 ++++---- d2ir/d2ir.go | 7 +- .../d2ir/TestCompile/edge/nested.exp.json | 181 +++++++++++++++++- testdata/d2ir/TestCompile/edge/root.exp.json | 71 ++++++- .../d2ir/TestCompile/edge/underscore.exp.json | 71 ++++++- .../d2ir/TestCompile/field/array.exp.json | 33 +++- .../d2ir/TestCompile/field/label.exp.json | 33 +++- .../d2ir/TestCompile/field/nested.exp.json | 88 ++++++++- .../TestCompile/field/primary/nested.exp.json | 121 +++++++++++- .../TestCompile/field/primary/root.exp.json | 66 ++++++- testdata/d2ir/TestCompile/field/root.exp.json | 33 +++- 11 files changed, 729 insertions(+), 57 deletions(-) diff --git a/d2ir/compile.go b/d2ir/compile.go index ba3744d3f..fa84c49f6 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -43,18 +43,22 @@ func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { for _, n := range ast.Nodes { switch { case n.MapKey != nil: - c.compileKey(dst, n.MapKey) + c.compileKey(dst, &RefContext{ + Key: n.MapKey, + Scope: ast, + }) case n.Substitution != nil: panic("TODO") } } } -func (c *compiler) compileKey(dst *Map, k *d2ast.Key) { - if len(k.Edges) == 0 { - c.compileField(dst, k) +func (c *compiler) compileKey(dst *Map, refctx *RefContext) { + if len(refctx.Key.Edges) == 0 { + c.compileField(dst, refctx.Key) + dst.appendFieldReferences(0, refctx.Key.Key, refctx) } else { - c.compileEdges(dst, k) + c.compileEdges(dst, refctx) } } @@ -78,15 +82,14 @@ func (c *compiler) compileField(dst *Map, k *d2ast.Key) { c.compileArray(a, k.Value.Array) f.Composite = a } else if k.Value.Map != nil { - if f_m, ok := f.Composite.(*Map); ok { - c.compileMap(f_m, k.Value.Map) - } else { - m := &Map{ + f_m := ToMap(f) + if f_m == nil { + f_m = &Map{ parent: f, } - c.compileMap(m, k.Value.Map) - f.Composite = m + f.Composite = f_m } + c.compileMap(f_m, k.Value.Map) } else if k.Value.ScalarBox().Unbox() != nil { f.Primary = &Scalar{ parent: f, @@ -95,79 +98,88 @@ func (c *compiler) compileField(dst *Map, k *d2ast.Key) { } } -func (c *compiler) compileEdges(dst *Map, k *d2ast.Key) { - if k.Key != nil && len(k.Key.Path) > 0 { - f, err := dst.EnsureField(d2format.KeyPath(k.Key)) +func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { + if refctx.Key.Key != nil && len(refctx.Key.Key.Path) > 0 { + f, err := dst.EnsureField(d2format.KeyPath(refctx.Key.Key)) if err != nil { - c.errorf(k, err.Error()) + c.errorf(refctx.Key.Key, err.Error()) return } - if f_m, ok := f.Composite.(*Map); ok { - dst = f_m - } else { - m := &Map{ + dst.appendFieldReferences(0, refctx.Key.Key, refctx) + if _, ok := f.Composite.(*Array); ok { + c.errorf(refctx.Key.Key, "cannot index into array") + return + } + f_m := ToMap(f) + if f_m == nil { + f_m = &Map{ parent: f, } - f.Composite = m - dst = m + f.Composite = f_m } + dst = f_m } - eida := NewEdgeIDs(k) + eida := NewEdgeIDs(refctx.Key) for i, eid := range eida { var e *Edge if eid.Index != nil { ea := dst.GetEdges(eid) if len(ea) == 0 { - c.errorf(k.Edges[i], "indexed edge does not exist") + c.errorf(refctx.Key.Edges[i], "indexed edge does not exist") continue } e = ea[0] } else { _, err := dst.EnsureField(eid.SrcPath) if err != nil { - c.errorf(k.Edges[i].Src, err.Error()) + c.errorf(refctx.Key.Edges[i].Src, err.Error()) continue } _, err = dst.EnsureField(eid.DstPath) if err != nil { - c.errorf(k.Edges[i].Dst, err.Error()) + c.errorf(refctx.Key.Edges[i].Dst, err.Error()) continue } e, err = dst.EnsureEdge(eid) if err != nil { - c.errorf(k.Edges[i], err.Error()) + c.errorf(refctx.Key.Edges[i], err.Error()) continue } } - if k.EdgeKey != nil { + refctx = refctx.Copy() + refctx.Edge = refctx.Key.Edges[i] + dst.appendEdgeReferences(e, refctx) + + if refctx.Key.EdgeKey != nil { if e.Map == nil { e.Map = &Map{ parent: e, } } tmpk := &d2ast.Key{ - Range: k.EdgeKey.Range, - Key: k.EdgeKey, + Range: refctx.Key.EdgeKey.Range, + Key: refctx.Key.EdgeKey, } c.compileField(e.Map, tmpk) + e.Map.appendFieldReferences(0, refctx.Key.EdgeKey, refctx) } else { - if k.Primary.Unbox() != nil { + if refctx.Key.Primary.Unbox() != nil { e.Primary = &Scalar{ parent: e, - Value: k.Primary.Unbox(), + Value: refctx.Key.Primary.Unbox(), } - } else if k.Value.Map != nil { + } else if refctx.Key.Value.Map != nil { if e.Map == nil { e.Map = &Map{ parent: e, } } - c.compileMap(e.Map, k.Value.Map) - } else if k.Value.Unbox() != nil { - c.errorf(k.Value.Unbox(), "edges cannot be assigned arrays") + c.compileMap(e.Map, refctx.Key.Value.Map) + } else if refctx.Key.Value.Unbox() != nil { + c.errorf(refctx.Key.Value.Unbox(), "edges cannot be assigned arrays") continue } } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 66a566acd..b3983548d 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -338,7 +338,7 @@ func (kr FieldReference) EdgeDest() bool { } func (kr FieldReference) InEdge() bool { - return kr.KeyPath != kr.Context.Key.Key + return kr.Context.Edge != nil } type EdgeReference struct { @@ -351,6 +351,11 @@ type RefContext struct { Scope *d2ast.Map } +func (rc *RefContext) Copy() *RefContext { + tmp := *rc + return &tmp +} + // UnresolvedScopeMap is scope prior to interpreting _ // It does this by finding the referenced *Map of rc.Scope func (rc *RefContext) UnresolvedScopeMap(m *Map) *Map { diff --git a/testdata/d2ir/TestCompile/edge/nested.exp.json b/testdata/d2ir/TestCompile/edge/nested.exp.json index 171f32700..e3ae5deca 100644 --- a/testdata/d2ir/TestCompile/edge/nested.exp.json +++ b/testdata/d2ir/TestCompile/edge/nested.exp.json @@ -79,22 +79,190 @@ "composite": { "fields": [ { - "name": "y" + "name": "y", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + ] } ], "edges": null - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + ] }, { "name": "z", "composite": { "fields": [ { - "name": "p" + "name": "p", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + } + } + ] } ], "edges": null - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + } + } + ] } ], "edges": [ @@ -111,7 +279,10 @@ ], "dst_arrow": true, "index": 0 - } + }, + "references": [ + {} + ] } ] } diff --git a/testdata/d2ir/TestCompile/edge/root.exp.json b/testdata/d2ir/TestCompile/edge/root.exp.json index 110559953..2e9d3451b 100644 --- a/testdata/d2ir/TestCompile/edge/root.exp.json +++ b/testdata/d2ir/TestCompile/edge/root.exp.json @@ -53,10 +53,72 @@ "base": { "fields": [ { - "name": "x" + "name": "x", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + ] }, { - "name": "y" + "name": "y", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + ] } ], "edges": [ @@ -71,7 +133,10 @@ ], "dst_arrow": true, "index": 0 - } + }, + "references": [ + {} + ] } ] } diff --git a/testdata/d2ir/TestCompile/edge/underscore.exp.json b/testdata/d2ir/TestCompile/edge/underscore.exp.json index a1076d021..720a7ec8d 100644 --- a/testdata/d2ir/TestCompile/edge/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edge/underscore.exp.json @@ -97,11 +97,73 @@ "composite": { "fields": [ { - "name": "z" + "name": "z", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + } + } + ] } ], "edges": null - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + "key_path": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + } + } + ] }, { "name": "x" @@ -120,7 +182,10 @@ ], "dst_arrow": true, "index": 0 - } + }, + "references": [ + {} + ] } ] } diff --git a/testdata/d2ir/TestCompile/field/array.exp.json b/testdata/d2ir/TestCompile/field/array.exp.json index cd5a6697e..99972608e 100644 --- a/testdata/d2ir/TestCompile/field/array.exp.json +++ b/testdata/d2ir/TestCompile/field/array.exp.json @@ -96,7 +96,38 @@ } } ] - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + ] } ], "edges": null diff --git a/testdata/d2ir/TestCompile/field/label.exp.json b/testdata/d2ir/TestCompile/field/label.exp.json index 86d9d7079..f7e0f8f67 100644 --- a/testdata/d2ir/TestCompile/field/label.exp.json +++ b/testdata/d2ir/TestCompile/field/label.exp.json @@ -51,7 +51,38 @@ } ] } - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + ] } ], "edges": null diff --git a/testdata/d2ir/TestCompile/field/nested.exp.json b/testdata/d2ir/TestCompile/field/nested.exp.json index 3c77060e2..68cced08d 100644 --- a/testdata/d2ir/TestCompile/field/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/nested.exp.json @@ -66,11 +66,95 @@ } ] } - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + ] } ], "edges": null - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + ] } ], "edges": null diff --git a/testdata/d2ir/TestCompile/field/primary/nested.exp.json b/testdata/d2ir/TestCompile/field/primary/nested.exp.json index 870609c5d..c3237d7d9 100644 --- a/testdata/d2ir/TestCompile/field/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/nested.exp.json @@ -99,15 +99,130 @@ "composite": { "fields": [ { - "name": "pqrs" + "name": "pqrs", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + } + } + ] } ], "edges": null - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + ] } ], "edges": null - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + } + } + ] } ], "edges": null diff --git a/testdata/d2ir/TestCompile/field/primary/root.exp.json b/testdata/d2ir/TestCompile/field/primary/root.exp.json index 69c46b633..86a8ee87a 100644 --- a/testdata/d2ir/TestCompile/field/primary/root.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/root.exp.json @@ -84,11 +84,73 @@ "composite": { "fields": [ { - "name": "pqrs" + "name": "pqrs", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + } + } + ] } ], "edges": null - } + }, + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + ] } ], "edges": null diff --git a/testdata/d2ir/TestCompile/field/root.exp.json b/testdata/d2ir/TestCompile/field/root.exp.json index c4ef7e3f4..bed994d89 100644 --- a/testdata/d2ir/TestCompile/field/root.exp.json +++ b/testdata/d2ir/TestCompile/field/root.exp.json @@ -30,7 +30,38 @@ "base": { "fields": [ { - "name": "x" + "name": "x", + "references": [ + { + "string": { + "unquoted_string": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + "key_path": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + } + } + ] } ], "edges": null From 33ae53dc7525869cb845acb86687a9c5de9df528 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 17 Jan 2023 21:30:28 -0800 Subject: [PATCH 20/60] d2ir: IR Root wip --- d2ir/d2ir.go | 10 +- .../d2ir/TestCompile/edge/nested.exp.json | 638 +++++++++++++++++- testdata/d2ir/TestCompile/edge/root.exp.json | 252 ++++++- .../d2ir/TestCompile/edge/underscore.exp.json | 300 +++++++- .../d2ir/TestCompile/field/array.exp.json | 58 ++ .../d2ir/TestCompile/field/label.exp.json | 34 + .../d2ir/TestCompile/field/nested.exp.json | 90 +++ .../TestCompile/field/primary/nested.exp.json | 172 +++++ .../TestCompile/field/primary/root.exp.json | 87 +++ testdata/d2ir/TestCompile/field/root.exp.json | 24 + 10 files changed, 1657 insertions(+), 8 deletions(-) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index b3983548d..2b73eae3d 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -321,7 +321,7 @@ type FieldReference struct { String *d2ast.StringBox `json:"string"` KeyPath *d2ast.KeyPath `json:"key_path"` - Context *RefContext `json:"-"` + Context *RefContext `json:"context"` } func (kr FieldReference) KeyPathIndex() int { @@ -342,13 +342,13 @@ func (kr FieldReference) InEdge() bool { } type EdgeReference struct { - Context *RefContext `json:"-"` + Context *RefContext `json:"context"` } type RefContext struct { - Key *d2ast.Key - Edge *d2ast.Edge - Scope *d2ast.Map + Key *d2ast.Key `json:"key"` + Edge *d2ast.Edge `json:"edge"` + Scope *d2ast.Map `json:"-"` } func (rc *RefContext) Copy() *RefContext { diff --git a/testdata/d2ir/TestCompile/edge/nested.exp.json b/testdata/d2ir/TestCompile/edge/nested.exp.json index e3ae5deca..bad3e6fa4 100644 --- a/testdata/d2ir/TestCompile/edge/nested.exp.json +++ b/testdata/d2ir/TestCompile/edge/nested.exp.json @@ -119,6 +119,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -165,6 +292,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -214,6 +468,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -260,6 +641,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -281,7 +789,135 @@ "index": 0 }, "references": [ - {} + { + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } ] } ] diff --git a/testdata/d2ir/TestCompile/edge/root.exp.json b/testdata/d2ir/TestCompile/edge/root.exp.json index 2e9d3451b..c38220c0b 100644 --- a/testdata/d2ir/TestCompile/edge/root.exp.json +++ b/testdata/d2ir/TestCompile/edge/root.exp.json @@ -82,6 +82,89 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -116,6 +199,89 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -135,7 +301,91 @@ "index": 0 }, "references": [ - {} + { + "context": { + "key": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } ] } ] diff --git a/testdata/d2ir/TestCompile/edge/underscore.exp.json b/testdata/d2ir/TestCompile/edge/underscore.exp.json index 720a7ec8d..fc8d86fea 100644 --- a/testdata/d2ir/TestCompile/edge/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edge/underscore.exp.json @@ -126,6 +126,111 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -161,6 +266,93 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/edge/underscore.d2,0:3:3-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] @@ -184,7 +376,113 @@ "index": 0 }, "references": [ - {} + { + "context": { + "key": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } ] } ] diff --git a/testdata/d2ir/TestCompile/field/array.exp.json b/testdata/d2ir/TestCompile/field/array.exp.json index 99972608e..68ffe36cc 100644 --- a/testdata/d2ir/TestCompile/field/array.exp.json +++ b/testdata/d2ir/TestCompile/field/array.exp.json @@ -125,6 +125,64 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/array.d2,0:0:0-0:12:12", + "key": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/field/array.d2,0:3:3-0:11:11", + "nodes": [ + { + "number": { + "range": "TestCompile/field/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" + } + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/label.exp.json b/testdata/d2ir/TestCompile/field/label.exp.json index f7e0f8f67..305f3aef1 100644 --- a/testdata/d2ir/TestCompile/field/label.exp.json +++ b/testdata/d2ir/TestCompile/field/label.exp.json @@ -80,6 +80,40 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/label.d2,0:0:0-0:6:6", + "key": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/nested.exp.json b/testdata/d2ir/TestCompile/field/nested.exp.json index 68cced08d..5cddad1b9 100644 --- a/testdata/d2ir/TestCompile/field/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/nested.exp.json @@ -106,6 +106,51 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } } ] @@ -152,6 +197,51 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/primary/nested.exp.json b/testdata/d2ir/TestCompile/field/primary/nested.exp.json index c3237d7d9..ebd8af9a3 100644 --- a/testdata/d2ir/TestCompile/field/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/nested.exp.json @@ -128,6 +128,30 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null } } ] @@ -174,6 +198,80 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] @@ -220,6 +318,80 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/primary/root.exp.json b/testdata/d2ir/TestCompile/field/primary/root.exp.json index 86a8ee87a..595bf1ea9 100644 --- a/testdata/d2ir/TestCompile/field/primary/root.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/root.exp.json @@ -113,6 +113,30 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null } } ] @@ -148,6 +172,69 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/root.d2,0:7:7-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/root.exp.json b/testdata/d2ir/TestCompile/field/root.exp.json index bed994d89..01ab1fa88 100644 --- a/testdata/d2ir/TestCompile/field/root.exp.json +++ b/testdata/d2ir/TestCompile/field/root.exp.json @@ -59,6 +59,30 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "key": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null } } ] From 473d5ba5820159ed229d52df5412d954fadc9398 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 02:06:44 -0800 Subject: [PATCH 21/60] d2ir: IR Root wip --- d2ir/compile.go | 87 +++--- d2ir/compile_test.go | 122 +++++--- d2ir/d2ir.go | 153 ++++++---- d2parser/parse.go | 9 + .../{edge => edges}/nested.exp.json | 256 ++++++++-------- .../TestCompile/{edge => edges}/root.exp.json | 120 ++++---- .../{edge => edges}/underscore.exp.json | 285 +++++++++++++----- .../{field => fields}/array.exp.json | 62 ++-- .../{field => fields}/label.exp.json | 40 ++- .../{field => fields}/nested.exp.json | 78 +++-- .../{field => fields}/primary/nested.exp.json | 128 ++++---- .../{field => fields}/primary/root.exp.json | 82 +++-- .../{field => fields}/root.exp.json | 34 +-- 13 files changed, 813 insertions(+), 643 deletions(-) rename testdata/d2ir/TestCompile/{edge => edges}/nested.exp.json (74%) rename testdata/d2ir/TestCompile/{edge => edges}/root.exp.json (71%) rename testdata/d2ir/TestCompile/{edge => edges}/underscore.exp.json (58%) rename testdata/d2ir/TestCompile/{field => fields}/array.exp.json (67%) rename testdata/d2ir/TestCompile/{field => fields}/label.exp.json (67%) rename testdata/d2ir/TestCompile/{field => fields}/nested.exp.json (71%) rename testdata/d2ir/TestCompile/{field => fields}/primary/nested.exp.json (69%) rename testdata/d2ir/TestCompile/{field => fields}/primary/root.exp.json (66%) rename testdata/d2ir/TestCompile/{field => fields}/root.exp.json (64%) diff --git a/d2ir/compile.go b/d2ir/compile.go index fa84c49f6..3944d1901 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -1,10 +1,7 @@ package d2ir import ( - "fmt" - "oss.terrastruct.com/d2/d2ast" - "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2parser" ) @@ -13,30 +10,25 @@ type compiler struct { } func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { - f = "%v: " + f - v = append([]interface{}{n.GetRange()}, v...) - c.err.Errors = append(c.err.Errors, d2ast.Error{ - Range: n.GetRange(), - Message: fmt.Sprintf(f, v...), - }) + c.err.Errors = append(c.err.Errors, d2parser.Errorf(n, f, v...).(d2ast.Error)) } -func Compile(ast *d2ast.Map) (*IR, error) { - ir := &IR{ +func Compile(ast *d2ast.Map) (*Layer, error) { + l := &Layer{ AST: ast, Map: &Map{}, } c := &compiler{} - c.compile(ir) + c.compile(l) if !c.err.Empty() { return nil, c.err } - return ir, nil + return l, nil } -func (c *compiler) compile(ir *IR) { - c.compileMap(ir.Map, ir.AST) +func (c *compiler) compile(l *Layer) { + c.compileMap(l.Map, l.AST) } func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { @@ -55,33 +47,32 @@ func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { func (c *compiler) compileKey(dst *Map, refctx *RefContext) { if len(refctx.Key.Edges) == 0 { - c.compileField(dst, refctx.Key) - dst.appendFieldReferences(0, refctx.Key.Key, refctx) + c.compileField(dst, refctx.Key.Key, refctx) } else { c.compileEdges(dst, refctx) } } -func (c *compiler) compileField(dst *Map, k *d2ast.Key) { - f, err := dst.EnsureField(d2format.KeyPath(k.Key)) +func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) { + f, err := dst.EnsureField(kp, refctx) if err != nil { - c.errorf(k, err.Error()) + c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) return } - if k.Primary.Unbox() != nil { + if refctx.Key.Primary.Unbox() != nil { f.Primary = &Scalar{ parent: f, - Value: k.Primary.Unbox(), + Value: refctx.Key.Primary.Unbox(), } } - if k.Value.Array != nil { + if refctx.Key.Value.Array != nil { a := &Array{ parent: f, } - c.compileArray(a, k.Value.Array) + c.compileArray(a, refctx.Key.Value.Array) f.Composite = a - } else if k.Value.Map != nil { + } else if refctx.Key.Value.Map != nil { f_m := ToMap(f) if f_m == nil { f_m = &Map{ @@ -89,23 +80,22 @@ func (c *compiler) compileField(dst *Map, k *d2ast.Key) { } f.Composite = f_m } - c.compileMap(f_m, k.Value.Map) - } else if k.Value.ScalarBox().Unbox() != nil { + c.compileMap(f_m, refctx.Key.Value.Map) + } else if refctx.Key.Value.ScalarBox().Unbox() != nil { f.Primary = &Scalar{ parent: f, - Value: k.Value.ScalarBox().Unbox(), + Value: refctx.Key.Value.ScalarBox().Unbox(), } } } func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { - if refctx.Key.Key != nil && len(refctx.Key.Key.Path) > 0 { - f, err := dst.EnsureField(d2format.KeyPath(refctx.Key.Key)) + if refctx.Key.Key != nil { + f, err := dst.EnsureField(refctx.Key.Key, refctx) if err != nil { - c.errorf(refctx.Key.Key, err.Error()) + c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) return } - dst.appendFieldReferences(0, refctx.Key.Key, refctx) if _, ok := f.Composite.(*Array); ok { c.errorf(refctx.Key.Key, "cannot index into array") return @@ -122,49 +112,48 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { eida := NewEdgeIDs(refctx.Key) for i, eid := range eida { + refctx = refctx.Copy() + refctx.Edge = refctx.Key.Edges[i] + var e *Edge if eid.Index != nil { ea := dst.GetEdges(eid) if len(ea) == 0 { - c.errorf(refctx.Key.Edges[i], "indexed edge does not exist") + c.errorf(refctx.Edge, "indexed edge does not exist") continue } e = ea[0] + e.References = append(e.References, EdgeReference{ + Context: refctx, + }) + dst.appendFieldReferences(0, refctx.Edge.Src, refctx) + dst.appendFieldReferences(0, refctx.Edge.Dst, refctx) } else { - _, err := dst.EnsureField(eid.SrcPath) + _, err := dst.EnsureField(refctx.Edge.Src, refctx) if err != nil { - c.errorf(refctx.Key.Edges[i].Src, err.Error()) + c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) continue } - _, err = dst.EnsureField(eid.DstPath) + _, err = dst.EnsureField(refctx.Edge.Dst, refctx) if err != nil { - c.errorf(refctx.Key.Edges[i].Dst, err.Error()) + c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) continue } - e, err = dst.EnsureEdge(eid) + e, err = dst.CreateEdge(eid, refctx) if err != nil { - c.errorf(refctx.Key.Edges[i], err.Error()) + c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) continue } } - refctx = refctx.Copy() - refctx.Edge = refctx.Key.Edges[i] - dst.appendEdgeReferences(e, refctx) - if refctx.Key.EdgeKey != nil { if e.Map == nil { e.Map = &Map{ parent: e, } } - tmpk := &d2ast.Key{ - Range: refctx.Key.EdgeKey.Range, - Key: refctx.Key.EdgeKey, - } - c.compileField(e.Map, tmpk) - e.Map.appendFieldReferences(0, refctx.Key.EdgeKey, refctx) + c.compileField(e.Map, refctx.Key.EdgeKey, refctx) } else { if refctx.Key.Primary.Unbox() != nil { e.Primary = &Scalar{ diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 043525cc3..4a9672410 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -18,8 +18,9 @@ import ( func TestCompile(t *testing.T) { t.Parallel() - t.Run("field", testCompileField) - t.Run("edge", testCompileEdge) + t.Run("fields", testCompileFields) + t.Run("edges", testCompileEdges) + t.Run("layer", testCompileLayers) } type testCase struct { @@ -37,23 +38,23 @@ func runa(t *testing.T, tca []testCase) { } } -func compile(t testing.TB, text string) (*d2ir.IR, error) { +func compile(t testing.TB, text string) (*d2ir.Layer, error) { t.Helper() d2Path := fmt.Sprintf("%v.d2", t.Name()) ast, err := d2parser.Parse(d2Path, strings.NewReader(text), nil) assert.Success(t, err) - ir, err := d2ir.Compile(ast) + l, err := d2ir.Compile(ast) if err != nil { return nil, err } - err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), ir) + err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), l) if err != nil { return nil, err } - return ir ,nil + return l, nil } func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { @@ -67,7 +68,7 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa var f *d2ir.Field if len(ida) > 0 { - f = m.GetField(ida) + f = m.GetField(ida...) if f == nil { t.Fatalf("expected field %v in map %s", ida, m) } @@ -145,49 +146,49 @@ func makeScalar(v interface{}) *d2ir.Scalar { return s } -func testCompileField(t *testing.T) { +func testCompileFields(t *testing.T) { t.Parallel() t.Run("primary", testCompileFieldPrimary) tca := []testCase{ { name: "root", run: func(t testing.TB) { - ir, err := compile(t, `x`) + l, err := compile(t, `x`) assert.Success(t, err) - assertField(t, ir, 1, 0, nil) + assertField(t, l, 1, 0, nil) - assertField(t, ir, 0, 0, nil, "x") + assertField(t, l, 0, 0, nil, "x") }, }, { name: "label", run: func(t testing.TB) { - ir, err := compile(t, `x: yes`) + l, err := compile(t, `x: yes`) assert.Success(t, err) - assertField(t, ir, 1, 0, nil) + assertField(t, l, 1, 0, nil) - assertField(t, ir, 0, 0, "yes", "x") + assertField(t, l, 0, 0, "yes", "x") }, }, { name: "nested", run: func(t testing.TB) { - ir, err := compile(t, `x.y: yes`) + l, err := compile(t, `x.y: yes`) assert.Success(t, err) - assertField(t, ir, 2, 0, nil) + assertField(t, l, 2, 0, nil) - assertField(t, ir, 1, 0, nil, "x") - assertField(t, ir, 0, 0, "yes", "x", "y") + assertField(t, l, 1, 0, nil, "x") + assertField(t, l, 0, 0, "yes", "x", "y") }, }, { name: "array", run: func(t testing.TB) { - ir, err := compile(t, `x: [1;2;3;4]`) + l, err := compile(t, `x: [1;2;3;4]`) assert.Success(t, err) - assertField(t, ir, 1, 0, nil) + assertField(t, l, 1, 0, nil) - f := assertField(t, ir, 0, 0, nil, "x") + f := assertField(t, l, 0, 0, nil, "x") assert.String(t, `[1; 2; 3; 4]`, f.Composite.String()) }, }, @@ -201,72 +202,97 @@ func testCompileFieldPrimary(t *testing.T) { { name: "root", run: func(t testing.TB) { - ir, err := compile(t, `x: yes { pqrs }`) + l, err := compile(t, `x: yes { pqrs }`) assert.Success(t, err) - assertField(t, ir, 2, 0, nil) + assertField(t, l, 2, 0, nil) - assertField(t, ir, 1, 0, "yes", "x") - assertField(t, ir, 0, 0, nil, "x", "pqrs") + assertField(t, l, 1, 0, "yes", "x") + assertField(t, l, 0, 0, nil, "x", "pqrs") }, }, { name: "nested", run: func(t testing.TB) { - ir, err := compile(t, `x.y: yes { pqrs }`) + l, err := compile(t, `x.y: yes { pqrs }`) assert.Success(t, err) - assertField(t, ir, 3, 0, nil) + assertField(t, l, 3, 0, nil) - assertField(t, ir, 2, 0, nil, "x") - assertField(t, ir, 1, 0, "yes", "x", "y") - assertField(t, ir, 0, 0, nil, "x", "y", "pqrs") + assertField(t, l, 2, 0, nil, "x") + assertField(t, l, 1, 0, "yes", "x", "y") + assertField(t, l, 0, 0, nil, "x", "y", "pqrs") }, }, } runa(t, tca) } -func testCompileEdge(t *testing.T) { +func testCompileEdges(t *testing.T) { t.Parallel() tca := []testCase{ { name: "root", run: func(t testing.TB) { - ir, err := compile(t, `x -> y`) + l, err := compile(t, `x -> y`) assert.Success(t, err) - assertField(t, ir, 2, 1, nil) - assertEdge(t, ir, 0, nil, `(x -> y)[0]`) + assertField(t, l, 2, 1, nil) + assertEdge(t, l, 0, nil, `(x -> y)[0]`) - assertField(t, ir, 0, 0, nil, "x") - assertField(t, ir, 0, 0, nil, "y") + assertField(t, l, 0, 0, nil, "x") + assertField(t, l, 0, 0, nil, "y") }, }, { name: "nested", run: func(t testing.TB) { - ir, err := compile(t, `x.y -> z.p`) + l, err := compile(t, `x.y -> z.p`) assert.Success(t, err) - assertField(t, ir, 4, 1, nil) + assertField(t, l, 4, 1, nil) - assertField(t, ir, 1, 0, nil, "x") - assertField(t, ir, 0, 0, nil, "x", "y") + assertField(t, l, 1, 0, nil, "x") + assertField(t, l, 0, 0, nil, "x", "y") - assertField(t, ir, 1, 0, nil, "z") - assertField(t, ir, 0, 0, nil, "z", "p") + assertField(t, l, 1, 0, nil, "z") + assertField(t, l, 0, 0, nil, "z", "p") - assertEdge(t, ir, 0, nil, "(x.y -> z.p)[0]") + assertEdge(t, l, 0, nil, "(x.y -> z.p)[0]") }, }, { name: "underscore", run: func(t testing.TB) { - ir, err := compile(t, `p: { _.x -> z }`) + l, err := compile(t, `p: { _.x -> z }`) assert.Success(t, err) - assertField(t, ir, 3, 1, nil) + assertField(t, l, 3, 1, nil) - assertField(t, ir, 0, 0, nil, "x") - assertField(t, ir, 1, 0, nil, "p") + assertField(t, l, 0, 0, nil, "x") + assertField(t, l, 1, 0, nil, "p") - assertEdge(t, ir, 0, nil, "(x -> p.z)[0]") + assertEdge(t, l, 0, nil, "(x -> p.z)[0]") + }, + }, + } + runa(t, tca) +} + +func testCompileLayers(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "root", + run: func(t testing.TB) { + l, err := compile(t, `x -> y +layers: { + bingo: { p.q.z } +}`) + assert.Success(t, err) + + assertField(t, l, 5, 1, nil) + assertEdge(t, l, 0, nil, `(x -> y)[0]`) + + assertField(t, l, 0, 0, nil, "x") + assertField(t, l, 0, 0, nil, "y") + + assertField(t, l, 0, 0, nil, "layers", "bingo") }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 2b73eae3d..f4ad3f545 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -1,3 +1,5 @@ +// Package d2ir implements a tree data structure to keep track of the resolved value of D2 +// keys. package d2ir import ( @@ -9,8 +11,11 @@ import ( "oss.terrastruct.com/d2/d2ast" "oss.terrastruct.com/d2/d2format" + "oss.terrastruct.com/d2/d2parser" ) +// Most errors returned by a node should be created with d2parser.Errorf +// to indicate the offending AST node. type Node interface { node() Copy(parent Node) Node @@ -20,7 +25,7 @@ type Node interface { fmt.Stringer } -var _ Node = &IR{} +var _ Node = &Layer{} var _ Node = &Scalar{} var _ Node = &Field{} var _ Node = &Edge{} @@ -45,14 +50,14 @@ type Composite interface { var _ Composite = &Array{} var _ Composite = &Map{} -func (n *IR) node() {} +func (n *Layer) node() {} func (n *Scalar) node() {} func (n *Field) node() {} func (n *Edge) node() {} func (n *Array) node() {} func (n *Map) node() {} -func (n *IR) Parent() Node { return n.parent } +func (n *Layer) Parent() Node { return n.parent } func (n *Scalar) Parent() Node { return n.parent } func (n *Field) Parent() Node { return n.parent } func (n *Edge) Parent() Node { return n.parent } @@ -62,33 +67,33 @@ func (n *Map) Parent() Node { return n.parent } func (n *Scalar) value() {} func (n *Array) value() {} func (n *Map) value() {} -func (n *IR) value() {} +func (n *Layer) value() {} func (n *Array) composite() {} func (n *Map) composite() {} -func (n *IR) composite() {} +func (n *Layer) composite() {} -func (n *IR) String() string { return d2format.Format(n.ast()) } +func (n *Layer) String() string { return d2format.Format(n.ast()) } func (n *Scalar) String() string { return d2format.Format(n.ast()) } func (n *Field) String() string { return d2format.Format(n.ast()) } func (n *Edge) String() string { return d2format.Format(n.ast()) } func (n *Array) String() string { return d2format.Format(n.ast()) } func (n *Map) String() string { return d2format.Format(n.ast()) } -type IR struct { +type Layer struct { parent Node AST *d2ast.Map `json:"ast"` Map *Map `json:"base"` } -func (ir *IR) Copy(newp Node) Node { - tmp := *ir - ir = &tmp +func (l *Layer) Copy(newp Node) Node { + tmp := *l + l = &tmp - ir.parent = newp.(*IR) - ir.Map = ir.Map.Copy(ir).(*Map) - return ir + l.parent = newp.(*Layer) + l.Map = l.Map.Copy(l).(*Map) + return l } type Scalar struct { @@ -138,7 +143,12 @@ func (m *Map) Copy(newp Node) Node { // Root reports whether the Map is the root of the D2 tree. func (m *Map) Root() bool { - _, ok := m.parent.(*IR) + return ParentMap(m) == nil +} + +// Layer reports whether the Map represents the root of a layer. +func (m *Map) Layer() bool { + _, ok := m.parent.(*Layer) return ok } @@ -318,7 +328,7 @@ func (a *Array) Copy(newp Node) Node { } type FieldReference struct { - String *d2ast.StringBox `json:"string"` + String d2ast.String `json:"string"` KeyPath *d2ast.KeyPath `json:"key_path"` Context *RefContext `json:"context"` @@ -326,7 +336,7 @@ type FieldReference struct { func (kr FieldReference) KeyPathIndex() int { for i, sb := range kr.KeyPath.Path { - if sb == kr.String { + if sb.Unbox() == kr.String { return i } } @@ -346,9 +356,9 @@ type EdgeReference struct { } type RefContext struct { - Key *d2ast.Key `json:"key"` + Key *d2ast.Key `json:"key"` Edge *d2ast.Edge `json:"edge"` - Scope *d2ast.Map `json:"-"` + Scope *d2ast.Map `json:"-"` } func (rc *RefContext) Copy() *RefContext { @@ -423,7 +433,7 @@ func (m *Map) EdgeCountRecursive() int { return acc } -func (m *Map) GetField(ida []string) *Field { +func (m *Map) GetField(ida ...string) *Field { for len(ida) > 0 && ida[0] == "_" { m = ParentMap(m) if m == nil { @@ -460,38 +470,51 @@ func (m *Map) getField(ida []string) *Field { return nil } -func (m *Map) EnsureField(ida []string) (*Field, error) { - for len(ida) > 0 && ida[0] == "_" { +func (m *Map) EnsureField(kp *d2ast.KeyPath, refctx *RefContext) (*Field, error) { + i := 0 + for kp.Path[i].Unbox().ScalarString() == "_" { m = ParentMap(m) if m == nil { - return nil, errors.New("invalid underscore") + return nil, d2parser.Errorf(kp.Path[i].Unbox(), "invalid underscore: no parent") } - ida = ida[1:] + if i+1 == len(kp.Path) { + return nil, d2parser.Errorf(kp.Path[i].Unbox(), "field key must contain more than underscores") + } + i++ } - return m.ensureField(ida) + return m.ensureField(i, kp, refctx) } -func (m *Map) ensureField(ida []string) (*Field, error) { - if len(ida) == 0 { - return nil, errors.New("invalid underscore") +func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, error) { + head := kp.Path[i].Unbox().ScalarString() + + if head == "_" { + return nil, d2parser.Errorf(kp, `parent "_" can only be used in the beginning of paths, e.g. "_.x"`) } - s := ida[0] - rest := ida[1:] - - if s == "_" { - return nil, errors.New(`parent "_" can only be used in the beginning of paths, e.g. "_.x"`) + switch head { + case "layers", "scenarios", "steps": + if !m.Layer() { + return nil, d2parser.Errorf(kp, "%s is only allowed at a layer root", head) + } } for _, f := range m.Fields { - if !strings.EqualFold(f.Name, s) { + if !strings.EqualFold(f.Name, head) { continue } - if len(rest) == 0 { + + f.References = append(f.References, FieldReference{ + String: kp.Path[i].Unbox(), + KeyPath: kp, + Context: refctx, + }) + + if i+1 == len(kp.Path) { return f, nil } if _, ok := f.Composite.(*Array); ok { - return nil, errors.New("cannot index into array") + return nil, d2parser.Errorf(kp, "cannot index into array") } f_m := ToMap(f) if f_m == nil { @@ -500,22 +523,27 @@ func (m *Map) ensureField(ida []string) (*Field, error) { } f.Composite = f_m } - return f_m.ensureField(rest) + return f_m.ensureField(i+1, kp, refctx) } f := &Field{ parent: m, - Name: s, + Name: head, + References: []FieldReference{{ + String: kp.Path[i].Unbox(), + KeyPath: kp, + Context: refctx, + }}, } m.Fields = append(m.Fields, f) - if len(rest) == 0 { + if i+1 == len(kp.Path) { return f, nil } f_m := &Map{ parent: f, } f.Composite = f_m - return f_m.ensureField(rest) + return f_m.ensureField(i+1, kp, refctx) } func (m *Map) DeleteField(ida []string) bool { @@ -549,7 +577,7 @@ func (m *Map) GetEdges(eid *EdgeID) []*Edge { } common, eid := eid.trimCommon() if len(common) > 0 { - f := m.GetField(common) + f := m.GetField(common...) if f == nil { return nil } @@ -569,19 +597,22 @@ func (m *Map) GetEdges(eid *EdgeID) []*Edge { return ea } -func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { +func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { eid, m, err := eid.resolveUnderscores(m) if err != nil { - return nil, err + return nil, d2parser.Errorf(refctx.Edge, err.Error()) } common, eid := eid.trimCommon() if len(common) > 0 { - f, err := m.EnsureField(common) + tmp := *refctx.Edge.Src + kp := &tmp + kp.Path = kp.Path[:len(common)] + f, err := m.EnsureField(kp, refctx) if err != nil { return nil, err } if _, ok := f.Composite.(*Array); ok { - return nil, errors.New("cannot index into array") + return nil, d2parser.Errorf(refctx.Edge, "cannot index into array") } f_m := ToMap(f) if f_m == nil { @@ -590,7 +621,7 @@ func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { } f.Composite = f_m } - return f_m.EnsureEdge(eid) + return f_m.CreateEdge(eid, refctx) } eid.Index = nil @@ -600,14 +631,17 @@ func (m *Map) EnsureEdge(eid *EdgeID) (*Edge, error) { e := &Edge{ parent: m, ID: eid, + References: []EdgeReference{{ + Context: refctx, + }}, } m.Edges = append(m.Edges, e) return e, nil } -func (ir *IR) ast() d2ast.Node { - return ir.Map.ast() +func (l *Layer) ast() d2ast.Node { + return l.Map.ast() } func (s *Scalar) ast() d2ast.Node { @@ -691,13 +725,13 @@ func (m *Map) ast() d2ast.Node { func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext) { sb := kp.Path[i] - f := m.GetField([]string{sb.Unbox().ScalarString()}) + f := m.GetField(sb.Unbox().ScalarString()) if f == nil { return } f.References = append(f.References, FieldReference{ - String: sb, + String: sb.Unbox(), KeyPath: kp, Context: refctx, }) @@ -710,19 +744,11 @@ func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext } } -func (m *Map) appendEdgeReferences(e *Edge, refctx *RefContext) { - e.References = append(e.References, EdgeReference{ - Context: refctx, - }) - m.appendFieldReferences(0, refctx.Edge.Src, refctx) - m.appendFieldReferences(0, refctx.Edge.Dst, refctx) -} - func ToMap(n Node) *Map { switch n := n.(type) { case *Map: return n - case *IR: + case *Layer: return n.Map case *Field: return ToMap(n.Composite) @@ -774,3 +800,14 @@ func countUnderscores(p []string) int { } return count } + +func IDA(n Node) (ida []string) { + for { + f := ParentField(n) + if f == nil { + return ida + } + ida = append(ida, f.Name) + n = f + } +} diff --git a/d2parser/parse.go b/d2parser/parse.go index 0e7e5eefc..34d63b43d 100644 --- a/d2parser/parse.go +++ b/d2parser/parse.go @@ -130,6 +130,15 @@ type ParseError struct { Errors []d2ast.Error `json:"errs"` } +func Errorf(n d2ast.Node, f string, v ...interface{}) error { + f = "%v: " + f + v = append([]interface{}{n.GetRange()}, v...) + return d2ast.Error{ + Range: n.GetRange(), + Message: fmt.Sprintf(f, v...), + } +} + func (pe ParseError) Empty() bool { return pe.IOError == nil && len(pe.Errors) == 0 } diff --git a/testdata/d2ir/TestCompile/edge/nested.exp.json b/testdata/d2ir/TestCompile/edges/nested.exp.json similarity index 74% rename from testdata/d2ir/TestCompile/edge/nested.exp.json rename to testdata/d2ir/TestCompile/edges/nested.exp.json index bad3e6fa4..2bf781919 100644 --- a/testdata/d2ir/TestCompile/edge/nested.exp.json +++ b/testdata/d2ir/TestCompile/edges/nested.exp.json @@ -1,19 +1,19 @@ { "ast": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "nodes": [ { "map_key": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "edges": [ { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -24,7 +24,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -37,11 +37,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -52,7 +52,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -83,22 +83,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] }, "key_path": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -109,7 +107,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -122,16 +120,16 @@ }, "context": { "key": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "edges": [ { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -142,7 +140,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -155,11 +153,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -170,7 +168,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -188,13 +186,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -205,7 +203,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -218,11 +216,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -233,7 +231,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -256,22 +254,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -282,7 +278,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -295,16 +291,16 @@ }, "context": { "key": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "edges": [ { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -315,7 +311,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -328,11 +324,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -343,7 +339,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -361,13 +357,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -378,7 +374,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -391,11 +387,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -406,7 +402,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -432,22 +428,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] }, "key_path": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -458,7 +452,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -471,16 +465,16 @@ }, "context": { "key": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "edges": [ { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -491,7 +485,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -504,11 +498,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -519,7 +513,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -537,13 +531,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -554,7 +548,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -567,11 +561,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -582,7 +576,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -605,22 +599,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] }, "key_path": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -631,7 +623,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -644,16 +636,16 @@ }, "context": { "key": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "edges": [ { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -664,7 +656,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -677,11 +669,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -692,7 +684,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -710,13 +702,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -727,7 +719,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -740,11 +732,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -755,7 +747,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -792,16 +784,16 @@ { "context": { "key": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "edges": [ { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -812,7 +804,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -825,11 +817,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -840,7 +832,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", @@ -858,13 +850,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -875,7 +867,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -888,11 +880,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", "value": [ { "string": "z", @@ -903,7 +895,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", "value": [ { "string": "p", diff --git a/testdata/d2ir/TestCompile/edge/root.exp.json b/testdata/d2ir/TestCompile/edges/root.exp.json similarity index 71% rename from testdata/d2ir/TestCompile/edge/root.exp.json rename to testdata/d2ir/TestCompile/edges/root.exp.json index c38220c0b..f8b7f0552 100644 --- a/testdata/d2ir/TestCompile/edge/root.exp.json +++ b/testdata/d2ir/TestCompile/edges/root.exp.json @@ -1,19 +1,19 @@ { "ast": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "nodes": [ { "map_key": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "edges": [ { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -26,11 +26,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -57,22 +57,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -85,16 +83,16 @@ }, "context": { "key": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "edges": [ { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -107,11 +105,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -129,13 +127,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -148,11 +146,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -174,22 +172,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] }, "key_path": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -202,16 +198,16 @@ }, "context": { "key": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "edges": [ { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -224,11 +220,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -246,13 +242,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -265,11 +261,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -304,16 +300,16 @@ { "context": { "key": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "edges": [ { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -326,11 +322,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -348,13 +344,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -367,11 +363,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", diff --git a/testdata/d2ir/TestCompile/edge/underscore.exp.json b/testdata/d2ir/TestCompile/edges/underscore.exp.json similarity index 58% rename from testdata/d2ir/TestCompile/edge/underscore.exp.json rename to testdata/d2ir/TestCompile/edges/underscore.exp.json index fc8d86fea..f248396d9 100644 --- a/testdata/d2ir/TestCompile/edge/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edges/underscore.exp.json @@ -1,16 +1,16 @@ { "ast": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:15:15", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", "nodes": [ { "map_key": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:15:15", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", "key": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", "value": [ { "string": "p", @@ -24,20 +24,20 @@ "primary": {}, "value": { "map": { - "range": "TestCompile/edge/underscore.d2,0:3:3-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", "nodes": [ { "map_key": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "edges": [ { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "src": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", "value": [ { "string": "_", @@ -48,7 +48,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", "value": [ { "string": "x", @@ -61,11 +61,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { "string": "z", @@ -101,22 +101,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] }, "key_path": { - "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { "string": "z", @@ -129,16 +127,16 @@ }, "context": { "key": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "edges": [ { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "src": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", "value": [ { "string": "_", @@ -149,7 +147,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", "value": [ { "string": "x", @@ -162,11 +160,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { "string": "z", @@ -184,13 +182,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "src": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", "value": [ { "string": "_", @@ -201,7 +199,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", "value": [ { "string": "x", @@ -214,11 +212,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { "string": "z", @@ -241,22 +239,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] }, "key_path": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", "value": [ { "string": "p", @@ -269,13 +265,13 @@ }, "context": { "key": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:15:15", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", "key": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", "value": [ { "string": "p", @@ -289,20 +285,20 @@ "primary": {}, "value": { "map": { - "range": "TestCompile/edge/underscore.d2,0:3:3-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", "nodes": [ { "map_key": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "edges": [ { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "src": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", "value": [ { "string": "_", @@ -313,7 +309,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", "value": [ { "string": "x", @@ -326,11 +322,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { "string": "z", @@ -358,7 +354,152 @@ ] }, { - "name": "x" + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] } ], "edges": [ @@ -379,16 +520,16 @@ { "context": { "key": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "edges": [ { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "src": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", "value": [ { "string": "_", @@ -399,7 +540,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", "value": [ { "string": "x", @@ -412,11 +553,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { "string": "z", @@ -434,13 +575,13 @@ "value": {} }, "edge": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "src": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", "value": [ { "string": "_", @@ -451,7 +592,7 @@ }, { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", "value": [ { "string": "x", @@ -464,11 +605,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { "string": "z", diff --git a/testdata/d2ir/TestCompile/field/array.exp.json b/testdata/d2ir/TestCompile/fields/array.exp.json similarity index 67% rename from testdata/d2ir/TestCompile/field/array.exp.json rename to testdata/d2ir/TestCompile/fields/array.exp.json index 68ffe36cc..fa6329969 100644 --- a/testdata/d2ir/TestCompile/field/array.exp.json +++ b/testdata/d2ir/TestCompile/fields/array.exp.json @@ -1,16 +1,16 @@ { "ast": { - "range": "TestCompile/field/array.d2,0:0:0-0:12:12", + "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", "nodes": [ { "map_key": { - "range": "TestCompile/field/array.d2,0:0:0-0:12:12", + "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", "key": { - "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -24,32 +24,32 @@ "primary": {}, "value": { "array": { - "range": "TestCompile/field/array.d2,0:3:3-0:11:11", + "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", "nodes": [ { "number": { - "range": "TestCompile/field/array.d2,0:4:4-0:5:5", + "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", "raw": "1", "value": "1" } }, { "number": { - "range": "TestCompile/field/array.d2,0:6:6-0:7:7", + "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", "raw": "2", "value": "2" } }, { "number": { - "range": "TestCompile/field/array.d2,0:8:8-0:9:9", + "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", "raw": "3", "value": "3" } }, { "number": { - "range": "TestCompile/field/array.d2,0:10:10-0:11:11", + "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", "raw": "4", "value": "4" } @@ -69,28 +69,28 @@ "values": [ { "value": { - "range": "TestCompile/field/array.d2,0:4:4-0:5:5", + "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", "raw": "1", "value": "1" } }, { "value": { - "range": "TestCompile/field/array.d2,0:6:6-0:7:7", + "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", "raw": "2", "value": "2" } }, { "value": { - "range": "TestCompile/field/array.d2,0:8:8-0:9:9", + "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", "raw": "3", "value": "3" } }, { "value": { - "range": "TestCompile/field/array.d2,0:10:10-0:11:11", + "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", "raw": "4", "value": "4" } @@ -100,22 +100,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/array.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -128,13 +126,13 @@ }, "context": { "key": { - "range": "TestCompile/field/array.d2,0:0:0-0:12:12", + "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", "key": { - "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -148,32 +146,32 @@ "primary": {}, "value": { "array": { - "range": "TestCompile/field/array.d2,0:3:3-0:11:11", + "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", "nodes": [ { "number": { - "range": "TestCompile/field/array.d2,0:4:4-0:5:5", + "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", "raw": "1", "value": "1" } }, { "number": { - "range": "TestCompile/field/array.d2,0:6:6-0:7:7", + "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", "raw": "2", "value": "2" } }, { "number": { - "range": "TestCompile/field/array.d2,0:8:8-0:9:9", + "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", "raw": "3", "value": "3" } }, { "number": { - "range": "TestCompile/field/array.d2,0:10:10-0:11:11", + "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", "raw": "4", "value": "4" } diff --git a/testdata/d2ir/TestCompile/field/label.exp.json b/testdata/d2ir/TestCompile/fields/label.exp.json similarity index 67% rename from testdata/d2ir/TestCompile/field/label.exp.json rename to testdata/d2ir/TestCompile/fields/label.exp.json index 305f3aef1..0d90b55dc 100644 --- a/testdata/d2ir/TestCompile/field/label.exp.json +++ b/testdata/d2ir/TestCompile/fields/label.exp.json @@ -1,16 +1,16 @@ { "ast": { - "range": "TestCompile/field/label.d2,0:0:0-0:6:6", + "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", "nodes": [ { "map_key": { - "range": "TestCompile/field/label.d2,0:0:0-0:6:6", + "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", "key": { - "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -24,7 +24,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "TestCompile/field/label.d2,0:3:3-0:6:6", + "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", "value": [ { "string": "yes", @@ -43,7 +43,7 @@ "name": "x", "primary": { "value": { - "range": "TestCompile/field/label.d2,0:3:3-0:6:6", + "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", "value": [ { "string": "yes", @@ -55,22 +55,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/label.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -83,13 +81,13 @@ }, "context": { "key": { - "range": "TestCompile/field/label.d2,0:0:0-0:6:6", + "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", "key": { - "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -103,7 +101,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "TestCompile/field/label.d2,0:3:3-0:6:6", + "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", "value": [ { "string": "yes", diff --git a/testdata/d2ir/TestCompile/field/nested.exp.json b/testdata/d2ir/TestCompile/fields/nested.exp.json similarity index 71% rename from testdata/d2ir/TestCompile/field/nested.exp.json rename to testdata/d2ir/TestCompile/fields/nested.exp.json index 5cddad1b9..c9828d235 100644 --- a/testdata/d2ir/TestCompile/field/nested.exp.json +++ b/testdata/d2ir/TestCompile/fields/nested.exp.json @@ -1,16 +1,16 @@ { "ast": { - "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", "nodes": [ { "map_key": { - "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", "key": { - "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -21,7 +21,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -35,7 +35,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", @@ -58,7 +58,7 @@ "name": "y", "primary": { "value": { - "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", @@ -70,22 +70,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] }, "key_path": { - "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -96,7 +94,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -109,13 +107,13 @@ }, "context": { "key": { - "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", "key": { - "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -126,7 +124,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -140,7 +138,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", @@ -161,22 +159,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -187,7 +183,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -200,13 +196,13 @@ }, "context": { "key": { - "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", "key": { - "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -217,7 +213,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -231,7 +227,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", diff --git a/testdata/d2ir/TestCompile/field/primary/nested.exp.json b/testdata/d2ir/TestCompile/fields/primary/nested.exp.json similarity index 69% rename from testdata/d2ir/TestCompile/field/primary/nested.exp.json rename to testdata/d2ir/TestCompile/fields/primary/nested.exp.json index ebd8af9a3..f7f4069c8 100644 --- a/testdata/d2ir/TestCompile/field/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/fields/primary/nested.exp.json @@ -1,16 +1,16 @@ { "ast": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", "nodes": [ { "map_key": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", "key": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -21,7 +21,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -34,7 +34,7 @@ }, "primary": { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", @@ -45,17 +45,17 @@ }, "value": { "map": { - "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", "nodes": [ { "map_key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", "value": [ { "string": "pqrs", @@ -87,7 +87,7 @@ "name": "y", "primary": { "value": { - "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", @@ -103,22 +103,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] }, "key_path": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", "value": [ { "string": "pqrs", @@ -131,13 +129,13 @@ }, "context": { "key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", "value": [ { "string": "pqrs", @@ -162,22 +160,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] }, "key_path": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -188,7 +184,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -201,13 +197,13 @@ }, "context": { "key": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", "key": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -218,7 +214,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -231,7 +227,7 @@ }, "primary": { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", @@ -242,17 +238,17 @@ }, "value": { "map": { - "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", "nodes": [ { "map_key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", "value": [ { "string": "pqrs", @@ -282,22 +278,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -308,7 +302,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -321,13 +315,13 @@ }, "context": { "key": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", "key": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -338,7 +332,7 @@ }, { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", "value": [ { "string": "y", @@ -351,7 +345,7 @@ }, "primary": { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", "value": [ { "string": "yes", @@ -362,17 +356,17 @@ }, "value": { "map": { - "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", "nodes": [ { "map_key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "key": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", "value": [ { "string": "pqrs", diff --git a/testdata/d2ir/TestCompile/field/primary/root.exp.json b/testdata/d2ir/TestCompile/fields/primary/root.exp.json similarity index 66% rename from testdata/d2ir/TestCompile/field/primary/root.exp.json rename to testdata/d2ir/TestCompile/fields/primary/root.exp.json index 595bf1ea9..1381cf544 100644 --- a/testdata/d2ir/TestCompile/field/primary/root.exp.json +++ b/testdata/d2ir/TestCompile/fields/primary/root.exp.json @@ -1,16 +1,16 @@ { "ast": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:15:15", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", "nodes": [ { "map_key": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:15:15", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", "key": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -23,7 +23,7 @@ }, "primary": { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:3:3-0:6:6", + "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", "value": [ { "string": "yes", @@ -34,17 +34,17 @@ }, "value": { "map": { - "range": "TestCompile/field/primary/root.d2,0:7:7-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", "nodes": [ { "map_key": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "key": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", "value": [ { "string": "pqrs", @@ -72,7 +72,7 @@ "name": "x", "primary": { "value": { - "range": "TestCompile/field/primary/root.d2,0:3:3-0:6:6", + "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", "value": [ { "string": "yes", @@ -88,22 +88,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] }, "key_path": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", "value": [ { "string": "pqrs", @@ -116,13 +114,13 @@ }, "context": { "key": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "key": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", "value": [ { "string": "pqrs", @@ -147,22 +145,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -175,13 +171,13 @@ }, "context": { "key": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:15:15", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", "key": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -194,7 +190,7 @@ }, "primary": { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:3:3-0:6:6", + "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", "value": [ { "string": "yes", @@ -205,17 +201,17 @@ }, "value": { "map": { - "range": "TestCompile/field/primary/root.d2,0:7:7-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", "nodes": [ { "map_key": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "key": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "path": [ { "unquoted_string": { - "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", "value": [ { "string": "pqrs", diff --git a/testdata/d2ir/TestCompile/field/root.exp.json b/testdata/d2ir/TestCompile/fields/root.exp.json similarity index 64% rename from testdata/d2ir/TestCompile/field/root.exp.json rename to testdata/d2ir/TestCompile/fields/root.exp.json index 01ab1fa88..a76d04522 100644 --- a/testdata/d2ir/TestCompile/field/root.exp.json +++ b/testdata/d2ir/TestCompile/fields/root.exp.json @@ -1,16 +1,16 @@ { "ast": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "nodes": [ { "map_key": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "key": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -34,22 +34,20 @@ "references": [ { "string": { - "unquoted_string": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] }, "key_path": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -62,13 +60,13 @@ }, "context": { "key": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "key": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "path": [ { "unquoted_string": { - "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", From 98ede1f5863ee68065401f80f9d8de6633329974 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 02:08:41 -0800 Subject: [PATCH 22/60] d2ir: IR Root wip --- d2ir/compile.go | 4 +- testdata/d2ir/TestCompile/layer/root.exp.json | 1055 +++++++++++++++++ 2 files changed, 1058 insertions(+), 1 deletion(-) create mode 100644 testdata/d2ir/TestCompile/layer/root.exp.json diff --git a/d2ir/compile.go b/d2ir/compile.go index 3944d1901..8e01a3f69 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -16,7 +16,9 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { func Compile(ast *d2ast.Map) (*Layer, error) { l := &Layer{ AST: ast, - Map: &Map{}, + } + l.Map = &Map{ + parent: l, } c := &compiler{} diff --git a/testdata/d2ir/TestCompile/layer/root.exp.json b/testdata/d2ir/TestCompile/layer/root.exp.json new file mode 100644 index 000000000..6d6daa531 --- /dev/null +++ b/testdata/d2ir/TestCompile/layer/root.exp.json @@ -0,0 +1,1055 @@ +{ + "ast": { + "range": "TestCompile/layer/root.d2,0:0:0-3:1:36", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", + "key": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", + "key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "base": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "layers", + "composite": { + "fields": [ + { + "name": "bingo", + "composite": { + "fields": [ + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", + "key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", + "key": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", + "key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + } +} From 29b936252b6c7990f7c3c1c71a0c05cefbb97bbe Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 03:45:34 -0800 Subject: [PATCH 23/60] d2ir: IR Root wip --- d2ir/compile.go | 10 ++--- d2ir/compile_test.go | 6 +-- d2ir/d2ir.go | 91 +++++++++++++++++++++++++++++--------------- 3 files changed, 67 insertions(+), 40 deletions(-) diff --git a/d2ir/compile.go b/d2ir/compile.go index 8e01a3f69..bd6719e32 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -13,10 +13,8 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { c.err.Errors = append(c.err.Errors, d2parser.Errorf(n, f, v...).(d2ast.Error)) } -func Compile(ast *d2ast.Map) (*Layer, error) { - l := &Layer{ - AST: ast, - } +func Compile(ast *d2ast.Map) (*Map, error) { + l := &Layer{} l.Map = &Map{ parent: l, } @@ -75,7 +73,7 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) c.compileArray(a, refctx.Key.Value.Array) f.Composite = a } else if refctx.Key.Value.Map != nil { - f_m := ToMap(f) + f_m := ChildMap(f) if f_m == nil { f_m = &Map{ parent: f, @@ -102,7 +100,7 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { c.errorf(refctx.Key.Key, "cannot index into array") return } - f_m := ToMap(f) + f_m := ChildMap(f) if f_m == nil { f_m = &Map{ parent: f, diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 4a9672410..ff66dc61e 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -60,7 +60,7 @@ func compile(t testing.TB, text string) (*d2ir.Layer, error) { func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { t.Helper() - m := d2ir.ToMap(n) + m := d2ir.ChildMap(n) if m == nil { t.Fatalf("nil m from %T", n) } @@ -73,7 +73,7 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa t.Fatalf("expected field %v in map %s", ida, m) } p = f.Primary - m = d2ir.ToMap(f) + m = d2ir.ChildMap(f) } assert.Equal(t, nfields, m.FieldCountRecursive()) @@ -93,7 +93,7 @@ func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eid eid := d2ir.NewEdgeIDs(k)[0] - m := d2ir.ToMap(n) + m := d2ir.ChildMap(n) if m == nil { t.Fatalf("nil m from %T", n) } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index f4ad3f545..ad7b62f91 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -82,8 +82,6 @@ func (n *Map) String() string { return d2format.Format(n.ast()) } type Layer struct { parent Node - - AST *d2ast.Map `json:"ast"` Map *Map `json:"base"` } @@ -148,8 +146,20 @@ func (m *Map) Root() bool { // Layer reports whether the Map represents the root of a layer. func (m *Map) Layer() bool { - _, ok := m.parent.(*Layer) - return ok + f := ParentField(m) + if f == nil { + return true + } + f = ParentField(f) + if f == nil { + return false + } + switch f.Name { + case "layers", "scenarios", "steps": + return true + default: + return false + } } type Field struct { @@ -401,7 +411,7 @@ func (m *Map) FieldCountRecursive() int { } acc := len(m.Fields) for _, f := range m.Fields { - f_m := ToMap(f) + f_m := ChildMap(f) if f_m != nil { acc += f_m.FieldCountRecursive() } @@ -420,7 +430,7 @@ func (m *Map) EdgeCountRecursive() int { } acc := len(m.Edges) for _, f := range m.Fields { - f_m := ToMap(f) + f_m := ChildMap(f) if f_m != nil { acc += f_m.EdgeCountRecursive() } @@ -462,7 +472,7 @@ func (m *Map) getField(ida []string) *Field { if len(rest) == 0 { return f } - f_m := ToMap(f) + f_m := ChildMap(f) if f_m != nil { return f_m.getField(rest) } @@ -489,13 +499,13 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, head := kp.Path[i].Unbox().ScalarString() if head == "_" { - return nil, d2parser.Errorf(kp, `parent "_" can only be used in the beginning of paths, e.g. "_.x"`) + return nil, d2parser.Errorf(kp.Path[i].Unbox(), `parent "_" can only be used in the beginning of paths, e.g. "_.x"`) } switch head { case "layers", "scenarios", "steps": if !m.Layer() { - return nil, d2parser.Errorf(kp, "%s is only allowed at a layer root", head) + return nil, d2parser.Errorf(kp.Path[i].Unbox(), "%s is only allowed at a layer root", head) } } @@ -514,9 +524,9 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, return f, nil } if _, ok := f.Composite.(*Array); ok { - return nil, d2parser.Errorf(kp, "cannot index into array") + return nil, d2parser.Errorf(kp.Path[i].Unbox(), "cannot index into array") } - f_m := ToMap(f) + f_m := ChildMap(f) if f_m == nil { f_m = &Map{ parent: f, @@ -535,6 +545,28 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, Context: refctx, }}, } + pf := ParentField(m) + switch pf.Name { + case "layers", "scenarios", "steps": + var l *Layer + switch pf.Name { + case "layers": + l = &Layer{ + parent: f, + } + l.Map = &Map{parent: l} + case "scenarios": + l = ParentLayer(m).Copy(f) + case "steps": + panic("TODO") + } + f.Composite = l + + if kp == refctx.Key.Key && refctx.Edge == nil { + kp. + } + l.AST = + } m.Fields = append(m.Fields, f) if i+1 == len(kp.Path) { return f, nil @@ -562,7 +594,7 @@ func (m *Map) DeleteField(ida []string) bool { copy(m.Fields[i:], m.Fields[i+1:]) return true } - f_m := ToMap(f) + f_m := ChildMap(f) if f_m != nil { return f_m.DeleteField(rest) } @@ -581,7 +613,7 @@ func (m *Map) GetEdges(eid *EdgeID) []*Edge { if f == nil { return nil } - f_m := ToMap(f) + f_m := ChildMap(f) if f_m != nil { return f_m.GetEdges(eid) } @@ -612,9 +644,9 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { return nil, err } if _, ok := f.Composite.(*Array); ok { - return nil, d2parser.Errorf(refctx.Edge, "cannot index into array") + return nil, d2parser.Errorf(refctx.Edge.Src, "cannot index into array") } - f_m := ToMap(f) + f_m := ChildMap(f) if f_m == nil { f_m = &Map{ parent: f, @@ -738,20 +770,18 @@ func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext if i+1 == len(kp.Path) { return } - f_m := ToMap(f) + f_m := ChildMap(f) if f_m != nil { f_m.appendFieldReferences(i+1, kp, refctx) } } -func ToMap(n Node) *Map { +func ChildMap(n Node) *Map { switch n := n.(type) { case *Map: return n - case *Layer: - return n.Map case *Field: - return ToMap(n.Composite) + return ChildMap(n.Composite) case *Edge: return n.Map default: @@ -790,6 +820,16 @@ func ParentField(n Node) *Field { return nil } +func ParentLayer(n Node) *Layer { + for n.Parent() != nil { + n = n.Parent() + if n_f, ok := n.(*Layer); ok { + return n_f + } + } + return nil +} + func countUnderscores(p []string) int { var count int for _, el := range p { @@ -800,14 +840,3 @@ func countUnderscores(p []string) int { } return count } - -func IDA(n Node) (ida []string) { - for { - f := ParentField(n) - if f == nil { - return ida - } - ida = append(ida, f.Name) - n = f - } -} From 6e04ebb304ac46d7619b43974b775c994901e1ba Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 03:46:25 -0800 Subject: [PATCH 24/60] d2ir: IR Root wip --- d2ir/d2ir.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index ad7b62f91..f5030e839 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -25,7 +25,6 @@ type Node interface { fmt.Stringer } -var _ Node = &Layer{} var _ Node = &Scalar{} var _ Node = &Field{} var _ Node = &Edge{} @@ -50,14 +49,12 @@ type Composite interface { var _ Composite = &Array{} var _ Composite = &Map{} -func (n *Layer) node() {} func (n *Scalar) node() {} func (n *Field) node() {} func (n *Edge) node() {} func (n *Array) node() {} func (n *Map) node() {} -func (n *Layer) Parent() Node { return n.parent } func (n *Scalar) Parent() Node { return n.parent } func (n *Field) Parent() Node { return n.parent } func (n *Edge) Parent() Node { return n.parent } @@ -67,33 +64,16 @@ func (n *Map) Parent() Node { return n.parent } func (n *Scalar) value() {} func (n *Array) value() {} func (n *Map) value() {} -func (n *Layer) value() {} func (n *Array) composite() {} func (n *Map) composite() {} -func (n *Layer) composite() {} -func (n *Layer) String() string { return d2format.Format(n.ast()) } func (n *Scalar) String() string { return d2format.Format(n.ast()) } func (n *Field) String() string { return d2format.Format(n.ast()) } func (n *Edge) String() string { return d2format.Format(n.ast()) } func (n *Array) String() string { return d2format.Format(n.ast()) } func (n *Map) String() string { return d2format.Format(n.ast()) } -type Layer struct { - parent Node - Map *Map `json:"base"` -} - -func (l *Layer) Copy(newp Node) Node { - tmp := *l - l = &tmp - - l.parent = newp.(*Layer) - l.Map = l.Map.Copy(l).(*Map) - return l -} - type Scalar struct { parent Node Value d2ast.Scalar `json:"value"` @@ -545,28 +525,6 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, Context: refctx, }}, } - pf := ParentField(m) - switch pf.Name { - case "layers", "scenarios", "steps": - var l *Layer - switch pf.Name { - case "layers": - l = &Layer{ - parent: f, - } - l.Map = &Map{parent: l} - case "scenarios": - l = ParentLayer(m).Copy(f) - case "steps": - panic("TODO") - } - f.Composite = l - - if kp == refctx.Key.Key && refctx.Edge == nil { - kp. - } - l.AST = - } m.Fields = append(m.Fields, f) if i+1 == len(kp.Path) { return f, nil From 180334a8e11535758d3370664270ee243da62193 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 03:51:16 -0800 Subject: [PATCH 25/60] d2ir: IR Root wip --- d2ir/compile.go | 14 +- d2ir/compile_test.go | 98 +- d2ir/d2ir.go | 19 +- .../d2ir/TestCompile/edges/nested.exp.json | 1473 ++++++++-------- testdata/d2ir/TestCompile/edges/root.exp.json | 583 +++---- .../TestCompile/edges/underscore.exp.json | 943 +++++----- .../d2ir/TestCompile/fields/array.exp.json | 270 ++- .../d2ir/TestCompile/fields/label.exp.json | 158 +- .../d2ir/TestCompile/fields/nested.exp.json | 363 ++-- .../fields/primary/nested.exp.json | 614 +++---- .../TestCompile/fields/primary/root.exp.json | 337 ++-- .../d2ir/TestCompile/fields/root.exp.json | 106 +- testdata/d2ir/TestCompile/layer/root.exp.json | 1542 ++++++++--------- 13 files changed, 2902 insertions(+), 3618 deletions(-) diff --git a/d2ir/compile.go b/d2ir/compile.go index bd6719e32..661d36027 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -14,21 +14,17 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { } func Compile(ast *d2ast.Map) (*Map, error) { - l := &Layer{} - l.Map = &Map{ - parent: l, - } - + m := &Map{} c := &compiler{} - c.compile(l) + c.compile(m, ast) if !c.err.Empty() { return nil, c.err } - return l, nil + return m, nil } -func (c *compiler) compile(l *Layer) { - c.compileMap(l.Map, l.AST) +func (c *compiler) compile(dst *Map, ast *d2ast.Map) { + c.compileMap(dst, ast) } func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index ff66dc61e..42d0ec32d 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -38,23 +38,23 @@ func runa(t *testing.T, tca []testCase) { } } -func compile(t testing.TB, text string) (*d2ir.Layer, error) { +func compile(t testing.TB, text string) (*d2ir.Map, error) { t.Helper() d2Path := fmt.Sprintf("%v.d2", t.Name()) ast, err := d2parser.Parse(d2Path, strings.NewReader(text), nil) assert.Success(t, err) - l, err := d2ir.Compile(ast) + m, err := d2ir.Compile(ast) if err != nil { return nil, err } - err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), l) + err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), m) if err != nil { return nil, err } - return l, nil + return m, nil } func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { @@ -153,42 +153,42 @@ func testCompileFields(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x`) + m, err := compile(t, `x`) assert.Success(t, err) - assertField(t, l, 1, 0, nil) + assertField(t, m, 1, 0, nil) - assertField(t, l, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "x") }, }, { name: "label", run: func(t testing.TB) { - l, err := compile(t, `x: yes`) + m, err := compile(t, `x: yes`) assert.Success(t, err) - assertField(t, l, 1, 0, nil) + assertField(t, m, 1, 0, nil) - assertField(t, l, 0, 0, "yes", "x") + assertField(t, m, 0, 0, "yes", "x") }, }, { name: "nested", run: func(t testing.TB) { - l, err := compile(t, `x.y: yes`) + m, err := compile(t, `x.y: yes`) assert.Success(t, err) - assertField(t, l, 2, 0, nil) + assertField(t, m, 2, 0, nil) - assertField(t, l, 1, 0, nil, "x") - assertField(t, l, 0, 0, "yes", "x", "y") + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, "yes", "x", "y") }, }, { name: "array", run: func(t testing.TB) { - l, err := compile(t, `x: [1;2;3;4]`) + m, err := compile(t, `x: [1;2;3;4]`) assert.Success(t, err) - assertField(t, l, 1, 0, nil) + assertField(t, m, 1, 0, nil) - f := assertField(t, l, 0, 0, nil, "x") + f := assertField(t, m, 0, 0, nil, "x") assert.String(t, `[1; 2; 3; 4]`, f.Composite.String()) }, }, @@ -202,24 +202,24 @@ func testCompileFieldPrimary(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x: yes { pqrs }`) + m, err := compile(t, `x: yes { pqrs }`) assert.Success(t, err) - assertField(t, l, 2, 0, nil) + assertField(t, m, 2, 0, nil) - assertField(t, l, 1, 0, "yes", "x") - assertField(t, l, 0, 0, nil, "x", "pqrs") + assertField(t, m, 1, 0, "yes", "x") + assertField(t, m, 0, 0, nil, "x", "pqrs") }, }, { name: "nested", run: func(t testing.TB) { - l, err := compile(t, `x.y: yes { pqrs }`) + m, err := compile(t, `x.y: yes { pqrs }`) assert.Success(t, err) - assertField(t, l, 3, 0, nil) + assertField(t, m, 3, 0, nil) - assertField(t, l, 2, 0, nil, "x") - assertField(t, l, 1, 0, "yes", "x", "y") - assertField(t, l, 0, 0, nil, "x", "y", "pqrs") + assertField(t, m, 2, 0, nil, "x") + assertField(t, m, 1, 0, "yes", "x", "y") + assertField(t, m, 0, 0, nil, "x", "y", "pqrs") }, }, } @@ -232,42 +232,42 @@ func testCompileEdges(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x -> y`) + m, err := compile(t, `x -> y`) assert.Success(t, err) - assertField(t, l, 2, 1, nil) - assertEdge(t, l, 0, nil, `(x -> y)[0]`) + assertField(t, m, 2, 1, nil) + assertEdge(t, m, 0, nil, `(x -> y)[0]`) - assertField(t, l, 0, 0, nil, "x") - assertField(t, l, 0, 0, nil, "y") + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "y") }, }, { name: "nested", run: func(t testing.TB) { - l, err := compile(t, `x.y -> z.p`) + m, err := compile(t, `x.y -> z.p`) assert.Success(t, err) - assertField(t, l, 4, 1, nil) + assertField(t, m, 4, 1, nil) - assertField(t, l, 1, 0, nil, "x") - assertField(t, l, 0, 0, nil, "x", "y") + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, nil, "x", "y") - assertField(t, l, 1, 0, nil, "z") - assertField(t, l, 0, 0, nil, "z", "p") + assertField(t, m, 1, 0, nil, "z") + assertField(t, m, 0, 0, nil, "z", "p") - assertEdge(t, l, 0, nil, "(x.y -> z.p)[0]") + assertEdge(t, m, 0, nil, "(x.y -> z.p)[0]") }, }, { name: "underscore", run: func(t testing.TB) { - l, err := compile(t, `p: { _.x -> z }`) + m, err := compile(t, `p: { _.x -> z }`) assert.Success(t, err) - assertField(t, l, 3, 1, nil) + assertField(t, m, 3, 1, nil) - assertField(t, l, 0, 0, nil, "x") - assertField(t, l, 1, 0, nil, "p") + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 1, 0, nil, "p") - assertEdge(t, l, 0, nil, "(x -> p.z)[0]") + assertEdge(t, m, 0, nil, "(x -> p.z)[0]") }, }, } @@ -280,19 +280,19 @@ func testCompileLayers(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x -> y + m, err := compile(t, `x -> y layers: { bingo: { p.q.z } }`) assert.Success(t, err) - assertField(t, l, 5, 1, nil) - assertEdge(t, l, 0, nil, `(x -> y)[0]`) + assertField(t, m, 7, 1, nil) + assertEdge(t, m, 0, nil, `(x -> y)[0]`) - assertField(t, l, 0, 0, nil, "x") - assertField(t, l, 0, 0, nil, "y") + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "y") - assertField(t, l, 0, 0, nil, "layers", "bingo") + assertField(t, m, 3, 0, nil, "layers", "bingo") }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index f5030e839..caf819019 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -630,10 +630,6 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { return e, nil } -func (l *Layer) ast() d2ast.Node { - return l.Map.ast() -} - func (s *Scalar) ast() d2ast.Node { return s.Value } @@ -778,14 +774,17 @@ func ParentField(n Node) *Field { return nil } -func ParentLayer(n Node) *Layer { - for n.Parent() != nil { - n = n.Parent() - if n_f, ok := n.(*Layer); ok { - return n_f +func ParentLayer(n Node) *Map { + for { + m := ParentMap(n) + if m == nil { + return nil } + if m.Layer() { + return m + } + n = m } - return nil } func countUnderscores(p []string) int { diff --git a/testdata/d2ir/TestCompile/edges/nested.exp.json b/testdata/d2ir/TestCompile/edges/nested.exp.json index 2bf781919..c843d9b44 100644 --- a/testdata/d2ir/TestCompile/edges/nested.exp.json +++ b/testdata/d2ir/TestCompile/edges/nested.exp.json @@ -1,12 +1,288 @@ { - "ast": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", @@ -65,33 +341,232 @@ }, "dst_arrow": ">" } - ], - "primary": {}, - "value": {} + } } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" + ] + }, + { + "name": "z", + "composite": { + "fields": [ + { + "name": "p", + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} }, - "key_path": { + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { @@ -118,325 +593,8 @@ } ] }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - }, - { - "name": "z", - "composite": { - "fields": [ - { - "name": "p", - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - }, - "key_path": { + "src_arrow": "", + "dst": { "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { @@ -463,455 +621,222 @@ } ] }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } + "dst_arrow": ">" } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] + ], + "primary": {}, + "value": {} }, - "key_path": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + "string": "y", + "raw_string": "y" } ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x", - "y" - ], - "src_arrow": false, - "dst_path": [ - "z", - "p" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x", + "y" + ], + "src_arrow": false, + "dst_path": [ + "z", + "p" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + "string": "y", + "raw_string": "y" } ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ] - } + } + ] + } + ] } diff --git a/testdata/d2ir/TestCompile/edges/root.exp.json b/testdata/d2ir/TestCompile/edges/root.exp.json index f8b7f0552..2dd443a34 100644 --- a/testdata/d2ir/TestCompile/edges/root.exp.json +++ b/testdata/d2ir/TestCompile/edges/root.exp.json @@ -1,12 +1,80 @@ { - "ast": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ - { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", @@ -43,347 +111,226 @@ }, "dst_arrow": ">" } - ], - "primary": {}, - "value": {} + } } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "references": [ - { - "string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "key_path": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "edges": [ { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "string": "x", - "raw_string": "x" + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] - } + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ + "edge": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 }, - { - "name": "y", - "references": [ - { - "string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "edges": [ { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "string": "y", - "raw_string": "y" + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] - } + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ + "edge": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "y" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ - { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - } - ] - } + } + ] + } + ] } diff --git a/testdata/d2ir/TestCompile/edges/underscore.exp.json b/testdata/d2ir/TestCompile/edges/underscore.exp.json index f248396d9..68ba516a2 100644 --- a/testdata/d2ir/TestCompile/edges/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edges/underscore.exp.json @@ -1,33 +1,40 @@ { - "ast": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "path": [ + "fields": [ + { + "name": "p", + "composite": { + "fields": [ + { + "name": "z", + "references": [ { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { - "string": "p", - "raw_string": "p" + "string": "z", + "raw_string": "z" } ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", - "nodes": [ - { - "map_key": { + }, + "key_path": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "edges": [ { @@ -81,35 +88,254 @@ ], "primary": {}, "value": {} + }, + "edge": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" } } - ] - } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } - } - ] - }, - "base": { - "fields": [ - { - "name": "p", - "composite": { - "fields": [ - { - "name": "z", - "references": [ + ] + }, + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "edges": [ { - "string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ { - "string": "z", - "raw_string": "z" + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] }, - "key_path": { + "src_arrow": "", + "dst": { "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { @@ -125,507 +351,188 @@ } ] }, - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" + "string": "_", + "raw_string": "_" } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ - { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - ] - } - } + ] }, - "edge": null + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" } } - ] + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "p", + "z" + ], + "dst_arrow": true, + "index": 0 }, - { - "name": "x", - "references": [ - { - "string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "edges": [ { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ { - "string": "_", - "raw_string": "_" + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ { - "string": "x", - "raw_string": "x" + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } } ] - } + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ + "edge": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "_", + "raw_string": "_" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "p", - "z" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ - { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - } - ] - } + } + ] + } + ] } diff --git a/testdata/d2ir/TestCompile/fields/array.exp.json b/testdata/d2ir/TestCompile/fields/array.exp.json index fa6329969..fbf42989a 100644 --- a/testdata/d2ir/TestCompile/fields/array.exp.json +++ b/testdata/d2ir/TestCompile/fields/array.exp.json @@ -1,11 +1,51 @@ { - "ast": { - "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", - "key": { + "fields": [ + { + "name": "x", + "composite": { + "values": [ + { + "value": { + "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "value": { + "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "value": { + "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "value": { + "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" + } + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "path": [ { @@ -21,171 +61,67 @@ } ] }, - "primary": {}, - "value": { - "array": { - "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", - "nodes": [ - { - "number": { - "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", - "raw": "1", - "value": "1" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", - "raw": "2", - "value": "2" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", - "raw": "3", - "value": "3" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", - "raw": "4", - "value": "4" - } - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "values": [ - { - "value": { - "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", - "raw": "1", - "value": "1" - } - }, - { - "value": { - "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", - "raw": "2", - "value": "2" - } - }, - { - "value": { - "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", - "raw": "3", - "value": "3" - } - }, - { - "value": { - "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", - "raw": "4", - "value": "4" - } - } - ] - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { + "context": { + "key": { + "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", "key": { - "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", - "key": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "path": [ + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", + "nodes": [ { - "unquoted_string": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] + "number": { + "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "number": { + "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "number": { + "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "number": { + "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" } } ] - }, - "primary": {}, - "value": { - "array": { - "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", - "nodes": [ - { - "number": { - "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", - "raw": "1", - "value": "1" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", - "raw": "2", - "value": "2" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", - "raw": "3", - "value": "3" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", - "raw": "4", - "value": "4" - } - } - ] - } } - }, - "edge": null - } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/label.exp.json b/testdata/d2ir/TestCompile/fields/label.exp.json index 0d90b55dc..6098e519f 100644 --- a/testdata/d2ir/TestCompile/fields/label.exp.json +++ b/testdata/d2ir/TestCompile/fields/label.exp.json @@ -1,11 +1,30 @@ { - "ast": { - "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", - "key": { + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "path": [ { @@ -21,102 +40,43 @@ } ] }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { + "context": { + "key": { + "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", "key": { - "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", - "key": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "path": [ + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", + "value": [ { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "yes", + "raw_string": "yes" } ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } } - }, - "edge": null - } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/nested.exp.json b/testdata/d2ir/TestCompile/fields/nested.exp.json index c9828d235..1bd7e29b6 100644 --- a/testdata/d2ir/TestCompile/fields/nested.exp.json +++ b/testdata/d2ir/TestCompile/fields/nested.exp.json @@ -1,26 +1,25 @@ { - "ast": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "references": [ { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { + "string": { "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", "value": [ { @@ -28,176 +27,8 @@ "raw_string": "y" } ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } }, - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "key": { + "key_path": { "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", "path": [ { @@ -224,25 +55,143 @@ } ] }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" + "context": { + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] } - ] - } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } }, - "edge": null - } + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/primary/nested.exp.json b/testdata/d2ir/TestCompile/fields/primary/nested.exp.json index f7f4069c8..e6085c395 100644 --- a/testdata/d2ir/TestCompile/fields/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/fields/primary/nested.exp.json @@ -1,26 +1,86 @@ { - "ast": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs", + "references": [ { - "string": "x", - "raw_string": "x" + "string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } } ] } - }, + ], + "edges": null + }, + "references": [ { - "unquoted_string": { + "string": { "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", "value": [ { @@ -28,295 +88,8 @@ "raw_string": "y" } ] - } - } - ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs", - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } - } - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } }, - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "key": { + "key_path": { "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", "path": [ { @@ -343,54 +116,201 @@ } ] }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ + "context": { + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "primary": {}, - "value": {} + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] } - ] - } + }, + "value": { + "map": { + "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } }, - "edge": null - } + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/primary/root.exp.json b/testdata/d2ir/TestCompile/fields/primary/root.exp.json index 1381cf544..e44960cf1 100644 --- a/testdata/d2ir/TestCompile/fields/primary/root.exp.json +++ b/testdata/d2ir/TestCompile/fields/primary/root.exp.json @@ -1,43 +1,51 @@ { - "ast": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "path": [ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs", + "references": [ { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "string": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", "value": [ { - "string": "x", - "raw_string": "x" + "string": "pqrs", + "raw_string": "pqrs" } ] - } - } - ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", - "nodes": [ - { - "map_key": { + }, + "key_path": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "context": { + "key": { "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "key": { "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", @@ -57,185 +65,108 @@ }, "primary": {}, "value": {} - } + }, + "edge": null } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" } ] } - }, - "composite": { - "fields": [ - { - "name": "pqrs", - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", + "key": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", + "path": [ { - "string": "pqrs", - "raw_string": "pqrs" + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } } ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] + }, + "primary": {}, + "value": {} } } ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } } - }, - "edge": null - } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/root.exp.json b/testdata/d2ir/TestCompile/fields/root.exp.json index a76d04522..1d204d613 100644 --- a/testdata/d2ir/TestCompile/fields/root.exp.json +++ b/testdata/d2ir/TestCompile/fields/root.exp.json @@ -1,11 +1,19 @@ { - "ast": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "key": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "path": [ { @@ -21,71 +29,33 @@ } ] }, - "primary": {}, - "value": {} - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "references": [ - { - "string": { + "context": { + "key": { "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { "key": { "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "key": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } - ] - }, - "primary": {}, - "value": {} + } + ] }, - "edge": null - } + "primary": {}, + "value": {} + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/layer/root.exp.json b/testdata/d2ir/TestCompile/layer/root.exp.json index 6d6daa531..e3e50b414 100644 --- a/testdata/d2ir/TestCompile/layer/root.exp.json +++ b/testdata/d2ir/TestCompile/layer/root.exp.json @@ -1,12 +1,80 @@ { - "ast": { - "range": "TestCompile/layer/root.d2,0:0:0-3:1:36", - "nodes": [ - { - "map_key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ - { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", "src": { "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", @@ -43,37 +111,475 @@ }, "dst_arrow": ">" } - ], - "primary": {}, - "value": {} + } } - }, - { - "map_key": { - "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", - "key": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", "value": [ { - "string": "layers", - "raw_string": "layers" + "string": "y", + "raw_string": "y" } ] } } ] }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", - "nodes": [ + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ { - "map_key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "layers", + "composite": { + "fields": [ + { + "name": "bingo", + "composite": { + "fields": [ + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "context": { + "key": { "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", "key": { "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", @@ -144,417 +650,92 @@ ] } } - } + }, + "edge": null } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ - { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" } - } + ] } - ] + ], + "edges": null }, - { - "name": "y", - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ - { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" } - } - } - ] - }, - { - "name": "layers", - "composite": { - "fields": [ - { - "name": "bingo", - "composite": { - "fields": [ + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", + "key": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "path": [ { - "name": "p", - "composite": { - "fields": [ + "unquoted_string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ { - "name": "q", - "composite": { - "fields": [ - { - "name": "z", - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", + "key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ { - "string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", "value": [ { - "string": "q", - "raw_string": "q" + "string": "bingo", + "raw_string": "bingo" } ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "context": { - "key": { + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", + "nodes": [ + { + "map_key": { "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", "key": { "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", @@ -596,460 +777,123 @@ }, "primary": {}, "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null + } + ] + } } } - ] - } - ], - "edges": null - }, - "references": [ + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ { - "string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "value": [ - { - "string": "bingo", - "raw_string": "bingo" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", "value": [ { - "string": "bingo", - "raw_string": "bingo" + "string": "x", + "raw_string": "x" } ] } } ] }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", - "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "value": [ - { - "string": "bingo", - "raw_string": "bingo" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", - "nodes": [ + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ { - "map_key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } + "string": "y", + "raw_string": "y" } ] } } - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "value": [ - { - "string": "layers", - "raw_string": "layers" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "value": [ - { - "string": "layers", - "raw_string": "layers" - } ] - } + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", - "key": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "value": [ - { - "string": "layers", - "raw_string": "layers" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", - "nodes": [ - { - "map_key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", - "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "value": [ - { - "string": "bingo", - "raw_string": "bingo" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", - "nodes": [ - { - "map_key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } - } - } - } - ] - } - } - }, - "edge": null - } - } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "y" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ + "edge": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ] - } + } + ] + } + ] } From 748557d8f26828ff4982b6aba84a61c2f3f5e39f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 04:32:12 -0800 Subject: [PATCH 26/60] d2ir: IR Root wip --- d2compiler/compile_test.go | 71 ++++++++++++----------------------- d2ir/compile_test.go | 19 ++++++++++ d2ir/d2ir.go | 76 +++++++++++++++++++++++++++----------- d2parser/parse.go | 7 ++-- 4 files changed, 102 insertions(+), 71 deletions(-) diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 926dbeb2a..90b521782 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -242,8 +242,7 @@ d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height c } } `, - expErr: `d2/testdata/d2compiler/TestCompile/shape_unquoted_hex.d2:3:10: missing value after colon -`, + expErr: `d2/testdata/d2compiler/TestCompile/shape_unquoted_hex.d2:3:10: missing value after colon`, }, { name: "edge_unquoted_hex", @@ -254,8 +253,7 @@ d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height c } } `, - expErr: `d2/testdata/d2compiler/TestCompile/edge_unquoted_hex.d2:3:10: missing value after colon -`, + expErr: `d2/testdata/d2compiler/TestCompile/edge_unquoted_hex.d2:3:10: missing value after colon`, }, { name: "blank_underscore", @@ -265,8 +263,7 @@ d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height c _ } `, - expErr: `d2/testdata/d2compiler/TestCompile/blank_underscore.d2:3:3: invalid use of parent "_" -`, + expErr: `d2/testdata/d2compiler/TestCompile/blank_underscore.d2:3:3: invalid use of parent "_"`, }, { name: "image_non_style", @@ -277,8 +274,7 @@ d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height c name: y } `, - expErr: `d2/testdata/d2compiler/TestCompile/image_non_style.d2:4:3: image shapes cannot have children. -`, + expErr: `d2/testdata/d2compiler/TestCompile/image_non_style.d2:4:3: image shapes cannot have children.`, }, { name: "stroke-width", @@ -303,8 +299,7 @@ d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height c style.stroke-width: -1 } `, - expErr: `d2/testdata/d2compiler/TestCompile/illegal-stroke-width.d2:2:23: expected "stroke-width" to be a number between 0 and 15 -`, + expErr: `d2/testdata/d2compiler/TestCompile/illegal-stroke-width.d2:2:23: expected "stroke-width" to be a number between 0 and 15`, }, { name: "underscore_parent_create", @@ -457,8 +452,7 @@ x: { text: ` _.x `, - expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_root.d2:2:1: parent "_" cannot be used in the root scope -`, + expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_root.d2:2:1: parent "_" cannot be used in the root scope`, }, { name: "underscore_parent_middle_path", @@ -468,8 +462,7 @@ x: { y._.z } `, - expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_middle_path.d2:3:3: parent "_" can only be used in the beginning of paths, e.g. "_.x" -`, + expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_middle_path.d2:3:3: parent "_" can only be used in the beginning of paths, e.g. "_.x"`, }, { name: "underscore_parent_sandwich_path", @@ -479,8 +472,7 @@ x: { _.z._ } `, - expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_sandwich_path.d2:3:3: parent "_" can only be used in the beginning of paths, e.g. "_.x" -`, + expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_sandwich_path.d2:3:3: parent "_" can only be used in the beginning of paths, e.g. "_.x"`, }, { name: "underscore_edge", @@ -997,8 +989,7 @@ x -> y: { text: `x: {shape: triangle} `, - expErr: `d2/testdata/d2compiler/TestCompile/object_arrowhead_shape.d2:1:5: invalid shape, can only set "triangle" for arrowheads -`, + expErr: `d2/testdata/d2compiler/TestCompile/object_arrowhead_shape.d2:1:5: invalid shape, can only set "triangle" for arrowheads`, }, { name: "edge_flat_label_arrowhead", @@ -1084,8 +1075,7 @@ x -> y: { space -> stars } `, - expErr: `d2/testdata/d2compiler/TestCompile/nested_edge.d2:1:1: edges cannot be nested within another edge -`, + expErr: `d2/testdata/d2compiler/TestCompile/nested_edge.d2:1:1: edges cannot be nested within another edge`, }, { name: "shape_edge_style", @@ -1095,8 +1085,7 @@ x: { style.animated: true } `, - expErr: `d2/testdata/d2compiler/TestCompile/shape_edge_style.d2:3:2: key "animated" can only be applied to edges -`, + expErr: `d2/testdata/d2compiler/TestCompile/shape_edge_style.d2:3:2: key "animated" can only be applied to edges`, }, { name: "edge_chain_map", @@ -1352,8 +1341,7 @@ x -> y: { z } `, - expErr: `d2/testdata/d2compiler/TestCompile/edge_map_non_reserved.d2:2:1: edge map keys must be reserved keywords -`, + expErr: `d2/testdata/d2compiler/TestCompile/edge_map_non_reserved.d2:2:1: edge map keys must be reserved keywords`, }, { name: "url_link", @@ -1398,8 +1386,7 @@ x -> y: { text: `x.near: txop-center `, - expErr: `d2/testdata/d2compiler/TestCompile/near_bad_constant.d2:1:1: near key "txop-center" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right -`, + expErr: `d2/testdata/d2compiler/TestCompile/near_bad_constant.d2:1:1: near key "txop-center" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right`, }, { name: "near_bad_container", @@ -1409,8 +1396,7 @@ x -> y: { y } `, - expErr: `d2/testdata/d2compiler/TestCompile/near_bad_container.d2:1:1: constant near keys cannot be set on shapes with children -`, + expErr: `d2/testdata/d2compiler/TestCompile/near_bad_container.d2:1:1: constant near keys cannot be set on shapes with children`, }, { name: "near_bad_connected", @@ -1420,16 +1406,14 @@ x -> y: { } x -> y `, - expErr: `d2/testdata/d2compiler/TestCompile/near_bad_connected.d2:1:1: constant near keys cannot be set on connected shapes -`, + expErr: `d2/testdata/d2compiler/TestCompile/near_bad_connected.d2:1:1: constant near keys cannot be set on connected shapes`, }, { name: "nested_near_constant", text: `x.y.near: top-center `, - expErr: `d2/testdata/d2compiler/TestCompile/nested_near_constant.d2:1:1: constant near keys can only be set on root level shapes -`, + expErr: `d2/testdata/d2compiler/TestCompile/nested_near_constant.d2:1:1: constant near keys can only be set on root level shapes`, }, { name: "reserved_icon_near_style", @@ -1477,15 +1461,13 @@ y expErr: `d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:3:9: bad icon url "::????:::%%orange": parse "::????:::%%orange": missing protocol scheme d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:4:18: expected "opacity" to be a number between 0.0 and 1.0 d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:5:18: expected "opacity" to be a number between 0.0 and 1.0 -d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:1:1: near key "y" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right -`, +d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:1:1: near key "y" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right`, }, { name: "errors/missing_shape_icon", - text: `x.shape: image`, - expErr: `d2/testdata/d2compiler/TestCompile/errors/missing_shape_icon.d2:1:1: image shape must include an "icon" field -`, + text: `x.shape: image`, + expErr: `d2/testdata/d2compiler/TestCompile/errors/missing_shape_icon.d2:1:1: image shape must include an "icon" field`, }, { name: "edge_in_column", @@ -1501,8 +1483,7 @@ d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:1:1: near key " text: `x: {style.opacity: 0.4} y -> x.style `, - expErr: `d2/testdata/d2compiler/TestCompile/edge_to_style.d2:2:1: cannot connect to reserved keyword -`, + expErr: `d2/testdata/d2compiler/TestCompile/edge_to_style.d2:2:1: cannot connect to reserved keyword`, }, { name: "escaped_id", @@ -1683,8 +1664,7 @@ x.y -> a.b: { text: `SVP1.style.shape: oval SVP1.style.3d: true`, - expErr: `d2/testdata/d2compiler/TestCompile/3d_oval.d2:2:1: key "3d" can only be applied to squares and rectangles -`, + expErr: `d2/testdata/d2compiler/TestCompile/3d_oval.d2:2:1: key "3d" can only be applied to squares and rectangles`, }, { name: "edge_column_index", text: `src: { @@ -1741,8 +1721,7 @@ dst.id <-> src.dst_id } b -> x.a `, - expErr: `d2/testdata/d2compiler/TestCompile/leaky_sequence.d2:5:1: connections within sequence diagrams can connect only to other objects within the same sequence diagram -`, + expErr: `d2/testdata/d2compiler/TestCompile/leaky_sequence.d2:5:1: connections within sequence diagrams can connect only to other objects within the same sequence diagram`, }, { name: "sequence_scoping", @@ -1819,8 +1798,7 @@ choo: { text: `x: { direction: diagonal }`, - expErr: `d2/testdata/d2compiler/TestCompile/invalid_direction.d2:2:14: direction must be one of up, down, right, left, got "diagonal" -`, + expErr: `d2/testdata/d2compiler/TestCompile/invalid_direction.d2:2:14: direction must be one of up, down, right, left, got "diagonal"`, }, { name: "self-referencing", @@ -1869,8 +1847,7 @@ choo: { test_id: varchar(64) {constraint: [primary_key, foreign_key]} } `, - expErr: `d2/testdata/d2compiler/TestCompile/sql-panic.d2:3:27: constraint value must be a string -`, + expErr: `d2/testdata/d2compiler/TestCompile/sql-panic.d2:3:27: constraint value must be a string`, }, { name: "wrong_column_index", diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 42d0ec32d..6c973137b 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -276,6 +276,25 @@ func testCompileEdges(t *testing.T) { func testCompileLayers(t *testing.T) { t.Parallel() + t.Run("errs", func(t *testing.T) { + tca := []testCase{ + { + name: "bad_edge/1", + run: func(t testing.TB) { + _, err := compile(t, `layers.x -> layers.y`) + assert.ErrorString(t, err, `TestCompile/layer/errs/bad_edge/1.d2:1:1: cannot create edges between layers, scenarios or steps`) + }, + }, + { + name: "bad_edge/2", + run: func(t testing.TB) { + _, err := compile(t, `layers -> scenarios`) + assert.ErrorString(t, err, `TestCompile/layer/errs/bad_edge/2.d2:1:1: cannot create edges between layers, scenarios or steps`) + }, + }, + } + runa(t, tca) + }) tca := []testCase{ { name: "root", diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index caf819019..70d173255 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -121,25 +121,28 @@ func (m *Map) Copy(newp Node) Node { // Root reports whether the Map is the root of the D2 tree. func (m *Map) Root() bool { - return ParentMap(m) == nil + return m.parent == nil } -// Layer reports whether the Map represents the root of a layer. -func (m *Map) Layer() bool { - f := ParentField(m) - if f == nil { - return true - } - f = ParentField(f) - if f == nil { - return false - } - switch f.Name { - case "layers", "scenarios", "steps": - return true - default: - return false +// Layer reports whether n represents the root of a layer. +func IsLayer(n Node) bool { + switch n := n.(type) { + case *Field: + n = ParentField(n) + if n != nil { + switch n.Name { + case "layers", "scenarios", "steps": + return true + } + } + case *Map: + f := ParentField(n) + if f == nil { + return true + } + return IsLayer(f) } + return false } type Field struct { @@ -318,8 +321,8 @@ func (a *Array) Copy(newp Node) Node { } type FieldReference struct { - String d2ast.String `json:"string"` - KeyPath *d2ast.KeyPath `json:"key_path"` + String d2ast.String `json:"string"` + KeyPath *d2ast.KeyPath `json:"key_path"` Context *RefContext `json:"context"` } @@ -484,7 +487,7 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, switch head { case "layers", "scenarios", "steps": - if !m.Layer() { + if !IsLayer(m) { return nil, d2parser.Errorf(kp.Path[i].Unbox(), "%s is only allowed at a layer root", head) } } @@ -614,6 +617,27 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { return f_m.CreateEdge(eid, refctx) } + ij := hasLayerKeyword(eid.SrcPath) + if ij != -1 { + return nil, d2parser.Errorf(refctx.Edge.Src.Path[ij].Unbox(), "cannot create edges between layers, scenarios or steps") + } + src := m.GetField(eid.SrcPath...) + if IsLayer(src) { + return nil, d2parser.Errorf(refctx.Edge.Src, "cannot create edges between layers, scenarios or steps") + } + ij = hasLayerKeyword(eid.DstPath) + if ij != -1 { + return nil, d2parser.Errorf(refctx.Edge.Dst.Path[ij].Unbox(), "cannot create edges between layers, scenarios or steps") + } + dst := m.GetField(eid.DstPath...) + if IsLayer(dst) { + return nil, d2parser.Errorf(refctx.Edge.Dst, "cannot create edges between layers, scenarios or steps") + } + + if ParentLayer(src) != ParentLayer(dst) { + return nil, d2parser.Errorf(refctx.Edge, "cannot create edges between layers, scenarios or steps") + } + eid.Index = nil ea := m.GetEdges(eid) index := len(ea) @@ -774,13 +798,13 @@ func ParentField(n Node) *Field { return nil } -func ParentLayer(n Node) *Map { +func ParentLayer(n Node) Node { for { m := ParentMap(n) if m == nil { return nil } - if m.Layer() { + if IsLayer(m) { return m } n = m @@ -797,3 +821,13 @@ func countUnderscores(p []string) int { } return count } + +func hasLayerKeyword(ida []string) int { + for i := range ida { + switch ida[i] { + case "layers", "scenarios", "steps": + return i + } + } + return -1 +} diff --git a/d2parser/parse.go b/d2parser/parse.go index 34d63b43d..b4c3bf9e8 100644 --- a/d2parser/parse.go +++ b/d2parser/parse.go @@ -147,11 +147,12 @@ func (pe ParseError) Error() string { var sb strings.Builder if pe.IOError != nil { sb.WriteString(pe.IOError.Error()) - sb.WriteByte('\n') } - for _, err := range pe.Errors { + for i, err := range pe.Errors { + if pe.IOError != nil || i > 0 { + sb.WriteByte('\n') + } sb.WriteString(err.Error()) - sb.WriteByte('\n') } return sb.String() } From 7d89174a1b4e18c63518bf3f82acd26c029b1b19 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 04:42:34 -0800 Subject: [PATCH 27/60] d2ir: IR Root wip --- d2ir/compile_test.go | 7 +++++++ d2ir/d2ir.go | 49 ++++++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 6c973137b..e47269d72 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -292,6 +292,13 @@ func testCompileLayers(t *testing.T) { assert.ErrorString(t, err, `TestCompile/layer/errs/bad_edge/2.d2:1:1: cannot create edges between layers, scenarios or steps`) }, }, + { + name: "bad_edge/3", + run: func(t testing.TB) { + _, err := compile(t, `layers.x.y -> steps.z.p`) + assert.ErrorString(t, err, `TestCompile/layer/errs/bad_edge/3.d2:1:1: cannot create edges between layers, scenarios or steps`) + }, + }, } runa(t, tca) }) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 70d173255..7e66343cf 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -110,6 +110,9 @@ func (m *Map) Copy(newp Node) Node { m.parent = newp m.Fields = append([]*Field(nil), m.Fields...) for i := range m.Fields { + if hasLayerKeywords(m.Fields[i].Name) != -1 { + continue + } m.Fields[i] = m.Fields[i].Copy(m).(*Field) } m.Edges = append([]*Edge(nil), m.Edges...) @@ -124,25 +127,38 @@ func (m *Map) Root() bool { return m.parent == nil } -// Layer reports whether n represents the root of a layer. -func IsLayer(n Node) bool { +type LayerKind string + +const ( + LayerLayer LayerKind = "layer" + LayerScenario LayerKind = "scenario" + LayerStep LayerKind = "step" +) + +// NodeLayerKind reports whether n represents the root of a layer. +// n should be *Field or *Map +func NodeLayerKind(n Node) LayerKind { switch n := n.(type) { case *Field: n = ParentField(n) if n != nil { switch n.Name { - case "layers", "scenarios", "steps": - return true + case "layers": + return LayerLayer + case "scenarios": + return LayerScenario + case "steps": + return LayerStep } } case *Map: f := ParentField(n) if f == nil { - return true + return LayerLayer } - return IsLayer(f) + return NodeLayerKind(f) } - return false + return "" } type Field struct { @@ -485,11 +501,8 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, return nil, d2parser.Errorf(kp.Path[i].Unbox(), `parent "_" can only be used in the beginning of paths, e.g. "_.x"`) } - switch head { - case "layers", "scenarios", "steps": - if !IsLayer(m) { - return nil, d2parser.Errorf(kp.Path[i].Unbox(), "%s is only allowed at a layer root", head) - } + if hasLayerKeywords(head) != -1 && NodeLayerKind(m) == "" { + return nil, d2parser.Errorf(kp.Path[i].Unbox(), "%s is only allowed at a layer root", head) } for _, f := range m.Fields { @@ -617,20 +630,20 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { return f_m.CreateEdge(eid, refctx) } - ij := hasLayerKeyword(eid.SrcPath) + ij := hasLayerKeywords(eid.SrcPath...) if ij != -1 { return nil, d2parser.Errorf(refctx.Edge.Src.Path[ij].Unbox(), "cannot create edges between layers, scenarios or steps") } src := m.GetField(eid.SrcPath...) - if IsLayer(src) { + if NodeLayerKind(src) != "" { return nil, d2parser.Errorf(refctx.Edge.Src, "cannot create edges between layers, scenarios or steps") } - ij = hasLayerKeyword(eid.DstPath) + ij = hasLayerKeywords(eid.DstPath...) if ij != -1 { return nil, d2parser.Errorf(refctx.Edge.Dst.Path[ij].Unbox(), "cannot create edges between layers, scenarios or steps") } dst := m.GetField(eid.DstPath...) - if IsLayer(dst) { + if NodeLayerKind(dst) != "" { return nil, d2parser.Errorf(refctx.Edge.Dst, "cannot create edges between layers, scenarios or steps") } @@ -804,7 +817,7 @@ func ParentLayer(n Node) Node { if m == nil { return nil } - if IsLayer(m) { + if NodeLayerKind(m) != "" { return m } n = m @@ -822,7 +835,7 @@ func countUnderscores(p []string) int { return count } -func hasLayerKeyword(ida []string) int { +func hasLayerKeywords(ida ...string) int { for i := range ida { switch ida[i] { case "layers", "scenarios", "steps": From d239b8dad104dd725605b9a2f6505364ebe369e5 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 07:15:16 -0800 Subject: [PATCH 28/60] d2ir: Fully implement scenarios/steps --- d2ast/d2ast.go | 7 + d2ir/compile.go | 87 +- d2ir/compile_test.go | 328 ++- d2ir/d2ir.go | 187 +- d2ir/d2ir_test.go | 18 +- d2ir/merge.go | 45 + d2ir/query.go | 61 + .../d2ir/TestCompile/edges/chain.exp.json | 1652 +++++++++++++ .../d2ir/TestCompile/fields/null.exp.json | 131 ++ .../{layer => layers}/root.exp.json | 194 +- .../d2ir/TestCompile/scenarios/root.exp.json | 1759 ++++++++++++++ testdata/d2ir/TestCompile/steps/root.exp.json | 2069 +++++++++++++++++ 12 files changed, 6198 insertions(+), 340 deletions(-) create mode 100644 d2ir/merge.go create mode 100644 d2ir/query.go create mode 100644 testdata/d2ir/TestCompile/edges/chain.exp.json create mode 100644 testdata/d2ir/TestCompile/fields/null.exp.json rename testdata/d2ir/TestCompile/{layer => layers}/root.exp.json (80%) create mode 100644 testdata/d2ir/TestCompile/scenarios/root.exp.json create mode 100644 testdata/d2ir/TestCompile/steps/root.exp.json diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 37906a163..09a00e63e 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -658,6 +658,13 @@ func MakeKeyPath(a []string) *KeyPath { return kp } +func (kp *KeyPath) IDA() (ida []string) { + for _, el := range kp.Path { + ida = append(ida, el.Unbox().ScalarString()) + } + return ida +} + type Edge struct { Range Range `json:"range"` diff --git a/d2ir/compile.go b/d2ir/compile.go index 661d36027..e5ca7baf1 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -14,17 +14,62 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { } func Compile(ast *d2ast.Map) (*Map, error) { - m := &Map{} c := &compiler{} - c.compile(m, ast) + m := &Map{} + c.compileMap(m, ast) + c.compileScenarios(m) + c.compileSteps(m) if !c.err.Empty() { return nil, c.err } return m, nil } -func (c *compiler) compile(dst *Map, ast *d2ast.Map) { - c.compileMap(dst, ast) +func (c *compiler) compileScenarios(m *Map) { + scenariosf := m.GetField("scenarios") + if scenariosf == nil { + return + } + scenarios := scenariosf.Map() + if scenarios == nil { + return + } + + for _, sf := range scenarios.Fields { + if sf.Map() == nil { + sf.Composite = &Map{ + parent: sf, + } + } + base := m.Copy(sf).(*Map) + sf.Composite = Overlay(base, sf.Map()) + } +} + +func (c *compiler) compileSteps(m *Map) { + stepsf := m.GetField("steps") + if stepsf == nil { + return + } + steps := stepsf.Map() + if steps == nil { + return + } + for i, sf := range steps.Fields { + if sf.Map() == nil { + sf.Composite = &Map{ + parent: sf, + } + } + + var base *Map + if i == 0 { + base = m.Copy(sf).(*Map) + } else { + base = steps.Fields[i-1].Map().Copy(sf).(*Map) + } + sf.Composite = Overlay(base, sf.Map()) + } } func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { @@ -57,7 +102,7 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) } if refctx.Key.Primary.Unbox() != nil { - f.Primary = &Scalar{ + f.Primary_ = &Scalar{ parent: f, Value: refctx.Key.Primary.Unbox(), } @@ -69,16 +114,14 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) c.compileArray(a, refctx.Key.Value.Array) f.Composite = a } else if refctx.Key.Value.Map != nil { - f_m := ChildMap(f) - if f_m == nil { - f_m = &Map{ + if f.Map() == nil { + f.Composite = &Map{ parent: f, } - f.Composite = f_m } - c.compileMap(f_m, refctx.Key.Value.Map) + c.compileMap(f.Map(), refctx.Key.Value.Map) } else if refctx.Key.Value.ScalarBox().Unbox() != nil { - f.Primary = &Scalar{ + f.Primary_ = &Scalar{ parent: f, Value: refctx.Key.Value.ScalarBox().Unbox(), } @@ -96,14 +139,12 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { c.errorf(refctx.Key.Key, "cannot index into array") return } - f_m := ChildMap(f) - if f_m == nil { - f_m = &Map{ + if f.Map() == nil { + f.Composite = &Map{ parent: f, } - f.Composite = f_m } - dst = f_m + dst = f.Map() } eida := NewEdgeIDs(refctx.Key) @@ -144,25 +185,25 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { } if refctx.Key.EdgeKey != nil { - if e.Map == nil { - e.Map = &Map{ + if e.Map_ == nil { + e.Map_ = &Map{ parent: e, } } - c.compileField(e.Map, refctx.Key.EdgeKey, refctx) + c.compileField(e.Map_, refctx.Key.EdgeKey, refctx) } else { if refctx.Key.Primary.Unbox() != nil { - e.Primary = &Scalar{ + e.Primary_ = &Scalar{ parent: e, Value: refctx.Key.Primary.Unbox(), } } else if refctx.Key.Value.Map != nil { - if e.Map == nil { - e.Map = &Map{ + if e.Map_ == nil { + e.Map_ = &Map{ parent: e, } } - c.compileMap(e.Map, refctx.Key.Value.Map) + c.compileMap(e.Map_, refctx.Key.Value.Map) } else if refctx.Key.Value.Unbox() != nil { c.errorf(refctx.Key.Value.Unbox(), "edges cannot be assigned arrays") continue diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index e47269d72..3b53971ee 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -20,7 +20,9 @@ func TestCompile(t *testing.T) { t.Run("fields", testCompileFields) t.Run("edges", testCompileEdges) - t.Run("layer", testCompileLayers) + t.Run("layers", testCompileLayers) + t.Run("scenarios", testCompileScenarios) + t.Run("steps", testCompileSteps) } type testCase struct { @@ -57,23 +59,20 @@ func compile(t testing.TB, text string) (*d2ir.Map, error) { return m, nil } -func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { +func assertQueryOne(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, idStr string) d2ir.Node { t.Helper() - m := d2ir.ChildMap(n) - if m == nil { - t.Fatalf("nil m from %T", n) - } - p := d2ir.ToScalar(n) + m := n.Map() + p := n.Primary() - var f *d2ir.Field - if len(ida) > 0 { - f = m.GetField(ida...) - if f == nil { - t.Fatalf("expected field %v in map %s", ida, m) - } - p = f.Primary - m = d2ir.ChildMap(f) + if idStr != "" { + var err error + n, err = m.QueryOne(idStr) + assert.Success(t, err) + assert.NotEqual(t, n, nil) + + p = n.Primary() + m = n.Map() } assert.Equal(t, nfields, m.FieldCountRecursive()) @@ -82,34 +81,7 @@ func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interfa t.Fatalf("expected primary %#v but got %s", primary, p) } - return f -} - -func assertEdge(t testing.TB, n d2ir.Node, nfields int, primary interface{}, eids string) *d2ir.Edge { - t.Helper() - - k, err := d2parser.ParseMapKey(eids) - assert.Success(t, err) - - eid := d2ir.NewEdgeIDs(k)[0] - - m := d2ir.ChildMap(n) - if m == nil { - t.Fatalf("nil m from %T", n) - } - - ea := m.GetEdges(eid) - if len(ea) != 1 { - t.Fatalf("expected single edge %v in map %s but not found", eid, m) - } - e := ea[0] - - assert.Equal(t, nfields, e.Map.FieldCountRecursive()) - if !makeScalar(e.Primary).Equal(makeScalar(primary)) { - t.Fatalf("expected primary %#v but %s", primary, e.Primary) - } - - return e + return n } func makeScalar(v interface{}) *d2ir.Scalar { @@ -148,16 +120,15 @@ func makeScalar(v interface{}) *d2ir.Scalar { func testCompileFields(t *testing.T) { t.Parallel() - t.Run("primary", testCompileFieldPrimary) tca := []testCase{ { name: "root", run: func(t testing.TB) { m, err := compile(t, `x`) assert.Success(t, err) - assertField(t, m, 1, 0, nil) + assertQueryOne(t, m, 1, 0, nil, "") - assertField(t, m, 0, 0, nil, "x") + assertQueryOne(t, m, 0, 0, nil, "x") }, }, { @@ -165,9 +136,9 @@ func testCompileFields(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x: yes`) assert.Success(t, err) - assertField(t, m, 1, 0, nil) + assertQueryOne(t, m, 1, 0, nil, "") - assertField(t, m, 0, 0, "yes", "x") + assertQueryOne(t, m, 0, 0, "yes", "x") }, }, { @@ -175,10 +146,10 @@ func testCompileFields(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x.y: yes`) assert.Success(t, err) - assertField(t, m, 2, 0, nil) + assertQueryOne(t, m, 2, 0, nil, "") - assertField(t, m, 1, 0, nil, "x") - assertField(t, m, 0, 0, "yes", "x", "y") + assertQueryOne(t, m, 1, 0, nil, "x") + assertQueryOne(t, m, 0, 0, "yes", "x.y") }, }, { @@ -186,44 +157,56 @@ func testCompileFields(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x: [1;2;3;4]`) assert.Success(t, err) - assertField(t, m, 1, 0, nil) + assertQueryOne(t, m, 1, 0, nil, "") - f := assertField(t, m, 0, 0, nil, "x") + f := assertQueryOne(t, m, 0, 0, nil, "x").(*d2ir.Field) assert.String(t, `[1; 2; 3; 4]`, f.Composite.String()) }, }, - } - runa(t, tca) -} - -func testCompileFieldPrimary(t *testing.T) { - t.Parallel() - tca := []testCase{ { - name: "root", + name: "null", run: func(t testing.TB) { - m, err := compile(t, `x: yes { pqrs }`) + m, err := compile(t, `pq: pq +pq: null`) assert.Success(t, err) - assertField(t, m, 2, 0, nil) - - assertField(t, m, 1, 0, "yes", "x") - assertField(t, m, 0, 0, nil, "x", "pqrs") - }, - }, - { - name: "nested", - run: func(t testing.TB) { - m, err := compile(t, `x.y: yes { pqrs }`) - assert.Success(t, err) - assertField(t, m, 3, 0, nil) - - assertField(t, m, 2, 0, nil, "x") - assertField(t, m, 1, 0, "yes", "x", "y") - assertField(t, m, 0, 0, nil, "x", "y", "pqrs") + assertQueryOne(t, m, 1, 0, nil, "") + // null doesn't delete pq from *Map so that for language tooling + // we maintain the references. + // Instead d2compiler will ensure it doesn't get rendered. + assertQueryOne(t, m, 0, 0, nil, "pq") }, }, } runa(t, tca) + t.Run("primary", func(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "root", + run: func(t testing.TB) { + m, err := compile(t, `x: yes { pqrs }`) + assert.Success(t, err) + assertQueryOne(t, m, 2, 0, nil, "") + + assertQueryOne(t, m, 1, 0, "yes", "x") + assertQueryOne(t, m, 0, 0, nil, "x.pqrs") + }, + }, + { + name: "nested", + run: func(t testing.TB) { + m, err := compile(t, `x.y: yes { pqrs }`) + assert.Success(t, err) + assertQueryOne(t, m, 3, 0, nil, "") + + assertQueryOne(t, m, 2, 0, nil, "x") + assertQueryOne(t, m, 1, 0, "yes", "x.y") + assertQueryOne(t, m, 0, 0, nil, "x.y.pqrs") + }, + }, + } + runa(t, tca) + }) } func testCompileEdges(t *testing.T) { @@ -234,11 +217,11 @@ func testCompileEdges(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x -> y`) assert.Success(t, err) - assertField(t, m, 2, 1, nil) - assertEdge(t, m, 0, nil, `(x -> y)[0]`) + assertQueryOne(t, m, 2, 1, nil, "") + assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) - assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 0, 0, nil, "y") + assertQueryOne(t, m, 0, 0, nil, "x") + assertQueryOne(t, m, 0, 0, nil, "y") }, }, { @@ -246,15 +229,15 @@ func testCompileEdges(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x.y -> z.p`) assert.Success(t, err) - assertField(t, m, 4, 1, nil) + assertQueryOne(t, m, 4, 1, nil, "") - assertField(t, m, 1, 0, nil, "x") - assertField(t, m, 0, 0, nil, "x", "y") + assertQueryOne(t, m, 1, 0, nil, "x") + assertQueryOne(t, m, 0, 0, nil, "x.y") - assertField(t, m, 1, 0, nil, "z") - assertField(t, m, 0, 0, nil, "z", "p") + assertQueryOne(t, m, 1, 0, nil, "z") + assertQueryOne(t, m, 0, 0, nil, "z.p") - assertEdge(t, m, 0, nil, "(x.y -> z.p)[0]") + assertQueryOne(t, m, 0, 0, nil, "(x.y -> z.p)[0]") }, }, { @@ -262,46 +245,49 @@ func testCompileEdges(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `p: { _.x -> z }`) assert.Success(t, err) - assertField(t, m, 3, 1, nil) + assertQueryOne(t, m, 3, 1, nil, "") - assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 1, 0, nil, "p") + assertQueryOne(t, m, 0, 0, nil, "x") + assertQueryOne(t, m, 1, 0, nil, "p") - assertEdge(t, m, 0, nil, "(x -> p.z)[0]") + assertQueryOne(t, m, 0, 0, nil, "(x -> p.z)[0]") + }, + }, + { + name: "chain", + run: func(t testing.TB) { + m, err := compile(t, `a -> b -> c -> d`) + assert.Success(t, err) + assertQueryOne(t, m, 4, 3, nil, "") + + assertQueryOne(t, m, 0, 0, nil, "a") + assertQueryOne(t, m, 0, 0, nil, "b") + assertQueryOne(t, m, 0, 0, nil, "c") + assertQueryOne(t, m, 0, 0, nil, "d") + assertQueryOne(t, m, 0, 0, nil, "(a -> b)[0]") + assertQueryOne(t, m, 0, 0, nil, "(b -> c)[0]") + assertQueryOne(t, m, 0, 0, nil, "(c -> d)[0]") }, }, } runa(t, tca) -} - -func testCompileLayers(t *testing.T) { - t.Parallel() t.Run("errs", func(t *testing.T) { + t.Parallel() tca := []testCase{ { - name: "bad_edge/1", + name: "bad_edge", run: func(t testing.TB) { - _, err := compile(t, `layers.x -> layers.y`) - assert.ErrorString(t, err, `TestCompile/layer/errs/bad_edge/1.d2:1:1: cannot create edges between layers, scenarios or steps`) - }, - }, - { - name: "bad_edge/2", - run: func(t testing.TB) { - _, err := compile(t, `layers -> scenarios`) - assert.ErrorString(t, err, `TestCompile/layer/errs/bad_edge/2.d2:1:1: cannot create edges between layers, scenarios or steps`) - }, - }, - { - name: "bad_edge/3", - run: func(t testing.TB) { - _, err := compile(t, `layers.x.y -> steps.z.p`) - assert.ErrorString(t, err, `TestCompile/layer/errs/bad_edge/3.d2:1:1: cannot create edges between layers, scenarios or steps`) + _, err := compile(t, `(x -> y): { p -> q }`) + assert.ErrorString(t, err, `TestCompile/edges/errs/bad_edge.d2:1:13: cannot create edge inside edge`) }, }, } runa(t, tca) }) +} + +func testCompileLayers(t *testing.T) { + t.Parallel() tca := []testCase{ { name: "root", @@ -312,13 +298,119 @@ layers: { }`) assert.Success(t, err) - assertField(t, m, 7, 1, nil) - assertEdge(t, m, 0, nil, `(x -> y)[0]`) + assertQueryOne(t, m, 7, 1, nil, "") + assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) - assertField(t, m, 0, 0, nil, "x") - assertField(t, m, 0, 0, nil, "y") + assertQueryOne(t, m, 0, 0, nil, "x") + assertQueryOne(t, m, 0, 0, nil, "y") - assertField(t, m, 3, 0, nil, "layers", "bingo") + assertQueryOne(t, m, 3, 0, nil, "layers.bingo") + }, + }, + } + runa(t, tca) + t.Run("errs", func(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "bad_edge/1", + run: func(t testing.TB) { + _, err := compile(t, `layers.x -> layers.y`) + assert.ErrorString(t, err, `TestCompile/layers/errs/bad_edge/1.d2:1:1: cannot create edges between layers, scenarios or steps`) + }, + }, + { + name: "bad_edge/2", + run: func(t testing.TB) { + _, err := compile(t, `layers -> scenarios`) + assert.ErrorString(t, err, `TestCompile/layers/errs/bad_edge/2.d2:1:1: cannot create edges between layers, scenarios or steps`) + }, + }, + { + name: "bad_edge/3", + run: func(t testing.TB) { + _, err := compile(t, `layers.x.y -> steps.z.p`) + assert.ErrorString(t, err, `TestCompile/layers/errs/bad_edge/3.d2:1:1: cannot create edges between layers, scenarios or steps`) + }, + }, + } + runa(t, tca) + }) +} + +func testCompileScenarios(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "root", + run: func(t testing.TB) { + m, err := compile(t, `x -> y +scenarios: { + bingo: { p.q.z } + nuclear: { quiche } +}`) + assert.Success(t, err) + + assertQueryOne(t, m, 13, 3, nil, "") + + assertQueryOne(t, m, 0, 0, nil, "x") + assertQueryOne(t, m, 0, 0, nil, "y") + assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) + + assertQueryOne(t, m, 5, 1, nil, "scenarios.bingo") + assertQueryOne(t, m, 0, 0, nil, "scenarios.bingo.x") + assertQueryOne(t, m, 0, 0, nil, "scenarios.bingo.y") + assertQueryOne(t, m, 0, 0, nil, `scenarios.bingo.(x -> y)[0]`) + assertQueryOne(t, m, 2, 0, nil, "scenarios.bingo.p") + assertQueryOne(t, m, 1, 0, nil, "scenarios.bingo.p.q") + assertQueryOne(t, m, 0, 0, nil, "scenarios.bingo.p.q.z") + + assertQueryOne(t, m, 3, 1, nil, "scenarios.nuclear") + assertQueryOne(t, m, 0, 0, nil, "scenarios.nuclear.x") + assertQueryOne(t, m, 0, 0, nil, "scenarios.nuclear.y") + assertQueryOne(t, m, 0, 0, nil, `scenarios.nuclear.(x -> y)[0]`) + assertQueryOne(t, m, 0, 0, nil, "scenarios.nuclear.quiche") + }, + }, + } + runa(t, tca) +} + +func testCompileSteps(t *testing.T) { + t.Parallel() + tca := []testCase{ + { + name: "root", + run: func(t testing.TB) { + m, err := compile(t, `x -> y +steps: { + bingo: { p.q.z } + nuclear: { quiche } +}`) + assert.Success(t, err) + + assertQueryOne(t, m, 16, 3, nil, "") + + assertQueryOne(t, m, 0, 0, nil, "x") + assertQueryOne(t, m, 0, 0, nil, "y") + assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) + + assertQueryOne(t, m, 5, 1, nil, "steps.bingo") + assertQueryOne(t, m, 0, 0, nil, "steps.bingo.x") + assertQueryOne(t, m, 0, 0, nil, "steps.bingo.y") + assertQueryOne(t, m, 0, 0, nil, `steps.bingo.(x -> y)[0]`) + assertQueryOne(t, m, 2, 0, nil, "steps.bingo.p") + assertQueryOne(t, m, 1, 0, nil, "steps.bingo.p.q") + assertQueryOne(t, m, 0, 0, nil, "steps.bingo.p.q.z") + + assertQueryOne(t, m, 6, 1, nil, "steps.nuclear") + assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.x") + assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.y") + assertQueryOne(t, m, 0, 0, nil, `steps.nuclear.(x -> y)[0]`) + assertQueryOne(t, m, 2, 0, nil, "steps.nuclear.p") + assertQueryOne(t, m, 1, 0, nil, "steps.nuclear.p.q") + assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.p.q.z") + assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.quiche") }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 7e66343cf..16e2c0d1e 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -20,6 +20,8 @@ type Node interface { node() Copy(parent Node) Node Parent() Node + Primary() *Scalar + Map() *Map ast() d2ast.Node fmt.Stringer @@ -61,6 +63,23 @@ func (n *Edge) Parent() Node { return n.parent } func (n *Array) Parent() Node { return n.parent } func (n *Map) Parent() Node { return n.parent } +func (n *Scalar) Primary() *Scalar { return n } +func (n *Field) Primary() *Scalar { return n.Primary_ } +func (n *Edge) Primary() *Scalar { return n.Primary_ } +func (n *Array) Primary() *Scalar { return nil } +func (n *Map) Primary() *Scalar { return nil } + +func (n *Scalar) Map() *Map { return nil } +func (n *Field) Map() *Map { + if n.Composite == nil { + return nil + } + return n.Composite.Map() +} +func (n *Edge) Map() *Map { return n.Map_ } +func (n *Array) Map() *Map { return nil } +func (n *Map) Map() *Map { return n } + func (n *Scalar) value() {} func (n *Array) value() {} func (n *Map) value() {} @@ -94,7 +113,6 @@ func (s *Scalar) Equal(s2 *Scalar) bool { } } return s.Value.Type() == s2.Value.Type() && s.Value.ScalarString() == s2.Value.ScalarString() - } type Map struct { @@ -103,17 +121,19 @@ type Map struct { Edges []*Edge `json:"edges"` } +// Copy copies the map m without layers/scenarios/steps. func (m *Map) Copy(newp Node) Node { tmp := *m m = &tmp m.parent = newp - m.Fields = append([]*Field(nil), m.Fields...) - for i := range m.Fields { - if hasLayerKeywords(m.Fields[i].Name) != -1 { + pfields := m.Fields + m.Fields = make([]*Field, 0, len(pfields)) + for _, f := range pfields { + if hasLayerKeywords(f.Name) != -1 { continue } - m.Fields[i] = m.Fields[i].Copy(m).(*Field) + m.Fields = append(m.Fields, f.Copy(m).(*Field)) } m.Edges = append([]*Edge(nil), m.Edges...) for i := range m.Edges { @@ -130,9 +150,9 @@ func (m *Map) Root() bool { type LayerKind string const ( - LayerLayer LayerKind = "layer" + LayerLayer LayerKind = "layer" LayerScenario LayerKind = "scenario" - LayerStep LayerKind = "step" + LayerStep LayerKind = "step" ) // NodeLayerKind reports whether n represents the root of a layer. @@ -166,7 +186,7 @@ type Field struct { Name string `json:"name"` - Primary *Scalar `json:"primary,omitempty"` + Primary_ *Scalar `json:"primary,omitempty"` Composite Composite `json:"composite,omitempty"` References []FieldReference `json:"references,omitempty"` @@ -178,8 +198,8 @@ func (f *Field) Copy(newp Node) Node { f.parent = newp.(*Map) f.References = append([]FieldReference(nil), f.References...) - if f.Primary != nil { - f.Primary = f.Primary.Copy(f).(*Scalar) + if f.Primary_ != nil { + f.Primary_ = f.Primary_.Copy(f).(*Scalar) } if f.Composite != nil { f.Composite = f.Composite.Copy(f).(Composite) @@ -200,15 +220,16 @@ type EdgeID struct { func NewEdgeIDs(k *d2ast.Key) (eida []*EdgeID) { for _, ke := range k.Edges { - eida = append(eida, &EdgeID{ - SrcPath: d2format.KeyPath(ke.Src), + eid := &EdgeID{ + SrcPath: ke.Src.IDA(), SrcArrow: ke.SrcArrow == "<", - DstPath: d2format.KeyPath(ke.Dst), + DstPath: ke.Dst.IDA(), DstArrow: ke.DstArrow == ">", - }) - } - if k.EdgeIndex != nil && k.EdgeIndex.Int != nil { - eida[0].Index = k.EdgeIndex.Int + } + if k.EdgeIndex != nil { + eid.Index = k.EdgeIndex.Int + } + eida = append(eida, eid) } return eida } @@ -298,8 +319,8 @@ type Edge struct { ID *EdgeID `json:"edge_id"` - Primary *Scalar `json:"primary,omitempty"` - Map *Map `json:"map,omitempty"` + Primary_ *Scalar `json:"primary,omitempty"` + Map_ *Map `json:"map,omitempty"` References []EdgeReference `json:"references,omitempty"` } @@ -310,11 +331,11 @@ func (e *Edge) Copy(newp Node) Node { e.parent = newp.(*Map) e.References = append([]EdgeReference(nil), e.References...) - if e.Primary != nil { - e.Primary = e.Primary.Copy(e).(*Scalar) + if e.Primary_ != nil { + e.Primary_ = e.Primary_.Copy(e).(*Scalar) } - if e.Map != nil { - e.Map = e.Map.Copy(e).(*Map) + if e.Map_ != nil { + e.Map_ = e.Map_.Copy(e).(*Map) } return e } @@ -410,14 +431,13 @@ func (m *Map) FieldCountRecursive() int { } acc := len(m.Fields) for _, f := range m.Fields { - f_m := ChildMap(f) - if f_m != nil { - acc += f_m.FieldCountRecursive() + if f.Map() != nil { + acc += f.Map().FieldCountRecursive() } } for _, e := range m.Edges { - if e.Map != nil { - acc += e.Map.FieldCountRecursive() + if e.Map_ != nil { + acc += e.Map_.FieldCountRecursive() } } return acc @@ -429,14 +449,13 @@ func (m *Map) EdgeCountRecursive() int { } acc := len(m.Edges) for _, f := range m.Fields { - f_m := ChildMap(f) - if f_m != nil { - acc += f_m.EdgeCountRecursive() + if f.Map() != nil { + acc += f.Map().EdgeCountRecursive() } } for _, e := range m.Edges { - if e.Map != nil { - acc += e.Map.EdgeCountRecursive() + if e.Map_ != nil { + acc += e.Map_.EdgeCountRecursive() } } return acc @@ -471,9 +490,8 @@ func (m *Map) getField(ida []string) *Field { if len(rest) == 0 { return f } - f_m := ChildMap(f) - if f_m != nil { - return f_m.getField(rest) + if f.Map() != nil { + return f.Map().getField(rest) } } return nil @@ -522,14 +540,12 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, if _, ok := f.Composite.(*Array); ok { return nil, d2parser.Errorf(kp.Path[i].Unbox(), "cannot index into array") } - f_m := ChildMap(f) - if f_m == nil { - f_m = &Map{ + if f.Map() == nil { + f.Composite = &Map{ parent: f, } - f.Composite = f_m } - return f_m.ensureField(i+1, kp, refctx) + return f.Map().ensureField(i+1, kp, refctx) } f := &Field{ @@ -545,11 +561,10 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, if i+1 == len(kp.Path) { return f, nil } - f_m := &Map{ + f.Composite = &Map{ parent: f, } - f.Composite = f_m - return f_m.ensureField(i+1, kp, refctx) + return f.Map().ensureField(i+1, kp, refctx) } func (m *Map) DeleteField(ida []string) bool { @@ -568,9 +583,8 @@ func (m *Map) DeleteField(ida []string) bool { copy(m.Fields[i:], m.Fields[i+1:]) return true } - f_m := ChildMap(f) - if f_m != nil { - return f_m.DeleteField(rest) + if f.Map() != nil { + return f.Map().DeleteField(rest) } } return false @@ -587,9 +601,8 @@ func (m *Map) GetEdges(eid *EdgeID) []*Edge { if f == nil { return nil } - f_m := ChildMap(f) - if f_m != nil { - return f_m.GetEdges(eid) + if f.Map() != nil { + return f.Map().GetEdges(eid) } return nil } @@ -604,6 +617,10 @@ func (m *Map) GetEdges(eid *EdgeID) []*Edge { } func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { + if ParentEdge(m) != nil { + return nil, d2parser.Errorf(refctx.Edge, "cannot create edge inside edge") + } + eid, m, err := eid.resolveUnderscores(m) if err != nil { return nil, d2parser.Errorf(refctx.Edge, err.Error()) @@ -620,14 +637,12 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { if _, ok := f.Composite.(*Array); ok { return nil, d2parser.Errorf(refctx.Edge.Src, "cannot index into array") } - f_m := ChildMap(f) - if f_m == nil { - f_m = &Map{ + if f.Map() == nil { + f.Composite = &Map{ parent: f, } - f.Composite = f_m } - return f_m.CreateEdge(eid, refctx) + return f.Map().CreateEdge(eid, refctx) } ij := hasLayerKeywords(eid.SrcPath...) @@ -680,8 +695,8 @@ func (f *Field) ast() d2ast.Node { }, } - if f.Primary != nil { - k.Primary = d2ast.MakeValueBox(f.Primary.ast().(d2ast.Value)).ScalarBox() + if f.Primary_ != nil { + k.Primary = d2ast.MakeValueBox(f.Primary_.ast().(d2ast.Value)).ScalarBox() } if f.Composite != nil { k.Value = d2ast.MakeValueBox(f.Composite.ast().(d2ast.Value)) @@ -706,11 +721,11 @@ func (e *Edge) ast() d2ast.Node { Edges: []*d2ast.Edge{astEdge}, } - if e.Primary != nil { - k.Primary = d2ast.MakeValueBox(e.Primary.ast().(d2ast.Value)).ScalarBox() + if e.Primary_ != nil { + k.Primary = d2ast.MakeValueBox(e.Primary_.ast().(d2ast.Value)).ScalarBox() } - if e.Map != nil { - k.Value = d2ast.MakeValueBox(e.Map.ast().(*d2ast.Map)) + if e.Map_ != nil { + k.Value = d2ast.MakeValueBox(e.Map_.ast().(*d2ast.Map)) } return k @@ -761,41 +776,16 @@ func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext if i+1 == len(kp.Path) { return } - f_m := ChildMap(f) - if f_m != nil { - f_m.appendFieldReferences(i+1, kp, refctx) - } -} - -func ChildMap(n Node) *Map { - switch n := n.(type) { - case *Map: - return n - case *Field: - return ChildMap(n.Composite) - case *Edge: - return n.Map - default: - return nil - } -} - -func ToScalar(n Node) *Scalar { - switch n := n.(type) { - case *Field: - return n.Primary - case *Edge: - return n.Primary - default: - return nil + if f.Map() != nil { + f.Map().appendFieldReferences(i+1, kp, refctx) } } func ParentMap(n Node) *Map { for n.Parent() != nil { n = n.Parent() - if n_m, ok := n.(*Map); ok { - return n_m + if m, ok := n.(*Map); ok { + return m } } return nil @@ -804,15 +794,16 @@ func ParentMap(n Node) *Map { func ParentField(n Node) *Field { for n.Parent() != nil { n = n.Parent() - if n_f, ok := n.(*Field); ok { - return n_f + if f, ok := n.(*Field); ok { + return f } } return nil } -func ParentLayer(n Node) Node { +func ParentLayer(n Node) *Map { for { + // ParentMap and not ParentField so we get the root layer too. m := ParentMap(n) if m == nil { return nil @@ -824,6 +815,16 @@ func ParentLayer(n Node) Node { } } +func ParentEdge(n Node) *Edge { + for n.Parent() != nil { + n = n.Parent() + if e, ok := n.(*Edge); ok { + return e + } + } + return nil +} + func countUnderscores(p []string) int { var count int for _, el := range p { diff --git a/d2ir/d2ir_test.go b/d2ir/d2ir_test.go index 52cae5aad..cac84e7b3 100644 --- a/d2ir/d2ir_test.go +++ b/d2ir/d2ir_test.go @@ -27,7 +27,7 @@ func TestCopy(t *testing.T) { } m2 := &d2ir.Map{ Fields: []*d2ir.Field{ - {Primary: s}, + {Primary_: s}, }, } @@ -35,13 +35,13 @@ func TestCopy(t *testing.T) { f := &d2ir.Field{ Name: keyStr, - Primary: s, + Primary_: s, Composite: a, } e := &d2ir.Edge{ - Primary: s, - Map: m2, + Primary_: s, + Map_: m2, } m := &d2ir.Map{ @@ -54,7 +54,7 @@ func TestCopy(t *testing.T) { assert.Equal(t, m, m.Fields[0].Parent()) assert.Equal(t, keyStr, m.Fields[0].Name) - assert.Equal(t, m.Fields[0], m.Fields[0].Primary.Parent()) + assert.Equal(t, m.Fields[0], m.Fields[0].Primary_.Parent()) assert.Equal(t, m.Fields[0], m.Fields[0].Composite.(*d2ir.Array).Parent()) assert.Equal(t, @@ -63,9 +63,9 @@ func TestCopy(t *testing.T) { ) assert.Equal(t, m, m.Edges[0].Parent()) - assert.Equal(t, m.Edges[0], m.Edges[0].Primary.Parent()) - assert.Equal(t, m.Edges[0], m.Edges[0].Map.Parent()) + assert.Equal(t, m.Edges[0], m.Edges[0].Primary_.Parent()) + assert.Equal(t, m.Edges[0], m.Edges[0].Map_.Parent()) - assert.Equal(t, m.Edges[0].Map, m.Edges[0].Map.Fields[0].Parent()) - assert.Equal(t, m.Edges[0].Map.Fields[0], m.Edges[0].Map.Fields[0].Primary.Parent()) + assert.Equal(t, m.Edges[0].Map_, m.Edges[0].Map_.Fields[0].Parent()) + assert.Equal(t, m.Edges[0].Map_.Fields[0], m.Edges[0].Map_.Fields[0].Primary_.Parent()) } diff --git a/d2ir/merge.go b/d2ir/merge.go new file mode 100644 index 000000000..9d0834b4f --- /dev/null +++ b/d2ir/merge.go @@ -0,0 +1,45 @@ +package d2ir + +func Overlay(base, overlay *Map) *Map { + for _, of := range overlay.Fields { + bf := base.GetField(of.Name) + if bf == nil { + base.Fields = append(base.Fields, of.Copy(base).(*Field)) + continue + } + if of.Primary_ != nil { + bf.Primary_ = of.Primary_.Copy(bf).(*Scalar) + } + switch ofc := of.Composite.(type) { + case *Array: + bf.Composite = ofc.Copy(bf).(*Map) + case *Map: + if bf.Map() != nil { + bf.Composite = Overlay(bf.Map(), ofc) + } else { + bf.Composite = of.Composite.Copy(bf).(*Map) + } + } + } + + for _, oe := range overlay.Edges { + bea := base.GetEdges(oe.ID) + if len(bea) == 0 { + base.Edges = append(base.Edges, oe.Copy(base).(*Edge)) + continue + } + be := bea[0] + if oe.Primary_ != nil { + be.Primary_ = oe.Primary_.Copy(be).(*Scalar) + } + if oe.Map_ != nil { + if be.Map_ != nil { + be.Map_ = Overlay(be.Map(), oe.Map_) + } else { + be.Map_ = oe.Map_.Copy(be).(*Map) + } + } + } + + return base +} diff --git a/d2ir/query.go b/d2ir/query.go new file mode 100644 index 000000000..61b8d3b5c --- /dev/null +++ b/d2ir/query.go @@ -0,0 +1,61 @@ +package d2ir + +import ( + "fmt" + + "oss.terrastruct.com/d2/d2parser" +) + +// Query is only for tests and debugging. +func (m *Map) Query(idStr string) (na []Node, _ error) { + k, err := d2parser.ParseMapKey(idStr) + if err != nil { + return nil, err + } + + if k.Key != nil { + f := m.GetField(k.Key.IDA()...) + if f == nil { + return nil, nil + } + if len(k.Edges) == 0 { + na = append(na, f) + return na, nil + } + m = f.Map() + if m == nil { + return nil, nil + } + } + + eida := NewEdgeIDs(k) + for _, eid := range eida { + ea := m.GetEdges(eid) + for _, e := range ea { + if k.EdgeKey == nil { + na = append(na, e) + } else if e.Map_ != nil { + f := e.Map_.GetField(k.EdgeKey.IDA()...) + if f != nil { + na = append(na, f) + } + } + } + } + return na, nil +} + +func (m *Map) QueryOne(idStr string) (Node, error) { + na, err := m.Query(idStr) + if err != nil { + return nil, err + } + + if len(na) == 0 { + return nil, nil + } + if len(na) > 1 { + return nil, fmt.Errorf("expected only one query result but got: %#v", err) + } + return na[0], nil +} diff --git a/testdata/d2ir/TestCompile/edges/chain.exp.json b/testdata/d2ir/TestCompile/edges/chain.exp.json new file mode 100644 index 000000000..166b7da52 --- /dev/null +++ b/testdata/d2ir/TestCompile/edges/chain.exp.json @@ -0,0 +1,1652 @@ +{ + "fields": [ + { + "name": "a", + "references": [ + { + "string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "b", + "references": [ + { + "string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + }, + { + "string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "c", + "references": [ + { + "string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + }, + { + "string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "d", + "references": [ + { + "string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "a" + ], + "src_arrow": false, + "dst_path": [ + "b" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "b" + ], + "src_arrow": false, + "dst_path": [ + "c" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "c" + ], + "src_arrow": false, + "dst_path": [ + "d" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:16:16", + "edges": [ + { + "range": "TestCompile/edges/chain.d2,0:0:0-0:7:7", + "src": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:4:4-0:12:12", + "src": { + "range": "TestCompile/edges/chain.d2,0:4:4-0:7:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:5:5-0:6:6", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:16:16", + "src": { + "range": "TestCompile/edges/chain.d2,0:9:9-0:12:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:10:10-0:11:11", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/chain.d2,0:14:14-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/chain.d2,0:15:15-0:16:16", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] +} diff --git a/testdata/d2ir/TestCompile/fields/null.exp.json b/testdata/d2ir/TestCompile/fields/null.exp.json new file mode 100644 index 000000000..b5c954c20 --- /dev/null +++ b/testdata/d2ir/TestCompile/fields/null.exp.json @@ -0,0 +1,131 @@ +{ + "fields": [ + { + "name": "pq", + "primary": { + "value": { + "range": "TestCompile/fields/null.d2,1:4:11-1:8:15" + } + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", + "value": [ + { + "string": "pq", + "raw_string": "pq" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", + "value": [ + { + "string": "pq", + "raw_string": "pq" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/null.d2,0:0:0-0:6:6", + "key": { + "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/null.d2,0:0:0-0:2:2", + "value": [ + { + "string": "pq", + "raw_string": "pq" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/fields/null.d2,0:4:4-0:6:6", + "value": [ + { + "string": "pq", + "raw_string": "pq" + } + ] + } + } + }, + "edge": null + } + }, + { + "string": { + "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", + "value": [ + { + "string": "pq", + "raw_string": "pq" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", + "value": [ + { + "string": "pq", + "raw_string": "pq" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/null.d2,1:0:7-1:8:15", + "key": { + "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/null.d2,1:0:7-1:2:9", + "value": [ + { + "string": "pq", + "raw_string": "pq" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "null": { + "range": "TestCompile/fields/null.d2,1:4:11-1:8:15" + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/layer/root.exp.json b/testdata/d2ir/TestCompile/layers/root.exp.json similarity index 80% rename from testdata/d2ir/TestCompile/layer/root.exp.json rename to testdata/d2ir/TestCompile/layers/root.exp.json index e3e50b414..c2ff46f5c 100644 --- a/testdata/d2ir/TestCompile/layer/root.exp.json +++ b/testdata/d2ir/TestCompile/layers/root.exp.json @@ -5,7 +5,7 @@ "references": [ { "string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -14,11 +14,11 @@ ] }, "key_path": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "range": "TestCompile/layers/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -31,16 +31,16 @@ }, "context": { "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "edges": [ { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "range": "TestCompile/layers/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -53,11 +53,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "range": "TestCompile/layers/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -75,13 +75,13 @@ "value": {} }, "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "range": "TestCompile/layers/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -94,11 +94,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "range": "TestCompile/layers/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -120,7 +120,7 @@ "references": [ { "string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -129,11 +129,11 @@ ] }, "key_path": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "range": "TestCompile/layers/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -146,16 +146,16 @@ }, "context": { "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "edges": [ { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "range": "TestCompile/layers/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -168,11 +168,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "range": "TestCompile/layers/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -190,13 +190,13 @@ "value": {} }, "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "range": "TestCompile/layers/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -209,11 +209,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "range": "TestCompile/layers/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -251,7 +251,7 @@ "references": [ { "string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -260,11 +260,11 @@ ] }, "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -275,7 +275,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -286,7 +286,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -299,13 +299,13 @@ }, "context": { "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -316,7 +316,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -327,7 +327,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -352,7 +352,7 @@ "references": [ { "string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -361,11 +361,11 @@ ] }, "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -376,7 +376,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -387,7 +387,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -400,13 +400,13 @@ }, "context": { "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -417,7 +417,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -428,7 +428,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -453,7 +453,7 @@ "references": [ { "string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -462,11 +462,11 @@ ] }, "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -477,7 +477,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -488,7 +488,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -501,13 +501,13 @@ }, "context": { "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -518,7 +518,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -529,7 +529,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -554,7 +554,7 @@ "references": [ { "string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layers/root.d2,2:1:18-2:6:23", "value": [ { "string": "bingo", @@ -563,11 +563,11 @@ ] }, "key_path": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layers/root.d2,2:1:18-2:6:23", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layers/root.d2,2:1:18-2:6:23", "value": [ { "string": "bingo", @@ -580,13 +580,13 @@ }, "context": { "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", + "range": "TestCompile/layers/root.d2,2:1:18-2:17:34", "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layers/root.d2,2:1:18-2:6:23", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layers/root.d2,2:1:18-2:6:23", "value": [ { "string": "bingo", @@ -600,17 +600,17 @@ "primary": {}, "value": { "map": { - "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", + "range": "TestCompile/layers/root.d2,2:8:25-2:16:33", "nodes": [ { "map_key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -621,7 +621,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -632,7 +632,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -662,7 +662,7 @@ "references": [ { "string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "range": "TestCompile/layers/root.d2,1:0:7-1:6:13", "value": [ { "string": "layers", @@ -671,11 +671,11 @@ ] }, "key_path": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "range": "TestCompile/layers/root.d2,1:0:7-1:6:13", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "range": "TestCompile/layers/root.d2,1:0:7-1:6:13", "value": [ { "string": "layers", @@ -688,13 +688,13 @@ }, "context": { "key": { - "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", + "range": "TestCompile/layers/root.d2,1:0:7-3:1:36", "key": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "range": "TestCompile/layers/root.d2,1:0:7-1:6:13", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "range": "TestCompile/layers/root.d2,1:0:7-1:6:13", "value": [ { "string": "layers", @@ -708,17 +708,17 @@ "primary": {}, "value": { "map": { - "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", + "range": "TestCompile/layers/root.d2,1:8:15-3:0:35", "nodes": [ { "map_key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", + "range": "TestCompile/layers/root.d2,2:1:18-2:17:34", "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layers/root.d2,2:1:18-2:6:23", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layers/root.d2,2:1:18-2:6:23", "value": [ { "string": "bingo", @@ -732,17 +732,17 @@ "primary": {}, "value": { "map": { - "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", + "range": "TestCompile/layers/root.d2,2:8:25-2:16:33", "nodes": [ { "map_key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "range": "TestCompile/layers/root.d2,2:10:27-2:16:33", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "range": "TestCompile/layers/root.d2,2:10:27-2:11:28", "value": [ { "string": "p", @@ -753,7 +753,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "range": "TestCompile/layers/root.d2,2:12:29-2:13:30", "value": [ { "string": "q", @@ -764,7 +764,7 @@ }, { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "range": "TestCompile/layers/root.d2,2:14:31-2:15:32", "value": [ { "string": "z", @@ -811,16 +811,16 @@ { "context": { "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "edges": [ { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "range": "TestCompile/layers/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -833,11 +833,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "range": "TestCompile/layers/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", @@ -855,13 +855,13 @@ "value": {} }, "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "range": "TestCompile/layers/root.d2,0:0:0-0:6:6", "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "range": "TestCompile/layers/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "range": "TestCompile/layers/root.d2,0:0:0-0:1:1", "value": [ { "string": "x", @@ -874,11 +874,11 @@ }, "src_arrow": "", "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "range": "TestCompile/layers/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "range": "TestCompile/layers/root.d2,0:5:5-0:6:6", "value": [ { "string": "y", diff --git a/testdata/d2ir/TestCompile/scenarios/root.exp.json b/testdata/d2ir/TestCompile/scenarios/root.exp.json new file mode 100644 index 000000000..3e84f9996 --- /dev/null +++ b/testdata/d2ir/TestCompile/scenarios/root.exp.json @@ -0,0 +1,1759 @@ +{ + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "scenarios", + "composite": { + "fields": [ + { + "name": "bingo", + "composite": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:6:26", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:6:26", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:6:26", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:17:37", + "key": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:6:26", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:6:26", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/scenarios/root.d2,2:8:28-2:16:36", + "nodes": [ + { + "map_key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + }, + { + "name": "nuclear", + "composite": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "quiche", + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:18:56", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:19:57", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:18:56", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:19:57", + "key": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:19:57", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:18:56", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:8:46", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:8:46", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:8:46", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:20:58", + "key": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:8:46", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:8:46", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/scenarios/root.d2,3:10:48-3:19:57", + "nodes": [ + { + "map_key": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:19:57", + "key": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:19:57", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:18:56", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/scenarios/root.d2,1:0:7-1:9:16", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + }, + "key_path": { + "range": "TestCompile/scenarios/root.d2,1:0:7-1:9:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,1:0:7-1:9:16", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,1:0:7-4:1:60", + "key": { + "range": "TestCompile/scenarios/root.d2,1:0:7-1:9:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,1:0:7-1:9:16", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/scenarios/root.d2,1:11:18-4:0:59", + "nodes": [ + { + "map_key": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:17:37", + "key": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:6:26", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:1:21-2:6:26", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/scenarios/root.d2,2:8:28-2:16:36", + "nodes": [ + { + "map_key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "key": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:16:36", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:10:30-2:11:31", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:12:32-2:13:33", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,2:14:34-2:15:35", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:20:58", + "key": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:8:46", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,3:1:39-3:8:46", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/scenarios/root.d2,3:10:48-3:19:57", + "nodes": [ + { + "map_key": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:19:57", + "key": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:19:57", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,3:12:50-3:18:56", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/scenarios/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/scenarios/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] +} diff --git a/testdata/d2ir/TestCompile/steps/root.exp.json b/testdata/d2ir/TestCompile/steps/root.exp.json new file mode 100644 index 000000000..fc5a11b7d --- /dev/null +++ b/testdata/d2ir/TestCompile/steps/root.exp.json @@ -0,0 +1,2069 @@ +{ + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "steps", + "composite": { + "fields": [ + { + "name": "bingo", + "composite": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,2:1:17-2:6:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,2:1:17-2:17:33", + "key": { + "range": "TestCompile/steps/root.d2,2:1:17-2:6:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/root.d2,2:8:24-2:16:32", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + }, + { + "name": "nuclear", + "composite": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + }, + { + "name": "quiche", + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,3:12:46-3:18:52", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,3:12:46-3:19:53", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,3:12:46-3:18:52", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,3:12:46-3:19:53", + "key": { + "range": "TestCompile/steps/root.d2,3:12:46-3:19:53", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,3:12:46-3:18:52", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,3:1:35-3:8:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,3:1:35-3:20:54", + "key": { + "range": "TestCompile/steps/root.d2,3:1:35-3:8:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/root.d2,3:10:44-3:19:53", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/root.d2,3:12:46-3:19:53", + "key": { + "range": "TestCompile/steps/root.d2,3:12:46-3:19:53", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,3:12:46-3:18:52", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/root.d2,1:0:7-1:5:12", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/root.d2,1:0:7-1:5:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,1:0:7-1:5:12", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/root.d2,1:0:7-4:1:56", + "key": { + "range": "TestCompile/steps/root.d2,1:0:7-1:5:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,1:0:7-1:5:12", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/root.d2,1:7:14-4:0:55", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/root.d2,2:1:17-2:17:33", + "key": { + "range": "TestCompile/steps/root.d2,2:1:17-2:6:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/root.d2,2:8:24-2:16:32", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/root.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/steps/root.d2,3:1:35-3:20:54", + "key": { + "range": "TestCompile/steps/root.d2,3:1:35-3:8:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/root.d2,3:10:44-3:19:53", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/root.d2,3:12:46-3:19:53", + "key": { + "range": "TestCompile/steps/root.d2,3:12:46-3:19:53", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,3:12:46-3:18:52", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] +} From 4424a0f10e9b671aef3b138b1ce0f08127c6bbd8 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 07:20:21 -0800 Subject: [PATCH 29/60] d2ir: Fully implement scenarios/steps --- d2ir/compile_test.go | 164 +++++++++++++++++++++---------------------- d2ir/query.go | 9 +-- 2 files changed, 87 insertions(+), 86 deletions(-) diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 3b53971ee..9154c6280 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -59,7 +59,7 @@ func compile(t testing.TB, text string) (*d2ir.Map, error) { return m, nil } -func assertQueryOne(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, idStr string) d2ir.Node { +func assertQuery(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, idStr string) d2ir.Node { t.Helper() m := n.Map() @@ -67,7 +67,7 @@ func assertQueryOne(t testing.TB, n d2ir.Node, nfields, nedges int, primary inte if idStr != "" { var err error - n, err = m.QueryOne(idStr) + n, err = m.Query(idStr) assert.Success(t, err) assert.NotEqual(t, n, nil) @@ -126,9 +126,9 @@ func testCompileFields(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x`) assert.Success(t, err) - assertQueryOne(t, m, 1, 0, nil, "") + assertQuery(t, m, 1, 0, nil, "") - assertQueryOne(t, m, 0, 0, nil, "x") + assertQuery(t, m, 0, 0, nil, "x") }, }, { @@ -136,9 +136,9 @@ func testCompileFields(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x: yes`) assert.Success(t, err) - assertQueryOne(t, m, 1, 0, nil, "") + assertQuery(t, m, 1, 0, nil, "") - assertQueryOne(t, m, 0, 0, "yes", "x") + assertQuery(t, m, 0, 0, "yes", "x") }, }, { @@ -146,10 +146,10 @@ func testCompileFields(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x.y: yes`) assert.Success(t, err) - assertQueryOne(t, m, 2, 0, nil, "") + assertQuery(t, m, 2, 0, nil, "") - assertQueryOne(t, m, 1, 0, nil, "x") - assertQueryOne(t, m, 0, 0, "yes", "x.y") + assertQuery(t, m, 1, 0, nil, "x") + assertQuery(t, m, 0, 0, "yes", "x.y") }, }, { @@ -157,9 +157,9 @@ func testCompileFields(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x: [1;2;3;4]`) assert.Success(t, err) - assertQueryOne(t, m, 1, 0, nil, "") + assertQuery(t, m, 1, 0, nil, "") - f := assertQueryOne(t, m, 0, 0, nil, "x").(*d2ir.Field) + f := assertQuery(t, m, 0, 0, nil, "x").(*d2ir.Field) assert.String(t, `[1; 2; 3; 4]`, f.Composite.String()) }, }, @@ -169,11 +169,11 @@ func testCompileFields(t *testing.T) { m, err := compile(t, `pq: pq pq: null`) assert.Success(t, err) - assertQueryOne(t, m, 1, 0, nil, "") + assertQuery(t, m, 1, 0, nil, "") // null doesn't delete pq from *Map so that for language tooling // we maintain the references. // Instead d2compiler will ensure it doesn't get rendered. - assertQueryOne(t, m, 0, 0, nil, "pq") + assertQuery(t, m, 0, 0, nil, "pq") }, }, } @@ -186,10 +186,10 @@ pq: null`) run: func(t testing.TB) { m, err := compile(t, `x: yes { pqrs }`) assert.Success(t, err) - assertQueryOne(t, m, 2, 0, nil, "") + assertQuery(t, m, 2, 0, nil, "") - assertQueryOne(t, m, 1, 0, "yes", "x") - assertQueryOne(t, m, 0, 0, nil, "x.pqrs") + assertQuery(t, m, 1, 0, "yes", "x") + assertQuery(t, m, 0, 0, nil, "x.pqrs") }, }, { @@ -197,11 +197,11 @@ pq: null`) run: func(t testing.TB) { m, err := compile(t, `x.y: yes { pqrs }`) assert.Success(t, err) - assertQueryOne(t, m, 3, 0, nil, "") + assertQuery(t, m, 3, 0, nil, "") - assertQueryOne(t, m, 2, 0, nil, "x") - assertQueryOne(t, m, 1, 0, "yes", "x.y") - assertQueryOne(t, m, 0, 0, nil, "x.y.pqrs") + assertQuery(t, m, 2, 0, nil, "x") + assertQuery(t, m, 1, 0, "yes", "x.y") + assertQuery(t, m, 0, 0, nil, "x.y.pqrs") }, }, } @@ -217,11 +217,11 @@ func testCompileEdges(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x -> y`) assert.Success(t, err) - assertQueryOne(t, m, 2, 1, nil, "") - assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) + assertQuery(t, m, 2, 1, nil, "") + assertQuery(t, m, 0, 0, nil, `(x -> y)[0]`) - assertQueryOne(t, m, 0, 0, nil, "x") - assertQueryOne(t, m, 0, 0, nil, "y") + assertQuery(t, m, 0, 0, nil, "x") + assertQuery(t, m, 0, 0, nil, "y") }, }, { @@ -229,15 +229,15 @@ func testCompileEdges(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `x.y -> z.p`) assert.Success(t, err) - assertQueryOne(t, m, 4, 1, nil, "") + assertQuery(t, m, 4, 1, nil, "") - assertQueryOne(t, m, 1, 0, nil, "x") - assertQueryOne(t, m, 0, 0, nil, "x.y") + assertQuery(t, m, 1, 0, nil, "x") + assertQuery(t, m, 0, 0, nil, "x.y") - assertQueryOne(t, m, 1, 0, nil, "z") - assertQueryOne(t, m, 0, 0, nil, "z.p") + assertQuery(t, m, 1, 0, nil, "z") + assertQuery(t, m, 0, 0, nil, "z.p") - assertQueryOne(t, m, 0, 0, nil, "(x.y -> z.p)[0]") + assertQuery(t, m, 0, 0, nil, "(x.y -> z.p)[0]") }, }, { @@ -245,12 +245,12 @@ func testCompileEdges(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `p: { _.x -> z }`) assert.Success(t, err) - assertQueryOne(t, m, 3, 1, nil, "") + assertQuery(t, m, 3, 1, nil, "") - assertQueryOne(t, m, 0, 0, nil, "x") - assertQueryOne(t, m, 1, 0, nil, "p") + assertQuery(t, m, 0, 0, nil, "x") + assertQuery(t, m, 1, 0, nil, "p") - assertQueryOne(t, m, 0, 0, nil, "(x -> p.z)[0]") + assertQuery(t, m, 0, 0, nil, "(x -> p.z)[0]") }, }, { @@ -258,15 +258,15 @@ func testCompileEdges(t *testing.T) { run: func(t testing.TB) { m, err := compile(t, `a -> b -> c -> d`) assert.Success(t, err) - assertQueryOne(t, m, 4, 3, nil, "") + assertQuery(t, m, 4, 3, nil, "") - assertQueryOne(t, m, 0, 0, nil, "a") - assertQueryOne(t, m, 0, 0, nil, "b") - assertQueryOne(t, m, 0, 0, nil, "c") - assertQueryOne(t, m, 0, 0, nil, "d") - assertQueryOne(t, m, 0, 0, nil, "(a -> b)[0]") - assertQueryOne(t, m, 0, 0, nil, "(b -> c)[0]") - assertQueryOne(t, m, 0, 0, nil, "(c -> d)[0]") + assertQuery(t, m, 0, 0, nil, "a") + assertQuery(t, m, 0, 0, nil, "b") + assertQuery(t, m, 0, 0, nil, "c") + assertQuery(t, m, 0, 0, nil, "d") + assertQuery(t, m, 0, 0, nil, "(a -> b)[0]") + assertQuery(t, m, 0, 0, nil, "(b -> c)[0]") + assertQuery(t, m, 0, 0, nil, "(c -> d)[0]") }, }, } @@ -298,13 +298,13 @@ layers: { }`) assert.Success(t, err) - assertQueryOne(t, m, 7, 1, nil, "") - assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) + assertQuery(t, m, 7, 1, nil, "") + assertQuery(t, m, 0, 0, nil, `(x -> y)[0]`) - assertQueryOne(t, m, 0, 0, nil, "x") - assertQueryOne(t, m, 0, 0, nil, "y") + assertQuery(t, m, 0, 0, nil, "x") + assertQuery(t, m, 0, 0, nil, "y") - assertQueryOne(t, m, 3, 0, nil, "layers.bingo") + assertQuery(t, m, 3, 0, nil, "layers.bingo") }, }, } @@ -351,25 +351,25 @@ scenarios: { }`) assert.Success(t, err) - assertQueryOne(t, m, 13, 3, nil, "") + assertQuery(t, m, 13, 3, nil, "") - assertQueryOne(t, m, 0, 0, nil, "x") - assertQueryOne(t, m, 0, 0, nil, "y") - assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) + assertQuery(t, m, 0, 0, nil, "x") + assertQuery(t, m, 0, 0, nil, "y") + assertQuery(t, m, 0, 0, nil, `(x -> y)[0]`) - assertQueryOne(t, m, 5, 1, nil, "scenarios.bingo") - assertQueryOne(t, m, 0, 0, nil, "scenarios.bingo.x") - assertQueryOne(t, m, 0, 0, nil, "scenarios.bingo.y") - assertQueryOne(t, m, 0, 0, nil, `scenarios.bingo.(x -> y)[0]`) - assertQueryOne(t, m, 2, 0, nil, "scenarios.bingo.p") - assertQueryOne(t, m, 1, 0, nil, "scenarios.bingo.p.q") - assertQueryOne(t, m, 0, 0, nil, "scenarios.bingo.p.q.z") + assertQuery(t, m, 5, 1, nil, "scenarios.bingo") + assertQuery(t, m, 0, 0, nil, "scenarios.bingo.x") + assertQuery(t, m, 0, 0, nil, "scenarios.bingo.y") + assertQuery(t, m, 0, 0, nil, `scenarios.bingo.(x -> y)[0]`) + assertQuery(t, m, 2, 0, nil, "scenarios.bingo.p") + assertQuery(t, m, 1, 0, nil, "scenarios.bingo.p.q") + assertQuery(t, m, 0, 0, nil, "scenarios.bingo.p.q.z") - assertQueryOne(t, m, 3, 1, nil, "scenarios.nuclear") - assertQueryOne(t, m, 0, 0, nil, "scenarios.nuclear.x") - assertQueryOne(t, m, 0, 0, nil, "scenarios.nuclear.y") - assertQueryOne(t, m, 0, 0, nil, `scenarios.nuclear.(x -> y)[0]`) - assertQueryOne(t, m, 0, 0, nil, "scenarios.nuclear.quiche") + assertQuery(t, m, 3, 1, nil, "scenarios.nuclear") + assertQuery(t, m, 0, 0, nil, "scenarios.nuclear.x") + assertQuery(t, m, 0, 0, nil, "scenarios.nuclear.y") + assertQuery(t, m, 0, 0, nil, `scenarios.nuclear.(x -> y)[0]`) + assertQuery(t, m, 0, 0, nil, "scenarios.nuclear.quiche") }, }, } @@ -389,28 +389,28 @@ steps: { }`) assert.Success(t, err) - assertQueryOne(t, m, 16, 3, nil, "") + assertQuery(t, m, 16, 3, nil, "") - assertQueryOne(t, m, 0, 0, nil, "x") - assertQueryOne(t, m, 0, 0, nil, "y") - assertQueryOne(t, m, 0, 0, nil, `(x -> y)[0]`) + assertQuery(t, m, 0, 0, nil, "x") + assertQuery(t, m, 0, 0, nil, "y") + assertQuery(t, m, 0, 0, nil, `(x -> y)[0]`) - assertQueryOne(t, m, 5, 1, nil, "steps.bingo") - assertQueryOne(t, m, 0, 0, nil, "steps.bingo.x") - assertQueryOne(t, m, 0, 0, nil, "steps.bingo.y") - assertQueryOne(t, m, 0, 0, nil, `steps.bingo.(x -> y)[0]`) - assertQueryOne(t, m, 2, 0, nil, "steps.bingo.p") - assertQueryOne(t, m, 1, 0, nil, "steps.bingo.p.q") - assertQueryOne(t, m, 0, 0, nil, "steps.bingo.p.q.z") + assertQuery(t, m, 5, 1, nil, "steps.bingo") + assertQuery(t, m, 0, 0, nil, "steps.bingo.x") + assertQuery(t, m, 0, 0, nil, "steps.bingo.y") + assertQuery(t, m, 0, 0, nil, `steps.bingo.(x -> y)[0]`) + assertQuery(t, m, 2, 0, nil, "steps.bingo.p") + assertQuery(t, m, 1, 0, nil, "steps.bingo.p.q") + assertQuery(t, m, 0, 0, nil, "steps.bingo.p.q.z") - assertQueryOne(t, m, 6, 1, nil, "steps.nuclear") - assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.x") - assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.y") - assertQueryOne(t, m, 0, 0, nil, `steps.nuclear.(x -> y)[0]`) - assertQueryOne(t, m, 2, 0, nil, "steps.nuclear.p") - assertQueryOne(t, m, 1, 0, nil, "steps.nuclear.p.q") - assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.p.q.z") - assertQueryOne(t, m, 0, 0, nil, "steps.nuclear.quiche") + assertQuery(t, m, 6, 1, nil, "steps.nuclear") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.x") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.y") + assertQuery(t, m, 0, 0, nil, `steps.nuclear.(x -> y)[0]`) + assertQuery(t, m, 2, 0, nil, "steps.nuclear.p") + assertQuery(t, m, 1, 0, nil, "steps.nuclear.p.q") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.p.q.z") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche") }, }, } diff --git a/d2ir/query.go b/d2ir/query.go index 61b8d3b5c..e70ad88df 100644 --- a/d2ir/query.go +++ b/d2ir/query.go @@ -6,8 +6,8 @@ import ( "oss.terrastruct.com/d2/d2parser" ) -// Query is only for tests and debugging. -func (m *Map) Query(idStr string) (na []Node, _ error) { +// QueryAll is only for tests and debugging. +func (m *Map) QueryAll(idStr string) (na []Node, _ error) { k, err := d2parser.ParseMapKey(idStr) if err != nil { return nil, err @@ -45,8 +45,9 @@ func (m *Map) Query(idStr string) (na []Node, _ error) { return na, nil } -func (m *Map) QueryOne(idStr string) (Node, error) { - na, err := m.Query(idStr) +// Query is only for tests and debugging. +func (m *Map) Query(idStr string) (Node, error) { + na, err := m.QueryAll(idStr) if err != nil { return nil, err } From 9d0c73cef2e51da0565e09cce2b25b187cad0029 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 07:39:09 -0800 Subject: [PATCH 30/60] d2ast: Make null ScalarString empty string So people know it's special at least until I fix d2compiler. --- d2ast/d2ast.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 09a00e63e..bd4373f76 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -404,7 +404,7 @@ func (s *SingleQuotedString) scalar() {} func (s *BlockString) scalar() {} // TODO: mistake, move into parse.go -func (n *Null) ScalarString() string { return n.Type() } +func (n *Null) ScalarString() string { return "" } func (b *Boolean) ScalarString() string { return strconv.FormatBool(b.Value) } func (n *Number) ScalarString() string { return n.Raw } func (s *UnquotedString) ScalarString() string { From 26a72e3e0c7c812ea89aae5b8392356d0d603774 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 07:44:34 -0800 Subject: [PATCH 31/60] d2ir: Add recursive scenario/step test --- d2ir/compile.go | 4 ++++ d2ir/compile_test.go | 51 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/d2ir/compile.go b/d2ir/compile.go index e5ca7baf1..69660b3a9 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -43,6 +43,8 @@ func (c *compiler) compileScenarios(m *Map) { } base := m.Copy(sf).(*Map) sf.Composite = Overlay(base, sf.Map()) + c.compileScenarios(sf.Map() + c.compileSteps(sf.Map() } } @@ -69,6 +71,8 @@ func (c *compiler) compileSteps(m *Map) { base = steps.Fields[i-1].Map().Copy(sf).(*Map) } sf.Composite = Overlay(base, sf.Map()) + c.compileScenarios(sf.Map() + c.compileSteps(sf.Map() } } diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 9154c6280..a3b5ec53e 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -413,6 +413,57 @@ steps: { assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche") }, }, + { + name: "recursive", + run: func(t testing.TB) { + m, err := compile(t, `x -> y +steps: { + bingo: { p.q.z } + nuclear: { + quiche + scenarios: { + bavarian: { + perseverance + } + } + } +}`) + assert.Success(t, err) + + assertQuery(t, m, 16, 3, nil, "") + + assertQuery(t, m, 0, 0, nil, "x") + assertQuery(t, m, 0, 0, nil, "y") + assertQuery(t, m, 0, 0, nil, `(x -> y)[0]`) + + assertQuery(t, m, 5, 1, nil, "steps.bingo") + assertQuery(t, m, 0, 0, nil, "steps.bingo.x") + assertQuery(t, m, 0, 0, nil, "steps.bingo.y") + assertQuery(t, m, 0, 0, nil, `steps.bingo.(x -> y)[0]`) + assertQuery(t, m, 2, 0, nil, "steps.bingo.p") + assertQuery(t, m, 1, 0, nil, "steps.bingo.p.q") + assertQuery(t, m, 0, 0, nil, "steps.bingo.p.q.z") + + assertQuery(t, m, 6, 1, nil, "steps.nuclear") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.x") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.y") + assertQuery(t, m, 0, 0, nil, `steps.nuclear.(x -> y)[0]`) + assertQuery(t, m, 2, 0, nil, "steps.nuclear.p") + assertQuery(t, m, 1, 0, nil, "steps.nuclear.p.q") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.p.q.z") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche") + + assertQuery(t, m, 6, 1, nil, "steps.nuclear.scenarios.bavarian") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.x") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.y") + assertQuery(t, m, 0, 0, nil, `steps.nuclear.scenarios.bavarian.(x -> y)[0]`) + assertQuery(t, m, 2, 0, nil, "steps.nuclear.scenarios.bavarian.p") + assertQuery(t, m, 1, 0, nil, "steps.nuclear.scenarios.bavarian.p.q") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.p.q.z") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.quiche") + assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.perseverance") + }, + }, } runa(t, tca) } From ece34aaf018f76aceae6eda30ea2b829f4b0e6cb Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 18 Jan 2023 07:47:42 -0800 Subject: [PATCH 32/60] d2ir: Add recursive scenario/step test --- d2ir/compile.go | 8 +- d2ir/compile_test.go | 6 +- .../d2ir/TestCompile/steps/recursive.exp.json | 3193 +++++++++++++++++ 3 files changed, 3200 insertions(+), 7 deletions(-) create mode 100644 testdata/d2ir/TestCompile/steps/recursive.exp.json diff --git a/d2ir/compile.go b/d2ir/compile.go index 69660b3a9..024bfd594 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -43,8 +43,8 @@ func (c *compiler) compileScenarios(m *Map) { } base := m.Copy(sf).(*Map) sf.Composite = Overlay(base, sf.Map()) - c.compileScenarios(sf.Map() - c.compileSteps(sf.Map() + c.compileScenarios(sf.Map()) + c.compileSteps(sf.Map()) } } @@ -71,8 +71,8 @@ func (c *compiler) compileSteps(m *Map) { base = steps.Fields[i-1].Map().Copy(sf).(*Map) } sf.Composite = Overlay(base, sf.Map()) - c.compileScenarios(sf.Map() - c.compileSteps(sf.Map() + c.compileScenarios(sf.Map()) + c.compileSteps(sf.Map()) } } diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index a3b5ec53e..9841c7c03 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -430,7 +430,7 @@ steps: { }`) assert.Success(t, err) - assertQuery(t, m, 16, 3, nil, "") + assertQuery(t, m, 25, 4, nil, "") assertQuery(t, m, 0, 0, nil, "x") assertQuery(t, m, 0, 0, nil, "y") @@ -444,7 +444,7 @@ steps: { assertQuery(t, m, 1, 0, nil, "steps.bingo.p.q") assertQuery(t, m, 0, 0, nil, "steps.bingo.p.q.z") - assertQuery(t, m, 6, 1, nil, "steps.nuclear") + assertQuery(t, m, 15, 2, nil, "steps.nuclear") assertQuery(t, m, 0, 0, nil, "steps.nuclear.x") assertQuery(t, m, 0, 0, nil, "steps.nuclear.y") assertQuery(t, m, 0, 0, nil, `steps.nuclear.(x -> y)[0]`) @@ -453,7 +453,7 @@ steps: { assertQuery(t, m, 0, 0, nil, "steps.nuclear.p.q.z") assertQuery(t, m, 0, 0, nil, "steps.nuclear.quiche") - assertQuery(t, m, 6, 1, nil, "steps.nuclear.scenarios.bavarian") + assertQuery(t, m, 7, 1, nil, "steps.nuclear.scenarios.bavarian") assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.x") assertQuery(t, m, 0, 0, nil, "steps.nuclear.scenarios.bavarian.y") assertQuery(t, m, 0, 0, nil, `steps.nuclear.scenarios.bavarian.(x -> y)[0]`) diff --git a/testdata/d2ir/TestCompile/steps/recursive.exp.json b/testdata/d2ir/TestCompile/steps/recursive.exp.json new file mode 100644 index 000000000..dd0c42d9d --- /dev/null +++ b/testdata/d2ir/TestCompile/steps/recursive.exp.json @@ -0,0 +1,3193 @@ +{ + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "steps", + "composite": { + "fields": [ + { + "name": "bingo", + "composite": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:6:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:17:33", + "key": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:6:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,2:8:24-2:16:32", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + }, + { + "name": "nuclear", + "composite": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + }, + { + "name": "quiche", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + }, + { + "name": "scenarios", + "composite": { + "fields": [ + { + "name": "bavarian", + "composite": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + }, + { + "name": "quiche", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + }, + { + "name": "perseverance", + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "value": [ + { + "string": "perseverance", + "raw_string": "perseverance" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "value": [ + { + "string": "perseverance", + "raw_string": "perseverance" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "value": [ + { + "string": "perseverance", + "raw_string": "perseverance" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "value": [ + { + "string": "bavarian", + "raw_string": "bavarian" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "value": [ + { + "string": "bavarian", + "raw_string": "bavarian" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-8:4:106", + "key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "value": [ + { + "string": "bavarian", + "raw_string": "bavarian" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,6:13:83-8:3:105", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "value": [ + { + "string": "perseverance", + "raw_string": "perseverance" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,5:2:57-9:3:110", + "key": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,5:13:68-9:2:109", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-8:4:106", + "key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "value": [ + { + "string": "bavarian", + "raw_string": "bavarian" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,6:13:83-8:3:105", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "value": [ + { + "string": "perseverance", + "raw_string": "perseverance" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,3:1:35-3:8:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,3:1:35-10:2:113", + "key": { + "range": "TestCompile/steps/recursive.d2,3:1:35-3:8:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,3:10:44-10:1:112", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,5:2:57-9:3:110", + "key": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,5:13:68-9:2:109", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-8:4:106", + "key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "value": [ + { + "string": "bavarian", + "raw_string": "bavarian" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,6:13:83-8:3:105", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "value": [ + { + "string": "perseverance", + "raw_string": "perseverance" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/steps/recursive.d2,1:0:7-1:5:12", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + }, + "key_path": { + "range": "TestCompile/steps/recursive.d2,1:0:7-1:5:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,1:0:7-1:5:12", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,1:0:7-11:1:115", + "key": { + "range": "TestCompile/steps/recursive.d2,1:0:7-1:5:12", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,1:0:7-1:5:12", + "value": [ + { + "string": "steps", + "raw_string": "steps" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,1:7:14-11:0:114", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:17:33", + "key": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:6:22", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:1:17-2:6:22", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,2:8:24-2:16:32", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "key": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:16:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:10:26-2:11:27", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:12:28-2:13:29", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,2:14:30-2:15:31", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,3:1:35-10:2:113", + "key": { + "range": "TestCompile/steps/recursive.d2,3:1:35-3:8:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,3:1:35-3:8:42", + "value": [ + { + "string": "nuclear", + "raw_string": "nuclear" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,3:10:44-10:1:112", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "key": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,4:2:48-4:8:54", + "value": [ + { + "string": "quiche", + "raw_string": "quiche" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,5:2:57-9:3:110", + "key": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,5:2:57-5:11:66", + "value": [ + { + "string": "scenarios", + "raw_string": "scenarios" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,5:13:68-9:2:109", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-8:4:106", + "key": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,6:3:73-6:11:81", + "value": [ + { + "string": "bavarian", + "raw_string": "bavarian" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/steps/recursive.d2,6:13:83-8:3:105", + "nodes": [ + { + "map_key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "key": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,7:4:89-7:16:101", + "value": [ + { + "string": "perseverance", + "raw_string": "perseverance" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/steps/recursive.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/steps/recursive.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ] +} From bd7b5c3fc0fa7e124f14694e6333c1ab8b796abf Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 21 Jan 2023 18:52:33 -0800 Subject: [PATCH 33/60] d2ir: Add Map.CopyBase for better performance --- d2ir/compile.go | 6 ++--- d2ir/d2ir.go | 70 +++++++++++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/d2ir/compile.go b/d2ir/compile.go index 024bfd594..52e77dbd3 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -41,7 +41,7 @@ func (c *compiler) compileScenarios(m *Map) { parent: sf, } } - base := m.Copy(sf).(*Map) + base := m.CopyBase(sf) sf.Composite = Overlay(base, sf.Map()) c.compileScenarios(sf.Map()) c.compileSteps(sf.Map()) @@ -66,9 +66,9 @@ func (c *compiler) compileSteps(m *Map) { var base *Map if i == 0 { - base = m.Copy(sf).(*Map) + base = m.CopyBase(sf) } else { - base = steps.Fields[i-1].Map().Copy(sf).(*Map) + base = steps.Fields[i-1].Map().CopyBase(sf) } sf.Composite = Overlay(base, sf.Map()) c.compileScenarios(sf.Map()) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 16e2c0d1e..2d707d111 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -23,7 +23,7 @@ type Node interface { Primary() *Scalar Map() *Map - ast() d2ast.Node + AST() d2ast.Node fmt.Stringer } @@ -87,11 +87,11 @@ func (n *Map) value() {} func (n *Array) composite() {} func (n *Map) composite() {} -func (n *Scalar) String() string { return d2format.Format(n.ast()) } -func (n *Field) String() string { return d2format.Format(n.ast()) } -func (n *Edge) String() string { return d2format.Format(n.ast()) } -func (n *Array) String() string { return d2format.Format(n.ast()) } -func (n *Map) String() string { return d2format.Format(n.ast()) } +func (n *Scalar) String() string { return d2format.Format(n.AST()) } +func (n *Field) String() string { return d2format.Format(n.AST()) } +func (n *Edge) String() string { return d2format.Format(n.AST()) } +func (n *Array) String() string { return d2format.Format(n.AST()) } +func (n *Map) String() string { return d2format.Format(n.AST()) } type Scalar struct { parent Node @@ -121,7 +121,6 @@ type Map struct { Edges []*Edge `json:"edges"` } -// Copy copies the map m without layers/scenarios/steps. func (m *Map) Copy(newp Node) Node { tmp := *m m = &tmp @@ -130,9 +129,6 @@ func (m *Map) Copy(newp Node) Node { pfields := m.Fields m.Fields = make([]*Field, 0, len(pfields)) for _, f := range pfields { - if hasLayerKeywords(f.Name) != -1 { - continue - } m.Fields = append(m.Fields, f.Copy(m).(*Field)) } m.Edges = append([]*Edge(nil), m.Edges...) @@ -142,6 +138,24 @@ func (m *Map) Copy(newp Node) Node { return m } +// CopyBase copies the map m without layers/scenarios/steps. +func (m *Map) CopyBase(newp Node) *Map { + layers := m.DeleteField("layers") + scenarios := m.DeleteField("scenarios") + steps := m.DeleteField("steps") + m2 := m.Copy(newp).(*Map) + if layers != nil { + m.Fields = append(m.Fields, layers) + } + if scenarios != nil { + m.Fields = append(m.Fields, scenarios) + } + if steps != nil { + m.Fields = append(m.Fields, steps) + } + return m2 +} + // Root reports whether the Map is the root of the D2 tree. func (m *Map) Root() bool { return m.parent == nil @@ -567,9 +581,9 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, return f.Map().ensureField(i+1, kp, refctx) } -func (m *Map) DeleteField(ida []string) bool { +func (m *Map) DeleteField(ida ...string) *Field { if len(ida) == 0 { - return false + return nil } s := ida[0] @@ -580,14 +594,14 @@ func (m *Map) DeleteField(ida []string) bool { continue } if len(rest) == 0 { - copy(m.Fields[i:], m.Fields[i+1:]) - return true + m.Fields = append(m.Fields[:i], m.Fields[i+1:]...) + return f } if f.Map() != nil { - return f.Map().DeleteField(rest) + return f.Map().DeleteField(rest...) } } - return false + return nil } func (m *Map) GetEdges(eid *EdgeID) []*Edge { @@ -682,11 +696,11 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { return e, nil } -func (s *Scalar) ast() d2ast.Node { +func (s *Scalar) AST() d2ast.Node { return s.Value } -func (f *Field) ast() d2ast.Node { +func (f *Field) AST() d2ast.Node { k := &d2ast.Key{ Key: &d2ast.KeyPath{ Path: []*d2ast.StringBox{ @@ -696,16 +710,16 @@ func (f *Field) ast() d2ast.Node { } if f.Primary_ != nil { - k.Primary = d2ast.MakeValueBox(f.Primary_.ast().(d2ast.Value)).ScalarBox() + k.Primary = d2ast.MakeValueBox(f.Primary_.AST().(d2ast.Value)).ScalarBox() } if f.Composite != nil { - k.Value = d2ast.MakeValueBox(f.Composite.ast().(d2ast.Value)) + k.Value = d2ast.MakeValueBox(f.Composite.AST().(d2ast.Value)) } return k } -func (e *Edge) ast() d2ast.Node { +func (e *Edge) AST() d2ast.Node { astEdge := &d2ast.Edge{} astEdge.Src = d2ast.MakeKeyPath(e.ID.SrcPath) @@ -722,27 +736,27 @@ func (e *Edge) ast() d2ast.Node { } if e.Primary_ != nil { - k.Primary = d2ast.MakeValueBox(e.Primary_.ast().(d2ast.Value)).ScalarBox() + k.Primary = d2ast.MakeValueBox(e.Primary_.AST().(d2ast.Value)).ScalarBox() } if e.Map_ != nil { - k.Value = d2ast.MakeValueBox(e.Map_.ast().(*d2ast.Map)) + k.Value = d2ast.MakeValueBox(e.Map_.AST().(*d2ast.Map)) } return k } -func (a *Array) ast() d2ast.Node { +func (a *Array) AST() d2ast.Node { if a == nil { return nil } astArray := &d2ast.Array{} for _, av := range a.Values { - astArray.Nodes = append(astArray.Nodes, d2ast.MakeArrayNodeBox(av.ast().(d2ast.ArrayNode))) + astArray.Nodes = append(astArray.Nodes, d2ast.MakeArrayNodeBox(av.AST().(d2ast.ArrayNode))) } return astArray } -func (m *Map) ast() d2ast.Node { +func (m *Map) AST() d2ast.Node { if m == nil { return nil } @@ -753,10 +767,10 @@ func (m *Map) ast() d2ast.Node { astMap.Range = d2ast.MakeRange(",1:0:0-2:0:0") } for _, f := range m.Fields { - astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(f.ast().(d2ast.MapNode))) + astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(f.AST().(d2ast.MapNode))) } for _, e := range m.Edges { - astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(e.ast().(d2ast.MapNode))) + astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(e.AST().(d2ast.MapNode))) } return astMap } From 6543bf217ade2f6bd4d4757b89451c48d79f6cb3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 21 Jan 2023 23:49:07 -0800 Subject: [PATCH 34/60] d2compiler: Integrate d2ir (wip) --- d2compiler/compile.go | 956 +++++++++++++------------------------ d2compiler/compile_test.go | 4 +- 2 files changed, 325 insertions(+), 635 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 773cbae08..fa3827d87 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -1,7 +1,6 @@ package d2compiler import ( - "errors" "fmt" "io" "net/url" @@ -13,6 +12,7 @@ import ( "oss.terrastruct.com/d2/d2ast" "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2graph" + "oss.terrastruct.com/d2/d2ir" "oss.terrastruct.com/d2/d2parser" "oss.terrastruct.com/d2/d2target" ) @@ -32,27 +32,62 @@ func Compile(path string, r io.RuneReader, opts *CompileOptions) (*d2graph.Graph UTF16: opts.UTF16, }) if err != nil { - if !errors.As(err, &pe) { - return nil, err - } + return nil, err } - return compileAST(path, pe, ast) + ir, err := d2ir.Compile(ast) + if err != nil { + return nil, err + } + + g, err := compileIR(pe, ir.CopyBase(nil)) + if err != nil { + return nil, err + } + g.AST = ast + + err = compileLayersField(pe, g, ir, "layers") + if err != nil { + return nil, err + } + err = compileLayersField(pe, g, ir, "scenarios") + if err != nil { + return nil, err + } + err = compileLayersField(pe, g, ir, "steps") + return g, err } -func compileAST(path string, pe d2parser.ParseError, ast *d2ast.Map) (*d2graph.Graph, error) { - g := d2graph.NewGraph(ast) +func compileLayersField(pe d2parser.ParseError, g *d2graph.Graph, ir *d2ir.Map, fieldName string) error { + layers := ir.GetField(fieldName) + if layers.Map() == nil { + return nil + } + for _, f := range layers.Map().Fields { + if f.Map() == nil { + continue + } + g2, err := compileIR(pe, f.Map()) + if err != nil { + return err + } + g2.Name = f.Name + g.Layers = append(g.Layers, g2) + } + return nil +} + +func compileIR(pe d2parser.ParseError, m *d2ir.Map) (*d2graph.Graph, error) { + g := d2graph.NewGraph() c := &compiler{ - path: path, - err: pe, + err: pe, } - c.compileKeys(g.Root, ast) + c.compileMap(g.Root, m) if len(c.err.Errors) == 0 { - c.validateKeys(g.Root, ast) + c.validateKeys(g.Root, m) } - c.compileEdges(g.Root, ast) c.compileShapes(g.Root) c.validateNear(g) @@ -63,327 +98,54 @@ func compileAST(path string, pe d2parser.ParseError, ast *d2ast.Map) (*d2graph.G } type compiler struct { - path string - err d2parser.ParseError + err d2parser.ParseError } -func (c *compiler) errorf(start d2ast.Position, end d2ast.Position, f string, v ...interface{}) { - r := d2ast.Range{ - Path: c.path, - Start: start, - End: end, +func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { + c.err.Errors = append(c.err.Errors, d2parser.Errorf(n, f, v...).(d2ast.Error)) +} + +func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) { + for _, f := range m.Fields { + c.compileField(obj, f) } - f = "%v: " + f - v = append([]interface{}{r}, v...) - c.err.Errors = append(c.err.Errors, d2ast.Error{ - Range: r, - Message: fmt.Sprintf(f, v...), - }) -} - -func (c *compiler) compileKeys(obj *d2graph.Object, m *d2ast.Map) { - for _, n := range m.Nodes { - if n.MapKey != nil && n.MapKey.Key != nil && len(n.MapKey.Edges) == 0 { - c.compileKey(obj, m, n.MapKey) - } + for _, e := range m.Edges { + c.compileEdge(obj, m, e) } } -func (c *compiler) compileEdges(obj *d2graph.Object, m *d2ast.Map) { - for _, n := range m.Nodes { - if n.MapKey != nil { - if len(n.MapKey.Edges) > 0 { - obj := obj - if n.MapKey.Key != nil { - ida := d2graph.Key(n.MapKey.Key) - parent, resolvedIDA, err := d2graph.ResolveUnderscoreKey(ida, obj) - if err != nil { - c.errorf(n.MapKey.Range.Start, n.MapKey.Range.End, err.Error()) - return - } - unresolvedObj := obj - obj = parent.EnsureChild(resolvedIDA) - - parent.AppendReferences(ida, d2graph.Reference{ - Key: n.MapKey.Key, - - MapKey: n.MapKey, - Scope: m, - }, unresolvedObj) - } - c.compileEdgeMapKey(obj, m, n.MapKey) - } - if n.MapKey.Key != nil && n.MapKey.Value.Map != nil { - c.compileEdges(obj.EnsureChild(d2graph.Key(n.MapKey.Key)), n.MapKey.Value.Map) - } +func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { + keyword := strings.ToLower(f.Name) + _, isReserved := d2graph.ReservedKeywords[keyword] + if isReserved { + c.compileReserved(obj.Attributes, f) + return + } else if f.Name == "style" { + if f.Map() == nil { + return } + c.compileStyle(obj.Attributes, f.Map()) + return + } + + obj = obj.EnsureChild([]string{f.Name}) + if f.Primary() != nil { + c.compileLabel(obj, f) + } + if f.Map() != nil { + c.compileMap(obj, f.Map()) } } -// compileArrowheads compiles keywords for edge arrowhead attributes by -// 1. creating a fake, detached parent -// 2. compiling the arrowhead field as a fake object onto that fake parent -// 3. transferring the relevant attributes onto the edge -func (c *compiler) compileArrowheads(edge *d2graph.Edge, m *d2ast.Map, mk *d2ast.Key) bool { - arrowheadKey := mk.Key - if mk.EdgeKey != nil { - arrowheadKey = mk.EdgeKey - } - if arrowheadKey == nil || len(arrowheadKey.Path) == 0 { - return false - } - key := arrowheadKey.Path[0].Unbox().ScalarString() - var field *d2graph.Attributes - if key == "source-arrowhead" { - if edge.SrcArrowhead == nil { - edge.SrcArrowhead = &d2graph.Attributes{} - } - field = edge.SrcArrowhead - } else if key == "target-arrowhead" { - if edge.DstArrowhead == nil { - edge.DstArrowhead = &d2graph.Attributes{} - } - field = edge.DstArrowhead - } else { - return false - } - fakeParent := &d2graph.Object{ - Children: make(map[string]*d2graph.Object), - Attributes: &d2graph.Attributes{}, - } - detachedMK := &d2ast.Key{ - Key: arrowheadKey, - Primary: mk.Primary, - Value: mk.Value, - } - c.compileKey(fakeParent, m, detachedMK) - fakeObj := fakeParent.ChildrenArray[0] - c.compileShapes(fakeObj) - - if fakeObj.Attributes.Shape.Value != "" { - field.Shape = fakeObj.Attributes.Shape - } - if fakeObj.Attributes.Label.Value != "" && fakeObj.Attributes.Label.Value != "source-arrowhead" && fakeObj.Attributes.Label.Value != "target-arrowhead" { - field.Label = fakeObj.Attributes.Label - } - if fakeObj.Attributes.Style.Filled != nil { - field.Style.Filled = fakeObj.Attributes.Style.Filled - } - - return true -} - -func (c *compiler) compileAttributes(attrs *d2graph.Attributes, mk *d2ast.Key) { - var reserved string - var ok bool - - if mk.EdgeKey != nil { - _, reserved, ok = c.compileFlatKey(mk.EdgeKey) - } else if mk.Key != nil { - _, reserved, ok = c.compileFlatKey(mk.Key) - } - if !ok { - return - } - - if reserved == "" || reserved == "label" { - attrs.Label.MapKey = mk - } else if reserved == "shape" { - attrs.Shape.MapKey = mk - } else if reserved == "opacity" { - attrs.Style.Opacity = &d2graph.Scalar{MapKey: mk} - } else if reserved == "stroke" { - attrs.Style.Stroke = &d2graph.Scalar{MapKey: mk} - } else if reserved == "fill" { - attrs.Style.Fill = &d2graph.Scalar{MapKey: mk} - } else if reserved == "stroke-width" { - attrs.Style.StrokeWidth = &d2graph.Scalar{MapKey: mk} - } else if reserved == "stroke-dash" { - attrs.Style.StrokeDash = &d2graph.Scalar{MapKey: mk} - } else if reserved == "border-radius" { - attrs.Style.BorderRadius = &d2graph.Scalar{MapKey: mk} - } else if reserved == "shadow" { - attrs.Style.Shadow = &d2graph.Scalar{MapKey: mk} - } else if reserved == "3d" { - // TODO this should be movd to validateKeys, as shape may not be set yet - if attrs.Shape.Value != "" && !strings.EqualFold(attrs.Shape.Value, d2target.ShapeSquare) && !strings.EqualFold(attrs.Shape.Value, d2target.ShapeRectangle) { - c.errorf(mk.Range.Start, mk.Range.End, `key "3d" can only be applied to squares and rectangles`) - return - } - attrs.Style.ThreeDee = &d2graph.Scalar{MapKey: mk} - } else if reserved == "multiple" { - attrs.Style.Multiple = &d2graph.Scalar{MapKey: mk} - } else if reserved == "font" { - attrs.Style.Font = &d2graph.Scalar{MapKey: mk} - } else if reserved == "font-size" { - attrs.Style.FontSize = &d2graph.Scalar{MapKey: mk} - } else if reserved == "font-color" { - attrs.Style.FontColor = &d2graph.Scalar{MapKey: mk} - } else if reserved == "animated" { - attrs.Style.Animated = &d2graph.Scalar{MapKey: mk} - } else if reserved == "bold" { - attrs.Style.Bold = &d2graph.Scalar{MapKey: mk} - } else if reserved == "italic" { - attrs.Style.Italic = &d2graph.Scalar{MapKey: mk} - } else if reserved == "underline" { - attrs.Style.Underline = &d2graph.Scalar{MapKey: mk} - } else if reserved == "filled" { - attrs.Style.Filled = &d2graph.Scalar{MapKey: mk} - } else if reserved == "width" { - attrs.Width = &d2graph.Scalar{MapKey: mk} - } else if reserved == "height" { - attrs.Height = &d2graph.Scalar{MapKey: mk} - } -} - -func (c *compiler) compileKey(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) { - ida, reserved, ok := c.compileFlatKey(mk.Key) - if !ok { - return - } - if reserved == "desc" { - return - } - - resolvedObj, resolvedIDA, err := d2graph.ResolveUnderscoreKey(ida, obj) - if err != nil { - c.errorf(mk.Range.Start, mk.Range.End, err.Error()) - return - } - - parent := resolvedObj - if len(resolvedIDA) > 0 { - unresolvedObj := obj - obj = parent.EnsureChild(resolvedIDA) - parent.AppendReferences(ida, d2graph.Reference{ - Key: mk.Key, - - MapKey: mk, - Scope: m, - }, unresolvedObj) - } else if obj.Parent == nil { - // Top level reserved key set on root. - c.compileAttributes(obj.Attributes, mk) - c.applyScalar(obj.Attributes, reserved, mk.Value.ScalarBox()) - return - } - - if len(mk.Edges) > 0 { - return - } - - c.compileAttributes(obj.Attributes, mk) - if obj.Attributes.Style.Animated != nil { - c.errorf(mk.Range.Start, mk.Range.End, `key "animated" can only be applied to edges`) - return - } - - c.applyScalar(obj.Attributes, reserved, mk.Value.ScalarBox()) - if mk.Value.Map != nil { - if reserved != "" { - c.errorf(mk.Range.Start, mk.Range.End, "cannot set reserved key %q to a map", reserved) - return - } - obj.Map = mk.Value.Map - c.compileKeys(obj, mk.Value.Map) - } - - c.applyScalar(obj.Attributes, reserved, mk.Primary) -} - -func (c *compiler) applyScalar(attrs *d2graph.Attributes, reserved string, box d2ast.ScalarBox) { - scalar := box.Unbox() - if scalar == nil { - return - } - - switch reserved { - case "shape": - in := d2target.IsShape(scalar.ScalarString()) - _, isArrowhead := d2target.Arrowheads[scalar.ScalarString()] - if !in && !isArrowhead { - c.errorf(scalar.GetRange().Start, scalar.GetRange().End, "unknown shape %q", scalar.ScalarString()) - return - } - if box.Null != nil { - attrs.Shape.Value = "" - } else { - attrs.Shape.Value = scalar.ScalarString() - } - if attrs.Shape.Value == d2target.ShapeCode { - // Explicit code shape is plaintext. - attrs.Language = d2target.ShapeText - } - return - case "icon": - iconURL, err := url.Parse(scalar.ScalarString()) - if err != nil { - c.errorf(scalar.GetRange().Start, scalar.GetRange().End, "bad icon url %#v: %s", scalar.ScalarString(), err) - return - } - attrs.Icon = iconURL - return - case "near": - nearKey, err := d2parser.ParseKey(scalar.ScalarString()) - if err != nil { - c.errorf(scalar.GetRange().Start, scalar.GetRange().End, "bad near key %#v: %s", scalar.ScalarString(), err) - return - } - attrs.NearKey = nearKey - return - case "tooltip": - attrs.Tooltip = scalar.ScalarString() - return - case "width": - _, err := strconv.Atoi(scalar.ScalarString()) - if err != nil { - c.errorf(scalar.GetRange().Start, scalar.GetRange().End, "non-integer width %#v: %s", scalar.ScalarString(), err) - return - } - attrs.Width.Value = scalar.ScalarString() - return - case "height": - _, err := strconv.Atoi(scalar.ScalarString()) - if err != nil { - c.errorf(scalar.GetRange().Start, scalar.GetRange().End, "non-integer height %#v: %s", scalar.ScalarString(), err) - return - } - attrs.Height.Value = scalar.ScalarString() - return - case "link": - attrs.Link = scalar.ScalarString() - return - case "direction": - dirs := []string{"up", "down", "right", "left"} - if !go2.Contains(dirs, scalar.ScalarString()) { - c.errorf(scalar.GetRange().Start, scalar.GetRange().End, `direction must be one of %v, got %q`, strings.Join(dirs, ", "), scalar.ScalarString()) - return - } - attrs.Direction.Value = scalar.ScalarString() - return - case "constraint": - // Compilation for shape-specific keywords happens elsewhere - return - } - - if _, ok := d2graph.StyleKeywords[reserved]; ok { - if err := attrs.Style.Apply(reserved, scalar.ScalarString()); err != nil { - c.errorf(scalar.GetRange().Start, scalar.GetRange().End, err.Error()) - } - return - } - - if box.Null != nil { - // TODO: delete obj - attrs.Label.Value = "" - } else { +func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) { + scalar := f.Primary().Value + switch scalar := scalar.(type) { + case *d2ast.Null: + // TODO: Delete instaed. attrs.Label.Value = scalar.ScalarString() - } - - bs := box.BlockString - if bs != nil && reserved == "" { - attrs.Language = bs.Tag - fullTag, ok := ShortToFullLanguageAliases[bs.Tag] + case *d2ast.BlockString: + attrs.Language = scalar.Tag + fullTag, ok := ShortToFullLanguageAliases[scalar.Tag] if ok { attrs.Language = fullTag } @@ -392,168 +154,201 @@ func (c *compiler) applyScalar(attrs *d2graph.Attributes, reserved string, box d } else { attrs.Shape.Value = d2target.ShapeCode } + default: + attrs.Label.Value = scalar.ScalarString() } + attrs.Label.MapKey = f.LastPrimaryKey() } -func (c *compiler) compileEdgeMapKey(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) { - if mk.EdgeIndex != nil { - edge, ok := obj.HasEdge(mk) - if ok { - c.appendEdgeReferences(obj, m, mk) - edge.References = append(edge.References, d2graph.EdgeReference{ - Edge: mk.Edges[0], - - MapKey: mk, - MapKeyEdgeIndex: 0, - Scope: m, - ScopeObj: obj, - }) - c.compileEdge(edge, m, mk) +func (c *compiler) compileReserved(attrs *d2graph.Attributes, f d2ir.Node) { + scalar := f.Primary().Value + switch f.Name { + case "label": + c.compileLabel(obj, f) + case "shape": + in := d2target.IsShape(scalar.ScalarString()) + if !in { + c.errorf(scalar, "unknown shape %q", scalar.ScalarString()) + return } - return - } - for i, e := range mk.Edges { - if e.Src == nil || e.Dst == nil { - continue + attrs.Shape.Value = scalar.ScalarString() + if attrs.Shape.Value == d2target.ShapeCode { + // Explicit code shape is plaintext. + attrs.Language = d2target.ShapeText } - edge, err := obj.Connect(d2graph.Key(e.Src), d2graph.Key(e.Dst), e.SrcArrow == "<", e.DstArrow == ">", "") + attrs.Shape.MapKey = f.LastPrimaryKey() + case "icon": + iconURL, err := url.Parse(scalar.ScalarString()) if err != nil { - c.errorf(e.Range.Start, e.Range.End, err.Error()) + c.errorf(scalar, "bad icon url %#v: %s", scalar.ScalarString(), err) + return + } + attrs.Icon = iconURL + case "near": + nearKey, err := d2parser.ParseKey(scalar.ScalarString()) + if err != nil { + c.errorf(scalar, "bad near key %#v: %s", scalar.ScalarString(), err) + return + } + attrs.NearKey = nearKey + case "tooltip": + attrs.Tooltip = scalar.ScalarString() + case "width": + _, err := strconv.Atoi(scalar.ScalarString()) + if err != nil { + c.errorf(scalar, "non-integer width %#v: %s", scalar.ScalarString(), err) + return + } + attrs.Width = &d2graph.Scalar{} + attrs.Width.Value = scalar.ScalarString() + attrs.Width.MapKey = f.LastPrimaryKey() + case "height": + _, err := strconv.Atoi(scalar.ScalarString()) + if err != nil { + c.errorf(scalar, "non-integer height %#v: %s", scalar.ScalarString(), err) + return + } + attrs.Height = &d2graph.Scalar{} + attrs.Height.Value = scalar.ScalarString() + attrs.Height.MapKey = f.LastPrimaryKey() + case "link": + attrs.Link = scalar.ScalarString() + case "direction": + dirs := []string{"up", "down", "right", "left"} + if !go2.Contains(dirs, scalar.ScalarString()) { + c.errorf(scalar, `direction must be one of %v, got %q`, strings.Join(dirs, ", "), scalar.ScalarString()) + return + } + attrs.Direction.Value = scalar.ScalarString() + attrs.Direction.MapKey = f.LastPrimaryKey() + case "constraint": + // Compilation for shape-specific keywords happens elsewhere + } +} + +func (c *compiler) compileStyle(attrs *d2graph.Attributes, f d2ir.Node) { + scalar := f.Primary().Value + err := attrs.Style.Apply(f.Name, scalar.ScalarString()) + if err != nil { + c.errorf(scalar, err.Error()) + return + } + + switch f.Name { + case "opacity": + attrs.Style.Opacity = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "stroke": + attrs.Style.Stroke = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "fill": + attrs.Style.Fill = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "stroke-width": + attrs.Style.StrokeWidth = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "stroke-dash": + attrs.Style.StrokeDash = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "border-radius": + attrs.Style.BorderRadius = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "shadow": + attrs.Style.Shadow = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "3d": + attrs.Style.ThreeDee = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "multiple": + attrs.Style.Multiple = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "font": + attrs.Style.Font = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "font-size": + attrs.Style.FontSize = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "font-color": + attrs.Style.FontColor = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "animated": + attrs.Style.Animated = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "bold": + attrs.Style.Bold = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "italic": + attrs.Style.Italic = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "underline": + attrs.Style.Underline = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "filled": + attrs.Style.Filled = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "width": + attrs.Width = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + case "height": + attrs.Height = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + } +} + +func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { + edge, err := obj.Connect(e.ID.SrcPath, e.ID.DstPath, e.ID.SrcArrow, e.ID.DstArrow, "") + if err != nil { + c.errorf(e, err.Error()) + return + } + + if e.Primary() != nil { + c.compileLabel(edge.Attributes, e) + } + if e.Map() != nil { + for _, f := range e.Map().Fields { + _, ok := d2graph.ReservedKeywords[f.Name] + if !ok { + c.errorf(mk, `edge map keys must be reserved keywords`) + continue + } + c.compileEdgeField(edge, f) + } + } +} + +func (c *compiler) compileEdgeField(edge *d2graph.Edge, f *d2ir.Field) { + keyword := strings.ToLower(f.Name) + _, isReserved := d2graph.ReservedKeywords[keyword] + if isReserved { + c.compileReserved(edge.Attributes, f) + return + } else if f.Name == "style" { + if f.Map() == nil { + return + } + c.compileStyle(edge.Attributes, f.Map()) + return + } + + if f.Primary() != nil { + c.compileLabel(edge, f) + } + + if f.Name == "source-arrowhead" || f.Name == "target-arrowhead" { + if f.Map() != nil { + c.compileArrowheads(edge, f) + } + } +} + +func (c *compiler) compileArrowheads(edge *d2graph.Edge, f *d2ir.Field) { + var attrs *d2graph.Attributes + if f.Name == "source-arrowhead" { + edge.SrcArrowhead = &d2graph.Attributes{} + attrs = edge.SrcArrowhead + } else { + edge.DstArrowhead = &d2graph.Attributes{} + attrs = edge.DstArrowhead + } + + for _, f2 := range f.Map().Fields { + _, isReserved := d2graph.ReservedKeywords[keyword] + if isReserved { + c.compileReserved(attrs, f2) + continue + } else if f2.Name == "style" { + if f2.Map() == nil { + continue + } + c.compileStyle(attrs, f2.Map()) + continue + } else { + c.errorf(mk, `source-arrowhead/target-arrowhead map keys must be reserved keywords`) continue } - edge.References = append(edge.References, d2graph.EdgeReference{ - Edge: e, - - MapKey: mk, - MapKeyEdgeIndex: i, - Scope: m, - ScopeObj: obj, - }) - c.compileEdge(edge, m, mk) } - c.appendEdgeReferences(obj, m, mk) -} - -func (c *compiler) compileEdge(edge *d2graph.Edge, m *d2ast.Map, mk *d2ast.Key) { - if mk.Key == nil && mk.EdgeKey == nil { - if len(mk.Edges) == 1 { - edge.Attributes.Label.MapKey = mk - } - c.applyScalar(edge.Attributes, "", mk.Value.ScalarBox()) - c.applyScalar(edge.Attributes, "", mk.Primary) - } else { - c.compileEdgeKey(edge, m, mk) - } - if mk.Value.Map != nil && mk.EdgeKey == nil { - for _, n := range mk.Value.Map.Nodes { - if n.MapKey == nil { - continue - } - if len(n.MapKey.Edges) > 0 { - c.errorf(mk.Range.Start, mk.Range.End, `edges cannot be nested within another edge`) - continue - } - if n.MapKey.Key == nil { - continue - } - for _, p := range n.MapKey.Key.Path { - _, ok := d2graph.ReservedKeywords[strings.ToLower(p.Unbox().ScalarString())] - if !ok { - c.errorf(mk.Range.Start, mk.Range.End, `edge map keys must be reserved keywords`) - return - } - } - c.compileEdgeKey(edge, m, n.MapKey) - } - } -} - -func (c *compiler) compileEdgeKey(edge *d2graph.Edge, m *d2ast.Map, mk *d2ast.Key) { - var r string - var ok bool - - // Give precedence to EdgeKeys - // x.(a -> b)[0].style.opacity: 0.4 - // We want to compile the style.opacity, not the x - if mk.EdgeKey != nil { - _, r, ok = c.compileFlatKey(mk.EdgeKey) - } else if mk.Key != nil { - _, r, ok = c.compileFlatKey(mk.Key) - } - if !ok { - return - } - - ok = c.compileArrowheads(edge, m, mk) - if ok { - return - } - c.compileAttributes(edge.Attributes, mk) - c.applyScalar(edge.Attributes, r, mk.Value.ScalarBox()) - if mk.Value.Map != nil { - for _, n := range mk.Value.Map.Nodes { - if n.MapKey != nil { - c.compileEdgeKey(edge, m, n.MapKey) - } - } - } -} - -func (c *compiler) appendEdgeReferences(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) { - for i, e := range mk.Edges { - if e.Src != nil { - ida := d2graph.Key(e.Src) - - parent, _, err := d2graph.ResolveUnderscoreKey(ida, obj) - if err != nil { - c.errorf(mk.Range.Start, mk.Range.End, err.Error()) - return - } - parent.AppendReferences(ida, d2graph.Reference{ - Key: e.Src, - - MapKey: mk, - MapKeyEdgeIndex: i, - Scope: m, - }, obj) - } - if e.Dst != nil { - ida := d2graph.Key(e.Dst) - - parent, _, err := d2graph.ResolveUnderscoreKey(ida, obj) - if err != nil { - c.errorf(mk.Range.Start, mk.Range.End, err.Error()) - return - } - parent.AppendReferences(ida, d2graph.Reference{ - Key: e.Dst, - - MapKey: mk, - MapKeyEdgeIndex: i, - Scope: m, - }, obj) - } - } -} - -func (c *compiler) compileFlatKey(k *d2ast.KeyPath) ([]string, string, bool) { - k2 := *k - var reserved string - for i, s := range k.Path { - keyword := strings.ToLower(s.Unbox().ScalarString()) - _, isReserved := d2graph.ReservedKeywords[keyword] - _, isReservedHolder := d2graph.ReservedKeywordHolders[keyword] - if isReserved && !isReservedHolder { - reserved = keyword - k2.Path = k2.Path[:i] - break - } - } - if len(k2.Path) < len(k.Path)-1 { - c.errorf(k.Range.Start, k.Range.End, "reserved key %q cannot have children", reserved) - return nil, "", false - } - return d2graph.Key(&k2), reserved, true } // TODO add more, e.g. C, bash @@ -580,34 +375,11 @@ func (c *compiler) compileShapes(obj *d2graph.Object) { } c.compileShapes(obj) } - - for i := 0; i < len(obj.ChildrenArray); i++ { - ch := obj.ChildrenArray[i] - switch ch.Attributes.Shape.Value { - case d2target.ShapeClass, d2target.ShapeSQLTable: - flattenContainer(obj.Graph, ch) - } - if ch.IDVal == "style" { - obj.Attributes.Style = ch.Attributes.Style - if obj.Graph != nil { - flattenContainer(obj.Graph, ch) - for i := 0; i < len(obj.Graph.Objects); i++ { - if obj.Graph.Objects[i] == ch { - obj.Graph.Objects = append(obj.Graph.Objects[:i], obj.Graph.Objects[i+1:]...) - break - } - } - delete(obj.Children, ch.ID) - obj.ChildrenArray = append(obj.ChildrenArray[:i], obj.ChildrenArray[i+1:]...) - i-- - } - } - } } func (c *compiler) compileImage(obj *d2graph.Object) { if obj.Attributes.Icon == nil { - c.errorf(obj.Attributes.Shape.MapKey.Range.Start, obj.Attributes.Shape.MapKey.Range.End, `image shape must include an "icon" field`) + c.errorf(obj.Attributes.Shape.MapKey, `image shape must include an "icon" field`) } } @@ -687,7 +459,7 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) { } if n.MapKey.Key.Path[0].Unbox().ScalarString() == "constraint" { if n.MapKey.Value.StringBox().Unbox() == nil { - c.errorf(n.MapKey.GetRange().Start, n.MapKey.GetRange().End, "constraint value must be a string") + c.errorf(n.MapKey, "constraint value must be a string") return } d2Col.Constraint = n.MapKey.Value.StringBox().Unbox().ScalarString() @@ -717,144 +489,62 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) { } } -func flattenContainer(g *d2graph.Graph, obj *d2graph.Object) { - absID := obj.AbsID() - - toRemove := map[*d2graph.Edge]struct{}{} - toAdd := []*d2graph.Edge{} - for i := 0; i < len(g.Edges); i++ { - e := g.Edges[i] - srcID := e.Src.AbsID() - dstID := e.Dst.AbsID() - - srcIsChild := strings.HasPrefix(srcID, absID+".") - dstIsChild := strings.HasPrefix(dstID, absID+".") - if srcIsChild && dstIsChild { - toRemove[e] = struct{}{} - } else if srcIsChild { - toRemove[e] = struct{}{} - if dstID == absID { - continue - } - toAdd = append(toAdd, e) - } else if dstIsChild { - toRemove[e] = struct{}{} - if srcID == absID { - continue - } - toAdd = append(toAdd, e) - } - } - for _, e := range toAdd { - var newEdge *d2graph.Edge - if strings.HasPrefix(e.Src.AbsID(), absID+".") { - newEdge, _ = g.Root.Connect(obj.AbsIDArray(), e.Dst.AbsIDArray(), e.SrcArrow, e.DstArrow, e.Attributes.Label.Value) - } else { - newEdge, _ = g.Root.Connect(e.Src.AbsIDArray(), obj.AbsIDArray(), e.SrcArrow, e.DstArrow, e.Attributes.Label.Value) - } - // TODO more attributes - if e.SrcTableColumnIndex != nil { - newEdge.SrcTableColumnIndex = new(int) - newEdge.SrcArrowhead = e.SrcArrowhead - *newEdge.SrcTableColumnIndex = *e.SrcTableColumnIndex - } - if e.DstTableColumnIndex != nil { - newEdge.DstTableColumnIndex = new(int) - newEdge.DstArrowhead = e.DstArrowhead - *newEdge.DstTableColumnIndex = *e.DstTableColumnIndex - } - newEdge.Attributes = e.Attributes - newEdge.References = e.References - } - updatedEdges := []*d2graph.Edge{} - for _, e := range g.Edges { - if _, is := toRemove[e]; is { - continue - } - updatedEdges = append(updatedEdges, e) - } - g.Edges = updatedEdges - - for i := 0; i < len(g.Objects); i++ { - child := g.Objects[i] - if strings.HasPrefix(child.AbsID(), absID+".") { - g.Objects = append(g.Objects[:i], g.Objects[i+1:]...) - i-- - delete(obj.Children, child.ID) - for i, child2 := range obj.ChildrenArray { - if child == child2 { - obj.ChildrenArray = append(obj.ChildrenArray[:i], obj.ChildrenArray[i+1:]...) - break - } - } - } +func (c *compiler) validateKeys(obj *d2graph.Object, m *d2ir.Map) { + for _, n := range m.Fields { + c.validateKey(obj, f) } } -func (c *compiler) validateKey(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) { - ida, reserved, ok := c.compileFlatKey(mk.Key) - if !ok { +func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { + _, isReserved := d2graph.ReservedKeywords[keyword] + if isReserved { + switch obj.Attributes.Shape.Value { + case d2target.ShapeSQLTable, d2target.ShapeClass: + default: + if len(obj.Children) > 0 && (f.Name == "width" || f.Name == "height") { + c.errorf(f.LastPrimaryKey(), mk.Range.End, fmt.Sprintf("%s cannot be used on container: %s", f.Name, obj.AbsID())) + } + } + + switch obj.Attributes.Shape.Value { + case d2target.ShapeCircle, d2target.ShapeSquare: + checkEqual := (reserved == "width" && obj.Attributes.Height != nil) || (reserved == "height" && obj.Attributes.Width != nil) + if checkEqual && obj.Attributes.Width.Value != obj.Attributes.Height.Value { + c.errorf(f.LastPrimaryKey(), "width and height must be equal for %s shapes", obj.Attributes.Shape.Value) + } + } + + switch f.Name { + case "width": + if obj.Attributes.Shape.Value != d2target.ShapeImage { + c.errorf(f.LastPrimaryKey(), "width is only applicable to image shapes.") + } + case "height": + if obj.Attributes.Shape.Value != d2target.ShapeImage { + c.errorf(f.LastPrimaryKey(), "height is only applicable to image shapes.") + } + case "3d": + if obj.Attributes.Shape.Value != "" && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeSquare) && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeRectangle) { + c.errorf(f.LastPrimaryKey(), `key "3d" can only be applied to squares and rectangles`) + } + case "shape": + in := d2target.IsShape(obj.Attributes.Shape.Value) + _, arrowheadIn := d2target.Arrowheads[obj.Attributes.Shape.Value] + if !in && arrowheadIn { + c.errorf(f.LastPrimaryKey(), fmt.Sprintf(`invalid shape, can only set "%s" for arrowheads`, obj.Attributes.Shape.Value)) + } + } return } - switch strings.ToLower(obj.Attributes.Shape.Value) { - case d2target.ShapeImage: - if reserved == "" { - c.errorf(mk.Range.Start, mk.Range.End, "image shapes cannot have children.") - } - case d2target.ShapeCircle, d2target.ShapeSquare: - checkEqual := (reserved == "width" && obj.Attributes.Height != nil) || - (reserved == "height" && obj.Attributes.Width != nil) - - if checkEqual && obj.Attributes.Width.Value != obj.Attributes.Height.Value { - c.errorf(mk.Range.Start, mk.Range.End, fmt.Sprintf("width and height must be equal for %s shapes", obj.Attributes.Shape.Value)) - } - } - - in := d2target.IsShape(obj.Attributes.Shape.Value) - _, arrowheadIn := d2target.Arrowheads[obj.Attributes.Shape.Value] - if !in && arrowheadIn { - c.errorf(mk.Range.Start, mk.Range.End, fmt.Sprintf(`invalid shape, can only set "%s" for arrowheads`, obj.Attributes.Shape.Value)) - } - - resolvedObj, resolvedIDA, err := d2graph.ResolveUnderscoreKey(ida, obj) - if err != nil { - c.errorf(mk.Range.Start, mk.Range.End, err.Error()) - return - } - if resolvedObj != obj { - obj = resolvedObj - } - - parent := obj - if len(resolvedIDA) > 0 { - obj, _ = parent.HasChild(resolvedIDA) - } else if obj.Parent == nil { + if obj.Attributes.Shape.Value == d2target.ShapeImage { + c.errorf(mk, "image shapes cannot have children.") return } - switch strings.ToLower(obj.Attributes.Shape.Value) { - case d2target.ShapeSQLTable, d2target.ShapeClass: - default: - if len(obj.Children) > 0 && !(len(obj.Children) == 1 && obj.ChildrenArray[0].ID == "style") && (reserved == "width" || reserved == "height") { - c.errorf(mk.Range.Start, mk.Range.End, fmt.Sprintf("%s cannot be used on container: %s", reserved, obj.AbsID())) - } - } - - if len(mk.Edges) > 0 { - return - } - - if mk.Value.Map != nil { - c.validateKeys(obj, mk.Value.Map) - } -} - -func (c *compiler) validateKeys(obj *d2graph.Object, m *d2ast.Map) { - for _, n := range m.Nodes { - if n.MapKey != nil && n.MapKey.Key != nil && len(n.MapKey.Edges) == 0 { - c.validateKey(obj, m, n.MapKey) - } + obj = obj.HasChild([]string{f.Name}) + if f.Map() != nil { + c.validateKeys(obj, f.Map()) } } @@ -864,15 +554,15 @@ func (c *compiler) validateNear(g *d2graph.Graph) { _, isKey := g.Root.HasChild(d2graph.Key(obj.Attributes.NearKey)) _, isConst := d2graph.NearConstants[d2graph.Key(obj.Attributes.NearKey)[0]] if !isKey && !isConst { - c.errorf(obj.Attributes.NearKey.GetRange().Start, obj.Attributes.NearKey.GetRange().End, "near key %#v must be the absolute path to a shape or one of the following constants: %s", d2format.Format(obj.Attributes.NearKey), strings.Join(d2graph.NearConstantsArray, ", ")) + c.errorf(obj.Attributes.NearKey, "near key %#v must be the absolute path to a shape or one of the following constants: %s", d2format.Format(obj.Attributes.NearKey), strings.Join(d2graph.NearConstantsArray, ", ")) continue } if !isKey && isConst && obj.Parent != g.Root { - c.errorf(obj.Attributes.NearKey.GetRange().Start, obj.Attributes.NearKey.GetRange().End, "constant near keys can only be set on root level shapes") + c.errorf(obj.Attributes.NearKey, "constant near keys can only be set on root level shapes") continue } if !isKey && isConst && len(obj.ChildrenArray) > 0 { - c.errorf(obj.Attributes.NearKey.GetRange().Start, obj.Attributes.NearKey.GetRange().End, "constant near keys cannot be set on shapes with children") + c.errorf(obj.Attributes.NearKey, "constant near keys cannot be set on shapes with children") continue } if !isKey && isConst { @@ -884,7 +574,7 @@ func (c *compiler) validateNear(g *d2graph.Graph) { } } if is { - c.errorf(obj.Attributes.NearKey.GetRange().Start, obj.Attributes.NearKey.GetRange().End, "constant near keys cannot be set on connected shapes") + c.errorf(obj.Attributes.NearKey, "constant near keys cannot be set on connected shapes") continue } } diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 90b521782..514a503f8 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -1946,8 +1946,8 @@ layers: { } `, "") assert.JSON(t, 2, len(g.Layers)) - assert.JSON(t, "one", g.Layers[0].Root.ID) - assert.JSON(t, "two", g.Layers[1].Root.ID) + assert.JSON(t, "one", g.Layers[0].Name) + assert.JSON(t, "two", g.Layers[1].Name) }, }, } From afa26752e6422afec59cd2d71902326a69c840b2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 22 Jan 2023 00:21:03 -0800 Subject: [PATCH 35/60] d2compiler: Integrate d2ir (wip) --- d2compiler/compile.go | 70 ++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index fa3827d87..c2a829c7d 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -88,7 +88,6 @@ func compileIR(pe d2parser.ParseError, m *d2ir.Map) (*d2graph.Graph, error) { if len(c.err.Errors) == 0 { c.validateKeys(g.Root, m) } - c.compileShapes(g.Root) c.validateNear(g) if len(c.err.Errors) > 0 { @@ -109,6 +108,14 @@ func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) { for _, f := range m.Fields { c.compileField(obj, f) } + + switch obj.Attributes.Shape.Value { + case d2target.ShapeClass: + c.compileClass(obj, m) + case d2target.ShapeSQLTable: + c.compileSQLTable(obj, m) + } + for _, e := range m.Edges { c.compileEdge(obj, m, e) } @@ -370,26 +377,19 @@ func (c *compiler) compileShapes(obj *d2graph.Object) { c.compileClass(obj) case d2target.ShapeSQLTable: c.compileSQLTable(obj) - case d2target.ShapeImage: - c.compileImage(obj) } c.compileShapes(obj) } } -func (c *compiler) compileImage(obj *d2graph.Object) { - if obj.Attributes.Icon == nil { - c.errorf(obj.Attributes.Shape.MapKey, `image shape must include an "icon" field`) - } -} - func (c *compiler) compileClass(obj *d2graph.Object) { - obj.Class = &d2target.Class{} + if len(m.Edges) > 0 { + c.errorf(m.Edges[0].LastAST(), "class shapes cannot have edges inside") + return + } + obj.Class = &d2target.Class{} for _, f := range obj.ChildrenArray { - if f.IDVal == "style" { - continue - } visiblity := "public" name := f.IDVal // See https://www.uml-diagrams.org/visibility.html @@ -430,17 +430,22 @@ func (c *compiler) compileClass(obj *d2graph.Object) { }) } } + + obj.Children = nil + obj.ChildrenArray = nil } func (c *compiler) compileSQLTable(obj *d2graph.Object) { + if len(m.Edges) > 0 { + c.errorf(m.Edges[0].LastAST(), "sql_table shapes cannot have edges inside") + return + } + obj.SQLTable = &d2target.SQLTable{} parentID := obj.Parent.AbsID() tableIDPrefix := obj.AbsID() + "." for _, col := range obj.ChildrenArray { - if col.IDVal == "style" { - continue - } typ := col.Attributes.Label.Value if typ == col.IDVal { // Not great, AST should easily allow specifying alternate primary field @@ -467,26 +472,11 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) { } } - absID := col.AbsID() - for _, e := range obj.Graph.Edges { - srcID := e.Src.AbsID() - dstID := e.Dst.AbsID() - // skip edges between columns of the same table - if strings.HasPrefix(srcID, tableIDPrefix) && strings.HasPrefix(dstID, tableIDPrefix) { - continue - } - if srcID == absID { - d2Col.Reference = strings.TrimPrefix(dstID, parentID+".") - e.SrcTableColumnIndex = new(int) - *e.SrcTableColumnIndex = len(obj.SQLTable.Columns) - } else if dstID == absID { - e.DstTableColumnIndex = new(int) - *e.DstTableColumnIndex = len(obj.SQLTable.Columns) - } - } - obj.SQLTable.Columns = append(obj.SQLTable.Columns, d2Col) } + + obj.Children = nil + obj.ChildrenArray = nil } func (c *compiler) validateKeys(obj *d2graph.Object, m *d2ir.Map) { @@ -528,6 +518,18 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { c.errorf(f.LastPrimaryKey(), `key "3d" can only be applied to squares and rectangles`) } case "shape": + switch obj.Attributes.Shape.Value { + case d2target.ShapeSQLTable, d2target.ShapeClass: + case d2target.ShapeImage: + if obj.Attributes.Icon == nil { + c.errorf(f.LastPrimaryKey(), `image shape must include an "icon" field`) + } + default: + if len(obj.Children) > 0 && (f.Name == "width" || f.Name == "height") { + c.errorf(f.LastPrimaryKey(), mk.Range.End, fmt.Sprintf("%s cannot be used on container: %s", f.Name, obj.AbsID())) + } + } + in := d2target.IsShape(obj.Attributes.Shape.Value) _, arrowheadIn := d2target.Arrowheads[obj.Attributes.Shape.Value] if !in && arrowheadIn { From 3e7bdc546866e9bf1c99090e8b19f43553a06f2f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 22 Jan 2023 00:21:21 -0800 Subject: [PATCH 36/60] d2compiler: Integrate d2ir (wip) --- d2chaos/d2chaos.go | 3 +- d2graph/d2graph.go | 54 ++++++++-- d2ir/compile.go | 8 +- d2ir/d2ir.go | 152 ++++++++++++++++++++++------ d2layouts/d2sequence/layout_test.go | 4 +- 5 files changed, 170 insertions(+), 51 deletions(-) diff --git a/d2chaos/d2chaos.go b/d2chaos/d2chaos.go index 7729454a8..c26ea3c80 100644 --- a/d2chaos/d2chaos.go +++ b/d2chaos/d2chaos.go @@ -18,10 +18,11 @@ import ( func GenDSL(maxi int) (_ string, err error) { gs := &dslGenState{ rand: mathrand.New(mathrand.NewSource(time.Now().UnixNano())), - g: d2graph.NewGraph(&d2ast.Map{}), + g: d2graph.NewGraph(), nodeShapes: make(map[string]string), nodeContainer: make(map[string]string), } + gs.g.AST = &d2ast.Map{} err = gs.gen(maxi) if err != nil { return "", err diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index aa0c78ab7..9e2e9742b 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -25,7 +25,8 @@ const INNER_LABEL_PADDING int = 5 const DEFAULT_SHAPE_PADDING = 100. type Graph struct { - AST *d2ast.Map `json:"ast"` + Name string `json:"name"` + AST *d2ast.Map `json:"ast"` Root *Object `json:"root"` Edges []*Edge `json:"edges"` @@ -36,10 +37,8 @@ type Graph struct { Steps []*Graph `json:"steps,omitempty"` } -func NewGraph(ast *d2ast.Map) *Graph { - d := &Graph{ - AST: ast, - } +func NewGraph() *Graph { + d := &Graph{} d.Root = &Object{ Graph: d, Parent: nil, @@ -552,6 +551,7 @@ func (obj *Object) HasEdge(mk *d2ast.Key) (*Edge, bool) { return nil, false } +// TODO: remove once not used anywhere func ResolveUnderscoreKey(ida []string, obj *Object) (resolvedObj *Object, resolvedIDA []string, _ error) { if len(ida) > 0 && !obj.IsSequenceDiagram() { objSD := obj.OuterSequenceDiagram() @@ -635,6 +635,12 @@ func (obj *Object) FindEdges(mk *d2ast.Key) ([]*Edge, bool) { // EnsureChild grabs the child by ids or creates it if it does not exist including all // intermediate nodes. func (obj *Object) EnsureChild(ids []string) *Object { + switch obj.Attributes.Shape.Value { + case d2target.ShapeClass, d2target.ShapeSQLTable: + // This will only be called for connecting edges where we want to truncate to the + // container. + return obj + } _, is := ReservedKeywordHolders[ids[0]] if len(ids) == 1 && !is { _, ok := ReservedKeywords[ids[0]] @@ -954,7 +960,7 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label return nil, errors.New("connections within sequence diagrams can connect only to other objects within the same sequence diagram") } - edge := &Edge{ + e := &Edge{ Attributes: &Attributes{ Label: Scalar{ Value: label, @@ -965,10 +971,40 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label Dst: dst, DstArrow: dstArrow, } - edge.initIndex() + e.initIndex() - obj.Graph.Edges = append(obj.Graph.Edges, edge) - return edge, nil + if src.Attributes.Shape.Value == d2target.ShapeSQLTable { + objAbsID := obj.AbsIDArray() + srcAbsID := src.AbsIDArray() + if len(objAbsID) + len(srcID) > len(srcAbsID) { + for i, d2col := range src.SQLTable.Columns { + if d2col.Name.Label == srcID[len(srcID)-1] { + d2col.Reference = dst.AbsID() + e.SrcTableColumnIndex = new(int) + *e.SrcTableColumnIndex = i + break + } + } + } + } + if dst.Attributes.Shape.Value == d2target.ShapeSQLTable { + objAbsID := obj.AbsIDArray() + dstAbsID := dst.AbsIDArray() + if len(objAbsID) + len(dstID) > len(dstAbsID) { + for i, d2col := range dst.SQLTable.Columns { + if d2col.Name.Label == dstID[len(dstID)-1] { + d2col.Reference = dst.AbsID() + e.DstTableColumnIndex = new(int) + *e.DstTableColumnIndex = i + break + } + } + } + } + + + obj.Graph.Edges = append(obj.Graph.Edges, e) + return e, nil } // TODO: Treat undirectional/bidirectional edge here and in HasEdge flipped. Same with diff --git a/d2ir/compile.go b/d2ir/compile.go index 52e77dbd3..18278ac97 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -37,9 +37,7 @@ func (c *compiler) compileScenarios(m *Map) { for _, sf := range scenarios.Fields { if sf.Map() == nil { - sf.Composite = &Map{ - parent: sf, - } + continue } base := m.CopyBase(sf) sf.Composite = Overlay(base, sf.Map()) @@ -59,9 +57,7 @@ func (c *compiler) compileSteps(m *Map) { } for i, sf := range steps.Fields { if sf.Map() == nil { - sf.Composite = &Map{ - parent: sf, - } + continue } var base *Map diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 2d707d111..ca5a8b5ce 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -18,13 +18,21 @@ import ( // to indicate the offending AST node. type Node interface { node() - Copy(parent Node) Node + Copy(newParent Node) Node Parent() Node Primary() *Scalar Map() *Map - AST() d2ast.Node + ast() d2ast.Node fmt.Stringer + + LastRef() Reference + LastPrimaryKey() *d2ast.Key +} + +type Reference interface { + reference() + AST() d2ast.Node } var _ Node = &Scalar{} @@ -71,12 +79,20 @@ func (n *Map) Primary() *Scalar { return nil } func (n *Scalar) Map() *Map { return nil } func (n *Field) Map() *Map { + if n == nil { + return nil + } if n.Composite == nil { return nil } return n.Composite.Map() } -func (n *Edge) Map() *Map { return n.Map_ } +func (n *Edge) Map() *Map { + if n == nil { + return nil + } + return n.Map_ +} func (n *Array) Map() *Map { return nil } func (n *Map) Map() *Map { return n } @@ -87,22 +103,22 @@ func (n *Map) value() {} func (n *Array) composite() {} func (n *Map) composite() {} -func (n *Scalar) String() string { return d2format.Format(n.AST()) } -func (n *Field) String() string { return d2format.Format(n.AST()) } -func (n *Edge) String() string { return d2format.Format(n.AST()) } -func (n *Array) String() string { return d2format.Format(n.AST()) } -func (n *Map) String() string { return d2format.Format(n.AST()) } +func (n *Scalar) String() string { return d2format.Format(n.ast()) } +func (n *Field) String() string { return d2format.Format(n.ast()) } +func (n *Edge) String() string { return d2format.Format(n.ast()) } +func (n *Array) String() string { return d2format.Format(n.ast()) } +func (n *Map) String() string { return d2format.Format(n.ast()) } type Scalar struct { parent Node Value d2ast.Scalar `json:"value"` } -func (s *Scalar) Copy(newp Node) Node { +func (s *Scalar) Copy(newParent Node) Node { tmp := *s s = &tmp - s.parent = newp + s.parent = newParent return s } @@ -121,11 +137,11 @@ type Map struct { Edges []*Edge `json:"edges"` } -func (m *Map) Copy(newp Node) Node { +func (m *Map) Copy(newParent Node) Node { tmp := *m m = &tmp - m.parent = newp + m.parent = newParent pfields := m.Fields m.Fields = make([]*Field, 0, len(pfields)) for _, f := range pfields { @@ -139,11 +155,11 @@ func (m *Map) Copy(newp Node) Node { } // CopyBase copies the map m without layers/scenarios/steps. -func (m *Map) CopyBase(newp Node) *Map { +func (m *Map) CopyBase(newParent Node) *Map { layers := m.DeleteField("layers") scenarios := m.DeleteField("scenarios") steps := m.DeleteField("steps") - m2 := m.Copy(newp).(*Map) + m2 := m.Copy(newParent).(*Map) if layers != nil { m.Fields = append(m.Fields, layers) } @@ -161,6 +177,17 @@ func (m *Map) Root() bool { return m.parent == nil } +func (f *Map) LastRef() *MapReference { + if f.parent == nil { + return nil + } + return f.References[len(f.References)-1] +} + +func (f *Map) LastAST() d2ast.Node { + return f.LastRef().String +} + type LayerKind string const ( @@ -206,11 +233,11 @@ type Field struct { References []FieldReference `json:"references,omitempty"` } -func (f *Field) Copy(newp Node) Node { +func (f *Field) Copy(newParent Node) Node { tmp := *f f = &tmp - f.parent = newp.(*Map) + f.parent = newParent.(*Map) f.References = append([]FieldReference(nil), f.References...) if f.Primary_ != nil { f.Primary_ = f.Primary_.Copy(f).(*Scalar) @@ -221,6 +248,39 @@ func (f *Field) Copy(newp Node) Node { return f } +func (f *Field) LastPrimaryRef() *FieldReference { + inEdge := ParentEdge(f) != nil + for i := len(f.References) - 1; i >= 0; i-- { + fr := f.References[i] + if inEdge && len(fr.Context.Key.Edges) > 0 { + if fr.String == fr.Context.Key.EdgeKey.Path[len(fr.Context.Key.EdgeKey.Path)-1].Unbox() { + return fr + } + } else { + if fr.String == fr.Context.Key.Key.Path[len(fr.Context.Key.Key.Path)-1].Unbox() { + return fr + } + } + } + return nil +} + +func (f *Field) LastPrimaryKey() *d2ast.Key { + fr := f.LastModification() + if fr == nil { + return nil + } + return fr.Context.Key +} + +func (f *Field) LastRef() *FieldReference { + return f.References[len(f.References)-1] +} + +func (f *Field) LastAST() d2ast.Node { + return f.LastRef().String +} + type EdgeID struct { SrcPath []string `json:"src_path"` SrcArrow bool `json:"src_arrow"` @@ -339,11 +399,11 @@ type Edge struct { References []EdgeReference `json:"references,omitempty"` } -func (e *Edge) Copy(newp Node) Node { +func (e *Edge) Copy(newParent Node) Node { tmp := *e e = &tmp - e.parent = newp.(*Map) + e.parent = newParent.(*Map) e.References = append([]EdgeReference(nil), e.References...) if e.Primary_ != nil { e.Primary_ = e.Primary_.Copy(e).(*Scalar) @@ -354,16 +414,42 @@ func (e *Edge) Copy(newp Node) Node { return e } +func (e *Edge) LastPrimaryRef() *EdgeReference { + for i := len(e.References) - 1; i >= 0; i-- { + fr := e.References[i] + if fr.Context.Key.EdgeKey == nil { + return fr + } + } + return nil +} + +func (e *Edge) LastPrimaryKey() *d2ast.Key { + fr := f.LastModification() + if fr == nil { + return nil + } + return fr.Context.Key +} + +func (e *Edge) LastRef() *EdgeReference { + return e.References[len(e.References)-1] +} + +func (e *Edge) LastAST() d2ast.Node { + return e.LastRef().Context.Edge +} + type Array struct { parent Node Values []Value `json:"values"` } -func (a *Array) Copy(newp Node) Node { +func (a *Array) Copy(newParent Node) Node { tmp := *a a = &tmp - a.parent = newp + a.parent = newParent a.Values = append([]Value(nil), a.Values...) for i := range a.Values { a.Values[i] = a.Values[i].Copy(a).(Value) @@ -400,8 +486,8 @@ type EdgeReference struct { } type RefContext struct { - Key *d2ast.Key `json:"key"` Edge *d2ast.Edge `json:"edge"` + Key *d2ast.Key `json:"key"` Scope *d2ast.Map `json:"-"` } @@ -696,11 +782,11 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { return e, nil } -func (s *Scalar) AST() d2ast.Node { +func (s *Scalar) ast() d2ast.Node { return s.Value } -func (f *Field) AST() d2ast.Node { +func (f *Field) ast() d2ast.Node { k := &d2ast.Key{ Key: &d2ast.KeyPath{ Path: []*d2ast.StringBox{ @@ -710,16 +796,16 @@ func (f *Field) AST() d2ast.Node { } if f.Primary_ != nil { - k.Primary = d2ast.MakeValueBox(f.Primary_.AST().(d2ast.Value)).ScalarBox() + k.Primary = d2ast.MakeValueBox(f.Primary_.ast().(d2ast.Value)).ScalarBox() } if f.Composite != nil { - k.Value = d2ast.MakeValueBox(f.Composite.AST().(d2ast.Value)) + k.Value = d2ast.MakeValueBox(f.Composite.ast().(d2ast.Value)) } return k } -func (e *Edge) AST() d2ast.Node { +func (e *Edge) ast() d2ast.Node { astEdge := &d2ast.Edge{} astEdge.Src = d2ast.MakeKeyPath(e.ID.SrcPath) @@ -736,27 +822,27 @@ func (e *Edge) AST() d2ast.Node { } if e.Primary_ != nil { - k.Primary = d2ast.MakeValueBox(e.Primary_.AST().(d2ast.Value)).ScalarBox() + k.Primary = d2ast.MakeValueBox(e.Primary_.ast().(d2ast.Value)).ScalarBox() } if e.Map_ != nil { - k.Value = d2ast.MakeValueBox(e.Map_.AST().(*d2ast.Map)) + k.Value = d2ast.MakeValueBox(e.Map_.ast().(*d2ast.Map)) } return k } -func (a *Array) AST() d2ast.Node { +func (a *Array) ast() d2ast.Node { if a == nil { return nil } astArray := &d2ast.Array{} for _, av := range a.Values { - astArray.Nodes = append(astArray.Nodes, d2ast.MakeArrayNodeBox(av.AST().(d2ast.ArrayNode))) + astArray.Nodes = append(astArray.Nodes, d2ast.MakeArrayNodeBox(av.ast().(d2ast.ArrayNode))) } return astArray } -func (m *Map) AST() d2ast.Node { +func (m *Map) ast() d2ast.Node { if m == nil { return nil } @@ -767,10 +853,10 @@ func (m *Map) AST() d2ast.Node { astMap.Range = d2ast.MakeRange(",1:0:0-2:0:0") } for _, f := range m.Fields { - astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(f.AST().(d2ast.MapNode))) + astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(f.ast().(d2ast.MapNode))) } for _, e := range m.Edges { - astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(e.AST().(d2ast.MapNode))) + astMap.Nodes = append(astMap.Nodes, d2ast.MakeMapNodeBox(e.ast().(d2ast.MapNode))) } return astMap } diff --git a/d2layouts/d2sequence/layout_test.go b/d2layouts/d2sequence/layout_test.go index 77767f852..20220ce03 100644 --- a/d2layouts/d2sequence/layout_test.go +++ b/d2layouts/d2sequence/layout_test.go @@ -377,7 +377,7 @@ container -> c: edge 1 } func TestSelfEdges(t *testing.T) { - g := d2graph.NewGraph(nil) + g := d2graph.NewGraph() g.Root.Attributes.Shape = d2graph.Scalar{Value: d2target.ShapeSequenceDiagram} n1 := g.Root.EnsureChild([]string{"n1"}) n1.Box = geo.NewBox(nil, 100, 100) @@ -413,7 +413,7 @@ func TestSelfEdges(t *testing.T) { } func TestSequenceToDescendant(t *testing.T) { - g := d2graph.NewGraph(nil) + g := d2graph.NewGraph() g.Root.Attributes.Shape = d2graph.Scalar{Value: d2target.ShapeSequenceDiagram} a := g.Root.EnsureChild([]string{"a"}) a.Box = geo.NewBox(nil, 100, 100) From 154c7e8947547eb4252a327a7d15f85aac67b1ea Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 22 Jan 2023 00:59:02 -0800 Subject: [PATCH 37/60] d2compiler: Integrate d2ir (wip) --- d2compiler/compile.go | 65 ++++++----------- d2graph/d2graph.go | 15 +++- d2ir/compile.go | 13 +++- d2ir/d2ir.go | 166 ++++++++++++++++++++++++++---------------- d2ir/d2ir_test.go | 2 - 5 files changed, 149 insertions(+), 112 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index c2a829c7d..3133456dd 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -111,13 +111,13 @@ func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) { switch obj.Attributes.Shape.Value { case d2target.ShapeClass: - c.compileClass(obj, m) + c.compileClass(obj) case d2target.ShapeSQLTable: - c.compileSQLTable(obj, m) + c.compileSQLTable(obj) } for _, e := range m.Edges { - c.compileEdge(obj, m, e) + c.compileEdge(obj, e) } } @@ -137,7 +137,7 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { obj = obj.EnsureChild([]string{f.Name}) if f.Primary() != nil { - c.compileLabel(obj, f) + c.compileLabel(obj.Attributes, f) } if f.Map() != nil { c.compileMap(obj, f.Map()) @@ -167,11 +167,11 @@ func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) { attrs.Label.MapKey = f.LastPrimaryKey() } -func (c *compiler) compileReserved(attrs *d2graph.Attributes, f d2ir.Node) { +func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { scalar := f.Primary().Value switch f.Name { case "label": - c.compileLabel(obj, f) + c.compileLabel(attrs, f) case "shape": in := d2target.IsShape(scalar.ScalarString()) if !in { @@ -233,7 +233,13 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f d2ir.Node) { } } -func (c *compiler) compileStyle(attrs *d2graph.Attributes, f d2ir.Node) { +func (c *compiler) compileStyle(attrs *d2graph.Attributes, m *d2ir.Map) { + for _, f := range m.Fields { + c.compileStyleField(attrs, f) + } +} + +func (c *compiler) compileStyleField(attrs *d2graph.Attributes, f *d2ir.Field) { scalar := f.Primary().Value err := attrs.Style.Apply(f.Name, scalar.ScalarString()) if err != nil { @@ -286,7 +292,7 @@ func (c *compiler) compileStyle(attrs *d2graph.Attributes, f d2ir.Node) { func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { edge, err := obj.Connect(e.ID.SrcPath, e.ID.DstPath, e.ID.SrcArrow, e.ID.DstArrow, "") if err != nil { - c.errorf(e, err.Error()) + c.errorf(e.References[0].AST(), err.Error()) return } @@ -297,7 +303,7 @@ func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { for _, f := range e.Map().Fields { _, ok := d2graph.ReservedKeywords[f.Name] if !ok { - c.errorf(mk, `edge map keys must be reserved keywords`) + c.errorf(f.References[0].AST(), `edge map keys must be reserved keywords`) continue } c.compileEdgeField(edge, f) @@ -320,7 +326,7 @@ func (c *compiler) compileEdgeField(edge *d2graph.Edge, f *d2ir.Field) { } if f.Primary() != nil { - c.compileLabel(edge, f) + c.compileLabel(edge.Attributes, f) } if f.Name == "source-arrowhead" || f.Name == "target-arrowhead" { @@ -341,6 +347,7 @@ func (c *compiler) compileArrowheads(edge *d2graph.Edge, f *d2ir.Field) { } for _, f2 := range f.Map().Fields { + keyword := strings.ToLower(f2.Name) _, isReserved := d2graph.ReservedKeywords[keyword] if isReserved { c.compileReserved(attrs, f2) @@ -352,7 +359,7 @@ func (c *compiler) compileArrowheads(edge *d2graph.Edge, f *d2ir.Field) { c.compileStyle(attrs, f2.Map()) continue } else { - c.errorf(mk, `source-arrowhead/target-arrowhead map keys must be reserved keywords`) + c.errorf(f2.LastRef().AST(), `source-arrowhead/target-arrowhead map keys must be reserved keywords`) continue } } @@ -370,24 +377,7 @@ var ShortToFullLanguageAliases = map[string]string{ } var FullToShortLanguageAliases map[string]string -func (c *compiler) compileShapes(obj *d2graph.Object) { - for _, obj := range obj.ChildrenArray { - switch obj.Attributes.Shape.Value { - case d2target.ShapeClass: - c.compileClass(obj) - case d2target.ShapeSQLTable: - c.compileSQLTable(obj) - } - c.compileShapes(obj) - } -} - func (c *compiler) compileClass(obj *d2graph.Object) { - if len(m.Edges) > 0 { - c.errorf(m.Edges[0].LastAST(), "class shapes cannot have edges inside") - return - } - obj.Class = &d2target.Class{} for _, f := range obj.ChildrenArray { visiblity := "public" @@ -436,15 +426,7 @@ func (c *compiler) compileClass(obj *d2graph.Object) { } func (c *compiler) compileSQLTable(obj *d2graph.Object) { - if len(m.Edges) > 0 { - c.errorf(m.Edges[0].LastAST(), "sql_table shapes cannot have edges inside") - return - } - obj.SQLTable = &d2target.SQLTable{} - - parentID := obj.Parent.AbsID() - tableIDPrefix := obj.AbsID() + "." for _, col := range obj.ChildrenArray { typ := col.Attributes.Label.Value if typ == col.IDVal { @@ -480,12 +462,13 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) { } func (c *compiler) validateKeys(obj *d2graph.Object, m *d2ir.Map) { - for _, n := range m.Fields { + for _, f := range m.Fields { c.validateKey(obj, f) } } func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { + keyword := strings.ToLower(f.Name) _, isReserved := d2graph.ReservedKeywords[keyword] if isReserved { switch obj.Attributes.Shape.Value { @@ -526,7 +509,7 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { } default: if len(obj.Children) > 0 && (f.Name == "width" || f.Name == "height") { - c.errorf(f.LastPrimaryKey(), mk.Range.End, fmt.Sprintf("%s cannot be used on container: %s", f.Name, obj.AbsID())) + c.errorf(f.LastPrimaryKey(), fmt.Sprintf("%s cannot be used on container: %s", f.Name, obj.AbsID())) } } @@ -540,12 +523,12 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { } if obj.Attributes.Shape.Value == d2target.ShapeImage { - c.errorf(mk, "image shapes cannot have children.") + c.errorf(obj.Attributes.Shape.MapKey, "image shapes cannot have children.") return } - obj = obj.HasChild([]string{f.Name}) - if f.Map() != nil { + obj, ok := obj.HasChild([]string{f.Name}) + if ok && f.Map() != nil { c.validateKeys(obj, f.Map()) } } diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 9e2e9742b..4984c1864 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -973,7 +973,18 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label } e.initIndex() + addSQLTableColumnIndexes(e, srcID, dstID, obj, src, dst) + + obj.Graph.Edges = append(obj.Graph.Edges, e) + return e, nil +} + +func addSQLTableColumnIndexes(e *Edge, srcID, dstID []string, obj, src, dst *Object) { if src.Attributes.Shape.Value == d2target.ShapeSQLTable { + if src == dst { + // Ignore edge to column inside table. + return + } objAbsID := obj.AbsIDArray() srcAbsID := src.AbsIDArray() if len(objAbsID) + len(srcID) > len(srcAbsID) { @@ -1001,10 +1012,6 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label } } } - - - obj.Graph.Edges = append(obj.Graph.Edges, e) - return e, nil } // TODO: Treat undirectional/bidirectional edge here and in HasEdge flipped. Same with diff --git a/d2ir/compile.go b/d2ir/compile.go index 18278ac97..30f22bc49 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -15,7 +15,16 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { func Compile(ast *d2ast.Map) (*Map, error) { c := &compiler{} - m := &Map{} + m := &Map{ + parent: &Field{ + Name: "", + References: []*FieldReference{{ + Context: &RefContext{ + Scope: ast, + }, + }}, + }, + } c.compileMap(m, ast) c.compileScenarios(m) c.compileSteps(m) @@ -160,7 +169,7 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { continue } e = ea[0] - e.References = append(e.References, EdgeReference{ + e.References = append(e.References, &EdgeReference{ Context: refctx, }) dst.appendFieldReferences(0, refctx.Edge.Src, refctx) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index ca5a8b5ce..438eaf1c9 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -30,11 +30,6 @@ type Node interface { LastPrimaryKey() *d2ast.Key } -type Reference interface { - reference() - AST() d2ast.Node -} - var _ Node = &Scalar{} var _ Node = &Field{} var _ Node = &Edge{} @@ -109,6 +104,26 @@ func (n *Edge) String() string { return d2format.Format(n.ast()) } func (n *Array) String() string { return d2format.Format(n.ast()) } func (n *Map) String() string { return d2format.Format(n.ast()) } +func (n *Scalar) LastRef() Reference { return parentRef(n) } +func (n *Map) LastRef() Reference { return parentRef(n) } +func (n *Array) LastRef() Reference { return parentRef(n) } + +func (n *Scalar) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } +func (n *Map) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } +func (n *Array) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } + +type Reference interface { + reference() + // Most specific AST node for the reference. + AST() d2ast.Node +} + +var _ Reference = &FieldReference{} +var _ Reference = &EdgeReference{} + +func (r *FieldReference) reference() {} +func (r *EdgeReference) reference() {} + type Scalar struct { parent Node Value d2ast.Scalar `json:"value"` @@ -174,18 +189,14 @@ func (m *Map) CopyBase(newParent Node) *Map { // Root reports whether the Map is the root of the D2 tree. func (m *Map) Root() bool { - return m.parent == nil -} - -func (f *Map) LastRef() *MapReference { - if f.parent == nil { - return nil + // m.parent exists even on the root map as we store the root AST in + // m.parent.References[0].Context.Map for reporting error messages about the whole IR. + // Or if otherwise needed. + f, ok := m.parent.(*Field) + if !ok { + return false } - return f.References[len(f.References)-1] -} - -func (f *Map) LastAST() d2ast.Node { - return f.LastRef().String + return f.Name == "" } type LayerKind string @@ -199,25 +210,26 @@ const ( // NodeLayerKind reports whether n represents the root of a layer. // n should be *Field or *Map func NodeLayerKind(n Node) LayerKind { + var f *Field switch n := n.(type) { case *Field: - n = ParentField(n) - if n != nil { - switch n.Name { - case "layers": - return LayerLayer - case "scenarios": - return LayerScenario - case "steps": - return LayerStep - } - } + f = ParentField(n) case *Map: - f := ParentField(n) - if f == nil { - return LayerLayer - } - return NodeLayerKind(f) + f = ParentField(n) + } + if f == nil { + return "" + } + switch f.Name { + case "layers": + return LayerLayer + case "scenarios": + return LayerScenario + case "steps": + return LayerStep + case "": + // root + return LayerLayer } return "" } @@ -230,7 +242,7 @@ type Field struct { Primary_ *Scalar `json:"primary,omitempty"` Composite Composite `json:"composite,omitempty"` - References []FieldReference `json:"references,omitempty"` + References []*FieldReference `json:"references,omitempty"` } func (f *Field) Copy(newParent Node) Node { @@ -238,7 +250,7 @@ func (f *Field) Copy(newParent Node) Node { f = &tmp f.parent = newParent.(*Map) - f.References = append([]FieldReference(nil), f.References...) + f.References = append([]*FieldReference(nil), f.References...) if f.Primary_ != nil { f.Primary_ = f.Primary_.Copy(f).(*Scalar) } @@ -248,7 +260,7 @@ func (f *Field) Copy(newParent Node) Node { return f } -func (f *Field) LastPrimaryRef() *FieldReference { +func (f *Field) lastPrimaryRef() *FieldReference { inEdge := ParentEdge(f) != nil for i := len(f.References) - 1; i >= 0; i-- { fr := f.References[i] @@ -266,21 +278,17 @@ func (f *Field) LastPrimaryRef() *FieldReference { } func (f *Field) LastPrimaryKey() *d2ast.Key { - fr := f.LastModification() + fr := f.lastPrimaryRef() if fr == nil { return nil } return fr.Context.Key } -func (f *Field) LastRef() *FieldReference { +func (f *Field) LastRef() Reference { return f.References[len(f.References)-1] } -func (f *Field) LastAST() d2ast.Node { - return f.LastRef().String -} - type EdgeID struct { SrcPath []string `json:"src_path"` SrcArrow bool `json:"src_arrow"` @@ -396,7 +404,7 @@ type Edge struct { Primary_ *Scalar `json:"primary,omitempty"` Map_ *Map `json:"map,omitempty"` - References []EdgeReference `json:"references,omitempty"` + References []*EdgeReference `json:"references,omitempty"` } func (e *Edge) Copy(newParent Node) Node { @@ -404,7 +412,7 @@ func (e *Edge) Copy(newParent Node) Node { e = &tmp e.parent = newParent.(*Map) - e.References = append([]EdgeReference(nil), e.References...) + e.References = append([]*EdgeReference(nil), e.References...) if e.Primary_ != nil { e.Primary_ = e.Primary_.Copy(e).(*Scalar) } @@ -414,7 +422,7 @@ func (e *Edge) Copy(newParent Node) Node { return e } -func (e *Edge) LastPrimaryRef() *EdgeReference { +func (e *Edge) lastPrimaryRef() *EdgeReference { for i := len(e.References) - 1; i >= 0; i-- { fr := e.References[i] if fr.Context.Key.EdgeKey == nil { @@ -425,21 +433,17 @@ func (e *Edge) LastPrimaryRef() *EdgeReference { } func (e *Edge) LastPrimaryKey() *d2ast.Key { - fr := f.LastModification() - if fr == nil { + er := e.lastPrimaryRef() + if er == nil { return nil } - return fr.Context.Key + return er.Context.Key } -func (e *Edge) LastRef() *EdgeReference { +func (e *Edge) LastRef() Reference { return e.References[len(e.References)-1] } -func (e *Edge) LastAST() d2ast.Node { - return e.LastRef().Context.Edge -} - type Array struct { parent Node Values []Value `json:"values"` @@ -464,27 +468,39 @@ type FieldReference struct { Context *RefContext `json:"context"` } -func (kr FieldReference) KeyPathIndex() int { - for i, sb := range kr.KeyPath.Path { - if sb.Unbox() == kr.String { +func (fr *FieldReference) KeyPathIndex() int { + for i, sb := range fr.KeyPath.Path { + if sb.Unbox() == fr.String { return i } } panic("d2ir.KeyReference.KeyPathIndex: String not in KeyPath?") } -func (kr FieldReference) EdgeDest() bool { - return kr.KeyPath == kr.Context.Edge.Dst +func (fr *FieldReference) EdgeDest() bool { + return fr.KeyPath == fr.Context.Edge.Dst } -func (kr FieldReference) InEdge() bool { - return kr.Context.Edge != nil +func (fr *FieldReference) InEdge() bool { + return fr.Context.Edge != nil +} + +func (fr *FieldReference) AST() d2ast.Node { + if fr.String == nil { + // Root map. + return fr.Context.Scope + } + return fr.String } type EdgeReference struct { Context *RefContext `json:"context"` } +func (er *EdgeReference) AST() d2ast.Node { + return er.Context.Edge +} + type RefContext struct { Edge *d2ast.Edge `json:"edge"` Key *d2ast.Key `json:"key"` @@ -628,7 +644,7 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, continue } - f.References = append(f.References, FieldReference{ + f.References = append(f.References, &FieldReference{ String: kp.Path[i].Unbox(), KeyPath: kp, Context: refctx, @@ -651,7 +667,7 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, f := &Field{ parent: m, Name: head, - References: []FieldReference{{ + References: []*FieldReference{{ String: kp.Path[i].Unbox(), KeyPath: kp, Context: refctx, @@ -773,7 +789,7 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { e := &Edge{ parent: m, ID: eid, - References: []EdgeReference{{ + References: []*EdgeReference{{ Context: refctx, }}, } @@ -868,7 +884,7 @@ func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext return } - f.References = append(f.References, FieldReference{ + f.References = append(f.References, &FieldReference{ String: sb.Unbox(), KeyPath: kp, Context: refctx, @@ -945,3 +961,27 @@ func hasLayerKeywords(ida ...string) int { } return -1 } + +func parentRef(n Node) Reference { + f := ParentField(n) + if f != nil { + return f.LastRef() + } + e := ParentEdge(n) + if e != nil { + return e.LastRef() + } + return nil +} + +func parentPrimaryKey(n Node) *d2ast.Key { + f := ParentField(n) + if f != nil { + return f.LastPrimaryKey() + } + e := ParentEdge(n) + if e != nil { + return e.LastPrimaryKey() + } + return nil +} diff --git a/d2ir/d2ir_test.go b/d2ir/d2ir_test.go index cac84e7b3..c8b34dbc0 100644 --- a/d2ir/d2ir_test.go +++ b/d2ir/d2ir_test.go @@ -39,12 +39,10 @@ func TestCopy(t *testing.T) { Composite: a, } e := &d2ir.Edge{ - Primary_: s, Map_: m2, } m := &d2ir.Map{ - Fields: []*d2ir.Field{f}, Edges: []*d2ir.Edge{e}, } From b900f6341487996174ec75905d3670c48ba4f7fe Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 22 Jan 2023 01:08:13 -0800 Subject: [PATCH 38/60] d2compiler: Integrate d2ir (wip) --- d2compiler/compile.go | 6 ++++++ d2ir/d2ir.go | 25 ++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 3133456dd..9f4512dd5 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -168,6 +168,9 @@ func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) { } func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { + if f.Primary() == nil { + return + } scalar := f.Primary().Value switch f.Name { case "label": @@ -240,6 +243,9 @@ func (c *compiler) compileStyle(attrs *d2graph.Attributes, m *d2ir.Map) { } func (c *compiler) compileStyleField(attrs *d2graph.Attributes, f *d2ir.Field) { + if f.Primary() == nil { + return + } scalar := f.Primary().Value err := attrs.Style.Apply(f.Name, scalar.ScalarString()) if err != nil { diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 438eaf1c9..15788ee3d 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -235,7 +235,8 @@ func NodeLayerKind(n Node) LayerKind { } type Field struct { - parent *Map + // *Map. + parent Node Name string `json:"name"` @@ -249,7 +250,7 @@ func (f *Field) Copy(newParent Node) Node { tmp := *f f = &tmp - f.parent = newParent.(*Map) + f.parent = newParent f.References = append([]*FieldReference(nil), f.References...) if f.Primary_ != nil { f.Primary_ = f.Primary_.Copy(f).(*Scalar) @@ -397,7 +398,8 @@ func (eid *EdgeID) trimCommon() (common []string, _ *EdgeID) { } type Edge struct { - parent *Map + // *Map + parent Node ID *EdgeID `json:"edge_id"` @@ -411,7 +413,7 @@ func (e *Edge) Copy(newParent Node) Node { tmp := *e e = &tmp - e.parent = newParent.(*Map) + e.parent = newParent e.References = append([]*EdgeReference(nil), e.References...) if e.Primary_ != nil { e.Primary_ = e.Primary_.Copy(e).(*Scalar) @@ -898,8 +900,11 @@ func (m *Map) appendFieldReferences(i int, kp *d2ast.KeyPath, refctx *RefContext } func ParentMap(n Node) *Map { - for n.Parent() != nil { + for { n = n.Parent() + if n == nil { + return nil + } if m, ok := n.(*Map); ok { return m } @@ -908,8 +913,11 @@ func ParentMap(n Node) *Map { } func ParentField(n Node) *Field { - for n.Parent() != nil { + for { n = n.Parent() + if n == nil { + return nil + } if f, ok := n.(*Field); ok { return f } @@ -932,8 +940,11 @@ func ParentLayer(n Node) *Map { } func ParentEdge(n Node) *Edge { - for n.Parent() != nil { + for { n = n.Parent() + if n == nil { + return nil + } if e, ok := n.(*Edge); ok { return e } From 566ea11db7bccb057e88e0bedf117e27452e72b0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 22 Jan 2023 01:43:25 -0800 Subject: [PATCH 39/60] d2compiler: Integrate d2ir (wip) --- d2compiler/compile.go | 35 ++++++++++++++++++++++++++++++----- d2graph/d2graph.go | 14 +++++++++++--- d2ir/compile.go | 12 +++++++++--- d2ir/d2ir.go | 27 +++++++++++---------------- 4 files changed, 61 insertions(+), 27 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 9f4512dd5..c9d9b1604 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -123,7 +123,7 @@ func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) { func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { keyword := strings.ToLower(f.Name) - _, isReserved := d2graph.ReservedKeywords[keyword] + _, isReserved := d2graph.SimpleReservedKeywords[keyword] if isReserved { c.compileReserved(obj.Attributes, f) return @@ -142,6 +142,18 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { if f.Map() != nil { c.compileMap(obj, f.Map()) } + + for _, er := range f.References { + obj.References = append(obj.References, d2graph.Reference{ + Key: er.KeyPath, + KeyPathIndex: er.KeyPathIndex(), + + MapKey: er.Context.Key, + MapKeyEdgeIndex: er.Context.EdgeIndex(), + Scope: er.Context.Scope, + ScopeObj: obj.Parent, + }) + } } func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) { @@ -246,13 +258,16 @@ func (c *compiler) compileStyleField(attrs *d2graph.Attributes, f *d2ir.Field) { if f.Primary() == nil { return } + compileStyleFieldInit(attrs, f) scalar := f.Primary().Value err := attrs.Style.Apply(f.Name, scalar.ScalarString()) if err != nil { c.errorf(scalar, err.Error()) return } +} +func compileStyleFieldInit(attrs *d2graph.Attributes, f *d2ir.Field) { switch f.Name { case "opacity": attrs.Style.Opacity = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} @@ -315,11 +330,21 @@ func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { c.compileEdgeField(edge, f) } } + + for _, er := range e.References { + edge.References = append(edge.References, d2graph.EdgeReference{ + Edge: er.Context.Edge, + MapKey: er.Context.Key, + MapKeyEdgeIndex: er.Context.EdgeIndex(), + Scope: er.Context.Scope, + ScopeObj: obj, + }) + } } func (c *compiler) compileEdgeField(edge *d2graph.Edge, f *d2ir.Field) { keyword := strings.ToLower(f.Name) - _, isReserved := d2graph.ReservedKeywords[keyword] + _, isReserved := d2graph.SimpleReservedKeywords[keyword] if isReserved { c.compileReserved(edge.Attributes, f) return @@ -354,7 +379,7 @@ func (c *compiler) compileArrowheads(edge *d2graph.Edge, f *d2ir.Field) { for _, f2 := range f.Map().Fields { keyword := strings.ToLower(f2.Name) - _, isReserved := d2graph.ReservedKeywords[keyword] + _, isReserved := d2graph.SimpleReservedKeywords[keyword] if isReserved { c.compileReserved(attrs, f2) continue @@ -474,8 +499,8 @@ func (c *compiler) validateKeys(obj *d2graph.Object, m *d2ir.Map) { } func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { - keyword := strings.ToLower(f.Name) - _, isReserved := d2graph.ReservedKeywords[keyword] + keyword := strings.ToLower(f.Name) + _, isReserved := d2graph.SimpleReservedKeywords[keyword] if isReserved { switch obj.Attributes.Shape.Value { case d2target.ShapeSQLTable, d2target.ShapeClass: diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 4984c1864..27a723923 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -987,7 +987,7 @@ func addSQLTableColumnIndexes(e *Edge, srcID, dstID []string, obj, src, dst *Obj } objAbsID := obj.AbsIDArray() srcAbsID := src.AbsIDArray() - if len(objAbsID) + len(srcID) > len(srcAbsID) { + if len(objAbsID)+len(srcID) > len(srcAbsID) { for i, d2col := range src.SQLTable.Columns { if d2col.Name.Label == srcID[len(srcID)-1] { d2col.Reference = dst.AbsID() @@ -1001,7 +1001,7 @@ func addSQLTableColumnIndexes(e *Edge, srcID, dstID []string, obj, src, dst *Obj if dst.Attributes.Shape.Value == d2target.ShapeSQLTable { objAbsID := obj.AbsIDArray() dstAbsID := dst.AbsIDArray() - if len(objAbsID) + len(dstID) > len(dstAbsID) { + if len(objAbsID)+len(dstID) > len(dstAbsID) { for i, d2col := range dst.SQLTable.Columns { if d2col.Name.Label == dstID[len(dstID)-1] { d2col.Reference = dst.AbsID() @@ -1284,7 +1284,11 @@ func Key(k *d2ast.KeyPath) []string { return d2format.KeyPath(k) } -var ReservedKeywords = map[string]struct{}{ +// All reserved keywords. See init below. +var ReservedKeywords map[string]struct{} + +// Non Style/Holder keywords. +var SimpleReservedKeywords = map[string]struct{}{ "label": {}, "desc": {}, "shape": {}, @@ -1351,6 +1355,10 @@ var NearConstantsArray = []string{ var NearConstants map[string]struct{} func init() { + ReservedKeywords = make(map[string]struct{}) + for k, v := range SimpleReservedKeywords { + ReservedKeywords[k] = v + } for k, v := range StyleKeywords { ReservedKeywords[k] = v } diff --git a/d2ir/compile.go b/d2ir/compile.go index 30f22bc49..80021a606 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -206,6 +206,10 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { parent: e, Value: refctx.Key.Primary.Unbox(), } + } + if refctx.Key.Value.Array != nil { + c.errorf(refctx.Key.Value.Unbox(), "edges cannot be assigned arrays") + continue } else if refctx.Key.Value.Map != nil { if e.Map_ == nil { e.Map_ = &Map{ @@ -213,9 +217,11 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { } } c.compileMap(e.Map_, refctx.Key.Value.Map) - } else if refctx.Key.Value.Unbox() != nil { - c.errorf(refctx.Key.Value.Unbox(), "edges cannot be assigned arrays") - continue + } else if refctx.Key.Value.ScalarBox().Unbox() != nil { + e.Primary_ = &Scalar{ + parent: e, + Value: refctx.Key.Value.ScalarBox().Unbox(), + } } } } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 15788ee3d..f73d0e7fd 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -105,12 +105,12 @@ func (n *Array) String() string { return d2format.Format(n.ast()) } func (n *Map) String() string { return d2format.Format(n.ast()) } func (n *Scalar) LastRef() Reference { return parentRef(n) } -func (n *Map) LastRef() Reference { return parentRef(n) } -func (n *Array) LastRef() Reference { return parentRef(n) } +func (n *Map) LastRef() Reference { return parentRef(n) } +func (n *Array) LastRef() Reference { return parentRef(n) } func (n *Scalar) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } -func (n *Map) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } -func (n *Array) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } +func (n *Map) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } +func (n *Array) LastPrimaryKey() *d2ast.Key { return parentPrimaryKey(n) } type Reference interface { reference() @@ -213,7 +213,7 @@ func NodeLayerKind(n Node) LayerKind { var f *Field switch n := n.(type) { case *Field: - f = ParentField(n) + f = n case *Map: f = ParentField(n) } @@ -540,7 +540,7 @@ func (rc *RefContext) EdgeIndex() int { return i } } - panic("d2ir.RefContext.EdgeIndex: Edge not in Key.Edges?") + return -1 } func (m *Map) FieldCountRecursive() int { @@ -909,7 +909,6 @@ func ParentMap(n Node) *Map { return m } } - return nil } func ParentField(n Node) *Field { @@ -922,20 +921,17 @@ func ParentField(n Node) *Field { return f } } - return nil } -func ParentLayer(n Node) *Map { +func ParentLayer(n Node) Node { for { - // ParentMap and not ParentField so we get the root layer too. - m := ParentMap(n) - if m == nil { + n = n.Parent() + if n == nil { return nil } - if NodeLayerKind(m) != "" { - return m + if NodeLayerKind(n) != "" { + return n } - n = m } } @@ -949,7 +945,6 @@ func ParentEdge(n Node) *Edge { return e } } - return nil } func countUnderscores(p []string) int { From 5af31670d1f9fa762f2413595e7173ab0fa9b49e Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 23 Jan 2023 21:48:43 -0800 Subject: [PATCH 40/60] d2compiler: Integrate d2ir (wip) --- d2compiler/compile.go | 93 ++++++++++++++++-------- d2compiler/compile_test.go | 35 ++++++++- d2graph/d2graph.go | 36 +++++---- d2graph/seqdiagram.go | 2 +- d2ir/compile.go | 32 ++++---- d2ir/d2ir.go | 67 ++++++++--------- d2layouts/d2sequence/sequence_diagram.go | 2 +- d2oracle/edit.go | 6 +- 8 files changed, 173 insertions(+), 100 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index c9d9b1604..cfaf80f60 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -105,7 +105,14 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { } func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) { + shape := m.GetField("shape") + if shape != nil { + c.compileField(obj, shape) + } for _, f := range m.Fields { + if f.Name == "shape" { + continue + } c.compileField(obj, f) } @@ -135,7 +142,7 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { return } - obj = obj.EnsureChild([]string{f.Name}) + obj = obj.EnsureChild(d2graphIDA([]string{f.Name})) if f.Primary() != nil { c.compileLabel(obj.Attributes, f) } @@ -143,15 +150,20 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { c.compileMap(obj, f.Map()) } - for _, er := range f.References { + for _, fr := range f.References { + if fr.OurValue() && fr.Context.Key.Value.Map != nil { + obj.Map = fr.Context.Key.Value.Map + } + scopeObjIDA := d2ir.IDA(fr.Context.ScopeMap) + scopeObj, _ := obj.Graph.Root.HasChild(scopeObjIDA) obj.References = append(obj.References, d2graph.Reference{ - Key: er.KeyPath, - KeyPathIndex: er.KeyPathIndex(), + Key: fr.KeyPath, + KeyPathIndex: fr.KeyPathIndex(), - MapKey: er.Context.Key, - MapKeyEdgeIndex: er.Context.EdgeIndex(), - Scope: er.Context.Scope, - ScopeObj: obj.Parent, + MapKey: fr.Context.Key, + MapKeyEdgeIndex: fr.Context.EdgeIndex(), + Scope: fr.Context.Scope, + ScopeObj: scopeObj, }) } } @@ -181,6 +193,9 @@ func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) { func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { if f.Primary() == nil { + if f.Composite != nil { + c.errorf(f.LastPrimaryKey(), "reserved field %v does not accept composite", f.Name) + } return } scalar := f.Primary().Value @@ -244,7 +259,12 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { attrs.Direction.Value = scalar.ScalarString() attrs.Direction.MapKey = f.LastPrimaryKey() case "constraint": - // Compilation for shape-specific keywords happens elsewhere + if _, ok := scalar.(d2ast.String); !ok { + c.errorf(f.LastPrimaryKey(), "constraint value must be a string") + return + } + attrs.Constraint.Value = scalar.ScalarString() + attrs.Constraint.MapKey = f.LastPrimaryKey() } } @@ -311,7 +331,7 @@ func compileStyleFieldInit(attrs *d2graph.Attributes, f *d2ir.Field) { } func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { - edge, err := obj.Connect(e.ID.SrcPath, e.ID.DstPath, e.ID.SrcArrow, e.ID.DstArrow, "") + edge, err := obj.Connect(d2graphIDA(e.ID.SrcPath), d2graphIDA(e.ID.DstPath), e.ID.SrcArrow, e.ID.DstArrow, "") if err != nil { c.errorf(e.References[0].AST(), err.Error()) return @@ -332,12 +352,14 @@ func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { } for _, er := range e.References { + scopeObjIDA := d2ir.IDA(er.Context.ScopeMap) + scopeObj, _ := edge.Src.Graph.Root.HasChild(scopeObjIDA) edge.References = append(edge.References, d2graph.EdgeReference{ - Edge: er.Context.Edge, - MapKey: er.Context.Key, + Edge: er.Context.Edge, + MapKey: er.Context.Key, MapKeyEdgeIndex: er.Context.EdgeIndex(), - Scope: er.Context.Scope, - ScopeObj: obj, + Scope: er.Context.Scope, + ScopeObj: scopeObj, }) } } @@ -452,6 +474,14 @@ func (c *compiler) compileClass(obj *d2graph.Object) { } } + for _, ch := range obj.ChildrenArray { + for i := 0; i < len(obj.Graph.Objects); i++ { + if obj.Graph.Objects[i] == ch { + obj.Graph.Objects = append(obj.Graph.Objects[:i], obj.Graph.Objects[i+1:]...) + i-- + } + } + } obj.Children = nil obj.ChildrenArray = nil } @@ -469,25 +499,20 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) { Name: d2target.Text{Label: col.IDVal}, Type: d2target.Text{Label: typ}, } - // The only map a sql table field could have is to specify constraint - if col.Map != nil { - for _, n := range col.Map.Nodes { - if n.MapKey.Key == nil || len(n.MapKey.Key.Path) == 0 { - continue - } - if n.MapKey.Key.Path[0].Unbox().ScalarString() == "constraint" { - if n.MapKey.Value.StringBox().Unbox() == nil { - c.errorf(n.MapKey, "constraint value must be a string") - return - } - d2Col.Constraint = n.MapKey.Value.StringBox().Unbox().ScalarString() - } - } + if col.Attributes.Constraint.Value != "" { + d2Col.Constraint = col.Attributes.Constraint.Value } - obj.SQLTable.Columns = append(obj.SQLTable.Columns, d2Col) } + for _, ch := range obj.ChildrenArray { + for i := 0; i < len(obj.Graph.Objects); i++ { + if obj.Graph.Objects[i] == ch { + obj.Graph.Objects = append(obj.Graph.Objects[:i], obj.Graph.Objects[i+1:]...) + i-- + } + } + } obj.Children = nil obj.ChildrenArray = nil } @@ -604,3 +629,13 @@ func init() { FullToShortLanguageAliases[v] = k } } + +func d2graphIDA(irIDA []string) (ida []string) { + for _, el := range irIDA { + n := &d2ast.KeyPath{ + Path: []*d2ast.StringBox{d2ast.MakeValueBox(d2ast.RawString(el, true)).StringBox()}, + } + ida = append(ida, d2format.Format(n)) + } + return ida +} diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 514a503f8..a3ab9d75b 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -336,8 +336,7 @@ x: { `, assertions: func(t *testing.T, g *d2graph.Graph) { tassert.Equal(t, "y", g.Objects[1].ID) - tassert.Equal(t, g.Root.AbsID(), g.Objects[1].References[0].ScopeObj.AbsID()) - tassert.Equal(t, g.Objects[0].AbsID(), g.Objects[1].References[0].UnresolvedScopeObj.AbsID()) + tassert.Equal(t, g.Objects[0].AbsID(), g.Objects[1].References[0].ScopeObj.AbsID()) }, }, { @@ -1847,7 +1846,7 @@ choo: { test_id: varchar(64) {constraint: [primary_key, foreign_key]} } `, - expErr: `d2/testdata/d2compiler/TestCompile/sql-panic.d2:3:27: constraint value must be a string`, + expErr: `d2/testdata/d2compiler/TestCompile/sql-panic.d2:3:27: reserved field constraint does not accept composite`, }, { name: "wrong_column_index", @@ -1932,7 +1931,7 @@ func testScenarios(t *testing.T) { run func(t *testing.T) }{ { - name: "one", + name: "root", run: func(t *testing.T) { g := assertCompile(t, `base @@ -1950,6 +1949,34 @@ layers: { assert.JSON(t, "two", g.Layers[1].Name) }, }, + { + name: "recursive", + run: func(t *testing.T) { + g := assertCompile(t, `base + +layers: { + one: { + santa + } + two: { + clause + steps: { + seinfeld: { + reindeer + } + missoula: { + montana + } + } + } +} +`, "") + assert.Equal(t, 2, len(g.Layers)) + assert.Equal(t, "one", g.Layers[0].Name) + assert.Equal(t, "two", g.Layers[1].Name) + assert.Equal(t, 2, len(g.Layers[1].Steps)) + }, + }, } for _, tc := range tca { diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 27a723923..a685ae963 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -108,7 +108,8 @@ type Attributes struct { // TODO: default to ShapeRectangle instead of empty string Shape Scalar `json:"shape"` - Direction Scalar `json:"direction"` + Direction Scalar `json:"direction"` + Constraint Scalar `json:"constraint"` } // TODO references at the root scope should have their Scope set to root graph AST @@ -119,9 +120,7 @@ type Reference struct { MapKey *d2ast.Key `json:"-"` MapKeyEdgeIndex int `json:"map_key_edge_index"` Scope *d2ast.Map `json:"-"` - // The ScopeObj and UnresolvedScopeObj are the same except when the key contains underscores - ScopeObj *Object `json:"-"` - UnresolvedScopeObj *Object `json:"-"` + ScopeObj *Object `json:"-"` } func (r Reference) MapKeyEdgeDest() bool { @@ -517,6 +516,9 @@ func (obj *Object) newObject(id string) *Object { } func (obj *Object) HasChild(ids []string) (*Object, bool) { + if len(ids) == 0 { + return obj, true + } if len(ids) == 1 && ids[0] != "style" { _, ok := ReservedKeywords[ids[0]] if ok { @@ -632,15 +634,22 @@ func (obj *Object) FindEdges(mk *d2ast.Key) ([]*Edge, bool) { return ea, true } +func (obj *Object) ensureChildEdge(ids []string) *Object { + for i := range ids { + switch obj.Attributes.Shape.Value { + case d2target.ShapeClass, d2target.ShapeSQLTable: + // This will only be called for connecting edges where we want to truncate to the + // container. + return obj + } + obj = obj.EnsureChild(ids[i : i+1]) + } + return obj +} + // EnsureChild grabs the child by ids or creates it if it does not exist including all // intermediate nodes. func (obj *Object) EnsureChild(ids []string) *Object { - switch obj.Attributes.Shape.Value { - case d2target.ShapeClass, d2target.ShapeSQLTable: - // This will only be called for connecting edges where we want to truncate to the - // container. - return obj - } _, is := ReservedKeywordHolders[ids[0]] if len(ids) == 1 && !is { _, ok := ReservedKeywords[ids[0]] @@ -664,8 +673,7 @@ func (obj *Object) EnsureChild(ids []string) *Object { } func (obj *Object) AppendReferences(ida []string, ref Reference, unresolvedObj *Object) { - ref.ScopeObj = obj - ref.UnresolvedScopeObj = unresolvedObj + ref.ScopeObj = unresolvedObj numUnderscores := 0 for i := range ida { if ida[i] == "_" { @@ -953,8 +961,8 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label } } - src := srcObj.EnsureChild(srcID) - dst := dstObj.EnsureChild(dstID) + src := srcObj.ensureChildEdge(srcID) + dst := dstObj.ensureChildEdge(dstID) if src.OuterSequenceDiagram() != dst.OuterSequenceDiagram() { return nil, errors.New("connections within sequence diagrams can connect only to other objects within the same sequence diagram") diff --git a/d2graph/seqdiagram.go b/d2graph/seqdiagram.go index 0f6567596..08a2f6ce3 100644 --- a/d2graph/seqdiagram.go +++ b/d2graph/seqdiagram.go @@ -65,7 +65,7 @@ func (obj *Object) ContainsAnyObject(objects []*Object) bool { func (o *Object) ContainedBy(obj *Object) bool { for _, ref := range o.References { - curr := ref.UnresolvedScopeObj + curr := ref.ScopeObj for curr != nil { if curr == obj { return true diff --git a/d2ir/compile.go b/d2ir/compile.go index 80021a606..e09bb2836 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -25,6 +25,7 @@ func Compile(ast *d2ast.Map) (*Map, error) { }}, }, } + m.parent.(*Field).References[0].Context.ScopeMap = m c.compileMap(m, ast) c.compileScenarios(m) c.compileSteps(m) @@ -85,9 +86,10 @@ func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { for _, n := range ast.Nodes { switch { case n.MapKey != nil: - c.compileKey(dst, &RefContext{ - Key: n.MapKey, - Scope: ast, + c.compileKey(&RefContext{ + Key: n.MapKey, + Scope: ast, + ScopeMap: dst, }) case n.Substitution != nil: panic("TODO") @@ -95,11 +97,11 @@ func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { } } -func (c *compiler) compileKey(dst *Map, refctx *RefContext) { +func (c *compiler) compileKey(refctx *RefContext) { if len(refctx.Key.Edges) == 0 { - c.compileField(dst, refctx.Key.Key, refctx) + c.compileField(refctx.ScopeMap, refctx.Key.Key, refctx) } else { - c.compileEdges(dst, refctx) + c.compileEdges(refctx) } } @@ -137,9 +139,9 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) } } -func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { +func (c *compiler) compileEdges(refctx *RefContext) { if refctx.Key.Key != nil { - f, err := dst.EnsureField(refctx.Key.Key, refctx) + f, err := refctx.ScopeMap.EnsureField(refctx.Key.Key, refctx) if err != nil { c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) return @@ -153,7 +155,7 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { parent: f, } } - dst = f.Map() + refctx.ScopeMap = f.Map() } eida := NewEdgeIDs(refctx.Key) @@ -163,7 +165,7 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { var e *Edge if eid.Index != nil { - ea := dst.GetEdges(eid) + ea := refctx.ScopeMap.GetEdges(eid) if len(ea) == 0 { c.errorf(refctx.Edge, "indexed edge does not exist") continue @@ -172,21 +174,21 @@ func (c *compiler) compileEdges(dst *Map, refctx *RefContext) { e.References = append(e.References, &EdgeReference{ Context: refctx, }) - dst.appendFieldReferences(0, refctx.Edge.Src, refctx) - dst.appendFieldReferences(0, refctx.Edge.Dst, refctx) + refctx.ScopeMap.appendFieldReferences(0, refctx.Edge.Src, refctx) + refctx.ScopeMap.appendFieldReferences(0, refctx.Edge.Dst, refctx) } else { - _, err := dst.EnsureField(refctx.Edge.Src, refctx) + _, err := refctx.ScopeMap.EnsureField(refctx.Edge.Src, refctx) if err != nil { c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) continue } - _, err = dst.EnsureField(refctx.Edge.Dst, refctx) + _, err = refctx.ScopeMap.EnsureField(refctx.Edge.Dst, refctx) if err != nil { c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) continue } - e, err = dst.CreateEdge(eid, refctx) + e, err = refctx.ScopeMap.CreateEdge(eid, refctx) if err != nil { c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) continue diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index f73d0e7fd..59aee6941 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -262,17 +262,9 @@ func (f *Field) Copy(newParent Node) Node { } func (f *Field) lastPrimaryRef() *FieldReference { - inEdge := ParentEdge(f) != nil for i := len(f.References) - 1; i >= 0; i-- { - fr := f.References[i] - if inEdge && len(fr.Context.Key.Edges) > 0 { - if fr.String == fr.Context.Key.EdgeKey.Path[len(fr.Context.Key.EdgeKey.Path)-1].Unbox() { - return fr - } - } else { - if fr.String == fr.Context.Key.Key.Path[len(fr.Context.Key.Key.Path)-1].Unbox() { - return fr - } + if f.References[i].OurValue() { + return f.References[i] } } return nil @@ -470,6 +462,17 @@ type FieldReference struct { Context *RefContext `json:"context"` } +// OurValue returns true if the Value in Context.Key.Value corresponds to the Field +// represented by String. +func (fr *FieldReference) OurValue() bool { + if fr.KeyPath == fr.Context.Key.Key { + return fr.KeyPathIndex() == len(fr.KeyPath.Path)-1 + } else if fr.KeyPath == fr.Context.Key.EdgeKey { + return fr.KeyPathIndex() == len(fr.KeyPath.Path)-1 + } + return false +} + func (fr *FieldReference) KeyPathIndex() int { for i, sb := range fr.KeyPath.Path { if sb.Unbox() == fr.String { @@ -504,9 +507,10 @@ func (er *EdgeReference) AST() d2ast.Node { } type RefContext struct { - Edge *d2ast.Edge `json:"edge"` - Key *d2ast.Key `json:"key"` - Scope *d2ast.Map `json:"-"` + Edge *d2ast.Edge `json:"edge"` + Key *d2ast.Key `json:"key"` + Scope *d2ast.Map `json:"-"` + ScopeMap *Map `json:"-"` } func (rc *RefContext) Copy() *RefContext { @@ -514,26 +518,6 @@ func (rc *RefContext) Copy() *RefContext { return &tmp } -// UnresolvedScopeMap is scope prior to interpreting _ -// It does this by finding the referenced *Map of rc.Scope -func (rc *RefContext) UnresolvedScopeMap(m *Map) *Map { - for { - fm := ParentField(m) - if fm == nil { - return m - } - for _, ref := range fm.References { - if ref.KeyPath != ref.Context.Key.Key { - continue - } - if ref.Context.Key.Value.Unbox() == rc.Scope { - return m - } - } - m = ParentMap(m) - } -} - func (rc *RefContext) EdgeIndex() int { for i, e := range rc.Key.Edges { if e == rc.Edge { @@ -991,3 +975,20 @@ func parentPrimaryKey(n Node) *d2ast.Key { } return nil } + +func IDA(n Node) (ida []string) { + for { + f, ok := n.(*Field) + if ok { + if f.Name == "" { + return ida + } + ida = append(ida, f.Name) + } + f = ParentField(n) + if f == nil { + return ida + } + n = f + } +} diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 1da928656..43859aa35 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -225,7 +225,7 @@ func (sd *sequenceDiagram) placeGroup(group *d2graph.Object) { for _, n := range sd.notes { inGroup := false for _, ref := range n.References { - curr := ref.UnresolvedScopeObj + curr := ref.ScopeObj for curr != nil { if curr == group { inGroup = true diff --git a/d2oracle/edit.go b/d2oracle/edit.go index b379df0d5..7fa3e8ccb 100644 --- a/d2oracle/edit.go +++ b/d2oracle/edit.go @@ -1104,7 +1104,7 @@ func move(g *d2graph.Graph, key, newKey string) (*d2graph.Graph, error) { Key: detachedMK.Key, MapKey: detachedMK, Scope: mostNestedRef.Scope, - }, mostNestedRef.UnresolvedScopeObj) + }, mostNestedRef.ScopeObj) } } @@ -1279,8 +1279,8 @@ func move(g *d2graph.Graph, key, newKey string) (*d2graph.Graph, error) { // We don't want this to be underscore-resolved scope. We want to ignore underscores var scopeak []string - if ref.UnresolvedScopeObj != g.Root { - scopek, err := d2parser.ParseKey(ref.UnresolvedScopeObj.AbsID()) + if ref.ScopeObj != g.Root { + scopek, err := d2parser.ParseKey(ref.ScopeObj.AbsID()) if err != nil { return nil, err } From 7d011bab47e33d513741de5dfc6815be2b30f270 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 23 Jan 2023 22:45:21 -0800 Subject: [PATCH 41/60] d2compiler: Integrate d2ir (wip) --- d2compiler/compile.go | 99 +++++++++++++++++++++----------------- d2compiler/compile_test.go | 27 +++++------ d2ir/compile.go | 14 ++---- d2ir/d2ir.go | 33 +++++++++++-- 4 files changed, 98 insertions(+), 75 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index cfaf80f60..4ab8e37b4 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -40,60 +40,62 @@ func Compile(path string, r io.RuneReader, opts *CompileOptions) (*d2graph.Graph return nil, err } - g, err := compileIR(pe, ir.CopyBase(nil)) + g, err := compileIR(pe, ir) if err != nil { return nil, err } g.AST = ast - - err = compileLayersField(pe, g, ir, "layers") - if err != nil { - return nil, err - } - err = compileLayersField(pe, g, ir, "scenarios") - if err != nil { - return nil, err - } - err = compileLayersField(pe, g, ir, "steps") return g, err } -func compileLayersField(pe d2parser.ParseError, g *d2graph.Graph, ir *d2ir.Map, fieldName string) error { - layers := ir.GetField(fieldName) - if layers.Map() == nil { - return nil - } - for _, f := range layers.Map().Fields { - if f.Map() == nil { - continue - } - g2, err := compileIR(pe, f.Map()) - if err != nil { - return err - } - g2.Name = f.Name - g.Layers = append(g.Layers, g2) - } - return nil -} - func compileIR(pe d2parser.ParseError, m *d2ir.Map) (*d2graph.Graph, error) { - g := d2graph.NewGraph() - c := &compiler{ err: pe, } + g := c.compileLayer(m) + if len(c.err.Errors) > 0 { + return nil, c.err + } + return g, nil +} + +func (c *compiler) compileLayer(ir *d2ir.Map) *d2graph.Graph { + g := d2graph.NewGraph() + + m := ir.CopyRoot() c.compileMap(g.Root, m) if len(c.err.Errors) == 0 { c.validateKeys(g.Root, m) } c.validateNear(g) - if len(c.err.Errors) > 0 { - return nil, c.err + c.compileLayersField(g, ir, "layers") + c.compileLayersField(g, ir, "scenarios") + c.compileLayersField(g, ir, "steps") + return g +} + +func (c *compiler) compileLayersField(g *d2graph.Graph, ir *d2ir.Map, fieldName string) { + layers := ir.GetField(fieldName) + if layers.Map() == nil { + return + } + for _, f := range layers.Map().Fields { + if f.Map() == nil { + continue + } + g2 := c.compileLayer(f.Map()) + g2.Name = f.Name + switch fieldName { + case "layers": + g.Layers = append(g.Layers, g2) + case "scenarios": + g.Scenarios = append(g.Scenarios, g2) + case "steps": + g.Steps = append(g.Steps, g2) + } } - return g, nil } type compiler struct { @@ -139,6 +141,9 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { return } c.compileStyle(obj.Attributes, f.Map()) + if obj.Attributes.Style.Animated != nil { + c.errorf(obj.Attributes.Style.Animated.MapKey, `key "animated" can only be applied to edges`) + } return } @@ -204,7 +209,8 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { c.compileLabel(attrs, f) case "shape": in := d2target.IsShape(scalar.ScalarString()) - if !in { + _, isArrowhead := d2target.Arrowheads[scalar.ScalarString()] + if !in && !isArrowhead { c.errorf(scalar, "unknown shape %q", scalar.ScalarString()) return } @@ -227,6 +233,7 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) { c.errorf(scalar, "bad near key %#v: %s", scalar.ScalarString(), err) return } + nearKey.Range = scalar.GetRange() attrs.NearKey = nearKey case "tooltip": attrs.Tooltip = scalar.ScalarString() @@ -378,10 +385,6 @@ func (c *compiler) compileEdgeField(edge *d2graph.Edge, f *d2ir.Field) { return } - if f.Primary() != nil { - c.compileLabel(edge.Attributes, f) - } - if f.Name == "source-arrowhead" || f.Name == "target-arrowhead" { if f.Map() != nil { c.compileArrowheads(edge, f) @@ -399,6 +402,10 @@ func (c *compiler) compileArrowheads(edge *d2graph.Edge, f *d2ir.Field) { attrs = edge.DstArrowhead } + if f.Primary() != nil { + c.compileLabel(attrs, f) + } + for _, f2 := range f.Map().Fields { keyword := strings.ToLower(f2.Name) _, isReserved := d2graph.SimpleReservedKeywords[keyword] @@ -552,10 +559,6 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { if obj.Attributes.Shape.Value != d2target.ShapeImage { c.errorf(f.LastPrimaryKey(), "height is only applicable to image shapes.") } - case "3d": - if obj.Attributes.Shape.Value != "" && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeSquare) && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeRectangle) { - c.errorf(f.LastPrimaryKey(), `key "3d" can only be applied to squares and rectangles`) - } case "shape": switch obj.Attributes.Shape.Value { case d2target.ShapeSQLTable, d2target.ShapeClass: @@ -578,8 +581,14 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { return } + if obj.Attributes.Style.ThreeDee != nil { + if !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeSquare) && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeRectangle) { + c.errorf(obj.Attributes.Style.ThreeDee.MapKey, `key "3d" can only be applied to squares and rectangles`) + } + } + if obj.Attributes.Shape.Value == d2target.ShapeImage { - c.errorf(obj.Attributes.Shape.MapKey, "image shapes cannot have children.") + c.errorf(f.LastRef().AST(), "image shapes cannot have children.") return } diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index a3ab9d75b..ca993db6c 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -263,7 +263,7 @@ d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height c _ } `, - expErr: `d2/testdata/d2compiler/TestCompile/blank_underscore.d2:3:3: invalid use of parent "_"`, + expErr: `d2/testdata/d2compiler/TestCompile/blank_underscore.d2:3:3: field key must contain more than underscores`, }, { name: "image_non_style", @@ -451,7 +451,7 @@ x: { text: ` _.x `, - expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_root.d2:2:1: parent "_" cannot be used in the root scope`, + expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_root.d2:2:1: invalid underscore: no parent`, }, { name: "underscore_parent_middle_path", @@ -461,7 +461,7 @@ x: { y._.z } `, - expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_middle_path.d2:3:3: parent "_" can only be used in the beginning of paths, e.g. "_.x"`, + expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_middle_path.d2:3:5: parent "_" can only be used in the beginning of paths, e.g. "_.x"`, }, { name: "underscore_parent_sandwich_path", @@ -471,7 +471,7 @@ x: { _.z._ } `, - expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_sandwich_path.d2:3:3: parent "_" can only be used in the beginning of paths, e.g. "_.x"`, + expErr: `d2/testdata/d2compiler/TestCompile/underscore_parent_sandwich_path.d2:3:7: parent "_" can only be used in the beginning of paths, e.g. "_.x"`, }, { name: "underscore_edge", @@ -1074,7 +1074,7 @@ x -> y: { space -> stars } `, - expErr: `d2/testdata/d2compiler/TestCompile/nested_edge.d2:1:1: edges cannot be nested within another edge`, + expErr: `d2/testdata/d2compiler/TestCompile/nested_edge.d2:2:3: cannot create edge inside edge`, }, { name: "shape_edge_style", @@ -1340,7 +1340,7 @@ x -> y: { z } `, - expErr: `d2/testdata/d2compiler/TestCompile/edge_map_non_reserved.d2:2:1: edge map keys must be reserved keywords`, + expErr: `d2/testdata/d2compiler/TestCompile/edge_map_non_reserved.d2:3:3: edge map keys must be reserved keywords`, }, { name: "url_link", @@ -1385,7 +1385,7 @@ x -> y: { text: `x.near: txop-center `, - expErr: `d2/testdata/d2compiler/TestCompile/near_bad_constant.d2:1:1: near key "txop-center" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right`, + expErr: `d2/testdata/d2compiler/TestCompile/near_bad_constant.d2:1:9: near key "txop-center" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right`, }, { name: "near_bad_container", @@ -1395,7 +1395,7 @@ x -> y: { y } `, - expErr: `d2/testdata/d2compiler/TestCompile/near_bad_container.d2:1:1: constant near keys cannot be set on shapes with children`, + expErr: `d2/testdata/d2compiler/TestCompile/near_bad_container.d2:2:9: constant near keys cannot be set on shapes with children`, }, { name: "near_bad_connected", @@ -1405,14 +1405,14 @@ x -> y: { } x -> y `, - expErr: `d2/testdata/d2compiler/TestCompile/near_bad_connected.d2:1:1: constant near keys cannot be set on connected shapes`, + expErr: `d2/testdata/d2compiler/TestCompile/near_bad_connected.d2:2:9: constant near keys cannot be set on connected shapes`, }, { name: "nested_near_constant", text: `x.y.near: top-center `, - expErr: `d2/testdata/d2compiler/TestCompile/nested_near_constant.d2:1:1: constant near keys can only be set on root level shapes`, + expErr: `d2/testdata/d2compiler/TestCompile/nested_near_constant.d2:1:11: constant near keys can only be set on root level shapes`, }, { name: "reserved_icon_near_style", @@ -1458,9 +1458,8 @@ y } `, expErr: `d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:3:9: bad icon url "::????:::%%orange": parse "::????:::%%orange": missing protocol scheme -d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:4:18: expected "opacity" to be a number between 0.0 and 1.0 d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:5:18: expected "opacity" to be a number between 0.0 and 1.0 -d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:1:1: near key "y" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right`, +d2/testdata/d2compiler/TestCompile/errors/reserved_icon_style.d2:2:9: near key "y" must be the absolute path to a shape or one of the following constants: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right`, }, { name: "errors/missing_shape_icon", @@ -1562,7 +1561,7 @@ b`, g.Objects[0].Attributes.Label.Value) GetType(): string style: { opacity: 0.4 - color: blue + font-color: blue } } `, @@ -1661,7 +1660,7 @@ x.y -> a.b: { { name: "3d_oval", - text: `SVP1.style.shape: oval + text: `SVP1.shape: oval SVP1.style.3d: true`, expErr: `d2/testdata/d2compiler/TestCompile/3d_oval.d2:2:1: key "3d" can only be applied to squares and rectangles`, }, { diff --git a/d2ir/compile.go b/d2ir/compile.go index e09bb2836..4c9871b21 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -15,17 +15,9 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { func Compile(ast *d2ast.Map) (*Map, error) { c := &compiler{} - m := &Map{ - parent: &Field{ - Name: "", - References: []*FieldReference{{ - Context: &RefContext{ - Scope: ast, - }, - }}, - }, - } - m.parent.(*Field).References[0].Context.ScopeMap = m + m := &Map{} + m.initRoot() + m.parent.(*Field).References[0].Context.Scope = ast c.compileMap(m, ast) c.compileScenarios(m) c.compileSteps(m) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 59aee6941..7f59ca207 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -152,6 +152,17 @@ type Map struct { Edges []*Edge `json:"edges"` } +func (m *Map) initRoot() { + m.parent = &Field{ + Name: "", + References: []*FieldReference{{ + Context: &RefContext{ + ScopeMap: m, + }, + }}, + } +} + func (m *Map) Copy(newParent Node) Node { tmp := *m m = &tmp @@ -187,6 +198,13 @@ func (m *Map) CopyBase(newParent Node) *Map { return m2 } +// CopyRoot copies the map such that it is now the root of a diagram. +func (m *Map) CopyRoot() *Map { + m = m.CopyBase(nil) + m.initRoot() + return m +} + // Root reports whether the Map is the root of the D2 tree. func (m *Map) Root() bool { // m.parent exists even on the root map as we store the root AST in @@ -213,9 +231,16 @@ func NodeLayerKind(n Node) LayerKind { var f *Field switch n := n.(type) { case *Field: - f = n + if n.Name == "" { + return LayerLayer + } + f = ParentField(n) case *Map: f = ParentField(n) + if f.Name == "" { + return LayerLayer + } + f = ParentField(f) } if f == nil { return "" @@ -227,11 +252,9 @@ func NodeLayerKind(n Node) LayerKind { return LayerScenario case "steps": return LayerStep - case "": - // root - return LayerLayer + default: + return "" } - return "" } type Field struct { From b350399d665681f94921d33a0c632cb93d1887f2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 24 Jan 2023 03:09:40 -0800 Subject: [PATCH 42/60] d2ir: Complete integration across all packages --- d2compiler/compile.go | 48 +- d2compiler/compile_test.go | 35 +- d2graph/d2graph.go | 41 +- d2ir/d2ir.go | 59 +- d2oracle/edit.go | 1 - d2oracle/edit_test.go | 14 +- .../d2sketch/testdata/animated/sketch.exp.svg | 2 +- .../testdata/arrowheads/sketch.exp.svg | 2 +- .../d2sketch/testdata/basic/sketch.exp.svg | 2 +- .../testdata/child_to_child/sketch.exp.svg | 2 +- .../testdata/connection_label/sketch.exp.svg | 2 +- .../d2sketch/testdata/opacity/sketch.exp.svg | 12 +- .../testdata/sql_tables/sketch.exp.svg | 2 +- .../d2sketch/testdata/twitter/sketch.exp.svg | 29 +- .../diagram_wider_than_tooltip/sketch.exp.svg | 26 +- .../appendix/testdata/links/sketch.exp.svg | 2 +- .../tooltip_wider_than_diagram/sketch.exp.svg | 2 +- e2etests/e2e_test.go | 18 +- .../dagre/board.exp.json | 38 +- .../dagre/sketch.exp.svg | 23 +- .../elk/board.exp.json | 38 +- .../elk/sketch.exp.svg | 23 +- .../dagre/board.exp.json | 90 +- .../dagre/sketch.exp.svg | 2 +- .../dagre_broken_arrowhead/elk/board.exp.json | 90 +- .../dagre_broken_arrowhead/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 12 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 12 +- .../elk/sketch.exp.svg | 2 +- .../dagre_special_ids/dagre/board.exp.json | 14 +- .../dagre_special_ids/dagre/sketch.exp.svg | 2 +- .../dagre_special_ids/elk/board.exp.json | 14 +- .../dagre_special_ids/elk/sketch.exp.svg | 2 +- .../elk_alignment/dagre/board.exp.json | 28 +- .../elk_alignment/dagre/sketch.exp.svg | 2 +- .../elk_alignment/elk/board.exp.json | 28 +- .../elk_alignment/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 2 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 2 +- .../elk/sketch.exp.svg | 2 +- .../elk_loop_panic/dagre/board.exp.json | 6 +- .../elk_loop_panic/dagre/sketch.exp.svg | 2 +- .../elk_loop_panic/elk/board.exp.json | 6 +- .../elk_loop_panic/elk/sketch.exp.svg | 2 +- .../regression/elk_order/dagre/board.exp.json | 104 +- .../regression/elk_order/dagre/sketch.exp.svg | 15 +- .../regression/elk_order/elk/board.exp.json | 88 +- .../regression/elk_order/elk/sketch.exp.svg | 15 +- .../md_h1_li_li/dagre/board.exp.json | 26 +- .../md_h1_li_li/dagre/sketch.exp.svg | 15 +- .../regression/md_h1_li_li/elk/board.exp.json | 22 +- .../regression/md_h1_li_li/elk/sketch.exp.svg | 15 +- .../regression/no-lexer/dagre/board.exp.json | 6 +- .../regression/no-lexer/dagre/sketch.exp.svg | 6 +- .../regression/no-lexer/elk/board.exp.json | 6 +- .../regression/no-lexer/elk/sketch.exp.svg | 6 +- .../opacity-on-label/dagre/board.exp.json | 10 +- .../opacity-on-label/dagre/sketch.exp.svg | 8 +- .../opacity-on-label/elk/board.exp.json | 10 +- .../opacity-on-label/elk/sketch.exp.svg | 8 +- .../dagre/board.exp.json | 20 +- .../dagre/sketch.exp.svg | 2 +- .../overlapping-edge-label/elk/board.exp.json | 20 +- .../overlapping-edge-label/elk/sketch.exp.svg | 2 +- .../query_param_escape/dagre/board.exp.json | 2 +- .../query_param_escape/dagre/sketch.exp.svg | 2 +- .../query_param_escape/elk/board.exp.json | 2 +- .../query_param_escape/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 164 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 164 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 2 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 2 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 12 +- .../dagre/sketch.exp.svg | 8 +- .../elk/board.exp.json | 12 +- .../elk/sketch.exp.svg | 8 +- .../sanity/1_to_2/dagre/board.exp.json | 6 +- .../sanity/1_to_2/dagre/sketch.exp.svg | 2 +- .../testdata/sanity/1_to_2/elk/board.exp.json | 6 +- .../testdata/sanity/1_to_2/elk/sketch.exp.svg | 2 +- .../sanity/basic/dagre/board.exp.json | 4 +- .../sanity/basic/dagre/sketch.exp.svg | 2 +- .../testdata/sanity/basic/elk/board.exp.json | 4 +- .../testdata/sanity/basic/elk/sketch.exp.svg | 2 +- .../child_to_child/dagre/board.exp.json | 8 +- .../child_to_child/dagre/sketch.exp.svg | 2 +- .../sanity/child_to_child/elk/board.exp.json | 8 +- .../sanity/child_to_child/elk/sketch.exp.svg | 2 +- .../connection_label/dagre/board.exp.json | 4 +- .../connection_label/dagre/sketch.exp.svg | 2 +- .../connection_label/elk/board.exp.json | 4 +- .../connection_label/elk/sketch.exp.svg | 2 +- .../all_shapes_multiple/dagre/board.exp.json | 340 +-- .../all_shapes_multiple/dagre/sketch.exp.svg | 6 +- .../all_shapes_multiple/elk/board.exp.json | 262 +- .../all_shapes_multiple/elk/sketch.exp.svg | 6 +- .../all_shapes_shadow/dagre/board.exp.json | 340 +-- .../all_shapes_shadow/dagre/sketch.exp.svg | 14 +- .../all_shapes_shadow/elk/board.exp.json | 262 +- .../all_shapes_shadow/elk/sketch.exp.svg | 14 +- .../stable/animated/dagre/board.exp.json | 26 +- .../stable/animated/dagre/sketch.exp.svg | 2 +- .../stable/animated/elk/board.exp.json | 26 +- .../stable/animated/elk/sketch.exp.svg | 2 +- .../arrowhead_adjustment/dagre/board.exp.json | 322 ++- .../arrowhead_adjustment/dagre/sketch.exp.svg | 6 +- .../arrowhead_adjustment/elk/board.exp.json | 258 +- .../arrowhead_adjustment/elk/sketch.exp.svg | 6 +- .../arrowhead_labels/dagre/board.exp.json | 6 +- .../arrowhead_labels/dagre/sketch.exp.svg | 2 +- .../arrowhead_labels/elk/board.exp.json | 6 +- .../arrowhead_labels/elk/sketch.exp.svg | 2 +- .../stable/binary_tree/dagre/board.exp.json | 30 +- .../stable/binary_tree/dagre/sketch.exp.svg | 2 +- .../stable/binary_tree/elk/board.exp.json | 30 +- .../stable/binary_tree/elk/sketch.exp.svg | 2 +- .../stable/border-radius/dagre/board.exp.json | 4 +- .../stable/border-radius/dagre/sketch.exp.svg | 2 +- .../stable/border-radius/elk/board.exp.json | 4 +- .../stable/border-radius/elk/sketch.exp.svg | 2 +- .../stable/chaos1/dagre/board.exp.json | 82 +- .../stable/chaos1/dagre/sketch.exp.svg | 2 +- .../testdata/stable/chaos1/elk/board.exp.json | 82 +- .../testdata/stable/chaos1/elk/sketch.exp.svg | 2 +- .../stable/chaos2/dagre/board.exp.json | 14 +- .../stable/chaos2/dagre/sketch.exp.svg | 2 +- .../testdata/stable/chaos2/elk/board.exp.json | 14 +- .../testdata/stable/chaos2/elk/sketch.exp.svg | 2 +- .../child_parent_edges/dagre/board.exp.json | 184 +- .../child_parent_edges/dagre/sketch.exp.svg | 2 +- .../child_parent_edges/elk/board.exp.json | 86 +- .../child_parent_edges/elk/sketch.exp.svg | 2 +- .../circle_arrowhead/dagre/board.exp.json | 8 +- .../circle_arrowhead/dagre/sketch.exp.svg | 2 +- .../circle_arrowhead/elk/board.exp.json | 8 +- .../circle_arrowhead/elk/sketch.exp.svg | 2 +- .../circular_dependency/dagre/board.exp.json | 6 +- .../circular_dependency/dagre/sketch.exp.svg | 2 +- .../circular_dependency/elk/board.exp.json | 6 +- .../circular_dependency/elk/sketch.exp.svg | 2 +- .../stable/code_snippet/dagre/board.exp.json | 46 +- .../stable/code_snippet/dagre/sketch.exp.svg | 14 +- .../stable/code_snippet/elk/board.exp.json | 34 +- .../stable/code_snippet/elk/sketch.exp.svg | 14 +- .../connected_container/dagre/board.exp.json | 14 +- .../connected_container/dagre/sketch.exp.svg | 2 +- .../connected_container/elk/board.exp.json | 14 +- .../connected_container/elk/sketch.exp.svg | 2 +- .../constant_near_stress/dagre/board.exp.json | 28 +- .../constant_near_stress/dagre/sketch.exp.svg | 10 +- .../constant_near_stress/elk/board.exp.json | 28 +- .../constant_near_stress/elk/sketch.exp.svg | 10 +- .../constant_near_title/dagre/board.exp.json | 24 +- .../constant_near_title/dagre/sketch.exp.svg | 8 +- .../constant_near_title/elk/board.exp.json | 24 +- .../constant_near_title/elk/sketch.exp.svg | 8 +- .../container_edges/dagre/board.exp.json | 94 +- .../container_edges/dagre/sketch.exp.svg | 2 +- .../stable/container_edges/elk/board.exp.json | 94 +- .../stable/container_edges/elk/sketch.exp.svg | 2 +- .../crow_foot_arrowhead/dagre/board.exp.json | 16 +- .../crow_foot_arrowhead/dagre/sketch.exp.svg | 2 +- .../crow_foot_arrowhead/elk/board.exp.json | 16 +- .../crow_foot_arrowhead/elk/sketch.exp.svg | 2 +- .../stable/dense/dagre/board.exp.json | 34 +- .../stable/dense/dagre/sketch.exp.svg | 2 +- .../testdata/stable/dense/elk/board.exp.json | 34 +- .../testdata/stable/dense/elk/sketch.exp.svg | 2 +- .../different_subgraphs/dagre/board.exp.json | 1762 ++++++------ .../different_subgraphs/dagre/sketch.exp.svg | 6 +- .../different_subgraphs/elk/board.exp.json | 820 +++--- .../different_subgraphs/elk/sketch.exp.svg | 6 +- .../stable/direction/dagre/board.exp.json | 1691 ++++++------ .../stable/direction/dagre/sketch.exp.svg | 6 +- .../stable/direction/elk/board.exp.json | 624 ++--- .../stable/direction/elk/sketch.exp.svg | 2 +- .../stable/font_colors/dagre/board.exp.json | 4 +- .../stable/font_colors/dagre/sketch.exp.svg | 2 +- .../stable/font_colors/elk/board.exp.json | 4 +- .../stable/font_colors/elk/sketch.exp.svg | 2 +- .../stable/font_sizes/dagre/board.exp.json | 24 +- .../stable/font_sizes/dagre/sketch.exp.svg | 2 +- .../stable/font_sizes/elk/board.exp.json | 24 +- .../stable/font_sizes/elk/sketch.exp.svg | 2 +- .../giant_markdown_test/dagre/board.exp.json | 46 +- .../giant_markdown_test/dagre/sketch.exp.svg | 278 +- .../giant_markdown_test/elk/board.exp.json | 34 +- .../giant_markdown_test/elk/sketch.exp.svg | 278 +- .../testdata/stable/hr/dagre/board.exp.json | 46 +- .../testdata/stable/hr/dagre/sketch.exp.svg | 11 +- .../testdata/stable/hr/elk/board.exp.json | 34 +- .../testdata/stable/hr/elk/sketch.exp.svg | 11 +- .../stable/icon-label/dagre/board.exp.json | 2 +- .../stable/icon-label/dagre/sketch.exp.svg | 2 +- .../stable/icon-label/elk/board.exp.json | 2 +- .../stable/icon-label/elk/sketch.exp.svg | 2 +- .../stable/investigate/dagre/board.exp.json | 1636 +++++------ .../stable/investigate/dagre/sketch.exp.svg | 2 +- .../stable/investigate/elk/board.exp.json | 2186 +++++++-------- .../stable/investigate/elk/sketch.exp.svg | 18 +- .../stable/large_arch/dagre/board.exp.json | 930 +++---- .../stable/large_arch/dagre/sketch.exp.svg | 2 +- .../stable/large_arch/elk/board.exp.json | 566 ++-- .../stable/large_arch/elk/sketch.exp.svg | 2 +- .../stable/latex/dagre/board.exp.json | 154 +- .../stable/latex/dagre/sketch.exp.svg | 8 +- .../testdata/stable/latex/elk/board.exp.json | 146 +- .../testdata/stable/latex/elk/sketch.exp.svg | 8 +- .../testdata/stable/li1/dagre/board.exp.json | 46 +- .../testdata/stable/li1/dagre/sketch.exp.svg | 19 +- .../testdata/stable/li1/elk/board.exp.json | 34 +- .../testdata/stable/li1/elk/sketch.exp.svg | 19 +- .../testdata/stable/li2/dagre/board.exp.json | 46 +- .../testdata/stable/li2/dagre/sketch.exp.svg | 22 +- .../testdata/stable/li2/elk/board.exp.json | 34 +- .../testdata/stable/li2/elk/sketch.exp.svg | 22 +- .../testdata/stable/li3/dagre/board.exp.json | 46 +- .../testdata/stable/li3/dagre/sketch.exp.svg | 40 +- .../testdata/stable/li3/elk/board.exp.json | 34 +- .../testdata/stable/li3/elk/sketch.exp.svg | 40 +- .../testdata/stable/li4/dagre/board.exp.json | 46 +- .../testdata/stable/li4/dagre/sketch.exp.svg | 45 +- .../testdata/stable/li4/elk/board.exp.json | 34 +- .../testdata/stable/li4/elk/sketch.exp.svg | 45 +- .../stable/links/dagre/board.exp.json | 4 +- .../stable/links/dagre/sketch.exp.svg | 2 +- .../testdata/stable/links/elk/board.exp.json | 4 +- .../testdata/stable/links/elk/sketch.exp.svg | 2 +- .../stable/lone_h1/dagre/board.exp.json | 46 +- .../stable/lone_h1/dagre/sketch.exp.svg | 8 +- .../stable/lone_h1/elk/board.exp.json | 34 +- .../stable/lone_h1/elk/sketch.exp.svg | 8 +- .../stable/markdown/dagre/board.exp.json | 46 +- .../stable/markdown/dagre/sketch.exp.svg | 21 +- .../stable/markdown/elk/board.exp.json | 34 +- .../stable/markdown/elk/sketch.exp.svg | 21 +- .../markdown_stroke_fill/dagre/board.exp.json | 44 +- .../markdown_stroke_fill/dagre/sketch.exp.svg | 24 +- .../markdown_stroke_fill/elk/board.exp.json | 34 +- .../markdown_stroke_fill/elk/sketch.exp.svg | 24 +- .../md_2space_newline/dagre/board.exp.json | 16 +- .../md_2space_newline/dagre/sketch.exp.svg | 9 +- .../md_2space_newline/elk/board.exp.json | 16 +- .../md_2space_newline/elk/sketch.exp.svg | 9 +- .../md_backslash_newline/dagre/board.exp.json | 16 +- .../md_backslash_newline/dagre/sketch.exp.svg | 9 +- .../md_backslash_newline/elk/board.exp.json | 16 +- .../md_backslash_newline/elk/sketch.exp.svg | 9 +- .../md_code_block_fenced/dagre/board.exp.json | 46 +- .../md_code_block_fenced/dagre/sketch.exp.svg | 19 +- .../md_code_block_fenced/elk/board.exp.json | 34 +- .../md_code_block_fenced/elk/sketch.exp.svg | 19 +- .../dagre/board.exp.json | 46 +- .../dagre/sketch.exp.svg | 20 +- .../md_code_block_indented/elk/board.exp.json | 34 +- .../md_code_block_indented/elk/sketch.exp.svg | 20 +- .../md_code_inline/dagre/board.exp.json | 12 +- .../md_code_inline/dagre/sketch.exp.svg | 11 +- .../stable/md_code_inline/elk/board.exp.json | 12 +- .../stable/md_code_inline/elk/sketch.exp.svg | 11 +- .../multiline_text/dagre/board.exp.json | 2 +- .../multiline_text/dagre/sketch.exp.svg | 2 +- .../stable/multiline_text/elk/board.exp.json | 2 +- .../stable/multiline_text/elk/sketch.exp.svg | 2 +- .../multiple_trees/dagre/board.exp.json | 46 +- .../multiple_trees/dagre/sketch.exp.svg | 2 +- .../stable/multiple_trees/elk/board.exp.json | 46 +- .../stable/multiple_trees/elk/sketch.exp.svg | 2 +- .../stable/n22_e32/dagre/board.exp.json | 42 +- .../stable/n22_e32/dagre/sketch.exp.svg | 2 +- .../stable/n22_e32/elk/board.exp.json | 42 +- .../stable/n22_e32/elk/sketch.exp.svg | 2 +- .../stable/near-alone/dagre/board.exp.json | 6 +- .../stable/near-alone/dagre/sketch.exp.svg | 2 +- .../stable/near-alone/elk/board.exp.json | 6 +- .../stable/near-alone/elk/sketch.exp.svg | 2 +- .../number_connections/dagre/board.exp.json | 86 +- .../number_connections/dagre/sketch.exp.svg | 2 +- .../number_connections/elk/board.exp.json | 102 +- .../number_connections/elk/sketch.exp.svg | 2 +- .../one_container_loop/dagre/board.exp.json | 94 +- .../one_container_loop/dagre/sketch.exp.svg | 2 +- .../one_container_loop/elk/board.exp.json | 94 +- .../one_container_loop/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 14 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 14 +- .../elk/sketch.exp.svg | 2 +- .../dagre/.!73950!sketch.exp.svg | 42 + .../dagre/board.exp.json | 106 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 88 +- .../elk/sketch.exp.svg | 2 +- .../testdata/stable/p/dagre/board.exp.json | 32 +- .../testdata/stable/p/dagre/sketch.exp.svg | 11 +- e2etests/testdata/stable/p/elk/board.exp.json | 24 +- e2etests/testdata/stable/p/elk/sketch.exp.svg | 11 +- .../testdata/stable/pre/dagre/board.exp.json | 46 +- .../testdata/stable/pre/dagre/sketch.exp.svg | 21 +- .../testdata/stable/pre/elk/board.exp.json | 34 +- .../testdata/stable/pre/elk/sketch.exp.svg | 21 +- .../self-referencing/dagre/board.exp.json | 6 +- .../self-referencing/dagre/sketch.exp.svg | 2 +- .../self-referencing/elk/board.exp.json | 6 +- .../self-referencing/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 156 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 156 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 12 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 12 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 208 +- .../dagre/sketch.exp.svg | 27 +- .../elk/board.exp.json | 208 +- .../elk/sketch.exp.svg | 27 +- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 442 +-- .../dagre/sketch.exp.svg | 16 +- .../elk/board.exp.json | 442 +-- .../elk/sketch.exp.svg | 16 +- .../dagre/board.exp.json | 254 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 254 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 996 +++---- .../dagre/sketch.exp.svg | 12 +- .../elk/board.exp.json | 996 +++---- .../elk/sketch.exp.svg | 12 +- .../dagre/board.exp.json | 106 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 106 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 242 +- .../dagre/sketch.exp.svg | 2 +- .../sequence_diagram_note/elk/board.exp.json | 242 +- .../sequence_diagram_note/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 616 ++--- .../dagre/sketch.exp.svg | 18 +- .../sequence_diagram_real/elk/board.exp.json | 616 ++--- .../sequence_diagram_real/elk/sketch.exp.svg | 18 +- .../dagre/board.exp.json | 346 +-- .../dagre/sketch.exp.svg | 10 +- .../elk/board.exp.json | 346 +-- .../elk/sketch.exp.svg | 10 +- .../dagre/board.exp.json | 2 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 2 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 168 +- .../dagre/sketch.exp.svg | 2 +- .../sequence_diagram_span/elk/board.exp.json | 168 +- .../sequence_diagram_span/elk/sketch.exp.svg | 2 +- .../sequence_diagrams/dagre/board.exp.json | 2458 ++++++++--------- .../sequence_diagrams/dagre/sketch.exp.svg | 54 +- .../sequence_diagrams/elk/board.exp.json | 1922 ++++++------- .../sequence_diagrams/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 2 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 2 +- .../elk/sketch.exp.svg | 2 +- .../stable/sql_tables/dagre/board.exp.json | 6 +- .../stable/sql_tables/dagre/sketch.exp.svg | 2 +- .../stable/sql_tables/elk/board.exp.json | 6 +- .../stable/sql_tables/elk/sketch.exp.svg | 2 +- .../stable/square_3d/dagre/board.exp.json | 28 +- .../stable/square_3d/dagre/sketch.exp.svg | 10 +- .../stable/square_3d/elk/board.exp.json | 24 +- .../stable/square_3d/elk/sketch.exp.svg | 10 +- .../dagre/board.exp.json | 50 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 50 +- .../elk/sketch.exp.svg | 2 +- .../stable/stylish/dagre/board.exp.json | 4 +- .../stable/stylish/dagre/sketch.exp.svg | 2 +- .../stable/stylish/elk/board.exp.json | 4 +- .../stable/stylish/elk/sketch.exp.svg | 2 +- .../stable/tooltips/dagre/board.exp.json | 4 +- .../stable/tooltips/dagre/sketch.exp.svg | 2 +- .../stable/tooltips/elk/board.exp.json | 4 +- .../stable/tooltips/elk/sketch.exp.svg | 2 +- .../transparent_3d/dagre/board.exp.json | 2 +- .../transparent_3d/dagre/sketch.exp.svg | 2 +- .../stable/transparent_3d/elk/board.exp.json | 2 +- .../stable/transparent_3d/elk/sketch.exp.svg | 2 +- .../unnamed_only_height/dagre/board.exp.json | 12 +- .../unnamed_only_height/dagre/sketch.exp.svg | 4 +- .../unnamed_only_height/elk/board.exp.json | 12 +- .../unnamed_only_height/elk/sketch.exp.svg | 4 +- .../unnamed_only_width/dagre/board.exp.json | 30 +- .../unnamed_only_width/dagre/sketch.exp.svg | 8 +- .../unnamed_only_width/elk/board.exp.json | 22 +- .../unnamed_only_width/elk/sketch.exp.svg | 8 +- .../stable/us_map/dagre/board.exp.json | 256 +- .../stable/us_map/dagre/sketch.exp.svg | 2 +- .../testdata/stable/us_map/elk/board.exp.json | 256 +- .../testdata/stable/us_map/elk/sketch.exp.svg | 2 +- .../container_child_edge/dagre/board.exp.json | 6 +- .../container_child_edge/dagre/sketch.exp.svg | 2 +- .../container_child_edge/elk/board.exp.json | 6 +- .../container_child_edge/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 10 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 10 +- .../elk/sketch.exp.svg | 2 +- .../font_sizes_large/dagre/board.exp.json | 10 +- .../font_sizes_large/dagre/sketch.exp.svg | 2 +- .../todo/font_sizes_large/elk/board.exp.json | 10 +- .../todo/font_sizes_large/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 122 +- .../dagre/sketch.exp.svg | 16 +- .../elk/board.exp.json | 122 +- .../elk/sketch.exp.svg | 16 +- .../dagre/board.exp.json | 391 ++- .../dagre/sketch.exp.svg | 786 +++++- .../shape_set_width_height/elk/board.exp.json | 387 ++- .../shape_set_width_height/elk/sketch.exp.svg | 786 +++++- .../todo/tall_edge_label/dagre/board.exp.json | 4 +- .../todo/tall_edge_label/dagre/sketch.exp.svg | 2 +- .../todo/tall_edge_label/elk/board.exp.json | 4 +- .../todo/tall_edge_label/elk/sketch.exp.svg | 2 +- go.mod | 12 +- go.sum | 413 +-- .../d2compiler/TestCompile/3d_oval.exp.json | 2 +- .../TestCompile/basic_icon.exp.json | 11 +- .../TestCompile/basic_sequence.exp.json | 9 +- .../TestCompile/basic_shape.exp.json | 9 +- .../TestCompile/basic_style.exp.json | 13 +- .../TestCompile/blank_underscore.exp.json | 2 +- .../TestCompile/class_paren.exp.json | 11 +- .../TestCompile/class_style.exp.json | 11 +- .../TestCompile/constraint_label.exp.json | 11 +- .../TestCompile/default_direction.exp.json | 11 +- .../TestCompile/default_orientation.exp.json | 100 - .../TestCompile/dimension_with_style.exp.json | 13 +- .../dimensions_on_nonimage.exp.json | 9 +- testdata/d2compiler/TestCompile/edge.exp.json | 17 +- .../edge_arrowhead_fields.exp.json | 23 +- .../TestCompile/edge_chain.exp.json | 25 +- .../TestCompile/edge_chain_map.exp.json | 25 +- .../TestCompile/edge_column_index.exp.json | 19 +- .../TestCompile/edge_exclusive_style.exp.json | 17 +- .../TestCompile/edge_flat_arrowhead.exp.json | 20 +- .../edge_flat_label_arrowhead.exp.json | 20 +- .../TestCompile/edge_in_column.exp.json | 140 +- .../TestCompile/edge_index.exp.json | 17 +- .../TestCompile/edge_index_map.exp.json | 17 +- .../TestCompile/edge_index_nested.exp.json | 24 +- .../edge_index_nested_cross_scope.exp.json | 26 +- .../edge_key_group_flat_nested.exp.json | 26 +- ..._key_group_flat_nested_underscore.exp.json | 170 +- ..._group_map_flat_nested_underscore.exp.json | 170 +- ...e_key_group_map_nested_underscore.exp.json | 170 +- .../TestCompile/edge_label_map.exp.json | 17 +- .../d2compiler/TestCompile/edge_map.exp.json | 17 +- .../TestCompile/edge_map_arrowhead.exp.json | 20 +- .../TestCompile/edge_map_group_flat.exp.json | 17 +- .../edge_map_group_semiflat.exp.json | 17 +- .../TestCompile/edge_map_nested.exp.json | 17 +- .../TestCompile/edge_map_nested_flat.exp.json | 17 +- .../edge_map_non_reserved.exp.json | 4 +- .../TestCompile/edge_mixed_arrowhead.exp.json | 23 +- .../edge_non_shape_arrowhead.exp.json | 20 +- .../edge_semiflat_arrowhead.exp.json | 20 +- .../errors/reserved_icon_style.exp.json | 8 +- .../TestCompile/escaped_id.exp.json | 11 +- .../TestCompile/image_dimensions.exp.json | 253 -- .../TestCompile/image_non_style.exp.json | 2 +- .../TestCompile/image_style.exp.json | 11 +- .../TestCompile/invalid_orientation.exp.json | 12 - .../TestCompile/near_bad_connected.exp.json | 4 +- .../TestCompile/near_bad_constant.exp.json | 4 +- .../TestCompile/near_bad_container.exp.json | 4 +- .../TestCompile/near_constant.exp.json | 13 +- .../TestCompile/nested_edge.exp.json | 4 +- .../TestCompile/nested_near_constant.exp.json | 4 +- .../TestCompile/nested_sql.exp.json | 18 +- testdata/d2compiler/TestCompile/null.exp.json | 11 +- .../d2compiler/TestCompile/path_link.exp.json | 11 +- .../reserved_icon_near_style.exp.json | 24 +- .../TestCompile/root_direction.exp.json | 4 + .../TestCompile/root_orientation.exp.json | 66 - .../TestCompile/root_sequence.exp.json | 4 + .../TestCompile/self-referencing.exp.json | 12 +- .../TestCompile/sequence_container.exp.json | 1063 +++++++ .../TestCompile/sequence_container_2.exp.json | 928 +++++++ .../sequence_grouped_note.exp.json | 34 +- .../TestCompile/sequence_scoping.exp.json | 54 +- .../TestCompile/set_direction.exp.json | 11 +- .../TestCompile/set_orientation.exp.json | 139 - .../d2compiler/TestCompile/shape.exp.json | 134 - .../single_dimension_on_circle.exp.json | 9 +- .../d2compiler/TestCompile/sql-panic.exp.json | 2 +- .../TestCompile/sql-regression.exp.json | 25 +- .../d2compiler/TestCompile/sql_paren.exp.json | 11 +- .../TestCompile/stroke-width.exp.json | 13 +- .../d2compiler/TestCompile/style.exp.json | 145 - .../table_connection_attr.exp.json | 19 +- .../TestCompile/table_style.exp.json | 11 +- .../TestCompile/table_style_map.exp.json | 36 +- .../TestCompile/underscore_edge.exp.json | 19 +- .../underscore_edge_chain.exp.json | 27 +- .../underscore_edge_existing.exp.json | 111 +- .../underscore_edge_existing_new.exp.json | 346 --- .../underscore_edge_index.exp.json | 170 +- .../underscore_edge_nested.exp.json | 26 +- .../underscore_edge_reference.exp.json | 336 --- .../TestCompile/underscore_parent.exp.json | 181 -- .../underscore_parent_create.exp.json | 18 +- .../underscore_parent_middle_path.exp.json | 4 +- .../underscore_parent_not_root.exp.json | 25 +- .../underscore_parent_preference.exp.json | 245 -- .../underscore_parent_preference_1.exp.json | 20 +- .../underscore_parent_preference_2.exp.json | 20 +- .../underscore_parent_root.exp.json | 4 +- .../underscore_parent_sandwich_path.exp.json | 4 +- .../underscore_parent_squared.exp.json | 25 +- .../underscore_unresolved_obj.exp.json | 18 +- .../TestCompile/unescaped_id_cr.exp.json | 11 +- .../d2compiler/TestCompile/url_link.exp.json | 11 +- .../TestCompile/wrong_column_index.exp.json | 19 +- .../TestCompile2/scenarios/recursive.exp.json | 695 +++++ .../scenarios/{one.exp.json => root.exp.json} | 435 ++- .../TestExport/connection/arrowhead.exp.json | 6 +- .../TestExport/connection/basic.exp.json | 4 +- .../connection/stroke-dash.exp.json | 4 +- .../connection/theme_stroke-dash.exp.json | 4 +- .../TestExport/label/basic_shape.exp.json | 2 +- .../label/connection_font_color.exp.json | 4 +- .../label/shape_font_color.exp.json | 2 +- .../TestExport/shape/basic.exp.json | 2 +- .../TestExport/shape/border-radius.exp.json | 2 +- .../shape/sequence_group_position.exp.json | 6 +- .../TestExport/shape/text_color.exp.json | 2 +- .../theme/connection_with_bold.exp.json | 4 +- .../theme/connection_with_italic.exp.json | 4 +- .../theme/connection_without_italic.exp.json | 4 +- .../theme/shape_with_italic.exp.json | 2 +- .../theme/shape_without_bold.exp.json | 2 +- .../d2ir/TestCompile/edges/chain.exp.json | 1036 +++---- .../d2ir/TestCompile/edges/nested.exp.json | 590 ++-- testdata/d2ir/TestCompile/edges/root.exp.json | 222 +- .../TestCompile/edges/underscore.exp.json | 292 +- .../d2ir/TestCompile/fields/array.exp.json | 4 +- .../d2ir/TestCompile/fields/label.exp.json | 4 +- .../d2ir/TestCompile/fields/nested.exp.json | 8 +- .../d2ir/TestCompile/fields/null.exp.json | 8 +- .../fields/primary/nested.exp.json | 12 +- .../TestCompile/fields/primary/root.exp.json | 8 +- .../d2ir/TestCompile/fields/root.exp.json | 4 +- .../d2ir/TestCompile/layers/root.exp.json | 242 +- .../d2ir/TestCompile/scenarios/root.exp.json | 694 ++--- .../d2ir/TestCompile/steps/recursive.exp.json | 956 +++---- testdata/d2ir/TestCompile/steps/root.exp.json | 706 ++--- testdata/d2oracle/TestCreate/base.exp.json | 11 +- .../d2oracle/TestCreate/container.exp.json | 18 +- .../TestCreate/container_edge.exp.json | 24 +- .../TestCreate/container_edge_label.exp.json | 24 +- testdata/d2oracle/TestCreate/edge.exp.json | 17 +- .../d2oracle/TestCreate/edge_nested.exp.json | 24 +- .../d2oracle/TestCreate/edge_scope.exp.json | 24 +- .../TestCreate/edge_scope_flat.exp.json | 24 +- .../TestCreate/edge_scope_nested.exp.json | 31 +- .../d2oracle/TestCreate/edge_unique.exp.json | 105 +- testdata/d2oracle/TestCreate/gen_key.exp.json | 18 +- .../d2oracle/TestCreate/gen_key_n.exp.json | 102 +- .../TestCreate/gen_key_nested.exp.json | 45 +- .../TestCreate/gen_key_scope.exp.json | 39 +- .../TestCreate/gen_key_suffix.exp.json | 18 +- .../TestCreate/make_scope_multiline.exp.json | 16 +- .../make_scope_multiline_spacing_1.exp.json | 30 +- .../make_scope_multiline_spacing_2.exp.json | 30 +- testdata/d2oracle/TestCreate/nested.exp.json | 25 +- testdata/d2oracle/TestCreate/scope.exp.json | 32 +- .../TestDelete/breakup_arrowhead.exp.json | 11 +- .../d2oracle/TestDelete/children.exp.json | 24 +- .../TestDelete/children_conflicts.exp.json | 18 +- .../children_edge_conflicts.exp.json | 148 +- .../children_edges_flat_conflicts.exp.json | 369 +-- .../children_flat_conflicts.exp.json | 20 +- .../children_multiple_conflicts.exp.json | 151 +- .../children_nested_conflicts.exp.json | 25 +- ...ldren_nested_referenced_conflicts.exp.json | 31 +- .../children_no_self_conflict.exp.json | 11 +- .../TestDelete/children_order.exp.json | 32 +- .../children_referenced_conflicts.exp.json | 20 +- .../TestDelete/children_scope.exp.json | 38 +- .../TestDelete/container_near.exp.json | 29 +- .../d2oracle/TestDelete/delete_icon.exp.json | 18 +- .../d2oracle/TestDelete/delete_link.exp.json | 11 +- .../d2oracle/TestDelete/delete_near.exp.json | 18 +- .../delete_needed_flat_near.exp.json | 18 +- .../delete_redundant_flat_near.exp.json | 18 +- .../TestDelete/delete_tooltip.exp.json | 11 +- .../edge_both_identical_childs.exp.json | 27 +- .../d2oracle/TestDelete/edge_common.exp.json | 17 +- .../TestDelete/edge_common_2.exp.json | 17 +- .../TestDelete/edge_common_3.exp.json | 27 +- .../TestDelete/edge_common_4.exp.json | 27 +- .../TestDelete/edge_conflict.exp.json | 113 +- .../TestDelete/edge_decrement.exp.json | 26 +- .../d2oracle/TestDelete/edge_first.exp.json | 53 +- .../TestDelete/edge_flat_style.exp.json | 11 +- .../TestDelete/edge_identical_child.exp.json | 32 +- .../TestDelete/edge_key_style.exp.json | 17 +- .../d2oracle/TestDelete/edge_last.exp.json | 141 +- .../TestDelete/edge_map_style.exp.json | 17 +- .../d2oracle/TestDelete/edge_middle.exp.json | 59 +- .../d2oracle/TestDelete/empty_map.exp.json | 18 +- testdata/d2oracle/TestDelete/flat.exp.json | 4 + .../TestDelete/flat_reserved.exp.json | 17 +- .../TestDelete/hoist_children.exp.json | 18 +- .../TestDelete/hoist_edge_children.exp.json | 24 +- .../TestDelete/key_with_edges.exp.json | 27 +- .../TestDelete/key_with_edges_2.exp.json | 18 +- .../TestDelete/key_with_edges_3.exp.json | 18 +- .../TestDelete/key_with_edges_4.exp.json | 27 +- .../d2oracle/TestDelete/multi_near.exp.json | 36 +- .../multi_path_map_conflict.exp.json | 27 +- .../multi_path_map_no_conflict.exp.json | 25 +- .../multiple_flat_middle_container.exp.json | 27 +- .../TestDelete/multiple_flat_style.exp.json | 13 +- .../TestDelete/multiple_map_styles.exp.json | 13 +- testdata/d2oracle/TestDelete/near.exp.json | 11 +- testdata/d2oracle/TestDelete/nested.exp.json | 25 +- .../d2oracle/TestDelete/nested_2.exp.json | 25 +- .../TestDelete/nested_edge_key_style.exp.json | 24 +- .../TestDelete/nested_flat_style.exp.json | 11 +- .../TestDelete/nested_reserved.exp.json | 29 +- .../nested_underscore_update.exp.json | 18 +- .../d2oracle/TestDelete/node_in_edge.exp.json | 212 +- .../TestDelete/node_in_edge_last.exp.json | 350 +-- .../only_delete_edge_reserved.exp.json | 21 +- .../only_delete_obj_reserved.exp.json | 21 +- testdata/d2oracle/TestDelete/order_1.exp.json | 24 +- testdata/d2oracle/TestDelete/order_2.exp.json | 18 +- testdata/d2oracle/TestDelete/order_3.exp.json | 18 +- testdata/d2oracle/TestDelete/order_4.exp.json | 11 +- testdata/d2oracle/TestDelete/order_5.exp.json | 37 +- testdata/d2oracle/TestDelete/order_6.exp.json | 34 +- testdata/d2oracle/TestDelete/order_7.exp.json | 41 +- testdata/d2oracle/TestDelete/order_8.exp.json | 39 +- .../d2oracle/TestDelete/shape_class.exp.json | 11 +- .../TestDelete/shape_sql_table.exp.json | 26 +- .../TestDelete/singular_flat_style.exp.json | 11 +- .../TestDelete/singular_map_style.exp.json | 11 +- .../underscore_no_conflict.exp.json | 105 +- .../TestDelete/underscore_remove.exp.json | 37 +- .../TestMove/append_multiple_styles.exp.json | 22 +- testdata/d2oracle/TestMove/basic.exp.json | 11 +- .../d2oracle/TestMove/basic_nested.exp.json | 18 +- .../TestMove/basic_out_of_container.exp.json | 18 +- .../TestMove/between_containers.exp.json | 25 +- .../TestMove/chain_connected_nested.exp.json | 111 +- ..._connected_nested_no_extra_create.exp.json | 30 +- .../TestMove/connected_nested.exp.json | 108 +- .../d2oracle/TestMove/container_near.exp.json | 48 +- .../TestMove/edge_across_containers.exp.json | 151 +- .../d2oracle/TestMove/edge_basic.exp.json | 17 +- .../TestMove/edge_chain_basic.exp.json | 25 +- .../TestMove/edge_chain_circular.exp.json | 149 +- .../edge_chain_into_container.exp.json | 70 +- .../edge_chain_out_container.exp.json | 114 +- .../d2oracle/TestMove/edge_conflict.exp.json | 204 +- .../TestMove/edge_into_container.exp.json | 31 +- .../TestMove/edge_nested_basic.exp.json | 24 +- .../TestMove/edge_out_of_container.exp.json | 106 +- .../d2oracle/TestMove/extend_map.exp.json | 34 +- .../TestMove/extend_stationary_path.exp.json | 31 +- .../TestMove/flat_between_containers.exp.json | 25 +- .../d2oracle/TestMove/flat_merge.exp.json | 32 +- .../TestMove/flat_middle_container.exp.json | 32 +- .../TestMove/flat_nested_merge.exp.json | 74 +- .../flat_nested_merge_multiple_refs.exp.json | 236 +- .../flat_reparent_with_map_value.exp.json | 16 +- ...lat_reparent_with_mixed_map_value.exp.json | 23 +- .../flat_reparent_with_value.exp.json | 18 +- .../d2oracle/TestMove/flat_style.exp.json | 22 +- .../TestMove/full_edge_slice.exp.json | 218 +- .../d2oracle/TestMove/full_slice.exp.json | 25 +- testdata/d2oracle/TestMove/gnarly_1.exp.json | 987 +++---- .../hoist_container_children.exp.json | 32 +- .../into_container_existing_map.exp.json | 25 +- .../into_container_nonexisting_map.exp.json | 18 +- .../into_container_with_flat_keys.exp.json | 20 +- .../into_container_with_flat_style.exp.json | 20 +- .../d2oracle/TestMove/map_transplant.exp.json | 34 +- .../d2oracle/TestMove/map_with_label.exp.json | 25 +- .../TestMove/merge_nested_maps.exp.json | 148 +- .../d2oracle/TestMove/merge_reserved.exp.json | 52 +- .../TestMove/middle_container.exp.json | 25 +- .../TestMove/move_container_children.exp.json | 39 +- .../move_container_conflict_children.exp.json | 39 +- .../move_into_key_with_value.exp.json | 18 +- .../TestMove/move_out_of_edge.exp.json | 123 +- .../TestMove/move_out_of_nested_edge.exp.json | 507 ++-- .../TestMove/multiple_nesting_levels.exp.json | 65 +- testdata/d2oracle/TestMove/near.exp.json | 20 +- .../d2oracle/TestMove/nhooyr_one.exp.json | 32 +- .../d2oracle/TestMove/nhooyr_two.exp.json | 293 +- .../d2oracle/TestMove/parentheses.exp.json | 170 +- .../TestMove/partial_edge_slice.exp.json | 64 +- .../d2oracle/TestMove/partial_slice.exp.json | 18 +- testdata/d2oracle/TestMove/rename_2.exp.json | 39 +- testdata/d2oracle/TestMove/reuse_map.exp.json | 41 +- .../d2oracle/TestMove/slice_style.exp.json | 20 +- .../TestMove/underscore_children.exp.json | 20 +- .../underscore_edge_children.exp.json | 168 +- .../underscore_edge_container_1.exp.json | 24 +- .../underscore_edge_container_2.exp.json | 24 +- .../underscore_edge_container_3.exp.json | 106 +- .../underscore_edge_container_4.exp.json | 24 +- .../underscore_edge_container_5.exp.json | 24 +- .../TestMove/underscore_edge_split.exp.json | 66 +- .../TestMove/underscore_merge.exp.json | 27 +- .../TestMove/underscore_split.exp.json | 32 +- .../TestMove/underscore_split_out.exp.json | 41 +- .../TestMove/underscore_transplant.exp.json | 25 +- .../d2oracle/TestMove/unique_name.exp.json | 36 +- .../unique_name_with_references.exp.json | 120 +- testdata/d2oracle/TestRename/arrows.exp.json | 17 +- .../d2oracle/TestRename/arrows_chain.exp.json | 33 +- .../TestRename/arrows_complex.exp.json | 49 +- .../TestRename/arrows_trim_common.exp.json | 40 +- .../TestRename/arrows_trim_common_2.exp.json | 38 +- .../TestRename/complex_edge_1.exp.json | 49 +- .../TestRename/complex_edge_2.exp.json | 49 +- .../d2oracle/TestRename/conflict.exp.json | 18 +- .../d2oracle/TestRename/conflict_2.exp.json | 39 +- .../TestRename/conflict_with_dots.exp.json | 18 +- .../d2oracle/TestRename/container.exp.json | 751 ++--- testdata/d2oracle/TestRename/edges.exp.json | 470 ++-- testdata/d2oracle/TestRename/flat.exp.json | 11 +- .../d2oracle/TestRename/generated.exp.json | 11 +- testdata/d2oracle/TestRename/near.exp.json | 20 +- testdata/d2oracle/TestRename/nested.exp.json | 49 +- testdata/d2oracle/TestSet/base.exp.json | 11 +- .../TestSet/block_string_multiline.exp.json | 11 +- .../TestSet/block_string_oneline.exp.json | 11 +- testdata/d2oracle/TestSet/edge.exp.json | 17 +- .../TestSet/edge_append_style.exp.json | 17 +- testdata/d2oracle/TestSet/edge_chain.exp.json | 32 +- .../TestSet/edge_chain_append_style.exp.json | 25 +- .../edge_chain_existing_style.exp.json | 25 +- .../TestSet/edge_chain_nested_set.exp.json | 32 +- .../d2oracle/TestSet/edge_index_case.exp.json | 124 +- .../TestSet/edge_index_nested.exp.json | 24 +- .../TestSet/edge_key_and_key.exp.json | 24 +- testdata/d2oracle/TestSet/edge_label.exp.json | 17 +- .../TestSet/edge_merge_style.exp.json | 17 +- .../TestSet/edge_nested_label_set.exp.json | 24 +- .../TestSet/edge_nested_style_set.exp.json | 24 +- .../TestSet/expanded_map_style.exp.json | 13 +- testdata/d2oracle/TestSet/icon.exp.json | 11 +- .../d2oracle/TestSet/inline_style.exp.json | 13 +- testdata/d2oracle/TestSet/label.exp.json | 11 +- .../d2oracle/TestSet/label_primary.exp.json | 24 +- .../d2oracle/TestSet/label_replace.exp.json | 11 +- .../d2oracle/TestSet/label_unset.exp.json | 11 +- .../d2oracle/TestSet/map_key_missing.exp.json | 57 +- .../d2oracle/TestSet/nested_alex.exp.json | 146 +- testdata/d2oracle/TestSet/new_style.exp.json | 13 +- .../d2oracle/TestSet/replace_shape.exp.json | 9 +- .../d2oracle/TestSet/replace_style.exp.json | 13 +- .../TestSet/replace_style_edgecase.exp.json | 15 +- testdata/d2oracle/TestSet/shape.exp.json | 9 +- .../TestSet/shape_nested_style_set.exp.json | 13 +- 781 files changed, 31567 insertions(+), 26574 deletions(-) create mode 100644 e2etests/testdata/stable/overlapping_image_container_labels/dagre/.!73950!sketch.exp.svg delete mode 100644 testdata/d2compiler/TestCompile/default_orientation.exp.json delete mode 100644 testdata/d2compiler/TestCompile/image_dimensions.exp.json delete mode 100644 testdata/d2compiler/TestCompile/invalid_orientation.exp.json delete mode 100644 testdata/d2compiler/TestCompile/root_orientation.exp.json create mode 100644 testdata/d2compiler/TestCompile/sequence_container.exp.json create mode 100644 testdata/d2compiler/TestCompile/sequence_container_2.exp.json delete mode 100644 testdata/d2compiler/TestCompile/set_orientation.exp.json delete mode 100644 testdata/d2compiler/TestCompile/shape.exp.json delete mode 100644 testdata/d2compiler/TestCompile/style.exp.json delete mode 100644 testdata/d2compiler/TestCompile/underscore_edge_existing_new.exp.json delete mode 100644 testdata/d2compiler/TestCompile/underscore_edge_reference.exp.json delete mode 100644 testdata/d2compiler/TestCompile/underscore_parent.exp.json delete mode 100644 testdata/d2compiler/TestCompile/underscore_parent_preference.exp.json create mode 100644 testdata/d2compiler/TestCompile2/scenarios/recursive.exp.json rename testdata/d2compiler/TestCompile2/scenarios/{one.exp.json => root.exp.json} (54%) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 4ab8e37b4..8afb333a8 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -155,9 +155,14 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { c.compileMap(obj, f.Map()) } + if obj.Attributes.Label.MapKey == nil { + obj.Attributes.Label.MapKey = f.LastPrimaryKey() + } for _, fr := range f.References { - if fr.OurValue() && fr.Context.Key.Value.Map != nil { - obj.Map = fr.Context.Key.Value.Map + if fr.Primary() { + if fr.Context.Key.Value.Map != nil { + obj.Map = fr.Context.Key.Value.Map + } } scopeObjIDA := d2ir.IDA(fr.Context.ScopeMap) scopeObj, _ := obj.Graph.Root.HasChild(scopeObjIDA) @@ -358,9 +363,10 @@ func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { } } + edge.Attributes.Label.MapKey = e.LastPrimaryKey() for _, er := range e.References { scopeObjIDA := d2ir.IDA(er.Context.ScopeMap) - scopeObj, _ := edge.Src.Graph.Root.HasChild(scopeObjIDA) + scopeObj, _ := edge.Src.Graph.Root.HasChild(d2graphIDA(scopeObjIDA)) edge.References = append(edge.References, d2graph.EdgeReference{ Edge: er.Context.Edge, MapKey: er.Context.Key, @@ -532,44 +538,34 @@ func (c *compiler) validateKeys(obj *d2graph.Object, m *d2ir.Map) { func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { keyword := strings.ToLower(f.Name) - _, isReserved := d2graph.SimpleReservedKeywords[keyword] + _, isReserved := d2graph.ReservedKeywords[keyword] if isReserved { switch obj.Attributes.Shape.Value { case d2target.ShapeSQLTable, d2target.ShapeClass: default: if len(obj.Children) > 0 && (f.Name == "width" || f.Name == "height") { - c.errorf(f.LastPrimaryKey(), mk.Range.End, fmt.Sprintf("%s cannot be used on container: %s", f.Name, obj.AbsID())) + c.errorf(f.LastPrimaryKey(), fmt.Sprintf("%s cannot be used on container: %s", f.Name, obj.AbsID())) } } switch obj.Attributes.Shape.Value { case d2target.ShapeCircle, d2target.ShapeSquare: - checkEqual := (reserved == "width" && obj.Attributes.Height != nil) || (reserved == "height" && obj.Attributes.Width != nil) + checkEqual := (keyword == "width" && obj.Attributes.Height != nil) || (keyword == "height" && obj.Attributes.Width != nil) if checkEqual && obj.Attributes.Width.Value != obj.Attributes.Height.Value { c.errorf(f.LastPrimaryKey(), "width and height must be equal for %s shapes", obj.Attributes.Shape.Value) } } switch f.Name { - case "width": - if obj.Attributes.Shape.Value != d2target.ShapeImage { - c.errorf(f.LastPrimaryKey(), "width is only applicable to image shapes.") - } - case "height": - if obj.Attributes.Shape.Value != d2target.ShapeImage { - c.errorf(f.LastPrimaryKey(), "height is only applicable to image shapes.") + case "style": + if obj.Attributes.Style.ThreeDee != nil { + if !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeSquare) && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeRectangle) { + c.errorf(obj.Attributes.Style.ThreeDee.MapKey, `key "3d" can only be applied to squares and rectangles`) + } } case "shape": - switch obj.Attributes.Shape.Value { - case d2target.ShapeSQLTable, d2target.ShapeClass: - case d2target.ShapeImage: - if obj.Attributes.Icon == nil { - c.errorf(f.LastPrimaryKey(), `image shape must include an "icon" field`) - } - default: - if len(obj.Children) > 0 && (f.Name == "width" || f.Name == "height") { - c.errorf(f.LastPrimaryKey(), fmt.Sprintf("%s cannot be used on container: %s", f.Name, obj.AbsID())) - } + if obj.Attributes.Shape.Value == d2target.ShapeImage && obj.Attributes.Icon == nil { + c.errorf(f.LastPrimaryKey(), `image shape must include an "icon" field`) } in := d2target.IsShape(obj.Attributes.Shape.Value) @@ -581,12 +577,6 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { return } - if obj.Attributes.Style.ThreeDee != nil { - if !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeSquare) && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeRectangle) { - c.errorf(obj.Attributes.Style.ThreeDee.MapKey, `key "3d" can only be applied to squares and rectangles`) - } - } - if obj.Attributes.Shape.Value == d2target.ShapeImage { c.errorf(f.LastRef().AST(), "image shapes cannot have children.") return diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index ca993db6c..3168c53f0 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -124,8 +124,7 @@ x: { } `, expErr: `d2/testdata/d2compiler/TestCompile/equal_dimensions_on_circle.d2:3:2: width and height must be equal for circle shapes -d2/testdata/d2compiler/TestCompile/equal_dimensions_on_circle.d2:4:2: width and height must be equal for circle shapes -`, +d2/testdata/d2compiler/TestCompile/equal_dimensions_on_circle.d2:4:2: width and height must be equal for circle shapes`, }, { name: "single_dimension_on_circle", @@ -208,8 +207,7 @@ d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:16:3: height c d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:25:3: width cannot be used on container: containers.oval container d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:26:3: height cannot be used on container: containers.oval container d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:36:3: width cannot be used on container: containers.hexagon container -d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height cannot be used on container: containers.hexagon container -`, +d2/testdata/d2compiler/TestCompile/no_dimensions_on_containers.d2:37:3: height cannot be used on container: containers.hexagon container`, }, { name: "dimension_with_style", @@ -1753,6 +1751,35 @@ choo: { tassert.Equal(t, 3, len(g.Root.ChildrenArray)) }, }, + { + name: "sequence_container", + + text: `shape: sequence_diagram +x.y.q -> j.y.p +ok: { + x.y.q -> j.y.p +} +`, + assertions: func(t *testing.T, g *d2graph.Graph) { + tassert.Equal(t, 7, len(g.Objects)) + tassert.Equal(t, 3, len(g.Root.ChildrenArray)) + }, + }, + { + name: "sequence_container_2", + + text: `shape: sequence_diagram +x.y.q +ok: { + x.y.q -> j.y.p + meow +} +`, + assertions: func(t *testing.T, g *d2graph.Graph) { + tassert.Equal(t, 8, len(g.Objects)) + tassert.Equal(t, 2, len(g.Root.ChildrenArray)) + }, + }, { name: "root_direction", diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index a685ae963..222149eab 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -497,6 +497,9 @@ func (obj *Object) newObject(id string) *Object { Label: Scalar{ Value: idval, }, + Shape: Scalar{ + Value: d2target.ShapeRectangle, + }, }, Graph: obj.Graph, @@ -649,25 +652,34 @@ func (obj *Object) ensureChildEdge(ids []string) *Object { // EnsureChild grabs the child by ids or creates it if it does not exist including all // intermediate nodes. -func (obj *Object) EnsureChild(ids []string) *Object { - _, is := ReservedKeywordHolders[ids[0]] - if len(ids) == 1 && !is { - _, ok := ReservedKeywords[ids[0]] +func (obj *Object) EnsureChild(ida []string) *Object { + seq := obj.OuterSequenceDiagram() + if seq != nil { + for _, c := range seq.ChildrenArray { + if c.ID == ida[0] { + obj = seq + break + } + } + } + _, is := ReservedKeywordHolders[ida[0]] + if len(ida) == 1 && !is { + _, ok := ReservedKeywords[ida[0]] if ok { return obj } } - id := ids[0] - ids = ids[1:] + id := ida[0] + ida = ida[1:] child, ok := obj.Children[strings.ToLower(id)] if !ok { child = obj.newObject(id) } - if len(ids) >= 1 { - return child.EnsureChild(ids) + if len(ida) >= 1 { + return child.EnsureChild(ida) } return child } @@ -944,15 +956,6 @@ func (e *Edge) AbsID() string { } func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label string) (*Edge, error) { - srcObj, srcID, err := ResolveUnderscoreKey(srcID, obj) - if err != nil { - return nil, err - } - dstObj, dstID, err := ResolveUnderscoreKey(dstID, obj) - if err != nil { - return nil, err - } - for _, id := range [][]string{srcID, dstID} { for _, p := range id { if _, ok := ReservedKeywords[p]; ok { @@ -961,8 +964,8 @@ func (obj *Object) Connect(srcID, dstID []string, srcArrow, dstArrow bool, label } } - src := srcObj.ensureChildEdge(srcID) - dst := dstObj.ensureChildEdge(dstID) + src := obj.ensureChildEdge(srcID) + dst := obj.ensureChildEdge(dstID) if src.OuterSequenceDiagram() != dst.OuterSequenceDiagram() { return nil, errors.New("connections within sequence diagrams can connect only to other objects within the same sequence diagram") diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 7f59ca207..3540536fc 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -116,6 +116,7 @@ type Reference interface { reference() // Most specific AST node for the reference. AST() d2ast.Node + Primary() bool } var _ Reference = &FieldReference{} @@ -214,7 +215,11 @@ func (m *Map) Root() bool { if !ok { return false } - return f.Name == "" + return f.Root() +} + +func (f *Field) Root() bool { + return f.parent == nil } type LayerKind string @@ -237,7 +242,7 @@ func NodeLayerKind(n Node) LayerKind { f = ParentField(n) case *Map: f = ParentField(n) - if f.Name == "" { + if f.Root() { return LayerLayer } f = ParentField(f) @@ -286,7 +291,7 @@ func (f *Field) Copy(newParent Node) Node { func (f *Field) lastPrimaryRef() *FieldReference { for i := len(f.References) - 1; i >= 0; i-- { - if f.References[i].OurValue() { + if f.References[i].Primary() { return f.References[i] } } @@ -485,13 +490,13 @@ type FieldReference struct { Context *RefContext `json:"context"` } -// OurValue returns true if the Value in Context.Key.Value corresponds to the Field +// Primary returns true if the Value in Context.Key.Value corresponds to the Field // represented by String. -func (fr *FieldReference) OurValue() bool { +func (fr *FieldReference) Primary() bool { if fr.KeyPath == fr.Context.Key.Key { - return fr.KeyPathIndex() == len(fr.KeyPath.Path)-1 + return len(fr.Context.Key.Edges) == 0 && fr.KeyPathIndex() == len(fr.KeyPath.Path)-1 } else if fr.KeyPath == fr.Context.Key.EdgeKey { - return fr.KeyPathIndex() == len(fr.KeyPath.Path)-1 + return len(fr.Context.Key.Edges) == 1 && fr.KeyPathIndex() == len(fr.KeyPath.Path)-1 } return false } @@ -529,6 +534,12 @@ func (er *EdgeReference) AST() d2ast.Node { return er.Context.Edge } +// Primary returns true if the Value in Context.Key.Value corresponds to the *Edge +// represented by Context.Edge +func (er *EdgeReference) Primary() bool { + return len(er.Context.Key.Edges) == 1 && er.Context.Key.EdgeKey == nil +} + type RefContext struct { Edge *d2ast.Edge `json:"edge"` Key *d2ast.Key `json:"key"` @@ -653,11 +664,14 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, continue } - f.References = append(f.References, &FieldReference{ - String: kp.Path[i].Unbox(), - KeyPath: kp, - Context: refctx, - }) + // Don't add references for fake common KeyPath from trimCommon in CreateEdge. + if refctx != nil { + f.References = append(f.References, &FieldReference{ + String: kp.Path[i].Unbox(), + KeyPath: kp, + Context: refctx, + }) + } if i+1 == len(kp.Path) { return f, nil @@ -676,11 +690,14 @@ func (m *Map) ensureField(i int, kp *d2ast.KeyPath, refctx *RefContext) (*Field, f := &Field{ parent: m, Name: head, - References: []*FieldReference{{ + } + // Don't add references for fake common KeyPath from trimCommon in CreateEdge. + if refctx != nil { + f.References = append(f.References, &FieldReference{ String: kp.Path[i].Unbox(), KeyPath: kp, Context: refctx, - }}, + }) } m.Fields = append(m.Fields, f) if i+1 == len(kp.Path) { @@ -755,7 +772,7 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { tmp := *refctx.Edge.Src kp := &tmp kp.Path = kp.Path[:len(common)] - f, err := m.EnsureField(kp, refctx) + f, err := m.EnsureField(kp, nil) if err != nil { return nil, err } @@ -1003,15 +1020,25 @@ func IDA(n Node) (ida []string) { for { f, ok := n.(*Field) if ok { - if f.Name == "" { + if f.Root() { + reverseIDA(ida) return ida } ida = append(ida, f.Name) } f = ParentField(n) if f == nil { + reverseIDA(ida) return ida } n = f } } + +func reverseIDA(ida []string) { + for i := 0; i < len(ida)/2; i++ { + tmp := ida[i] + ida[i] = ida[len(ida)-i-1] + ida[len(ida)-i-1] = tmp + } +} diff --git a/d2oracle/edit.go b/d2oracle/edit.go index 7fa3e8ccb..5d928d86a 100644 --- a/d2oracle/edit.go +++ b/d2oracle/edit.go @@ -391,7 +391,6 @@ func Delete(g *d2graph.Graph, key string) (_ *d2graph.Graph, err error) { if g != g2 { return g2, nil } - g = g2 if len(mk.Edges) == 1 { obj := g.Root diff --git a/d2oracle/edit_test.go b/d2oracle/edit_test.go index 7feba4572..dd3b430fc 100644 --- a/d2oracle/edit_test.go +++ b/d2oracle/edit_test.go @@ -1373,12 +1373,12 @@ more.(ok.q.z -> p.k): "furbling, v.:" { name: "complex_edge_1", - text: `a.b.(x -> y).q.z + text: `a.b.(x -> y).style.animated `, key: "a.b", newName: "ooo", - exp: `a.ooo.(x -> y).q.z + exp: `a.ooo.(x -> y).style.animated `, assertions: func(t *testing.T, g *d2graph.Graph) { if len(g.Objects) != 4 { @@ -1392,12 +1392,12 @@ more.(ok.q.z -> p.k): "furbling, v.:" { name: "complex_edge_2", - text: `a.b.(x -> y).q.z + text: `a.b.(x -> y).style.animated `, key: "a.b.x", newName: "papa", - exp: `a.b.(papa -> y).q.z + exp: `a.b.(papa -> y).style.animated `, assertions: func(t *testing.T, g *d2graph.Graph) { if len(g.Objects) != 4 { @@ -1454,12 +1454,12 @@ more.(ok.q.z -> p.k): "furbling, v.:" { name: "arrows_complex", - text: `a.b.(x -- y).q.z + text: `a.b.(x -- y).style.animated `, key: "a.b.(x -- y)[0]", newName: "(x <-> y)[0]", - exp: `a.b.(x <-> y).q.z + exp: `a.b.(x <-> y).style.animated `, assertions: func(t *testing.T, g *d2graph.Graph) { if len(g.Objects) != 4 { @@ -3025,7 +3025,7 @@ d if err == nil { objectsAfter := len(g.Objects) if objectsBefore != objectsAfter { - println(d2format.Format(g.AST)) + t.Log(d2format.Format(g.AST)) return nil, fmt.Errorf("move cannot destroy or create objects: found %d objects before and %d objects after", objectsBefore, objectsAfter) } } diff --git a/d2renderers/d2sketch/testdata/animated/sketch.exp.svg b/d2renderers/d2sketch/testdata/animated/sketch.exp.svg index 79cea04c6..f50aa2142 100644 --- a/d2renderers/d2sketch/testdata/animated/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/animated/sketch.exp.svg @@ -51,7 +51,7 @@ width="561" height="982" viewBox="-102 -102 561 982"> \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json index e37d0a2b3..2a47be779 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json @@ -54,7 +54,7 @@ }, { "id": "ico", - "type": "", + "type": "rectangle", "pos": { "x": 160, "y": 26 diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg index 6f53328fa..b66955ecf 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg @@ -39,7 +39,7 @@ width="452" height="332" viewBox="-90 -90 452 332"> \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json index ca5d11974..4db9f807e 100644 --- a/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json +++ b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json @@ -4,7 +4,7 @@ "shapes": [ { "id": "x", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 0 @@ -44,7 +44,7 @@ }, { "id": "x.a", - "type": "", + "type": "rectangle", "pos": { "x": 50, "y": 50 @@ -84,7 +84,7 @@ }, { "id": "x.b", - "type": "", + "type": "rectangle", "pos": { "x": 263, "y": 50 diff --git a/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg b/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg index 48ca96d52..4ca1c4d4d 100644 --- a/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="630" height="430" viewBox="-102 -102 630 430">

Oldest message

-

Offset

-

Last message

-

Next message will be
-inserted here

-
M0M1M2M3M4M5M6 - +

m0_desc

+

m2_desc

+

m5_desc

+

m6_desc

+
M0M1M2M3M4M5M6 +

Oldest message

-

Offset

-

Last message

-

Next message will be
-inserted here

-
M0M1M2M3M4M5M6 - +

m0_desc

+

m2_desc

+

m5_desc

+

m6_desc

+
M0M1M2M3M4M5M6 +

hey

-
    -
  • they -
      -
    1. they
    2. -
    -
  • -
-
ab - +

md

+
ab +

hey

-
    -
  • they -
      -
    1. they
    2. -
    -
  • -
-
ab - +

md

+
ab + x

linux: because a PC is a terrible thing to waste

-
a You don't have to know how the computer works,just how to work the computer. - +x

y

+
a You don't have to know how the computer works,just how to work the computer. + x

linux: because a PC is a terrible thing to waste

-
a You don't have to know how the computer works,just how to work the computer. - +x

y

+
a You don't have to know how the computer works,just how to work the computer. + aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 diff --git a/e2etests/testdata/stable/chaos2/elk/board.exp.json b/e2etests/testdata/stable/chaos2/elk/board.exp.json index 4c3490841..9a58a20cc 100644 --- a/e2etests/testdata/stable/chaos2/elk/board.exp.json +++ b/e2etests/testdata/stable/chaos2/elk/board.exp.json @@ -4,7 +4,7 @@ "shapes": [ { "id": "aa", - "type": "", + "type": "rectangle", "pos": { "x": 12, "y": 12 @@ -44,7 +44,7 @@ }, { "id": "aa.bb", - "type": "", + "type": "rectangle", "pos": { "x": 87, "y": 815 @@ -84,7 +84,7 @@ }, { "id": "aa.bb.cc", - "type": "", + "type": "rectangle", "pos": { "x": 423, "y": 1271 @@ -203,7 +203,7 @@ }, { "id": "aa.bb.cc.dd.ff", - "type": "", + "type": "rectangle", "pos": { "x": 609, "y": 1421 @@ -282,7 +282,7 @@ }, { "id": "aa.bb.cc.hh", - "type": "", + "type": "rectangle", "pos": { "x": 522, "y": 2090 @@ -442,7 +442,7 @@ }, { "id": "aa.ll", - "type": "", + "type": "rectangle", "pos": { "x": 612, "y": 363 @@ -561,7 +561,7 @@ }, { "id": "aa.oo", - "type": "", + "type": "rectangle", "pos": { "x": 689, "y": 87 diff --git a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg index e1498a328..f9e32197d 100644 --- a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg @@ -796,7 +796,7 @@ width="1275" height="2738" viewBox="-90 -90 1275 2738">aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 diff --git a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json index 29604db23..6404a9b86 100644 --- a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json @@ -4,7 +4,7 @@ "shapes": [ { "id": "a", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 0 @@ -44,7 +44,7 @@ }, { "id": "a.b", - "type": "", + "type": "rectangle", "pos": { "x": 40, "y": 50 @@ -84,7 +84,7 @@ }, { "id": "a.b.c", - "type": "", + "type": "rectangle", "pos": { "x": 80, "y": 100 @@ -124,7 +124,7 @@ }, { "id": "a.b.c.d", - "type": "", + "type": "rectangle", "pos": { "x": 130, "y": 150 @@ -165,11 +165,11 @@ ], "connections": [ { - "id": "(a.b -> a)[0]", + "id": "a.(b -> b.c)[0]", "src": "a.b", "srcArrow": "none", "srcLabel": "", - "dst": "a", + "dst": "a.b.c", "dstArrow": "triangle", "dstLabel": "", "opacity": 1, @@ -248,90 +248,6 @@ "icon": null, "zIndex": 0 }, - { - "id": "a.(b -> b.c)[0]", - "src": "a.b", - "srcArrow": "none", - "srcLabel": "", - "dst": "a.b.c", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 244, - "y": 182.30769230769232 - }, - { - "x": 292, - "y": 156.46153846153845 - }, - { - "x": 307, - "y": 150 - }, - { - "x": 311.5, - "y": 150 - }, - { - "x": 316, - "y": 150 - }, - { - "x": 322, - "y": 162.6 - }, - { - "x": 326.5, - "y": 181.5 - }, - { - "x": 331, - "y": 200.4 - }, - { - "x": 331, - "y": 225.6 - }, - { - "x": 326.5, - "y": 244.5 - }, - { - "x": 322, - "y": 263.4 - }, - { - "x": 292, - "y": 269.53846153846155 - }, - { - "x": 244, - "y": 243.69230769230768 - } - ], - "isCurve": true, - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 0 - }, { "id": "a.(b.c.d -> b)[0]", "src": "a.b.c.d", @@ -358,14 +274,98 @@ "labelPercentage": 0, "route": [ { - "x": 243.66666666666669, - "y": 238 + "x": 244, + "y": 244 + }, + { + "x": 244, + "y": 243.69230769230768 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(a.b -> a)[0]", + "src": "a.b", + "srcArrow": "none", + "srcLabel": "", + "dst": "a", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 244, + "y": 188.0046403712297 + }, + { + "x": 313.33333333333337, + "y": 157.60092807424593 + }, + { + "x": 335, + "y": 150 + }, + { + "x": 341.5, + "y": 150 + }, + { + "x": 348, + "y": 150 + }, + { + "x": 356.66666666666663, + "y": 162.6 + }, + { + "x": 363.16666666666663, + "y": 181.5 + }, + { + "x": 369.6666666666667, + "y": 200.4 + }, + { + "x": 369.6666666666667, + "y": 225.6 + }, + { + "x": 363.16666666666663, + "y": 244.5 + }, + { + "x": 356.66666666666663, + "y": 263.4 + }, + { + "x": 313.33333333333337, + "y": 268.3990719257541 }, { "x": 244, "y": 237.9953596287703 } ], + "isCurve": true, "animated": false, "tooltip": "", "icon": null, diff --git a/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg b/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg index 7bc1e8325..c6231a92e 100644 --- a/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="698" height="630" viewBox="-102 -102 698 630">xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

-

If we can't fix it, it ain't broke.

-

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +xyThe top of the mountain

bottom

+
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

-

If we can't fix it, it ain't broke.

-

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +xyThe top of the mountain

bottom

+
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + poll the peopleresultsunfavorablefavorablewill of the people

A winning strategy

-
- +poll the peopleresultsunfavorablefavorablewill of the people

title

+
+ poll the peopleresultsunfavorablefavorablewill of the people

A winning strategy

-
- +poll the peopleresultsunfavorablefavorablewill of the people

title

+
+

Markdown: Syntax

- -

Note: This document is itself written using Markdown; you -can see the source for it by adding '.text' to the URL.

-
-

Overview

-

Philosophy

-

Markdown is intended to be as easy-to-read and easy-to-write as is feasible.

-

Readability, however, is emphasized above all else. A Markdown-formatted -document should be publishable as-is, as plain text, without looking -like it's been marked up with tags or formatting instructions. While -Markdown's syntax has been influenced by several existing text-to-HTML -filters -- including Setext, atx, Textile, reStructuredText, -Grutatext, and EtText -- the single biggest source of -inspiration for Markdown's syntax is the format of plain text email.

-

Block Elements

-

Paragraphs and Line Breaks

-

A paragraph is simply one or more consecutive lines of text, separated -by one or more blank lines. (A blank line is any line that looks like a -blank line -- a line containing nothing but spaces or tabs is considered -blank.) Normal paragraphs should not be indented with spaces or tabs.

-

The implication of the "one or more consecutive lines of text" rule is -that Markdown supports "hard-wrapped" text paragraphs. This differs -significantly from most other text-to-HTML formatters (including Movable -Type's "Convert Line Breaks" option) which translate every line break -end a line with two or more spaces, then type return.

-

Headers

-

Markdown supports two styles of headers, [Setext] [1] and [atx] [2].

-

Optionally, you may "close" atx-style headers. This is purely -cosmetic -- you can use this if you think it looks better. The -closing hashes don't even need to match the number of hashes -used to open the header. (The number of opening hashes -determines the header level.)

-

Blockquotes

-

familiar with quoting passages of text in an email message, then you -know how to create a blockquote in Markdown. It looks best if you hard

-
-

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, -consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. -Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

-

Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse -id sem consectetuer libero luctus adipiscing.

-
-

line of a hard-wrapped paragraph:

-
-

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, -consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. -Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

-
-
-

Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse -id sem consectetuer libero luctus adipiscing.

-
-

Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by

-
-

This is the first level of quoting.

-
-

This is nested blockquote.

-
-

Back to the first level.

-
-

Blockquotes can contain other Markdown elements, including headers, lists, -and code blocks:

-
-

This is a header.

-
    -
  1. This is the first list item.
  2. -
  3. This is the second list item.
  4. -
-

Here's some example code:

-
return shell_exec("echo $input  $markdown_script");
-
-
-

Any decent text editor should make email-style quoting easy. For -example, with BBEdit, you can make a selection and choose Increase -Quote Level from the Text menu.

-

Lists

-

Markdown supports ordered (numbered) and unordered (bulleted) lists.

-

Unordered lists use asterisks, pluses, and hyphens -- interchangably --- as list markers:

-
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
-

is equivalent to:

-
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
-

and:

-
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
-

Ordered lists use numbers followed by periods:

-
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
-

It's important to note that the actual numbers you use to mark the -list have no effect on the HTML output Markdown produces. The HTML -Markdown produces from the above list is:

-

If you instead wrote the list in Markdown like this:

-
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
-

or even:

-
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
-

you'd get the exact same HTML output. The point is, if you want to, -you can use ordinal numbers in your ordered Markdown lists, so that -the numbers in your source match the numbers in your published HTML. -But if you want to be lazy, you don't have to.

-

To make lists look nice, you can wrap items with hanging indents:

-
    -
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. -Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, -viverra nec, fringilla in, laoreet vitae, risus.
  • -
  • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. -Suspendisse id sem consectetuer libero luctus adipiscing.
  • -
-

But if you want to be lazy, you don't have to:

-
    -
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. -Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, -viverra nec, fringilla in, laoreet vitae, risus.
  • -
  • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. -Suspendisse id sem consectetuer libero luctus adipiscing.
  • -
-

List items may consist of multiple paragraphs. Each subsequent -paragraph in a list item must be indented by either 4 spaces -or one tab:

-
    -
  1. -

    This is a list item with two paragraphs. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit. Aliquam hendrerit -mi posuere lectus.

    -

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet -vitae, risus. Donec sit amet nisl. Aliquam semper ipsum -sit amet velit.

    -
  2. -
  3. -

    Suspendisse id sem consectetuer libero luctus adipiscing.

    -
  4. -
-

It looks nice if you indent every line of the subsequent -paragraphs, but here again, Markdown will allow you to be -lazy:

-
    -
  • -

    This is a list item with two paragraphs.

    -
    This is the second paragraph in the list item. You're
    -
    -

    only required to indent the first line. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit.

    -
  • -
  • -

    Another item in the same list.

    -
  • -
-

delimiters need to be indented:

-
    -
  • -

    A list item with a blockquote:

    -
    -

    This is a blockquote -inside a list item.

    -
    -
  • -
-

To put a code block within a list item, the code block needs -to be indented twice -- 8 spaces or two tabs:

-
    -
  • A list item with a code block:
  • -
-

Code Blocks

-

Pre-formatted code blocks are used for writing about programming or -markup source code. Rather than forming normal paragraphs, the lines -of a code block are interpreted literally. Markdown wraps a code block

-

To produce a code block in Markdown, simply indent every line of the -block by at least 4 spaces or 1 tab.

-

This is a normal paragraph:

-
This is a code block.
-
-

Here is an example of AppleScript:

-
tell application "Foo"
-    beep
-end tell
-
-

A code block continues until it reaches a line that is not indented -(or the end of the article).

-

are automatically converted into HTML entities. This makes it very -easy to include example HTML source code using Markdown -- just paste -it and indent it, and Markdown will handle the hassle of encoding the -ampersands and angle brackets. For example, this:

-

Regular Markdown syntax is not processed within code blocks. E.g., -asterisks are just literal asterisks within a code block. This means -it's also easy to use Markdown to write about Markdown's own syntax.

-

Span Elements

-

Links

-

Markdown supports two style of links: inline and reference.

-

In both styles, the link text is delimited by [square brackets].

-

To create an inline link, use a set of regular parentheses immediately -after the link text's closing square bracket. Inside the parentheses, -put the URL where you want the link to point, along with an optional -title for the link, surrounded in quotes. For example:

-

This is an example inline link.

-

This link has no title attribute.

-

Emphasis

-

single asterisks

-

single underscores

-

double asterisks

-

double underscores

-

Code

-

Unlike a pre-formatted code block, a code span indicates code within a -normal paragraph. For example:

-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json index 52ab0e1e9..80332ab06 100644 --- a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json +++ b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 12, + "x": 57, "y": 238 }, - "width": 3051, - "height": 4853, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n - [Automatic Escaping for Special Characters](#autoescape)\n- [Block Elements](#block)\n - [Paragraphs and Line Breaks](#p)\n - [Headers](#header)\n - [Blockquotes](#blockquote)\n - [Lists](#list)\n - [Code Blocks](#precode)\n - [Horizontal Rules](#hr)\n- [Span Elements](#span)\n - [Links](#link)\n - [Emphasis](#em)\n - [Code](#code)\n - [Images](#img)\n- [Miscellaneous](#misc)\n - [Backslash Escapes](#backslash)\n - [Automatic Links](#autolink)\n\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL](/projects/markdown/syntax.text).\n\n---\n\n## Overview\n\n### Philosophy\n\nMarkdown is intended to be as easy-to-read and easy-to-write as is feasible.\n\nReadability, however, is emphasized above all else. A Markdown-formatted\ndocument should be publishable as-is, as plain text, without looking\nlike it's been marked up with tags or formatting instructions. While\nMarkdown's syntax has been influenced by several existing text-to-HTML\nfilters -- including [Setext](http://docutils.sourceforge.net/mirror/setext.html), [atx](http://www.aaronsw.com/2002/atx/), [Textile](http://textism.com/tools/textile/), [reStructuredText](http://docutils.sourceforge.net/rst.html),\n[Grutatext](http://www.triptico.com/software/grutatxt.html), and [EtText](http://ettext.taint.org/doc/) -- the single biggest source of\ninspiration for Markdown's syntax is the format of plain text email.\n\n## Block Elements\n\n### Paragraphs and Line Breaks\n\nA paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing but spaces or tabs is considered\nblank.) Normal paragraphs should not be indented with spaces or tabs.\n\nThe implication of the \"one or more consecutive lines of text\" rule is\nthat Markdown supports \"hard-wrapped\" text paragraphs. This differs\nsignificantly from most other text-to-HTML formatters (including Movable\nType's \"Convert Line Breaks\" option) which translate every line break\nend a line with two or more spaces, then type return.\n\n### Headers\n\nMarkdown supports two styles of headers, [Setext] [1] and [atx] [2].\n\nOptionally, you may \"close\" atx-style headers. This is purely\ncosmetic -- you can use this if you think it looks better. The\nclosing hashes don't even need to match the number of hashes\nused to open the header. (The number of opening hashes\ndetermines the header level.)\n\n### Blockquotes\n\nfamiliar with quoting passages of text in an email message, then you\nknow how to create a blockquote in Markdown. It looks best if you hard\n\n> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n>\n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n> id sem consectetuer libero luctus adipiscing.\n\nline of a hard-wrapped paragraph:\n\n> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n\n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n> id sem consectetuer libero luctus adipiscing.\n\nBlockquotes can be nested (i.e. a blockquote-in-a-blockquote) by\n\n> This is the first level of quoting.\n>\n> > This is nested blockquote.\n>\n> Back to the first level.\n\nBlockquotes can contain other Markdown elements, including headers, lists,\nand code blocks:\n\n> ## This is a header.\n>\n> 1. This is the first list item.\n> 2. This is the second list item.\n>\n> Here's some example code:\n>\n> return shell_exec(\"echo $input $markdown_script\");\n\nAny decent text editor should make email-style quoting easy. For\nexample, with BBEdit, you can make a selection and choose Increase\nQuote Level from the Text menu.\n\n### Lists\n\nMarkdown supports ordered (numbered) and unordered (bulleted) lists.\n\nUnordered lists use asterisks, pluses, and hyphens -- interchangably\n-- as list markers:\n\n- Red\n- Green\n- Blue\n\nis equivalent to:\n\n- Red\n- Green\n- Blue\n\nand:\n\n- Red\n- Green\n- Blue\n\nOrdered lists use numbers followed by periods:\n\n1. Bird\n2. McHale\n3. Parish\n\nIt's important to note that the actual numbers you use to mark the\nlist have no effect on the HTML output Markdown produces. The HTML\nMarkdown produces from the above list is:\n\nIf you instead wrote the list in Markdown like this:\n\n1. Bird\n1. McHale\n1. Parish\n\nor even:\n\n3. Bird\n1. McHale\n1. Parish\n\nyou'd get the exact same HTML output. The point is, if you want to,\nyou can use ordinal numbers in your ordered Markdown lists, so that\nthe numbers in your source match the numbers in your published HTML.\nBut if you want to be lazy, you don't have to.\n\nTo make lists look nice, you can wrap items with hanging indents:\n\n- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n- Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nBut if you want to be lazy, you don't have to:\n\n- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n- Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be indented by either 4 spaces\nor one tab:\n\n1. This is a list item with two paragraphs. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n mi posuere lectus.\n\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n sit amet velit.\n\n2. Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIt looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:\n\n- This is a list item with two paragraphs.\n\n This is the second paragraph in the list item. You're\n\n only required to indent the first line. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit.\n\n- Another item in the same list.\n\ndelimiters need to be indented:\n\n- A list item with a blockquote:\n\n > This is a blockquote\n > inside a list item.\n\nTo put a code block within a list item, the code block needs\nto be indented _twice_ -- 8 spaces or two tabs:\n\n- A list item with a code block:\n\n### Code Blocks\n\nPre-formatted code blocks are used for writing about programming or\nmarkup source code. Rather than forming normal paragraphs, the lines\nof a code block are interpreted literally. Markdown wraps a code block\n\nTo produce a code block in Markdown, simply indent every line of the\nblock by at least 4 spaces or 1 tab.\n\nThis is a normal paragraph:\n\n This is a code block.\n\nHere is an example of AppleScript:\n\n tell application \"Foo\"\n beep\n end tell\n\nA code block continues until it reaches a line that is not indented\n(or the end of the article).\n\nare automatically converted into HTML entities. This makes it very\neasy to include example HTML source code using Markdown -- just paste\nit and indent it, and Markdown will handle the hassle of encoding the\nampersands and angle brackets. For example, this:\n\nRegular Markdown syntax is not processed within code blocks. E.g.,\nasterisks are just literal asterisks within a code block. This means\nit's also easy to use Markdown to write about Markdown's own syntax.\n\n## Span Elements\n\n### Links\n\nMarkdown supports two style of links: _inline_ and _reference_.\n\nIn both styles, the link text is delimited by [square brackets].\n\nTo create an inline link, use a set of regular parentheses immediately\nafter the link text's closing square bracket. Inside the parentheses,\nput the URL where you want the link to point, along with an _optional_\ntitle for the link, surrounded in quotes. For example:\n\nThis is [an example](http://example.com/) inline link.\n\n[This link](http://example.net/) has no title attribute.\n\n### Emphasis\n\n_single asterisks_\n\n_single underscores_\n\n**double asterisks**\n\n**double underscores**\n\n### Code\n\nUnlike a pre-formatted code block, a code span indicates code within a\nnormal paragraph. For example:\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 3051, - "labelHeight": 4853, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 1481, + "x": 12, "y": 12 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 1481, - "y": 5191 + "x": 12, + "y": 362 }, "width": 113, "height": 126, @@ -149,11 +149,11 @@ "labelPercentage": 0, "route": [ { - "x": 1537.5, + "x": 68.5, "y": 138 }, { - "x": 1537.5, + "x": 68.5, "y": 238 } ], @@ -188,12 +188,12 @@ "labelPercentage": 0, "route": [ { - "x": 1537.5, - "y": 5091 + "x": 68.5, + "y": 262 }, { - "x": 1537.5, - "y": 5191 + "x": 68.5, + "y": 362 } ], "animated": false, diff --git a/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg b/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg index e68c3416d..6e3415cfc 100644 --- a/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="3255" height="5509" viewBox="-90 -90 3255 5509">

Markdown: Syntax

- -

Note: This document is itself written using Markdown; you -can see the source for it by adding '.text' to the URL.

-
-

Overview

-

Philosophy

-

Markdown is intended to be as easy-to-read and easy-to-write as is feasible.

-

Readability, however, is emphasized above all else. A Markdown-formatted -document should be publishable as-is, as plain text, without looking -like it's been marked up with tags or formatting instructions. While -Markdown's syntax has been influenced by several existing text-to-HTML -filters -- including Setext, atx, Textile, reStructuredText, -Grutatext, and EtText -- the single biggest source of -inspiration for Markdown's syntax is the format of plain text email.

-

Block Elements

-

Paragraphs and Line Breaks

-

A paragraph is simply one or more consecutive lines of text, separated -by one or more blank lines. (A blank line is any line that looks like a -blank line -- a line containing nothing but spaces or tabs is considered -blank.) Normal paragraphs should not be indented with spaces or tabs.

-

The implication of the "one or more consecutive lines of text" rule is -that Markdown supports "hard-wrapped" text paragraphs. This differs -significantly from most other text-to-HTML formatters (including Movable -Type's "Convert Line Breaks" option) which translate every line break -end a line with two or more spaces, then type return.

-

Headers

-

Markdown supports two styles of headers, [Setext] [1] and [atx] [2].

-

Optionally, you may "close" atx-style headers. This is purely -cosmetic -- you can use this if you think it looks better. The -closing hashes don't even need to match the number of hashes -used to open the header. (The number of opening hashes -determines the header level.)

-

Blockquotes

-

familiar with quoting passages of text in an email message, then you -know how to create a blockquote in Markdown. It looks best if you hard

-
-

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, -consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. -Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

-

Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse -id sem consectetuer libero luctus adipiscing.

-
-

line of a hard-wrapped paragraph:

-
-

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, -consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. -Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

-
-
-

Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse -id sem consectetuer libero luctus adipiscing.

-
-

Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by

-
-

This is the first level of quoting.

-
-

This is nested blockquote.

-
-

Back to the first level.

-
-

Blockquotes can contain other Markdown elements, including headers, lists, -and code blocks:

-
-

This is a header.

-
    -
  1. This is the first list item.
  2. -
  3. This is the second list item.
  4. -
-

Here's some example code:

-
return shell_exec("echo $input  $markdown_script");
-
-
-

Any decent text editor should make email-style quoting easy. For -example, with BBEdit, you can make a selection and choose Increase -Quote Level from the Text menu.

-

Lists

-

Markdown supports ordered (numbered) and unordered (bulleted) lists.

-

Unordered lists use asterisks, pluses, and hyphens -- interchangably --- as list markers:

-
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
-

is equivalent to:

-
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
-

and:

-
    -
  • Red
  • -
  • Green
  • -
  • Blue
  • -
-

Ordered lists use numbers followed by periods:

-
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
-

It's important to note that the actual numbers you use to mark the -list have no effect on the HTML output Markdown produces. The HTML -Markdown produces from the above list is:

-

If you instead wrote the list in Markdown like this:

-
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
-

or even:

-
    -
  1. Bird
  2. -
  3. McHale
  4. -
  5. Parish
  6. -
-

you'd get the exact same HTML output. The point is, if you want to, -you can use ordinal numbers in your ordered Markdown lists, so that -the numbers in your source match the numbers in your published HTML. -But if you want to be lazy, you don't have to.

-

To make lists look nice, you can wrap items with hanging indents:

-
    -
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. -Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, -viverra nec, fringilla in, laoreet vitae, risus.
  • -
  • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. -Suspendisse id sem consectetuer libero luctus adipiscing.
  • -
-

But if you want to be lazy, you don't have to:

-
    -
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. -Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, -viverra nec, fringilla in, laoreet vitae, risus.
  • -
  • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. -Suspendisse id sem consectetuer libero luctus adipiscing.
  • -
-

List items may consist of multiple paragraphs. Each subsequent -paragraph in a list item must be indented by either 4 spaces -or one tab:

-
    -
  1. -

    This is a list item with two paragraphs. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit. Aliquam hendrerit -mi posuere lectus.

    -

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet -vitae, risus. Donec sit amet nisl. Aliquam semper ipsum -sit amet velit.

    -
  2. -
  3. -

    Suspendisse id sem consectetuer libero luctus adipiscing.

    -
  4. -
-

It looks nice if you indent every line of the subsequent -paragraphs, but here again, Markdown will allow you to be -lazy:

-
    -
  • -

    This is a list item with two paragraphs.

    -
    This is the second paragraph in the list item. You're
    -
    -

    only required to indent the first line. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit.

    -
  • -
  • -

    Another item in the same list.

    -
  • -
-

delimiters need to be indented:

-
    -
  • -

    A list item with a blockquote:

    -
    -

    This is a blockquote -inside a list item.

    -
    -
  • -
-

To put a code block within a list item, the code block needs -to be indented twice -- 8 spaces or two tabs:

-
    -
  • A list item with a code block:
  • -
-

Code Blocks

-

Pre-formatted code blocks are used for writing about programming or -markup source code. Rather than forming normal paragraphs, the lines -of a code block are interpreted literally. Markdown wraps a code block

-

To produce a code block in Markdown, simply indent every line of the -block by at least 4 spaces or 1 tab.

-

This is a normal paragraph:

-
This is a code block.
-
-

Here is an example of AppleScript:

-
tell application "Foo"
-    beep
-end tell
-
-

A code block continues until it reaches a line that is not indented -(or the end of the article).

-

are automatically converted into HTML entities. This makes it very -easy to include example HTML source code using Markdown -- just paste -it and indent it, and Markdown will handle the hassle of encoding the -ampersands and angle brackets. For example, this:

-

Regular Markdown syntax is not processed within code blocks. E.g., -asterisks are just literal asterisks within a code block. This means -it's also easy to use Markdown to write about Markdown's own syntax.

-

Span Elements

-

Links

-

Markdown supports two style of links: inline and reference.

-

In both styles, the link text is delimited by [square brackets].

-

To create an inline link, use a set of regular parentheses immediately -after the link text's closing square bracket. Inside the parentheses, -put the URL where you want the link to point, along with an optional -title for the link, surrounded in quotes. For example:

-

This is an example inline link.

-

This link has no title attribute.

-

Emphasis

-

single asterisks

-

single underscores

-

double asterisks

-

double underscores

-

Code

-

Unlike a pre-formatted code block, a code span indicates code within a -normal paragraph. For example:

-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/hr/dagre/board.exp.json b/e2etests/testdata/stable/hr/dagre/board.exp.json index 53d038cc7..bdae01f3e 100644 --- a/e2etests/testdata/stable/hr/dagre/board.exp.json +++ b/e2etests/testdata/stable/hr/dagre/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 0, + "x": 45, "y": 226 }, - "width": 738, - "height": 135, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL](/projects/markdown/syntax.text).\n\n---\n\n## Overview\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 738, - "labelHeight": 135, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 313, + "x": 0, "y": 0 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 313, - "y": 461 + "x": 0, + "y": 350 }, "width": 113, "height": 126, @@ -149,19 +149,19 @@ "labelPercentage": 0, "route": [ { - "x": 369, + "x": 56.5, "y": 126 }, { - "x": 369, + "x": 56.5, "y": 166 }, { - "x": 369, + "x": 56.5, "y": 186 }, { - "x": 369, + "x": 56.5, "y": 226 } ], @@ -197,20 +197,20 @@ "labelPercentage": 0, "route": [ { - "x": 369, - "y": 361 + "x": 56.5, + "y": 250 }, { - "x": 369, - "y": 401 + "x": 56.5, + "y": 290 }, { - "x": 369, - "y": 421 + "x": 56.5, + "y": 310 }, { - "x": 369, - "y": 461 + "x": 56.5, + "y": 350 } ], "isCurve": true, diff --git a/e2etests/testdata/stable/hr/dagre/sketch.exp.svg b/e2etests/testdata/stable/hr/dagre/sketch.exp.svg index 7f81e905b..823f11cf2 100644 --- a/e2etests/testdata/stable/hr/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/hr/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="942" height="791" viewBox="-102 -102 942 791">

Note: This document is itself written using Markdown; you -can see the source for it by adding '.text' to the URL.

-
-

Overview

-
ab - +

md

+
ab +

Note: This document is itself written using Markdown; you -can see the source for it by adding '.text' to the URL.

-
-

Overview

-
ab - +

md

+
ab + mixed togethersugarsolution we get - - +mixed togethersugarsolution we get + + mixed togethersugarsolution we get - - +mixed togethersugarsolution we get + + ab - +

md

+
ab + ab - +

md

+
ab +
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/li2/elk/board.exp.json b/e2etests/testdata/stable/li2/elk/board.exp.json index dad2f653d..80332ab06 100644 --- a/e2etests/testdata/stable/li2/elk/board.exp.json +++ b/e2etests/testdata/stable/li2/elk/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 12, + "x": 57, "y": 238 }, - "width": 245, - "height": 76, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\n- [Overview](#overview) ok _this is all measured_\n\t- [Philosophy](#philosophy)\n\t- [Inline HTML](#html)\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 245, - "labelHeight": 76, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 78, + "x": 12, "y": 12 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 78, - "y": 414 + "x": 12, + "y": 362 }, "width": 113, "height": 126, @@ -149,11 +149,11 @@ "labelPercentage": 0, "route": [ { - "x": 134.5, + "x": 68.5, "y": 138 }, { - "x": 134.5, + "x": 68.5, "y": 238 } ], @@ -188,12 +188,12 @@ "labelPercentage": 0, "route": [ { - "x": 134.5, - "y": 314 + "x": 68.5, + "y": 262 }, { - "x": 134.5, - "y": 414 + "x": 68.5, + "y": 362 } ], "animated": false, diff --git a/e2etests/testdata/stable/li2/elk/sketch.exp.svg b/e2etests/testdata/stable/li2/elk/sketch.exp.svg index 6b418d9ac..6e3415cfc 100644 --- a/e2etests/testdata/stable/li2/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/li2/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="449" height="732" viewBox="-90 -90 449 732">
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/li3/dagre/board.exp.json b/e2etests/testdata/stable/li3/dagre/board.exp.json index b405619c1..bdae01f3e 100644 --- a/e2etests/testdata/stable/li3/dagre/board.exp.json +++ b/e2etests/testdata/stable/li3/dagre/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 0, + "x": 45, "y": 226 }, - "width": 347, - "height": 512, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n - [Automatic Escaping for Special Characters](#autoescape)\n- [Block Elements](#block)\n - [Paragraphs and Line Breaks](#p)\n - [Headers](#header)\n - [Blockquotes](#blockquote)\n - [Lists](#list)\n - [Code Blocks](#precode)\n - [Horizontal Rules](#hr)\n- [Span Elements](#span)\n - [Links](#link)\n - [Emphasis](#em)\n - [Code](#code)\n - [Images](#img)\n- [Miscellaneous](#misc)\n - [Backslash Escapes](#backslash)\n - [Automatic Links](#autolink)\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 347, - "labelHeight": 512, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 117, + "x": 0, "y": 0 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 117, - "y": 838 + "x": 0, + "y": 350 }, "width": 113, "height": 126, @@ -149,19 +149,19 @@ "labelPercentage": 0, "route": [ { - "x": 173.5, + "x": 56.5, "y": 126 }, { - "x": 173.5, + "x": 56.5, "y": 166 }, { - "x": 173.5, + "x": 56.5, "y": 186 }, { - "x": 173.5, + "x": 56.5, "y": 226 } ], @@ -197,20 +197,20 @@ "labelPercentage": 0, "route": [ { - "x": 173.5, - "y": 738 + "x": 56.5, + "y": 250 }, { - "x": 173.5, - "y": 778 + "x": 56.5, + "y": 290 }, { - "x": 173.5, - "y": 798 + "x": 56.5, + "y": 310 }, { - "x": 173.5, - "y": 838 + "x": 56.5, + "y": 350 } ], "isCurve": true, diff --git a/e2etests/testdata/stable/li3/dagre/sketch.exp.svg b/e2etests/testdata/stable/li3/dagre/sketch.exp.svg index eb5b87298..823f11cf2 100644 --- a/e2etests/testdata/stable/li3/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/li3/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="551" height="1168" viewBox="-102 -102 551 1168">ab - +

md

+
ab + ab - +

md

+
ab +

List items may consist of multiple paragraphs. Each subsequent -paragraph in a list item must be indented by either 4 spaces -or one tab:

-
    -
  1. -

    This is a list item with two paragraphs. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit. Aliquam hendrerit -mi posuere lectus.

    -

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet -vitae, risus. Donec sit amet nisl. Aliquam semper ipsum -sit amet velit.

    -
  2. -
  3. -

    Suspendisse id sem consectetuer libero luctus adipiscing.

    -
  4. -
-

It looks nice if you indent every line of the subsequent -paragraphs, but here again, Markdown will allow you to be -lazy:

-
    -
  • -

    This is a list item with two paragraphs.

    -
    This is the second paragraph in the list item. You're
    -
    -

    only required to indent the first line. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit.

    -
  • -
  • -

    Another item in the same list.

    -
  • -
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/li4/elk/board.exp.json b/e2etests/testdata/stable/li4/elk/board.exp.json index 93e3ba639..80332ab06 100644 --- a/e2etests/testdata/stable/li4/elk/board.exp.json +++ b/e2etests/testdata/stable/li4/elk/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 12, + "x": 57, "y": 238 }, - "width": 920, - "height": 376, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be indented by either 4 spaces\nor one tab:\n\n1. This is a list item with two paragraphs. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n mi posuere lectus.\n\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n sit amet velit.\n\n2. Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIt looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:\n\n- This is a list item with two paragraphs.\n\n This is the second paragraph in the list item. You're\n\n only required to indent the first line. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit.\n\n- Another item in the same list.\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 920, - "labelHeight": 376, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 415, + "x": 12, "y": 12 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 415, - "y": 714 + "x": 12, + "y": 362 }, "width": 113, "height": 126, @@ -149,11 +149,11 @@ "labelPercentage": 0, "route": [ { - "x": 472, + "x": 68.5, "y": 138 }, { - "x": 472, + "x": 68.5, "y": 238 } ], @@ -188,12 +188,12 @@ "labelPercentage": 0, "route": [ { - "x": 472, - "y": 614 + "x": 68.5, + "y": 262 }, { - "x": 472, - "y": 714 + "x": 68.5, + "y": 362 } ], "animated": false, diff --git a/e2etests/testdata/stable/li4/elk/sketch.exp.svg b/e2etests/testdata/stable/li4/elk/sketch.exp.svg index 1168eb8b2..6e3415cfc 100644 --- a/e2etests/testdata/stable/li4/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/li4/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="1124" height="1032" viewBox="-90 -90 1124 1032">

List items may consist of multiple paragraphs. Each subsequent -paragraph in a list item must be indented by either 4 spaces -or one tab:

-
    -
  1. -

    This is a list item with two paragraphs. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit. Aliquam hendrerit -mi posuere lectus.

    -

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet -vitae, risus. Donec sit amet nisl. Aliquam semper ipsum -sit amet velit.

    -
  2. -
  3. -

    Suspendisse id sem consectetuer libero luctus adipiscing.

    -
  4. -
-

It looks nice if you indent every line of the subsequent -paragraphs, but here again, Markdown will allow you to be -lazy:

-
    -
  • -

    This is a list item with two paragraphs.

    -
    This is the second paragraph in the list item. You're
    -
    -

    only required to indent the first line. Lorem ipsum dolor -sit amet, consectetuer adipiscing elit.

    -
  • -
  • -

    Another item in the same list.

    -
  • -
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/links/dagre/board.exp.json b/e2etests/testdata/stable/links/dagre/board.exp.json index ad73036b4..81d877183 100644 --- a/e2etests/testdata/stable/links/dagre/board.exp.json +++ b/e2etests/testdata/stable/links/dagre/board.exp.json @@ -4,7 +4,7 @@ "shapes": [ { "id": "x", - "type": "", + "type": "rectangle", "pos": { "x": 1, "y": 0 @@ -44,7 +44,7 @@ }, { "id": "y", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 226 diff --git a/e2etests/testdata/stable/links/dagre/sketch.exp.svg b/e2etests/testdata/stable/links/dagre/sketch.exp.svg index 01b4bf38b..d948b5fa0 100644 --- a/e2etests/testdata/stable/links/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/links/dagre/sketch.exp.svg @@ -77,7 +77,7 @@ knowing I can't make my satellite dish PAYMENTS! +

Markdown: Syntax

-
ab - +

md

+
ab +

Markdown: Syntax

-
ab - +

md

+
ab +

Every frustum longs to be a cone

-
    -
  • A continuing flow of paper is sufficient to continue the flow of paper
  • -
  • Please remain calm, it's no use both of us being hysterical at the same time
  • -
  • Visits always give pleasure: if not on arrival, then on the departure
  • -
-

Festivity Level 1: Your guests are chatting amiably with each other.

-
xy - +

hey

+
xy + \ No newline at end of file diff --git a/e2etests/testdata/stable/markdown/elk/board.exp.json b/e2etests/testdata/stable/markdown/elk/board.exp.json index c6464454f..4208359a7 100644 --- a/e2etests/testdata/stable/markdown/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown/elk/board.exp.json @@ -6,11 +6,11 @@ "id": "hey", "type": "text", "pos": { - "x": 12, + "x": 56, "y": 238 }, - "width": 531, - "height": 187, + "width": 25, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "# Every frustum longs to be a cone\n\n- A continuing flow of paper is sufficient to continue the flow of paper\n- Please remain calm, it's no use both of us being hysterical at the same time\n- Visits always give pleasure: if not on arrival, then on the departure\n\n*Festivity Level 1*: Your guests are chatting amiably with each other.", + "label": "hey", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 531, - "labelHeight": 187, + "labelWidth": 25, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "x", - "type": "", + "type": "rectangle", "pos": { - "x": 221, + "x": 12, "y": 12 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "y", - "type": "", + "type": "rectangle", "pos": { - "x": 220, - "y": 525 + "x": 12, + "y": 362 }, "width": 114, "height": 126, @@ -149,11 +149,11 @@ "labelPercentage": 0, "route": [ { - "x": 277.5, + "x": 69, "y": 138 }, { - "x": 277.5, + "x": 69, "y": 238 } ], @@ -188,12 +188,12 @@ "labelPercentage": 0, "route": [ { - "x": 277.5, - "y": 425 + "x": 69, + "y": 262 }, { - "x": 277.5, - "y": 525 + "x": 69, + "y": 362 } ], "animated": false, diff --git a/e2etests/testdata/stable/markdown/elk/sketch.exp.svg b/e2etests/testdata/stable/markdown/elk/sketch.exp.svg index 9f87d63de..5db1cda00 100644 --- a/e2etests/testdata/stable/markdown/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="735" height="843" viewBox="-90 -90 735 843">

Every frustum longs to be a cone

-
    -
  • A continuing flow of paper is sufficient to continue the flow of paper
  • -
  • Please remain calm, it's no use both of us being hysterical at the same time
  • -
  • Visits always give pleasure: if not on arrival, then on the departure
  • -
-

Festivity Level 1: Your guests are chatting amiably with each other.

-
xy - +

hey

+
xy + \ No newline at end of file diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json index 8ac374d25..ef95474c4 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json @@ -4,13 +4,13 @@ "shapes": [ { "id": "container", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 0 }, - "width": 312, - "height": 358, + "width": 141, + "height": 124, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -46,11 +46,11 @@ "id": "container.md", "type": "text", "pos": { - "x": 50, + "x": 69, "y": 50 }, - "width": 212, - "height": 258, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -68,7 +68,7 @@ "fields": null, "methods": null, "columns": null, - "label": "# a header\n\na line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n\nwalk into a bar.", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -76,8 +76,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 212, - "labelHeight": 258, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 2 }, @@ -85,10 +85,10 @@ "id": "no container", "type": "text", "pos": { - "x": 97, - "y": 458 + "x": 37, + "y": 224 }, - "width": 118, + "width": 86, "height": 24, "opacity": 1, "strokeDash": 0, @@ -107,7 +107,7 @@ "fields": null, "methods": null, "columns": null, - "label": "they did it in style", + "label": "no container", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -115,7 +115,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 118, + "labelWidth": 86, "labelHeight": 24, "zIndex": 0, "level": 1 @@ -148,20 +148,20 @@ "labelPercentage": 0, "route": [ { - "x": 156, - "y": 358 + "x": 80, + "y": 124 }, { - "x": 156, - "y": 398 + "x": 80, + "y": 164 }, { - "x": 156, - "y": 418 + "x": 80, + "y": 184 }, { - "x": 156, - "y": 458 + "x": 80, + "y": 224 } ], "isCurve": true, diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg index 9a9692643..f1225e1c5 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="516" height="686" viewBox="-102 -102 516 686">container

they did it in style

-

a header

-

a line of text and an

-
{
-	indented: "block",
-	of: "json",
-}
-
-

walk into a bar.

-
- +container

no container

+

md

+
+ \ No newline at end of file diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json index 8522f9433..813f43923 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json @@ -4,13 +4,13 @@ "shapes": [ { "id": "container", - "type": "", + "type": "rectangle", "pos": { "x": 12, "y": 12 }, - "width": 362, - "height": 408, + "width": 173, + "height": 174, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -49,8 +49,8 @@ "x": 87, "y": 87 }, - "width": 212, - "height": 258, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -68,7 +68,7 @@ "fields": null, "methods": null, "columns": null, - "label": "# a header\n\na line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n\nwalk into a bar.", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -76,8 +76,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 212, - "labelHeight": 258, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 2 }, @@ -85,10 +85,10 @@ "id": "no container", "type": "text", "pos": { - "x": 134, - "y": 520 + "x": 55, + "y": 286 }, - "width": 118, + "width": 86, "height": 24, "opacity": 1, "strokeDash": 0, @@ -107,7 +107,7 @@ "fields": null, "methods": null, "columns": null, - "label": "they did it in style", + "label": "no container", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -115,7 +115,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 118, + "labelWidth": 86, "labelHeight": 24, "zIndex": 0, "level": 1 @@ -148,12 +148,12 @@ "labelPercentage": 0, "route": [ { - "x": 193, - "y": 420 + "x": 98.5, + "y": 186 }, { - "x": 193, - "y": 520 + "x": 98.5, + "y": 286 } ], "animated": false, diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg index c67be9203..d129518c1 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="566" height="736" viewBox="-90 -90 566 736">container

they did it in style

-

a header

-

a line of text and an

-
{
-	indented: "block",
-	of: "json",
-}
-
-

walk into a bar.

-
- +container

no container

+

md

+
+ \ No newline at end of file diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json index 5376f8370..539f204b8 100644 --- a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json @@ -4,13 +4,13 @@ "shapes": [ { "id": "markdown", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 0 }, - "width": 559, - "height": 148, + "width": 123, + "height": 124, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -49,8 +49,8 @@ "x": 50, "y": 50 }, - "width": 459, - "height": 48, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -68,7 +68,7 @@ "fields": null, "methods": null, "columns": null, - "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -76,8 +76,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 459, - "labelHeight": 48, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 2 } diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg index 2a8197e7d..76cdf8fc5 100644 --- a/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="763" height="352" viewBox="-102 -102 763 352">markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
-sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
- +markdown

md

+
+ markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
-sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
- +markdown

md

+
+ markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
-sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
- +markdown

md

+
+ markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
-sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
- +markdown

md

+
+
{
-	fenced: "block",
-	of: "json",
-}
-
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json index 51ff40814..80332ab06 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 12, + "x": 57, "y": 238 }, - "width": 196, - "height": 111, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "```\n{\n\tfenced: \"block\",\n\tof: \"json\",\n}\n```", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 196, - "labelHeight": 111, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 53, + "x": 12, "y": 12 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 53, - "y": 449 + "x": 12, + "y": 362 }, "width": 113, "height": 126, @@ -149,11 +149,11 @@ "labelPercentage": 0, "route": [ { - "x": 110, + "x": 68.5, "y": 138 }, { - "x": 110, + "x": 68.5, "y": 238 } ], @@ -188,12 +188,12 @@ "labelPercentage": 0, "route": [ { - "x": 110, - "y": 349 + "x": 68.5, + "y": 262 }, { - "x": 110, - "y": 449 + "x": 68.5, + "y": 362 } ], "animated": false, diff --git a/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg b/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg index d2dfa9208..6e3415cfc 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="400" height="767" viewBox="-90 -90 400 767">
{
-	fenced: "block",
-	of: "json",
-}
-
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json index 6f3d1a97c..bdae01f3e 100644 --- a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 0, + "x": 45, "y": 226 }, - "width": 212, - "height": 151, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "a line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 212, - "labelHeight": 151, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 50, + "x": 0, "y": 0 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 50, - "y": 477 + "x": 0, + "y": 350 }, "width": 113, "height": 126, @@ -149,19 +149,19 @@ "labelPercentage": 0, "route": [ { - "x": 106, + "x": 56.5, "y": 126 }, { - "x": 106, + "x": 56.5, "y": 166 }, { - "x": 106, + "x": 56.5, "y": 186 }, { - "x": 106, + "x": 56.5, "y": 226 } ], @@ -197,20 +197,20 @@ "labelPercentage": 0, "route": [ { - "x": 106, - "y": 377 + "x": 56.5, + "y": 250 }, { - "x": 106, - "y": 417 + "x": 56.5, + "y": 290 }, { - "x": 106, - "y": 437 + "x": 56.5, + "y": 310 }, { - "x": 106, - "y": 477 + "x": 56.5, + "y": 350 } ], "isCurve": true, diff --git a/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg index 77c605302..823f11cf2 100644 --- a/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="416" height="807" viewBox="-102 -102 416 807">

a line of text and an

-
{
-	indented: "block",
-	of: "json",
-}
-
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json index 353e5a4d6..80332ab06 100644 --- a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 12, + "x": 57, "y": 238 }, - "width": 212, - "height": 151, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "a line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 212, - "labelHeight": 151, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 61, + "x": 12, "y": 12 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 61, - "y": 489 + "x": 12, + "y": 362 }, "width": 113, "height": 126, @@ -149,11 +149,11 @@ "labelPercentage": 0, "route": [ { - "x": 118, + "x": 68.5, "y": 138 }, { - "x": 118, + "x": 68.5, "y": 238 } ], @@ -188,12 +188,12 @@ "labelPercentage": 0, "route": [ { - "x": 118, - "y": 389 + "x": 68.5, + "y": 262 }, { - "x": 118, - "y": 489 + "x": 68.5, + "y": 362 } ], "animated": false, diff --git a/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg b/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg index 0128d015c..6e3415cfc 100644 --- a/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="416" height="807" viewBox="-90 -90 416 807">

a line of text and an

-
{
-	indented: "block",
-	of: "json",
-}
-
-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json index afb3938c0..bdae01f3e 100644 --- a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json @@ -6,10 +6,10 @@ "id": "md", "type": "text", "pos": { - "x": 34, + "x": 45, "y": 226 }, - "width": 46, + "width": 23, "height": 24, "opacity": 1, "strokeDash": 0, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "`code`", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,14 +36,14 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 46, + "labelWidth": 23, "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 0 @@ -83,7 +83,7 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 350 diff --git a/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg index faf0361bf..823f11cf2 100644 --- a/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg @@ -796,8 +796,8 @@ width="317" height="680" viewBox="-102 -102 317 680">

code

-
ab +

md

+
ab \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json index e92f3beed..80332ab06 100644 --- a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json @@ -6,10 +6,10 @@ "id": "md", "type": "text", "pos": { - "x": 45, + "x": 57, "y": 238 }, - "width": 46, + "width": 23, "height": 24, "opacity": 1, "strokeDash": 0, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "`code`", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,14 +36,14 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 46, + "labelWidth": 23, "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { "x": 12, "y": 12 @@ -83,7 +83,7 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { "x": 12, "y": 362 diff --git a/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg b/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg index 87ae9e984..6e3415cfc 100644 --- a/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg @@ -796,8 +796,8 @@ width="317" height="680" viewBox="-90 -90 317 680">

code

-
ab +

md

+
ab \ No newline at end of file diff --git a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json index c00ff06bf..381276777 100644 --- a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json +++ b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json @@ -4,7 +4,7 @@ "shapes": [ { "id": "hey", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 0 diff --git a/e2etests/testdata/stable/multiline_text/dagre/sketch.exp.svg b/e2etests/testdata/stable/multiline_text/dagre/sketch.exp.svg index ef5e0e5d8..280791570 100644 --- a/e2etests/testdata/stable/multiline_text/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/multiline_text/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="406" height="362" viewBox="-102 -102 406 362">rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root + + + + + + + +

A paragraph is simply one or more consecutive lines of text, separated -by one or more blank lines. (A blank line is any line that looks like a -blank line -- a line containing nothing but spaces or tabs is considered -blank.) Normal paragraphs should not be indented with spaces or tabs.

-
ab - +

md

+
ab +

A paragraph is simply one or more consecutive lines of text, separated -by one or more blank lines. (A blank line is any line that looks like a -blank line -- a line containing nothing but spaces or tabs is considered -blank.) Normal paragraphs should not be indented with spaces or tabs.

-
ab - +

md

+
ab +

Here is an example of AppleScript:

-
tell application "Foo"
-    beep
-end tell
-
-

A code block continues until it reaches a line that is not indented -(or the end of the article).

-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/pre/elk/board.exp.json b/e2etests/testdata/stable/pre/elk/board.exp.json index 42d05dd97..80332ab06 100644 --- a/e2etests/testdata/stable/pre/elk/board.exp.json +++ b/e2etests/testdata/stable/pre/elk/board.exp.json @@ -6,11 +6,11 @@ "id": "md", "type": "text", "pos": { - "x": 12, + "x": 57, "y": 238 }, - "width": 602, - "height": 170, + "width": 23, + "height": 24, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -28,7 +28,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\nHere is an example of AppleScript:\n\n tell application \"Foo\"\n beep\n end tell\n\nA code block continues until it reaches a line that is not indented\n(or the end of the article).\n", + "label": "md", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -36,16 +36,16 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 602, - "labelHeight": 170, + "labelWidth": 23, + "labelHeight": 24, "zIndex": 0, "level": 1 }, { "id": "a", - "type": "", + "type": "rectangle", "pos": { - "x": 256, + "x": 12, "y": 12 }, "width": 113, @@ -83,10 +83,10 @@ }, { "id": "b", - "type": "", + "type": "rectangle", "pos": { - "x": 256, - "y": 508 + "x": 12, + "y": 362 }, "width": 113, "height": 126, @@ -149,11 +149,11 @@ "labelPercentage": 0, "route": [ { - "x": 313, + "x": 68.5, "y": 138 }, { - "x": 313, + "x": 68.5, "y": 238 } ], @@ -188,12 +188,12 @@ "labelPercentage": 0, "route": [ { - "x": 313, - "y": 408 + "x": 68.5, + "y": 262 }, { - "x": 313, - "y": 508 + "x": 68.5, + "y": 362 } ], "animated": false, diff --git a/e2etests/testdata/stable/pre/elk/sketch.exp.svg b/e2etests/testdata/stable/pre/elk/sketch.exp.svg index ede9ad5de..6e3415cfc 100644 --- a/e2etests/testdata/stable/pre/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/pre/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="806" height="826" viewBox="-90 -90 806 826">

Here is an example of AppleScript:

-
tell application "Foo"
-    beep
-end tell
-
-

A code block continues until it reaches a line that is not indented -(or the end of the article).

-
ab - +

md

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json index 2b7fb17aa..2934816a9 100644 --- a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json +++ b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json @@ -4,7 +4,7 @@ "shapes": [ { "id": "x", - "type": "", + "type": "rectangle", "pos": { "x": 0, "y": 0 @@ -44,7 +44,7 @@ }, { "id": "y", - "type": "", + "type": "rectangle", "pos": { "x": 126, "y": 226 @@ -84,7 +84,7 @@ }, { "id": "z", - "type": "", + "type": "rectangle", "pos": { "x": 253, "y": 0 diff --git a/e2etests/testdata/stable/self-referencing/dagre/sketch.exp.svg b/e2etests/testdata/stable/self-referencing/dagre/sketch.exp.svg index 9fc29dbf0..bd7d2e548 100644 --- a/e2etests/testdata/stable/self-referencing/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/self-referencing/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="647" height="556" viewBox="-102 -102 647 556">containerscloudtall cylinderclass- num int- timeout @@ -61,11 +808,18 @@ width="2482" height="2672" viewBox="-102 -102 2482 2672">containerscloudtall cylinderclass- num int- timeout @@ -61,11 +808,18 @@ width="2622" height="2644" viewBox="-90 -90 2622 2644"> \ No newline at end of file diff --git a/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json b/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json index dcd887dd3..7989809d1 100644 --- a/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json +++ b/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -45,5 +46,8 @@ "neutralAccentColor": "#676C7E" } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/code_leading_trailing_newlines/dagre/board.exp.json b/e2etests/testdata/regression/code_leading_trailing_newlines/dagre/board.exp.json index 76e98b3ff..415b1eeb0 100644 --- a/e2etests/testdata/regression/code_leading_trailing_newlines/dagre/board.exp.json +++ b/e2etests/testdata/regression/code_leading_trailing_newlines/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -120,5 +121,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/code_leading_trailing_newlines/elk/board.exp.json b/e2etests/testdata/regression/code_leading_trailing_newlines/elk/board.exp.json index e78e3b9d2..2727081e4 100644 --- a/e2etests/testdata/regression/code_leading_trailing_newlines/elk/board.exp.json +++ b/e2etests/testdata/regression/code_leading_trailing_newlines/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -120,5 +121,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/dagre_broken_arrowhead/dagre/board.exp.json b/e2etests/testdata/regression/dagre_broken_arrowhead/dagre/board.exp.json index fc16fe6f9..19568aff2 100644 --- a/e2etests/testdata/regression/dagre_broken_arrowhead/dagre/board.exp.json +++ b/e2etests/testdata/regression/dagre_broken_arrowhead/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -388,5 +389,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json b/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json index b1cb0d7c2..2b9287bfe 100644 --- a/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json +++ b/e2etests/testdata/regression/dagre_broken_arrowhead/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -377,5 +378,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json index e18cc0d32..b63387d1c 100644 --- a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -436,5 +437,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/elk/board.exp.json b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/board.exp.json index 62acfa097..588b6a03f 100644 --- a/e2etests/testdata/regression/dagre_edge_label_spacing/elk/board.exp.json +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -400,5 +401,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json b/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json index 4809d833b..c6318c709 100644 --- a/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json +++ b/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -428,5 +429,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json b/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json index c52bda828..1dfce7f33 100644 --- a/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json +++ b/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -417,5 +418,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_alignment/dagre/board.exp.json b/e2etests/testdata/regression/elk_alignment/dagre/board.exp.json index b89cea9d4..e1d120f4a 100644 --- a/e2etests/testdata/regression/elk_alignment/dagre/board.exp.json +++ b/e2etests/testdata/regression/elk_alignment/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -948,5 +949,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_alignment/elk/board.exp.json b/e2etests/testdata/regression/elk_alignment/elk/board.exp.json index f6e90e546..762eff843 100644 --- a/e2etests/testdata/regression/elk_alignment/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_alignment/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -876,5 +877,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json b/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json index 2b81df1ac..ab57a4af1 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -103,5 +104,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json index 2a47be779..754b0c6f6 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -103,5 +104,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json index 4db9f807e..b5d6460d7 100644 --- a/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json +++ b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -208,5 +209,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json b/e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json index 301aebfe1..a2d06b8a5 100644 --- a/e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -171,5 +172,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_order/dagre/board.exp.json b/e2etests/testdata/regression/elk_order/dagre/board.exp.json index 04269e594..30cb37b0f 100644 --- a/e2etests/testdata/regression/elk_order/dagre/board.exp.json +++ b/e2etests/testdata/regression/elk_order/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -671,5 +672,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/elk_order/elk/board.exp.json b/e2etests/testdata/regression/elk_order/elk/board.exp.json index 2c9dc79b4..94dbcde40 100644 --- a/e2etests/testdata/regression/elk_order/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_order/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -635,5 +636,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json b/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json index 63644901e..e552e75e3 100644 --- a/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json +++ b/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/empty_sequence/elk/board.exp.json b/e2etests/testdata/regression/empty_sequence/elk/board.exp.json index 3fd0b10ce..beab1a1ed 100644 --- a/e2etests/testdata/regression/empty_sequence/elk/board.exp.json +++ b/e2etests/testdata/regression/empty_sequence/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/md_h1_li_li/dagre/board.exp.json b/e2etests/testdata/regression/md_h1_li_li/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/regression/md_h1_li_li/dagre/board.exp.json +++ b/e2etests/testdata/regression/md_h1_li_li/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/md_h1_li_li/elk/board.exp.json b/e2etests/testdata/regression/md_h1_li_li/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/regression/md_h1_li_li/elk/board.exp.json +++ b/e2etests/testdata/regression/md_h1_li_li/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/no-lexer/dagre/board.exp.json b/e2etests/testdata/regression/no-lexer/dagre/board.exp.json index 3523e0d7e..eda9b7ed0 100644 --- a/e2etests/testdata/regression/no-lexer/dagre/board.exp.json +++ b/e2etests/testdata/regression/no-lexer/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/no-lexer/elk/board.exp.json b/e2etests/testdata/regression/no-lexer/elk/board.exp.json index 5b1bd0c73..d951451e6 100644 --- a/e2etests/testdata/regression/no-lexer/elk/board.exp.json +++ b/e2etests/testdata/regression/no-lexer/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json b/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json index c35935f77..ac453a7b7 100644 --- a/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json +++ b/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -255,5 +256,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/only_header_class_table/elk/board.exp.json b/e2etests/testdata/regression/only_header_class_table/elk/board.exp.json index 31a428a6c..d3c7c37ef 100644 --- a/e2etests/testdata/regression/only_header_class_table/elk/board.exp.json +++ b/e2etests/testdata/regression/only_header_class_table/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -237,5 +238,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/opacity-on-label/dagre/board.exp.json b/e2etests/testdata/regression/opacity-on-label/dagre/board.exp.json index 29da4e673..2c37a06c1 100644 --- a/e2etests/testdata/regression/opacity-on-label/dagre/board.exp.json +++ b/e2etests/testdata/regression/opacity-on-label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -171,5 +172,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/opacity-on-label/elk/board.exp.json b/e2etests/testdata/regression/opacity-on-label/elk/board.exp.json index 6a885697a..10c92c6f5 100644 --- a/e2etests/testdata/regression/opacity-on-label/elk/board.exp.json +++ b/e2etests/testdata/regression/opacity-on-label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -162,5 +163,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/overlapping-edge-label/dagre/board.exp.json b/e2etests/testdata/regression/overlapping-edge-label/dagre/board.exp.json index 0f363f7a9..03e6a568a 100644 --- a/e2etests/testdata/regression/overlapping-edge-label/dagre/board.exp.json +++ b/e2etests/testdata/regression/overlapping-edge-label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -596,5 +597,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/overlapping-edge-label/elk/board.exp.json b/e2etests/testdata/regression/overlapping-edge-label/elk/board.exp.json index 55b8096e3..22ff09184 100644 --- a/e2etests/testdata/regression/overlapping-edge-label/elk/board.exp.json +++ b/e2etests/testdata/regression/overlapping-edge-label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -584,5 +585,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json b/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json index b0147081e..15ad7b8be 100644 --- a/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json +++ b/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -54,5 +55,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/query_param_escape/elk/board.exp.json b/e2etests/testdata/regression/query_param_escape/elk/board.exp.json index c73ea8993..96f4dfec1 100644 --- a/e2etests/testdata/regression/query_param_escape/elk/board.exp.json +++ b/e2etests/testdata/regression/query_param_escape/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -54,5 +55,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json index f1b5a732a..22688e3d4 100644 --- a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -526,5 +527,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json index 273695734..01e08934f 100644 --- a/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -517,5 +518,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json index b9fc705da..677699b7a 100644 --- a/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -162,5 +163,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json index b9fc705da..677699b7a 100644 --- a/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -162,5 +163,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json index 821108802..ed9eab89e 100644 --- a/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -216,5 +217,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json index 821108802..ed9eab89e 100644 --- a/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -216,5 +217,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json b/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json index 019dcf923..66a90f66d 100644 --- a/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json +++ b/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "neutralAccentColor": "#676C7E" } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json b/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json index 6b0307c7c..0eeb1cebf 100644 --- a/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json +++ b/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "neutralAccentColor": "#676C7E" } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json index ff6ae826c..60eac7648 100644 --- a/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json +++ b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -396,5 +397,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json b/e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json index 424b26d84..53a84f9dd 100644 --- a/e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json +++ b/e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -378,5 +379,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json b/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json index f1989ffca..bd2292653 100644 --- a/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json +++ b/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -220,5 +221,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/1_to_2/elk/board.exp.json b/e2etests/testdata/sanity/1_to_2/elk/board.exp.json index 9d6fb4521..85d19f8f7 100644 --- a/e2etests/testdata/sanity/1_to_2/elk/board.exp.json +++ b/e2etests/testdata/sanity/1_to_2/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -210,5 +211,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/basic/dagre/board.exp.json b/e2etests/testdata/sanity/basic/dagre/board.exp.json index bfe80ce58..916be1db0 100644 --- a/e2etests/testdata/sanity/basic/dagre/board.exp.json +++ b/e2etests/testdata/sanity/basic/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/basic/elk/board.exp.json b/e2etests/testdata/sanity/basic/elk/board.exp.json index 6436ed18d..1983fc784 100644 --- a/e2etests/testdata/sanity/basic/elk/board.exp.json +++ b/e2etests/testdata/sanity/basic/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json b/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json index 0d7169bfd..5e30e4a01 100644 --- a/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json +++ b/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -224,5 +225,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/child_to_child/elk/board.exp.json b/e2etests/testdata/sanity/child_to_child/elk/board.exp.json index 09fa35ea3..161d2b11d 100644 --- a/e2etests/testdata/sanity/child_to_child/elk/board.exp.json +++ b/e2etests/testdata/sanity/child_to_child/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -203,5 +204,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/connection_label/dagre/board.exp.json b/e2etests/testdata/sanity/connection_label/dagre/board.exp.json index 41ab1cfdb..dd7d4047c 100644 --- a/e2etests/testdata/sanity/connection_label/dagre/board.exp.json +++ b/e2etests/testdata/sanity/connection_label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/connection_label/elk/board.exp.json b/e2etests/testdata/sanity/connection_label/elk/board.exp.json index d6fe6c684..d863229fd 100644 --- a/e2etests/testdata/sanity/connection_label/elk/board.exp.json +++ b/e2etests/testdata/sanity/connection_label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/empty/dagre/board.exp.json b/e2etests/testdata/sanity/empty/dagre/board.exp.json index 57a381554..0c4d27d14 100644 --- a/e2etests/testdata/sanity/empty/dagre/board.exp.json +++ b/e2etests/testdata/sanity/empty/dagre/board.exp.json @@ -1,6 +1,10 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/sanity/empty/elk/board.exp.json b/e2etests/testdata/sanity/empty/elk/board.exp.json index 57a381554..0c4d27d14 100644 --- a/e2etests/testdata/sanity/empty/elk/board.exp.json +++ b/e2etests/testdata/sanity/empty/elk/board.exp.json @@ -1,6 +1,10 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/all_shapes/dagre/board.exp.json b/e2etests/testdata/stable/all_shapes/dagre/board.exp.json index 97f3baf20..61a09a4e3 100644 --- a/e2etests/testdata/stable/all_shapes/dagre/board.exp.json +++ b/e2etests/testdata/stable/all_shapes/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1212,5 +1213,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/all_shapes/elk/board.exp.json b/e2etests/testdata/stable/all_shapes/elk/board.exp.json index a05349cb8..b544c692d 100644 --- a/e2etests/testdata/stable/all_shapes/elk/board.exp.json +++ b/e2etests/testdata/stable/all_shapes/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1113,5 +1114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json b/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json index a02b7be57..35248416e 100644 --- a/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1212,5 +1213,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json b/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json index 5a2cd296e..f3568d463 100644 --- a/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1113,5 +1114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json b/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json index a02b7be57..35248416e 100644 --- a/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1212,5 +1213,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json b/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json index 5a2cd296e..f3568d463 100644 --- a/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1113,5 +1114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/animated/dagre/board.exp.json b/e2etests/testdata/stable/animated/dagre/board.exp.json index 54190534c..3f324de5e 100644 --- a/e2etests/testdata/stable/animated/dagre/board.exp.json +++ b/e2etests/testdata/stable/animated/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -908,5 +909,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/animated/elk/board.exp.json b/e2etests/testdata/stable/animated/elk/board.exp.json index c460dca33..5ad929580 100644 --- a/e2etests/testdata/stable/animated/elk/board.exp.json +++ b/e2etests/testdata/stable/animated/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -860,5 +861,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json b/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json index 2f9337bb5..60b2797ce 100644 --- a/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -451,5 +452,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json b/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json index b7afdc65f..fa20c256d 100644 --- a/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -390,5 +391,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json b/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json index 05be129dc..1a4bfc32b 100644 --- a/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json b/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json index 2d9c9c8f9..56a6ae4a1 100644 --- a/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/binary_tree/dagre/board.exp.json b/e2etests/testdata/stable/binary_tree/dagre/board.exp.json index 8e8458ee6..fc2ef080a 100644 --- a/e2etests/testdata/stable/binary_tree/dagre/board.exp.json +++ b/e2etests/testdata/stable/binary_tree/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1276,5 +1277,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/binary_tree/elk/board.exp.json b/e2etests/testdata/stable/binary_tree/elk/board.exp.json index edae9a020..ee66e16a2 100644 --- a/e2etests/testdata/stable/binary_tree/elk/board.exp.json +++ b/e2etests/testdata/stable/binary_tree/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1206,5 +1207,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/border-radius/dagre/board.exp.json b/e2etests/testdata/stable/border-radius/dagre/board.exp.json index 1b10e354e..b3bb6c731 100644 --- a/e2etests/testdata/stable/border-radius/dagre/board.exp.json +++ b/e2etests/testdata/stable/border-radius/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -83,5 +84,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/border-radius/elk/board.exp.json b/e2etests/testdata/stable/border-radius/elk/board.exp.json index 48a1e7558..548b6920c 100644 --- a/e2etests/testdata/stable/border-radius/elk/board.exp.json +++ b/e2etests/testdata/stable/border-radius/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -83,5 +84,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/chaos1/dagre/board.exp.json b/e2etests/testdata/stable/chaos1/dagre/board.exp.json index c4aa2c236..67b22e432 100644 --- a/e2etests/testdata/stable/chaos1/dagre/board.exp.json +++ b/e2etests/testdata/stable/chaos1/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -300,5 +301,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/chaos1/elk/board.exp.json b/e2etests/testdata/stable/chaos1/elk/board.exp.json index 32bffa54e..f36cc966c 100644 --- a/e2etests/testdata/stable/chaos1/elk/board.exp.json +++ b/e2etests/testdata/stable/chaos1/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -282,5 +283,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/chaos2/dagre/board.exp.json b/e2etests/testdata/stable/chaos2/dagre/board.exp.json index 0dc37d742..49eb4037f 100644 --- a/e2etests/testdata/stable/chaos2/dagre/board.exp.json +++ b/e2etests/testdata/stable/chaos2/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1231,5 +1232,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/chaos2/elk/board.exp.json b/e2etests/testdata/stable/chaos2/elk/board.exp.json index 9a58a20cc..1894d8657 100644 --- a/e2etests/testdata/stable/chaos2/elk/board.exp.json +++ b/e2etests/testdata/stable/chaos2/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1134,5 +1135,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json index 6404a9b86..602e988ae 100644 --- a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -371,5 +372,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json b/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json index d19f7a4d8..942b6f15a 100644 --- a/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json +++ b/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -289,5 +290,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/circle_arrowhead/dagre/board.exp.json b/e2etests/testdata/stable/circle_arrowhead/dagre/board.exp.json index 834dde685..6631e510b 100644 --- a/e2etests/testdata/stable/circle_arrowhead/dagre/board.exp.json +++ b/e2etests/testdata/stable/circle_arrowhead/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -260,5 +261,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/circle_arrowhead/elk/board.exp.json b/e2etests/testdata/stable/circle_arrowhead/elk/board.exp.json index 7bd3342e9..319ce35e1 100644 --- a/e2etests/testdata/stable/circle_arrowhead/elk/board.exp.json +++ b/e2etests/testdata/stable/circle_arrowhead/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -242,5 +243,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json b/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json index 2c67e2181..8edc1c9d8 100644 --- a/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json +++ b/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -316,5 +317,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/circular_dependency/elk/board.exp.json b/e2etests/testdata/stable/circular_dependency/elk/board.exp.json index 98feb0c0c..f32c59517 100644 --- a/e2etests/testdata/stable/circular_dependency/elk/board.exp.json +++ b/e2etests/testdata/stable/circular_dependency/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -280,5 +281,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/class/dagre/board.exp.json b/e2etests/testdata/stable/class/dagre/board.exp.json index ada2bfc60..2723662c5 100644 --- a/e2etests/testdata/stable/class/dagre/board.exp.json +++ b/e2etests/testdata/stable/class/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -77,5 +78,8 @@ "neutralAccentColor": "#676C7E" } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/class/elk/board.exp.json b/e2etests/testdata/stable/class/elk/board.exp.json index 438953ee7..af79e723c 100644 --- a/e2etests/testdata/stable/class/elk/board.exp.json +++ b/e2etests/testdata/stable/class/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -77,5 +78,8 @@ "neutralAccentColor": "#676C7E" } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/code_snippet/dagre/board.exp.json b/e2etests/testdata/stable/code_snippet/dagre/board.exp.json index b4947b21e..b8d35c729 100644 --- a/e2etests/testdata/stable/code_snippet/dagre/board.exp.json +++ b/e2etests/testdata/stable/code_snippet/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/code_snippet/elk/board.exp.json b/e2etests/testdata/stable/code_snippet/elk/board.exp.json index 82dbf2ea8..c5fef80e3 100644 --- a/e2etests/testdata/stable/code_snippet/elk/board.exp.json +++ b/e2etests/testdata/stable/code_snippet/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/connected_container/dagre/board.exp.json b/e2etests/testdata/stable/connected_container/dagre/board.exp.json index bfb88a5d4..cd70e20c9 100644 --- a/e2etests/testdata/stable/connected_container/dagre/board.exp.json +++ b/e2etests/testdata/stable/connected_container/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -416,5 +417,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/connected_container/elk/board.exp.json b/e2etests/testdata/stable/connected_container/elk/board.exp.json index 5bba23384..ca87dd8fe 100644 --- a/e2etests/testdata/stable/connected_container/elk/board.exp.json +++ b/e2etests/testdata/stable/connected_container/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -362,5 +363,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/constant_near_stress/dagre/board.exp.json b/e2etests/testdata/stable/constant_near_stress/dagre/board.exp.json index cb631d590..e4c914df7 100644 --- a/e2etests/testdata/stable/constant_near_stress/dagre/board.exp.json +++ b/e2etests/testdata/stable/constant_near_stress/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -452,5 +453,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/constant_near_stress/elk/board.exp.json b/e2etests/testdata/stable/constant_near_stress/elk/board.exp.json index 8c19dd34b..931187387 100644 --- a/e2etests/testdata/stable/constant_near_stress/elk/board.exp.json +++ b/e2etests/testdata/stable/constant_near_stress/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -443,5 +444,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/constant_near_title/dagre/board.exp.json b/e2etests/testdata/stable/constant_near_title/dagre/board.exp.json index 2e7100d8a..2a98aaeaa 100644 --- a/e2etests/testdata/stable/constant_near_title/dagre/board.exp.json +++ b/e2etests/testdata/stable/constant_near_title/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -496,5 +497,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/constant_near_title/elk/board.exp.json b/e2etests/testdata/stable/constant_near_title/elk/board.exp.json index 164571833..d4777805a 100644 --- a/e2etests/testdata/stable/constant_near_title/elk/board.exp.json +++ b/e2etests/testdata/stable/constant_near_title/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -455,5 +456,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/container_edges/dagre/board.exp.json b/e2etests/testdata/stable/container_edges/dagre/board.exp.json index dbd00d8b1..61537365f 100644 --- a/e2etests/testdata/stable/container_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/container_edges/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -615,5 +616,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/container_edges/elk/board.exp.json b/e2etests/testdata/stable/container_edges/elk/board.exp.json index 37be8bc83..fa806d02e 100644 --- a/e2etests/testdata/stable/container_edges/elk/board.exp.json +++ b/e2etests/testdata/stable/container_edges/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -590,5 +591,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json b/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json index f888b903a..5f6e964d6 100644 --- a/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json +++ b/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -564,5 +565,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/crow_foot_arrowhead/elk/board.exp.json b/e2etests/testdata/stable/crow_foot_arrowhead/elk/board.exp.json index 875e81938..a452e91d1 100644 --- a/e2etests/testdata/stable/crow_foot_arrowhead/elk/board.exp.json +++ b/e2etests/testdata/stable/crow_foot_arrowhead/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -527,5 +528,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/dense/dagre/board.exp.json b/e2etests/testdata/stable/dense/dagre/board.exp.json index 72ebecd6f..79ba3c764 100644 --- a/e2etests/testdata/stable/dense/dagre/board.exp.json +++ b/e2etests/testdata/stable/dense/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1968,5 +1969,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/dense/elk/board.exp.json b/e2etests/testdata/stable/dense/elk/board.exp.json index 397eff492..b490c0024 100644 --- a/e2etests/testdata/stable/dense/elk/board.exp.json +++ b/e2etests/testdata/stable/dense/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1772,5 +1773,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json b/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json index 0cd930c75..f9c2c5d9f 100644 --- a/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json +++ b/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1730,5 +1731,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json b/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json index 89b278577..47836714b 100644 --- a/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json +++ b/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1634,5 +1635,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/direction/dagre/board.exp.json b/e2etests/testdata/stable/direction/dagre/board.exp.json index 400037184..66982db66 100644 --- a/e2etests/testdata/stable/direction/dagre/board.exp.json +++ b/e2etests/testdata/stable/direction/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1162,5 +1163,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/direction/elk/board.exp.json b/e2etests/testdata/stable/direction/elk/board.exp.json index 51999a6e1..36f6fbd02 100644 --- a/e2etests/testdata/stable/direction/elk/board.exp.json +++ b/e2etests/testdata/stable/direction/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1072,5 +1073,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/font_colors/dagre/board.exp.json b/e2etests/testdata/stable/font_colors/dagre/board.exp.json index e97910b6e..9752a0099 100644 --- a/e2etests/testdata/stable/font_colors/dagre/board.exp.json +++ b/e2etests/testdata/stable/font_colors/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/font_colors/elk/board.exp.json b/e2etests/testdata/stable/font_colors/elk/board.exp.json index a5fc0a67b..f5617e371 100644 --- a/e2etests/testdata/stable/font_colors/elk/board.exp.json +++ b/e2etests/testdata/stable/font_colors/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/font_sizes/dagre/board.exp.json b/e2etests/testdata/stable/font_sizes/dagre/board.exp.json index 2f991d687..c6527ee2e 100644 --- a/e2etests/testdata/stable/font_sizes/dagre/board.exp.json +++ b/e2etests/testdata/stable/font_sizes/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -629,5 +630,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/font_sizes/elk/board.exp.json b/e2etests/testdata/stable/font_sizes/elk/board.exp.json index 9a3d1ae90..c9ab8ccd6 100644 --- a/e2etests/testdata/stable/font_sizes/elk/board.exp.json +++ b/e2etests/testdata/stable/font_sizes/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -602,5 +603,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json b/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json +++ b/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json +++ b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/hr/dagre/board.exp.json b/e2etests/testdata/stable/hr/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/hr/dagre/board.exp.json +++ b/e2etests/testdata/stable/hr/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/hr/elk/board.exp.json b/e2etests/testdata/stable/hr/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/hr/elk/board.exp.json +++ b/e2etests/testdata/stable/hr/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/icon-label/dagre/board.exp.json b/e2etests/testdata/stable/icon-label/dagre/board.exp.json index bb215f1b9..8092ead34 100644 --- a/e2etests/testdata/stable/icon-label/dagre/board.exp.json +++ b/e2etests/testdata/stable/icon-label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -54,5 +55,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/icon-label/elk/board.exp.json b/e2etests/testdata/stable/icon-label/elk/board.exp.json index 0ff31a1ea..23ac4e165 100644 --- a/e2etests/testdata/stable/icon-label/elk/board.exp.json +++ b/e2etests/testdata/stable/icon-label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -54,5 +55,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/images/dagre/board.exp.json b/e2etests/testdata/stable/images/dagre/board.exp.json index 27fa73e64..6d7b18e42 100644 --- a/e2etests/testdata/stable/images/dagre/board.exp.json +++ b/e2etests/testdata/stable/images/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -154,5 +155,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/images/elk/board.exp.json b/e2etests/testdata/stable/images/elk/board.exp.json index 7594c85d2..56df7d02c 100644 --- a/e2etests/testdata/stable/images/elk/board.exp.json +++ b/e2etests/testdata/stable/images/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -145,5 +146,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/investigate/dagre/board.exp.json b/e2etests/testdata/stable/investigate/dagre/board.exp.json index 4bc80bb52..0e8726e71 100644 --- a/e2etests/testdata/stable/investigate/dagre/board.exp.json +++ b/e2etests/testdata/stable/investigate/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -3246,5 +3247,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/investigate/elk/board.exp.json b/e2etests/testdata/stable/investigate/elk/board.exp.json index ebee05a63..3406a3237 100644 --- a/e2etests/testdata/stable/investigate/elk/board.exp.json +++ b/e2etests/testdata/stable/investigate/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2400,5 +2401,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/large_arch/dagre/board.exp.json b/e2etests/testdata/stable/large_arch/dagre/board.exp.json index a9e93d188..fd31093d9 100644 --- a/e2etests/testdata/stable/large_arch/dagre/board.exp.json +++ b/e2etests/testdata/stable/large_arch/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2632,5 +2633,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/large_arch/elk/board.exp.json b/e2etests/testdata/stable/large_arch/elk/board.exp.json index 31c512aed..5b1f95e4a 100644 --- a/e2etests/testdata/stable/large_arch/elk/board.exp.json +++ b/e2etests/testdata/stable/large_arch/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2145,5 +2146,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/latex/dagre/board.exp.json b/e2etests/testdata/stable/latex/dagre/board.exp.json index 7ac08fb00..58515b144 100644 --- a/e2etests/testdata/stable/latex/dagre/board.exp.json +++ b/e2etests/testdata/stable/latex/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -529,5 +530,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/latex/elk/board.exp.json b/e2etests/testdata/stable/latex/elk/board.exp.json index 14be2fd2d..e3cf521a7 100644 --- a/e2etests/testdata/stable/latex/elk/board.exp.json +++ b/e2etests/testdata/stable/latex/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -499,5 +500,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li1/dagre/board.exp.json b/e2etests/testdata/stable/li1/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/li1/dagre/board.exp.json +++ b/e2etests/testdata/stable/li1/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li1/elk/board.exp.json b/e2etests/testdata/stable/li1/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/li1/elk/board.exp.json +++ b/e2etests/testdata/stable/li1/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li2/dagre/board.exp.json b/e2etests/testdata/stable/li2/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/li2/dagre/board.exp.json +++ b/e2etests/testdata/stable/li2/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li2/elk/board.exp.json b/e2etests/testdata/stable/li2/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/li2/elk/board.exp.json +++ b/e2etests/testdata/stable/li2/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li3/dagre/board.exp.json b/e2etests/testdata/stable/li3/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/li3/dagre/board.exp.json +++ b/e2etests/testdata/stable/li3/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li3/elk/board.exp.json b/e2etests/testdata/stable/li3/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/li3/elk/board.exp.json +++ b/e2etests/testdata/stable/li3/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li4/dagre/board.exp.json b/e2etests/testdata/stable/li4/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/li4/dagre/board.exp.json +++ b/e2etests/testdata/stable/li4/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/li4/elk/board.exp.json b/e2etests/testdata/stable/li4/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/li4/elk/board.exp.json +++ b/e2etests/testdata/stable/li4/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/links/dagre/board.exp.json b/e2etests/testdata/stable/links/dagre/board.exp.json index 81d877183..600f94c66 100644 --- a/e2etests/testdata/stable/links/dagre/board.exp.json +++ b/e2etests/testdata/stable/links/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/links/elk/board.exp.json b/e2etests/testdata/stable/links/elk/board.exp.json index de7f6b024..7af95fe9e 100644 --- a/e2etests/testdata/stable/links/elk/board.exp.json +++ b/e2etests/testdata/stable/links/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/lone_h1/dagre/board.exp.json b/e2etests/testdata/stable/lone_h1/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/lone_h1/dagre/board.exp.json +++ b/e2etests/testdata/stable/lone_h1/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/lone_h1/elk/board.exp.json b/e2etests/testdata/stable/lone_h1/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/lone_h1/elk/board.exp.json +++ b/e2etests/testdata/stable/lone_h1/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/markdown/dagre/board.exp.json b/e2etests/testdata/stable/markdown/dagre/board.exp.json index 2f0ec56b3..6a82972e4 100644 --- a/e2etests/testdata/stable/markdown/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/markdown/elk/board.exp.json b/e2etests/testdata/stable/markdown/elk/board.exp.json index 4208359a7..763ebc6af 100644 --- a/e2etests/testdata/stable/markdown/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json index ef95474c4..751968efb 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -170,5 +171,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json index 813f43923..c3db623bf 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -161,5 +162,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json index 539f204b8..319b061c4 100644 --- a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -82,5 +83,8 @@ "level": 2 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json b/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json index be11d7dee..bbd6f48b6 100644 --- a/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -82,5 +83,8 @@ "level": 2 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json index 539f204b8..319b061c4 100644 --- a/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -82,5 +83,8 @@ "level": 2 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json b/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json index be11d7dee..bbd6f48b6 100644 --- a/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -82,5 +83,8 @@ "level": 2 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json b/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json index 381276777..a56ddae05 100644 --- a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json +++ b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -43,5 +44,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/multiline_text/elk/board.exp.json b/e2etests/testdata/stable/multiline_text/elk/board.exp.json index 02cc8b2cd..b29f59c45 100644 --- a/e2etests/testdata/stable/multiline_text/elk/board.exp.json +++ b/e2etests/testdata/stable/multiline_text/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -43,5 +44,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json b/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json index 257aa261d..a436e1948 100644 --- a/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json +++ b/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1980,5 +1981,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/multiple_trees/elk/board.exp.json b/e2etests/testdata/stable/multiple_trees/elk/board.exp.json index 110d86098..75a095705 100644 --- a/e2etests/testdata/stable/multiple_trees/elk/board.exp.json +++ b/e2etests/testdata/stable/multiple_trees/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1878,5 +1879,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/n22_e32/dagre/board.exp.json b/e2etests/testdata/stable/n22_e32/dagre/board.exp.json index 7b19244a3..eb337961a 100644 --- a/e2etests/testdata/stable/n22_e32/dagre/board.exp.json +++ b/e2etests/testdata/stable/n22_e32/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2812,5 +2813,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/n22_e32/elk/board.exp.json b/e2etests/testdata/stable/n22_e32/elk/board.exp.json index 0fd7c3bcc..e8364ae4b 100644 --- a/e2etests/testdata/stable/n22_e32/elk/board.exp.json +++ b/e2etests/testdata/stable/n22_e32/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2315,5 +2316,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/near-alone/dagre/board.exp.json b/e2etests/testdata/stable/near-alone/dagre/board.exp.json index 846ace044..efcaa08d9 100644 --- a/e2etests/testdata/stable/near-alone/dagre/board.exp.json +++ b/e2etests/testdata/stable/near-alone/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/near-alone/elk/board.exp.json b/e2etests/testdata/stable/near-alone/elk/board.exp.json index 846ace044..efcaa08d9 100644 --- a/e2etests/testdata/stable/near-alone/elk/board.exp.json +++ b/e2etests/testdata/stable/near-alone/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/number_connections/dagre/board.exp.json b/e2etests/testdata/stable/number_connections/dagre/board.exp.json index ae219240e..1d9dcd359 100644 --- a/e2etests/testdata/stable/number_connections/dagre/board.exp.json +++ b/e2etests/testdata/stable/number_connections/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -260,5 +261,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/number_connections/elk/board.exp.json b/e2etests/testdata/stable/number_connections/elk/board.exp.json index 6470faf82..038d87549 100644 --- a/e2etests/testdata/stable/number_connections/elk/board.exp.json +++ b/e2etests/testdata/stable/number_connections/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -242,5 +243,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json b/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json index c37488b62..b75872a87 100644 --- a/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json +++ b/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -768,5 +769,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/one_container_loop/elk/board.exp.json b/e2etests/testdata/stable/one_container_loop/elk/board.exp.json index cdee99f5c..c2f9e090e 100644 --- a/e2etests/testdata/stable/one_container_loop/elk/board.exp.json +++ b/e2etests/testdata/stable/one_container_loop/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -629,5 +630,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json b/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json index 7fa966e71..cc9fb991e 100644 --- a/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json +++ b/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -572,5 +573,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json b/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json index 95c206b34..401287523 100644 --- a/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json +++ b/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -550,5 +551,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json b/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json index 699e36fdc..936ba5864 100644 --- a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json +++ b/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -948,5 +949,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json index 68d5257a3..b6ef26727 100644 --- a/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json +++ b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -925,5 +926,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/p/dagre/board.exp.json b/e2etests/testdata/stable/p/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/p/dagre/board.exp.json +++ b/e2etests/testdata/stable/p/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/p/elk/board.exp.json b/e2etests/testdata/stable/p/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/p/elk/board.exp.json +++ b/e2etests/testdata/stable/p/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/pre/dagre/board.exp.json b/e2etests/testdata/stable/pre/dagre/board.exp.json index bdae01f3e..6018807a4 100644 --- a/e2etests/testdata/stable/pre/dagre/board.exp.json +++ b/e2etests/testdata/stable/pre/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -219,5 +220,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/pre/elk/board.exp.json b/e2etests/testdata/stable/pre/elk/board.exp.json index 80332ab06..a5886f5ec 100644 --- a/e2etests/testdata/stable/pre/elk/board.exp.json +++ b/e2etests/testdata/stable/pre/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -201,5 +202,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json index 2934816a9..7bedfa2bf 100644 --- a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json +++ b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -472,5 +473,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/self-referencing/elk/board.exp.json b/e2etests/testdata/stable/self-referencing/elk/board.exp.json index aa4c3d033..16b70dec8 100644 --- a/e2etests/testdata/stable/self-referencing/elk/board.exp.json +++ b/e2etests/testdata/stable/self-referencing/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -351,5 +352,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json b/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json index 040f3424f..970ef19c1 100644 --- a/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -365,5 +366,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence-inter-span-self/elk/board.exp.json b/e2etests/testdata/stable/sequence-inter-span-self/elk/board.exp.json index 040f3424f..970ef19c1 100644 --- a/e2etests/testdata/stable/sequence-inter-span-self/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence-inter-span-self/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -365,5 +366,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json index 53ab2c525..d5116b11d 100644 --- a/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -712,5 +713,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json index 53ab2c525..d5116b11d 100644 --- a/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -712,5 +713,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json index 1ef7565ef..f028c85e8 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2410,5 +2411,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json index 1ef7565ef..f028c85e8 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2410,5 +2411,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json index f31b189bf..4e3dd1cd8 100644 --- a/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -240,5 +241,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json index f31b189bf..4e3dd1cd8 100644 --- a/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -240,5 +241,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json index 7b5863078..a1fa23247 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1107,5 +1108,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json index 7b5863078..a1fa23247 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1107,5 +1108,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json index 5a1afad45..e3122c216 100644 --- a/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -281,5 +282,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json index 5a1afad45..e3122c216 100644 --- a/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -281,5 +282,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json index 458c11dd2..f8c0521bb 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1112,5 +1113,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json index 458c11dd2..f8c0521bb 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1112,5 +1113,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json index 6c4f8770e..07a4f2555 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1492,5 +1493,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json index 6c4f8770e..07a4f2555 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1492,5 +1493,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json index 8009e568a..ac256f8da 100644 --- a/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -597,5 +598,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json index 8009e568a..ac256f8da 100644 --- a/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -597,5 +598,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json index c05cedfc3..7dcd02919 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1420,5 +1421,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json index 58d38946a..ffb737d4e 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1420,5 +1421,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json index 809a1ab6f..cd5114e86 100644 --- a/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -662,5 +663,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json index 809a1ab6f..cd5114e86 100644 --- a/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -662,5 +663,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json index 12151f27a..895b55245 100644 --- a/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -789,5 +790,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json index 12151f27a..895b55245 100644 --- a/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -789,5 +790,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json index 565fc7f8a..dc023ebc9 100644 --- a/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1414,5 +1415,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json index 565fc7f8a..dc023ebc9 100644 --- a/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1414,5 +1415,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json index 0da668641..69b34c10a 100644 --- a/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -4853,5 +4854,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json index 90a925c15..2bd14b56f 100644 --- a/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -4772,5 +4773,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sql_table_tooltip_animated/dagre/board.exp.json b/e2etests/testdata/stable/sql_table_tooltip_animated/dagre/board.exp.json index 988bba089..a9c503abb 100644 --- a/e2etests/testdata/stable/sql_table_tooltip_animated/dagre/board.exp.json +++ b/e2etests/testdata/stable/sql_table_tooltip_animated/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -194,5 +195,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sql_table_tooltip_animated/elk/board.exp.json b/e2etests/testdata/stable/sql_table_tooltip_animated/elk/board.exp.json index 171b1c0f4..bcb65d699 100644 --- a/e2etests/testdata/stable/sql_table_tooltip_animated/elk/board.exp.json +++ b/e2etests/testdata/stable/sql_table_tooltip_animated/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -185,5 +186,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sql_tables/dagre/board.exp.json b/e2etests/testdata/stable/sql_tables/dagre/board.exp.json index 915cc0342..6a69a3d89 100644 --- a/e2etests/testdata/stable/sql_tables/dagre/board.exp.json +++ b/e2etests/testdata/stable/sql_tables/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -768,5 +769,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/sql_tables/elk/board.exp.json b/e2etests/testdata/stable/sql_tables/elk/board.exp.json index c7c9d439b..0ac1851b6 100644 --- a/e2etests/testdata/stable/sql_tables/elk/board.exp.json +++ b/e2etests/testdata/stable/sql_tables/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -757,5 +758,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/square_3d/dagre/board.exp.json b/e2etests/testdata/stable/square_3d/dagre/board.exp.json index cfa632b85..a3b08f953 100644 --- a/e2etests/testdata/stable/square_3d/dagre/board.exp.json +++ b/e2etests/testdata/stable/square_3d/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/square_3d/elk/board.exp.json b/e2etests/testdata/stable/square_3d/elk/board.exp.json index 50ec0be16..23f9a54e3 100644 --- a/e2etests/testdata/stable/square_3d/elk/board.exp.json +++ b/e2etests/testdata/stable/square_3d/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json b/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json index e0805d465..67cd5e07a 100644 --- a/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json +++ b/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1724,5 +1725,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json b/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json index 5ab316496..2a1467631 100644 --- a/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json +++ b/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1512,5 +1513,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/stylish/dagre/board.exp.json b/e2etests/testdata/stable/stylish/dagre/board.exp.json index 4a84becbc..442979fff 100644 --- a/e2etests/testdata/stable/stylish/dagre/board.exp.json +++ b/e2etests/testdata/stable/stylish/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -133,5 +134,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/stylish/elk/board.exp.json b/e2etests/testdata/stable/stylish/elk/board.exp.json index a8e49ddec..3ab9fd6a7 100644 --- a/e2etests/testdata/stable/stylish/elk/board.exp.json +++ b/e2etests/testdata/stable/stylish/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -124,5 +125,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/text_font_sizes/dagre/board.exp.json b/e2etests/testdata/stable/text_font_sizes/dagre/board.exp.json index fdb475c2b..2494c51f5 100644 --- a/e2etests/testdata/stable/text_font_sizes/dagre/board.exp.json +++ b/e2etests/testdata/stable/text_font_sizes/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -217,5 +218,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/text_font_sizes/elk/board.exp.json b/e2etests/testdata/stable/text_font_sizes/elk/board.exp.json index ae4e7c84e..869e454ee 100644 --- a/e2etests/testdata/stable/text_font_sizes/elk/board.exp.json +++ b/e2etests/testdata/stable/text_font_sizes/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -207,5 +208,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/tooltips/dagre/board.exp.json b/e2etests/testdata/stable/tooltips/dagre/board.exp.json index 8baf9da0c..50104fd68 100644 --- a/e2etests/testdata/stable/tooltips/dagre/board.exp.json +++ b/e2etests/testdata/stable/tooltips/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/tooltips/elk/board.exp.json b/e2etests/testdata/stable/tooltips/elk/board.exp.json index b0c096ebc..390267cf5 100644 --- a/e2etests/testdata/stable/tooltips/elk/board.exp.json +++ b/e2etests/testdata/stable/tooltips/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json b/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json index bfac93f00..76d3cfce0 100644 --- a/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json +++ b/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -43,5 +44,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/transparent_3d/elk/board.exp.json b/e2etests/testdata/stable/transparent_3d/elk/board.exp.json index f1fbff7e1..4ed4149f9 100644 --- a/e2etests/testdata/stable/transparent_3d/elk/board.exp.json +++ b/e2etests/testdata/stable/transparent_3d/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -43,5 +44,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json b/e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json index 253b0fbc0..b4627ce5f 100644 --- a/e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json +++ b/e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -570,5 +571,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json b/e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json index ca6884730..694baca33 100644 --- a/e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json +++ b/e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -534,5 +535,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json b/e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json index ce23b283a..681d02d92 100644 --- a/e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json +++ b/e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -570,5 +571,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json b/e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json index 371e7c33f..70c5a09ec 100644 --- a/e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json +++ b/e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -534,5 +535,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/us_map/dagre/board.exp.json b/e2etests/testdata/stable/us_map/dagre/board.exp.json index bbbab7732..73b5b191c 100644 --- a/e2etests/testdata/stable/us_map/dagre/board.exp.json +++ b/e2etests/testdata/stable/us_map/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -8280,5 +8281,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/stable/us_map/elk/board.exp.json b/e2etests/testdata/stable/us_map/elk/board.exp.json index a4e050175..fff8ac0b5 100644 --- a/e2etests/testdata/stable/us_map/elk/board.exp.json +++ b/e2etests/testdata/stable/us_map/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -6904,5 +6905,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json b/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json index 7474c5012..fc6a19cd7 100644 --- a/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json +++ b/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -220,5 +221,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/container_child_edge/elk/board.exp.json b/e2etests/testdata/todo/container_child_edge/elk/board.exp.json index 9a6ab6934..35d9ae4c7 100644 --- a/e2etests/testdata/todo/container_child_edge/elk/board.exp.json +++ b/e2etests/testdata/todo/container_child_edge/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -210,5 +211,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json b/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json index 31501e6eb..7684b169b 100644 --- a/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -203,5 +204,8 @@ "level": 5 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json b/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json index 2761a62eb..af6246d23 100644 --- a/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -203,5 +204,8 @@ "level": 5 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json b/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json index 6ec6659b7..f005ce3d2 100644 --- a/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -396,5 +397,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json b/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json index d08c6cfa1..25bc0c38a 100644 --- a/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -360,5 +361,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json index a5a0b22d3..35086f0c1 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -675,5 +676,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json index a5a0b22d3..35086f0c1 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -675,5 +676,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/shape_set_width_height/dagre/board.exp.json b/e2etests/testdata/todo/shape_set_width_height/dagre/board.exp.json index f6298e97f..20308e9ee 100644 --- a/e2etests/testdata/todo/shape_set_width_height/dagre/board.exp.json +++ b/e2etests/testdata/todo/shape_set_width_height/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1170,5 +1171,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json b/e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json index 6cd8b7964..321aed038 100644 --- a/e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json +++ b/e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1092,5 +1093,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json b/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json index 939a81a70..ef7c1b567 100644 --- a/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json +++ b/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -132,5 +133,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json b/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json index 112bd9e93..cc2d161af 100644 --- a/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json +++ b/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -123,5 +124,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/main.go b/main.go index c7a0429d9..c81bfa8af 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ import ( "oss.terrastruct.com/d2/d2renderers/d2fonts" "oss.terrastruct.com/d2/d2renderers/d2svg" "oss.terrastruct.com/d2/d2renderers/d2svg/appendix" + "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/d2themes" "oss.terrastruct.com/d2/d2themes/d2themescatalog" "oss.terrastruct.com/d2/lib/imgbundler" @@ -218,7 +219,6 @@ func run(ctx context.Context, ms *xmain.State) (err error) { } return fmt.Errorf("failed to compile: %w", err) } - ms.Log.Success.Printf("successfully compiled %v to %v", inputPath, outputPath) return nil } @@ -247,17 +247,53 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc return nil, false, err } + svg, err := render(ctx, ms, plugin, sketch, pad, inputPath, outputPath, bundle, page, ruler, diagram) + if err != nil { + return svg, false, err + } + return svg, true, nil +} + +func render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketch bool, pad int64, inputPath, outputPath string, bundle bool, page playwright.Page, ruler *textmeasure.Ruler, diagram *d2target.Diagram) ([]byte, error) { + outputPath = layerOutputPath(outputPath, diagram) + for _, dl := range diagram.Layers { + _, err := render(ctx, ms, plugin, sketch, pad, inputPath, outputPath, bundle, page, ruler, dl) + if err != nil { + return nil, err + } + } + for _, dl := range diagram.Scenarios { + _, err := render(ctx, ms, plugin, sketch, pad, inputPath, outputPath, bundle, page, ruler, dl) + if err != nil { + return nil, err + } + } + for _, dl := range diagram.Steps { + _, err := render(ctx, ms, plugin, sketch, pad, inputPath, outputPath, bundle, page, ruler, dl) + if err != nil { + return nil, err + } + } + svg, err := _render(ctx, ms, plugin, sketch, pad, outputPath, bundle, page, ruler, diagram) + if err != nil { + return svg, err + } + ms.Log.Success.Printf("successfully compiled %v to %v", inputPath, outputPath) + return svg, nil +} + +func _render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketch bool, pad int64, outputPath string, bundle bool, page playwright.Page, ruler *textmeasure.Ruler, diagram *d2target.Diagram) ([]byte, error) { svg, err := d2svg.Render(diagram, &d2svg.RenderOpts{ Pad: int(pad), Sketch: sketch, }) if err != nil { - return nil, false, err + return nil, err } svg, err = plugin.PostProcess(ctx, svg) if err != nil { - return svg, false, err + return svg, err } svg, bundleErr := imgbundler.BundleLocal(ctx, ms, svg) @@ -279,7 +315,7 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc out, err = png.ConvertSVG(ms, page, svg) if err != nil { - return svg, false, err + return svg, err } } else { if len(out) > 0 && out[len(out)-1] != '\n' { @@ -287,12 +323,26 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc } } + outputPath = layerOutputPath(outputPath, diagram) err = ms.WritePath(outputPath, out) if err != nil { - return svg, false, err + return svg, err } + if bundleErr != nil { + return svg, bundleErr + } + return svg, nil +} - return svg, true, bundleErr +func layerOutputPath(outputPath string, d *d2target.Diagram) string { + if d.Name == "" { + return outputPath + } + ext := filepath.Ext(outputPath) + outputPath = strings.TrimSuffix(outputPath, ext) + outputPath += "-" + d.Name + outputPath += ext + return outputPath } // newExt must include leading . diff --git a/testdata/d2compiler/TestCompile2/scenarios/recursive#01.exp.json b/testdata/d2compiler/TestCompile2/scenarios/recursive#01.exp.json new file mode 100644 index 000000000..22fa2ae4c --- /dev/null +++ b/testdata/d2compiler/TestCompile2/scenarios/recursive#01.exp.json @@ -0,0 +1,12 @@ +{ + "graph": null, + "err": { + "ioerr": null, + "errs": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/scenarios/recursive#01.d2,8:1:51-8:4:54", + "errmsg": "d2/testdata/d2compiler/TestCompile2/scenarios/recursive#01.d2:9:2: layer name one already used by another layer" + } + ] + } +} diff --git a/testdata/d2exporter/TestExport/connection/arrowhead.exp.json b/testdata/d2exporter/TestExport/connection/arrowhead.exp.json index d4312d7a6..62458de08 100644 --- a/testdata/d2exporter/TestExport/connection/arrowhead.exp.json +++ b/testdata/d2exporter/TestExport/connection/arrowhead.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -113,5 +114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/connection/basic.exp.json b/testdata/d2exporter/TestExport/connection/basic.exp.json index f90c5fb7b..fdc226f93 100644 --- a/testdata/d2exporter/TestExport/connection/basic.exp.json +++ b/testdata/d2exporter/TestExport/connection/basic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -113,5 +114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json b/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json index 650dffe51..58c13efc0 100644 --- a/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json +++ b/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -113,5 +114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json b/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json index e4381a7a7..632242a0a 100644 --- a/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json +++ b/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -144,5 +145,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/label/basic_shape.exp.json b/testdata/d2exporter/TestExport/label/basic_shape.exp.json index 4722c29fd..9012100b0 100644 --- a/testdata/d2exporter/TestExport/label/basic_shape.exp.json +++ b/testdata/d2exporter/TestExport/label/basic_shape.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/label/connection_font_color.exp.json b/testdata/d2exporter/TestExport/label/connection_font_color.exp.json index d14209596..93a956338 100644 --- a/testdata/d2exporter/TestExport/label/connection_font_color.exp.json +++ b/testdata/d2exporter/TestExport/label/connection_font_color.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -113,5 +114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/label/shape_font_color.exp.json b/testdata/d2exporter/TestExport/label/shape_font_color.exp.json index f271d7676..191f4545a 100644 --- a/testdata/d2exporter/TestExport/label/shape_font_color.exp.json +++ b/testdata/d2exporter/TestExport/label/shape_font_color.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/shape/basic.exp.json b/testdata/d2exporter/TestExport/shape/basic.exp.json index 0b4338e74..002d726a4 100644 --- a/testdata/d2exporter/TestExport/shape/basic.exp.json +++ b/testdata/d2exporter/TestExport/shape/basic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/shape/border-radius.exp.json b/testdata/d2exporter/TestExport/shape/border-radius.exp.json index b38fe2c44..fe791f3c6 100644 --- a/testdata/d2exporter/TestExport/shape/border-radius.exp.json +++ b/testdata/d2exporter/TestExport/shape/border-radius.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json b/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json index 1184300e9..beb868d1a 100644 --- a/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json +++ b/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -53,5 +54,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/shape/sequence_group_position.exp.json b/testdata/d2exporter/TestExport/shape/sequence_group_position.exp.json index 7408bcaa7..9dde517ed 100644 --- a/testdata/d2exporter/TestExport/shape/sequence_group_position.exp.json +++ b/testdata/d2exporter/TestExport/shape/sequence_group_position.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -250,5 +251,8 @@ "icon": null, "zIndex": 1 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/shape/synonyms.exp.json b/testdata/d2exporter/TestExport/shape/synonyms.exp.json index 820282971..95e0a72f3 100644 --- a/testdata/d2exporter/TestExport/shape/synonyms.exp.json +++ b/testdata/d2exporter/TestExport/shape/synonyms.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -81,5 +82,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/shape/text_color.exp.json b/testdata/d2exporter/TestExport/shape/text_color.exp.json index b45f95aac..c50980d6f 100644 --- a/testdata/d2exporter/TestExport/shape/text_color.exp.json +++ b/testdata/d2exporter/TestExport/shape/text_color.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json b/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json index 23ba623a2..4ad1ec939 100644 --- a/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json +++ b/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -113,5 +114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json b/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json index 8b33587da..3f6cb0879 100644 --- a/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json +++ b/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -113,5 +114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json b/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json index 148b1cf63..a892c2430 100644 --- a/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json +++ b/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -113,5 +114,8 @@ "icon": null, "zIndex": 0 } - ] + ], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json b/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json index 36f8f9dde..74898664a 100644 --- a/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json +++ b/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } diff --git a/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json b/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json index 5d6653b04..da69ad0aa 100644 --- a/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json +++ b/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json @@ -1,5 +1,6 @@ { "name": "", + "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -42,5 +43,8 @@ "level": 1 } ], - "connections": [] + "connections": [], + "layers": null, + "scenarios": null, + "steps": null } From d80b2d38428b7a4ad600378513a437604c2f1769 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 27 Jan 2023 11:01:16 -0800 Subject: [PATCH 44/60] cli: Output layers under subdirectory --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index c81bfa8af..f2b4bcd82 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "os" "os/exec" "path/filepath" "strings" @@ -323,7 +324,10 @@ func _render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc } } - outputPath = layerOutputPath(outputPath, diagram) + err = os.MkdirAll(filepath.Dir(outputPath), 0755) + if err != nil { + return svg, err + } err = ms.WritePath(outputPath, out) if err != nil { return svg, err @@ -340,7 +344,7 @@ func layerOutputPath(outputPath string, d *d2target.Diagram) string { } ext := filepath.Ext(outputPath) outputPath = strings.TrimSuffix(outputPath, ext) - outputPath += "-" + d.Name + outputPath += "/" + d.Name outputPath += ext return outputPath } From dffcb274cda1f0d5357f5ead35a0fa8557819e27 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 27 Jan 2023 11:06:35 -0800 Subject: [PATCH 45/60] next.md: Document layers/scenarios/steps --- ci/release/changelogs/next.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 17f4ec3db..8f0cadb4e 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -6,6 +6,10 @@ - `d2 fmt` accepts multiple files to be formatted [#718](https://github.com/terrastruct/d2/issues/718) +- You can now use the reserved keywords `layers`/`scenarios`/`steps` to define diagrams + with multiple levels of abstractions. [#714](https://github.com/terrastruct/d2/pull/714) + Docs to come soon + #### Improvements 🧹 #### Bugfixes ⛑️ From dce43856443c1cb816c59d886791f67ec8b64a99 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 27 Jan 2023 12:37:08 -0800 Subject: [PATCH 46/60] d2ir: Review fixes #714 --- d2ir/compile.go | 3 +- d2ir/d2ir.go | 2 + e2etests/stable_test.go | 56 + .../complex-layers/dagre/board.exp.json | 1284 +++++++++++++++++ .../complex-layers/dagre/sketch.exp.svg | 52 + .../stable/complex-layers/elk/board.exp.json | 1257 ++++++++++++++++ .../stable/complex-layers/elk/sketch.exp.svg | 52 + .../dagre/.!73950!sketch.exp.svg | 42 - 8 files changed, 2704 insertions(+), 44 deletions(-) create mode 100644 e2etests/testdata/stable/complex-layers/dagre/board.exp.json create mode 100644 e2etests/testdata/stable/complex-layers/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/stable/complex-layers/elk/board.exp.json create mode 100644 e2etests/testdata/stable/complex-layers/elk/sketch.exp.svg delete mode 100644 e2etests/testdata/stable/overlapping_image_container_labels/dagre/.!73950!sketch.exp.svg diff --git a/d2ir/compile.go b/d2ir/compile.go index 4c9871b21..70839d85c 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -61,7 +61,6 @@ func (c *compiler) compileSteps(m *Map) { if sf.Map() == nil { continue } - var base *Map if i == 0 { base = m.CopyBase(sf) @@ -243,7 +242,7 @@ func (c *compiler) compileArray(dst *Array, a *d2ast.Array) { Value: v, } case *d2ast.Substitution: - panic("TODO") + // panic("TODO") } dst.Values = append(dst.Values, irv) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 3540536fc..88b55600e 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -268,6 +268,8 @@ type Field struct { Name string `json:"name"` + // Primary_ to avoid clashing with Primary(). We need to keep it exported for + // encoding/json to marshal it so cannot prefix _ instead. Primary_ *Scalar `json:"primary,omitempty"` Composite Composite `json:"composite,omitempty"` diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index 0fa299c0d..b27a6a82a 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -1877,6 +1877,62 @@ a.sp1 -> a.sp2: redirect a.sp2 -> b: bar `, }, + { + name: "complex-layers", + script: ` +desc: Multi-layer diagram of a home. + +window: { + style.double-border: true +} +roof +garage + +layers: { + window: { + blinds + glass + } + roof: { + shingles + starlink + utility hookup + } + garage: { + tools + vehicles + } + repair: { + desc: How to repair a home. + + steps: { + 1: { + find contractors: { + craigslist + facebook + } + } + 2: { + find contractors -> solicit quotes + } + 3: { + obtain quotes -> negotiate + } + 4: { + negotiate -> book the best bid + } + } + } +} + +scenarios: { + storm: { + water + rain + thunder + } +}`, + }, } runa(t, tcs) diff --git a/e2etests/testdata/stable/complex-layers/dagre/board.exp.json b/e2etests/testdata/stable/complex-layers/dagre/board.exp.json new file mode 100644 index 000000000..0223f1681 --- /dev/null +++ b/e2etests/testdata/stable/complex-layers/dagre/board.exp.json @@ -0,0 +1,1284 @@ +{ + "name": "", + "type": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "window", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": true, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "window", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "roof", + "type": "rectangle", + "pos": { + "x": 223, + "y": 0 + }, + "width": 135, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "roof", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "garage", + "type": "rectangle", + "pos": { + "x": 418, + "y": 0 + }, + "width": 154, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "garage", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 54, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": [ + { + "name": "window", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "blinds", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 148, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "blinds", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 48, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "glass", + "type": "rectangle", + "pos": { + "x": 208, + "y": 0 + }, + "width": 141, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "glass", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 41, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "roof", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "shingles", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 164, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "shingles", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 64, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "starlink", + "type": "rectangle", + "pos": { + "x": 224, + "y": 0 + }, + "width": 161, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "starlink", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 61, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "utility hookup", + "type": "rectangle", + "pos": { + "x": 445, + "y": 0 + }, + "width": 206, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "utility hookup", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 106, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "garage", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "tools", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 141, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "tools", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 41, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "vehicles", + "type": "rectangle", + "pos": { + "x": 201, + "y": 0 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "vehicles", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "repair", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [], + "layers": null, + "scenarios": null, + "steps": [ + { + "name": "1", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "find contractors", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 501, + "height": 226, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "find contractors", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 192, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "find contractors.craigslist", + "type": "rectangle", + "pos": { + "x": 50, + "y": 50 + }, + "width": 170, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "craigslist", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 70, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "find contractors.facebook", + "type": "rectangle", + "pos": { + "x": 280, + "y": 50 + }, + "width": 171, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "facebook", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 71, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "2", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "find contractors", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 219, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "find contractors", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 119, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "solicit quotes", + "type": "rectangle", + "pos": { + "x": 10, + "y": 226 + }, + "width": 200, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "solicit quotes", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 100, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(find contractors -> solicit quotes)[0]", + "src": "find contractors", + "srcArrow": "none", + "srcLabel": "", + "dst": "solicit quotes", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 109.5, + "y": 126 + }, + { + "x": 109.5, + "y": 166 + }, + { + "x": 109.5, + "y": 186 + }, + { + "x": 109.5, + "y": 226 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "3", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "obtain quotes", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 203, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "obtain quotes", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 103, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "negotiate", + "type": "rectangle", + "pos": { + "x": 16, + "y": 226 + }, + "width": 172, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "negotiate", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 72, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(obtain quotes -> negotiate)[0]", + "src": "obtain quotes", + "srcArrow": "none", + "srcLabel": "", + "dst": "negotiate", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 101.5, + "y": 126 + }, + { + "x": 101.5, + "y": 166 + }, + { + "x": 101.5, + "y": 186 + }, + { + "x": 101.5, + "y": 226 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "4", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "negotiate", + "type": "rectangle", + "pos": { + "x": 28, + "y": 0 + }, + "width": 172, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "negotiate", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 72, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "book the best bid", + "type": "rectangle", + "pos": { + "x": 0, + "y": 226 + }, + "width": 227, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "book the best bid", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 127, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(negotiate -> book the best bid)[0]", + "src": "negotiate", + "srcArrow": "none", + "srcLabel": "", + "dst": "book the best bid", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 113.5, + "y": 126 + }, + { + "x": 113.5, + "y": 166 + }, + { + "x": 113.5, + "y": 186 + }, + { + "x": 113.5, + "y": 226 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "layers": null, + "scenarios": null, + "steps": null + } + ] + } + ], + "scenarios": [ + { + "name": "storm", + "type": "scenario", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "window", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": true, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "window", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "roof", + "type": "rectangle", + "pos": { + "x": 223, + "y": 0 + }, + "width": 135, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "roof", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "garage", + "type": "rectangle", + "pos": { + "x": 418, + "y": 0 + }, + "width": 154, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "garage", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 54, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "water", + "type": "rectangle", + "pos": { + "x": 632, + "y": 0 + }, + "width": 148, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "water", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 48, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "rain", + "type": "rectangle", + "pos": { + "x": 840, + "y": 0 + }, + "width": 133, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "rain", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 33, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "thunder", + "type": "rectangle", + "pos": { + "x": 1033, + "y": 0 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "thunder", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + } + ], + "steps": null +} diff --git a/e2etests/testdata/stable/complex-layers/dagre/sketch.exp.svg b/e2etests/testdata/stable/complex-layers/dagre/sketch.exp.svg new file mode 100644 index 000000000..1c804085b --- /dev/null +++ b/e2etests/testdata/stable/complex-layers/dagre/sketch.exp.svg @@ -0,0 +1,52 @@ + +windowroofgarage + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/complex-layers/elk/board.exp.json b/e2etests/testdata/stable/complex-layers/elk/board.exp.json new file mode 100644 index 000000000..7e4ed4603 --- /dev/null +++ b/e2etests/testdata/stable/complex-layers/elk/board.exp.json @@ -0,0 +1,1257 @@ +{ + "name": "", + "type": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "window", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": true, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "window", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "roof", + "type": "rectangle", + "pos": { + "x": 195, + "y": 12 + }, + "width": 135, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "roof", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "garage", + "type": "rectangle", + "pos": { + "x": 350, + "y": 12 + }, + "width": 154, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "garage", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 54, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": [ + { + "name": "window", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "blinds", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 148, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "blinds", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 48, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "glass", + "type": "rectangle", + "pos": { + "x": 180, + "y": 12 + }, + "width": 141, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "glass", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 41, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "roof", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "shingles", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 164, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "shingles", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 64, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "starlink", + "type": "rectangle", + "pos": { + "x": 196, + "y": 12 + }, + "width": 161, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "starlink", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 61, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "utility hookup", + "type": "rectangle", + "pos": { + "x": 377, + "y": 12 + }, + "width": 206, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "utility hookup", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 106, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "garage", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "tools", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 141, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "tools", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 41, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "vehicles", + "type": "rectangle", + "pos": { + "x": 173, + "y": 12 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "vehicles", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "repair", + "type": "layer", + "fontFamily": "SourceSansPro", + "shapes": [], + "connections": [], + "layers": null, + "scenarios": null, + "steps": [ + { + "name": "1", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "find contractors", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 511, + "height": 276, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "find contractors", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 192, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "find contractors.craigslist", + "type": "rectangle", + "pos": { + "x": 87, + "y": 87 + }, + "width": 170, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "craigslist", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 70, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "find contractors.facebook", + "type": "rectangle", + "pos": { + "x": 277, + "y": 87 + }, + "width": 171, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "facebook", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 71, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "2", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "find contractors", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 219, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "find contractors", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 119, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "solicit quotes", + "type": "rectangle", + "pos": { + "x": 21, + "y": 238 + }, + "width": 200, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "solicit quotes", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 100, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(find contractors -> solicit quotes)[0]", + "src": "find contractors", + "srcArrow": "none", + "srcLabel": "", + "dst": "solicit quotes", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 121.5, + "y": 138 + }, + { + "x": 121.5, + "y": 238 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "3", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "obtain quotes", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 203, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "obtain quotes", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 103, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "negotiate", + "type": "rectangle", + "pos": { + "x": 27, + "y": 238 + }, + "width": 172, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "negotiate", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 72, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(obtain quotes -> negotiate)[0]", + "src": "obtain quotes", + "srcArrow": "none", + "srcLabel": "", + "dst": "negotiate", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 113.5, + "y": 138 + }, + { + "x": 113.5, + "y": 238 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "layers": null, + "scenarios": null, + "steps": null + }, + { + "name": "4", + "type": "step", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "negotiate", + "type": "rectangle", + "pos": { + "x": 39, + "y": 12 + }, + "width": 172, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "negotiate", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 72, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "book the best bid", + "type": "rectangle", + "pos": { + "x": 12, + "y": 238 + }, + "width": 227, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "book the best bid", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 127, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(negotiate -> book the best bid)[0]", + "src": "negotiate", + "srcArrow": "none", + "srcLabel": "", + "dst": "book the best bid", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 125.5, + "y": 138 + }, + { + "x": 125.5, + "y": 238 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "layers": null, + "scenarios": null, + "steps": null + } + ] + } + ], + "scenarios": [ + { + "name": "storm", + "type": "scenario", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "window", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": true, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "window", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "roof", + "type": "rectangle", + "pos": { + "x": 195, + "y": 12 + }, + "width": 135, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "roof", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "garage", + "type": "rectangle", + "pos": { + "x": 350, + "y": 12 + }, + "width": 154, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "garage", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 54, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "water", + "type": "rectangle", + "pos": { + "x": 524, + "y": 12 + }, + "width": 148, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "water", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 48, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "rain", + "type": "rectangle", + "pos": { + "x": 692, + "y": 12 + }, + "width": 133, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "rain", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 33, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "thunder", + "type": "rectangle", + "pos": { + "x": 845, + "y": 12 + }, + "width": 163, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "thunder", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 63, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [], + "layers": null, + "scenarios": null, + "steps": null + } + ], + "steps": null +} diff --git a/e2etests/testdata/stable/complex-layers/elk/sketch.exp.svg b/e2etests/testdata/stable/complex-layers/elk/sketch.exp.svg new file mode 100644 index 000000000..bfaa24c21 --- /dev/null +++ b/e2etests/testdata/stable/complex-layers/elk/sketch.exp.svg @@ -0,0 +1,52 @@ + +windowroofgarage + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/.!73950!sketch.exp.svg b/e2etests/testdata/stable/overlapping_image_container_labels/dagre/.!73950!sketch.exp.svg deleted file mode 100644 index 47d55bec6..000000000 --- a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/.!73950!sketch.exp.svg +++ /dev/null @@ -1,42 +0,0 @@ - -rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root - - - - - - - - \ No newline at end of file diff --git a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json index 378f076e0..20391bbd6 100644 --- a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json +++ b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 57, + "x": 12, "y": 238 }, - "width": 23, - "height": 24, + "width": 3051, + "height": 4853, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n - [Automatic Escaping for Special Characters](#autoescape)\n- [Block Elements](#block)\n - [Paragraphs and Line Breaks](#p)\n - [Headers](#header)\n - [Blockquotes](#blockquote)\n - [Lists](#list)\n - [Code Blocks](#precode)\n - [Horizontal Rules](#hr)\n- [Span Elements](#span)\n - [Links](#link)\n - [Emphasis](#em)\n - [Code](#code)\n - [Images](#img)\n- [Miscellaneous](#misc)\n - [Backslash Escapes](#backslash)\n - [Automatic Links](#autolink)\n\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL](/projects/markdown/syntax.text).\n\n---\n\n## Overview\n\n### Philosophy\n\nMarkdown is intended to be as easy-to-read and easy-to-write as is feasible.\n\nReadability, however, is emphasized above all else. A Markdown-formatted\ndocument should be publishable as-is, as plain text, without looking\nlike it's been marked up with tags or formatting instructions. While\nMarkdown's syntax has been influenced by several existing text-to-HTML\nfilters -- including [Setext](http://docutils.sourceforge.net/mirror/setext.html), [atx](http://www.aaronsw.com/2002/atx/), [Textile](http://textism.com/tools/textile/), [reStructuredText](http://docutils.sourceforge.net/rst.html),\n[Grutatext](http://www.triptico.com/software/grutatxt.html), and [EtText](http://ettext.taint.org/doc/) -- the single biggest source of\ninspiration for Markdown's syntax is the format of plain text email.\n\n## Block Elements\n\n### Paragraphs and Line Breaks\n\nA paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing but spaces or tabs is considered\nblank.) Normal paragraphs should not be indented with spaces or tabs.\n\nThe implication of the \"one or more consecutive lines of text\" rule is\nthat Markdown supports \"hard-wrapped\" text paragraphs. This differs\nsignificantly from most other text-to-HTML formatters (including Movable\nType's \"Convert Line Breaks\" option) which translate every line break\nend a line with two or more spaces, then type return.\n\n### Headers\n\nMarkdown supports two styles of headers, [Setext] [1] and [atx] [2].\n\nOptionally, you may \"close\" atx-style headers. This is purely\ncosmetic -- you can use this if you think it looks better. The\nclosing hashes don't even need to match the number of hashes\nused to open the header. (The number of opening hashes\ndetermines the header level.)\n\n### Blockquotes\n\nfamiliar with quoting passages of text in an email message, then you\nknow how to create a blockquote in Markdown. It looks best if you hard\n\n> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n>\n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n> id sem consectetuer libero luctus adipiscing.\n\nline of a hard-wrapped paragraph:\n\n> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n\n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n> id sem consectetuer libero luctus adipiscing.\n\nBlockquotes can be nested (i.e. a blockquote-in-a-blockquote) by\n\n> This is the first level of quoting.\n>\n> > This is nested blockquote.\n>\n> Back to the first level.\n\nBlockquotes can contain other Markdown elements, including headers, lists,\nand code blocks:\n\n> ## This is a header.\n>\n> 1. This is the first list item.\n> 2. This is the second list item.\n>\n> Here's some example code:\n>\n> return shell_exec(\"echo $input $markdown_script\");\n\nAny decent text editor should make email-style quoting easy. For\nexample, with BBEdit, you can make a selection and choose Increase\nQuote Level from the Text menu.\n\n### Lists\n\nMarkdown supports ordered (numbered) and unordered (bulleted) lists.\n\nUnordered lists use asterisks, pluses, and hyphens -- interchangably\n-- as list markers:\n\n- Red\n- Green\n- Blue\n\nis equivalent to:\n\n- Red\n- Green\n- Blue\n\nand:\n\n- Red\n- Green\n- Blue\n\nOrdered lists use numbers followed by periods:\n\n1. Bird\n2. McHale\n3. Parish\n\nIt's important to note that the actual numbers you use to mark the\nlist have no effect on the HTML output Markdown produces. The HTML\nMarkdown produces from the above list is:\n\nIf you instead wrote the list in Markdown like this:\n\n1. Bird\n1. McHale\n1. Parish\n\nor even:\n\n3. Bird\n1. McHale\n1. Parish\n\nyou'd get the exact same HTML output. The point is, if you want to,\nyou can use ordinal numbers in your ordered Markdown lists, so that\nthe numbers in your source match the numbers in your published HTML.\nBut if you want to be lazy, you don't have to.\n\nTo make lists look nice, you can wrap items with hanging indents:\n\n- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n- Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nBut if you want to be lazy, you don't have to:\n\n- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n- Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be indented by either 4 spaces\nor one tab:\n\n1. This is a list item with two paragraphs. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n mi posuere lectus.\n\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n sit amet velit.\n\n2. Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIt looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:\n\n- This is a list item with two paragraphs.\n\n This is the second paragraph in the list item. You're\n\n only required to indent the first line. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit.\n\n- Another item in the same list.\n\ndelimiters need to be indented:\n\n- A list item with a blockquote:\n\n > This is a blockquote\n > inside a list item.\n\nTo put a code block within a list item, the code block needs\nto be indented _twice_ -- 8 spaces or two tabs:\n\n- A list item with a code block:\n\n### Code Blocks\n\nPre-formatted code blocks are used for writing about programming or\nmarkup source code. Rather than forming normal paragraphs, the lines\nof a code block are interpreted literally. Markdown wraps a code block\n\nTo produce a code block in Markdown, simply indent every line of the\nblock by at least 4 spaces or 1 tab.\n\nThis is a normal paragraph:\n\n This is a code block.\n\nHere is an example of AppleScript:\n\n tell application \"Foo\"\n beep\n end tell\n\nA code block continues until it reaches a line that is not indented\n(or the end of the article).\n\nare automatically converted into HTML entities. This makes it very\neasy to include example HTML source code using Markdown -- just paste\nit and indent it, and Markdown will handle the hassle of encoding the\nampersands and angle brackets. For example, this:\n\nRegular Markdown syntax is not processed within code blocks. E.g.,\nasterisks are just literal asterisks within a code block. This means\nit's also easy to use Markdown to write about Markdown's own syntax.\n\n## Span Elements\n\n### Links\n\nMarkdown supports two style of links: _inline_ and _reference_.\n\nIn both styles, the link text is delimited by [square brackets].\n\nTo create an inline link, use a set of regular parentheses immediately\nafter the link text's closing square bracket. Inside the parentheses,\nput the URL where you want the link to point, along with an _optional_\ntitle for the link, surrounded in quotes. For example:\n\nThis is [an example](http://example.com/) inline link.\n\n[This link](http://example.net/) has no title attribute.\n\n### Emphasis\n\n_single asterisks_\n\n_single underscores_\n\n**double asterisks**\n\n**double underscores**\n\n### Code\n\nUnlike a pre-formatted code block, a code span indicates code within a\nnormal paragraph. For example:\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 3051, + "labelHeight": 4853, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 12, + "x": 1481, "y": 12 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 12, - "y": 362 + "x": 1481, + "y": 5191 }, "width": 113, "height": 126, @@ -153,11 +152,11 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, + "x": 1537.5, "y": 138 }, { - "x": 68.5, + "x": 1537.5, "y": 238 } ], @@ -192,12 +191,12 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, - "y": 262 + "x": 1537.5, + "y": 5091 }, { - "x": 68.5, - "y": 362 + "x": 1537.5, + "y": 5191 } ], "animated": false, @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg b/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg index 4ef05dfe3..e0b0c127a 100644 --- a/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-90 -90 317 680">

md

-
ab - +

Markdown: Syntax

+ +

Note: This document is itself written using Markdown; you +can see the source for it by adding '.text' to the URL.

+
+

Overview

+

Philosophy

+

Markdown is intended to be as easy-to-read and easy-to-write as is feasible.

+

Readability, however, is emphasized above all else. A Markdown-formatted +document should be publishable as-is, as plain text, without looking +like it's been marked up with tags or formatting instructions. While +Markdown's syntax has been influenced by several existing text-to-HTML +filters -- including Setext, atx, Textile, reStructuredText, +Grutatext, and EtText -- the single biggest source of +inspiration for Markdown's syntax is the format of plain text email.

+

Block Elements

+

Paragraphs and Line Breaks

+

A paragraph is simply one or more consecutive lines of text, separated +by one or more blank lines. (A blank line is any line that looks like a +blank line -- a line containing nothing but spaces or tabs is considered +blank.) Normal paragraphs should not be indented with spaces or tabs.

+

The implication of the "one or more consecutive lines of text" rule is +that Markdown supports "hard-wrapped" text paragraphs. This differs +significantly from most other text-to-HTML formatters (including Movable +Type's "Convert Line Breaks" option) which translate every line break +end a line with two or more spaces, then type return.

+

Headers

+

Markdown supports two styles of headers, [Setext] [1] and [atx] [2].

+

Optionally, you may "close" atx-style headers. This is purely +cosmetic -- you can use this if you think it looks better. The +closing hashes don't even need to match the number of hashes +used to open the header. (The number of opening hashes +determines the header level.)

+

Blockquotes

+

familiar with quoting passages of text in an email message, then you +know how to create a blockquote in Markdown. It looks best if you hard

+
+

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, +consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. +Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

+

Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse +id sem consectetuer libero luctus adipiscing.

+
+

line of a hard-wrapped paragraph:

+
+

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, +consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. +Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

+
+
+

Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse +id sem consectetuer libero luctus adipiscing.

+
+

Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by

+
+

This is the first level of quoting.

+
+

This is nested blockquote.

+
+

Back to the first level.

+
+

Blockquotes can contain other Markdown elements, including headers, lists, +and code blocks:

+
+

This is a header.

+
    +
  1. This is the first list item.
  2. +
  3. This is the second list item.
  4. +
+

Here's some example code:

+
return shell_exec("echo $input  $markdown_script");
+
+
+

Any decent text editor should make email-style quoting easy. For +example, with BBEdit, you can make a selection and choose Increase +Quote Level from the Text menu.

+

Lists

+

Markdown supports ordered (numbered) and unordered (bulleted) lists.

+

Unordered lists use asterisks, pluses, and hyphens -- interchangably +-- as list markers:

+
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
+

is equivalent to:

+
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
+

and:

+
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
+

Ordered lists use numbers followed by periods:

+
    +
  1. Bird
  2. +
  3. McHale
  4. +
  5. Parish
  6. +
+

It's important to note that the actual numbers you use to mark the +list have no effect on the HTML output Markdown produces. The HTML +Markdown produces from the above list is:

+

If you instead wrote the list in Markdown like this:

+
    +
  1. Bird
  2. +
  3. McHale
  4. +
  5. Parish
  6. +
+

or even:

+
    +
  1. Bird
  2. +
  3. McHale
  4. +
  5. Parish
  6. +
+

you'd get the exact same HTML output. The point is, if you want to, +you can use ordinal numbers in your ordered Markdown lists, so that +the numbers in your source match the numbers in your published HTML. +But if you want to be lazy, you don't have to.

+

To make lists look nice, you can wrap items with hanging indents:

+
    +
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. +Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, +viverra nec, fringilla in, laoreet vitae, risus.
  • +
  • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. +Suspendisse id sem consectetuer libero luctus adipiscing.
  • +
+

But if you want to be lazy, you don't have to:

+
    +
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. +Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, +viverra nec, fringilla in, laoreet vitae, risus.
  • +
  • Donec sit amet nisl. Aliquam semper ipsum sit amet velit. +Suspendisse id sem consectetuer libero luctus adipiscing.
  • +
+

List items may consist of multiple paragraphs. Each subsequent +paragraph in a list item must be indented by either 4 spaces +or one tab:

+
    +
  1. +

    This is a list item with two paragraphs. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit. Aliquam hendrerit +mi posuere lectus.

    +

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet +vitae, risus. Donec sit amet nisl. Aliquam semper ipsum +sit amet velit.

    +
  2. +
  3. +

    Suspendisse id sem consectetuer libero luctus adipiscing.

    +
  4. +
+

It looks nice if you indent every line of the subsequent +paragraphs, but here again, Markdown will allow you to be +lazy:

+
    +
  • +

    This is a list item with two paragraphs.

    +
    This is the second paragraph in the list item. You're
    +
    +

    only required to indent the first line. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit.

    +
  • +
  • +

    Another item in the same list.

    +
  • +
+

delimiters need to be indented:

+
    +
  • +

    A list item with a blockquote:

    +
    +

    This is a blockquote +inside a list item.

    +
    +
  • +
+

To put a code block within a list item, the code block needs +to be indented twice -- 8 spaces or two tabs:

+
    +
  • A list item with a code block:
  • +
+

Code Blocks

+

Pre-formatted code blocks are used for writing about programming or +markup source code. Rather than forming normal paragraphs, the lines +of a code block are interpreted literally. Markdown wraps a code block

+

To produce a code block in Markdown, simply indent every line of the +block by at least 4 spaces or 1 tab.

+

This is a normal paragraph:

+
This is a code block.
+
+

Here is an example of AppleScript:

+
tell application "Foo"
+    beep
+end tell
+
+

A code block continues until it reaches a line that is not indented +(or the end of the article).

+

are automatically converted into HTML entities. This makes it very +easy to include example HTML source code using Markdown -- just paste +it and indent it, and Markdown will handle the hassle of encoding the +ampersands and angle brackets. For example, this:

+

Regular Markdown syntax is not processed within code blocks. E.g., +asterisks are just literal asterisks within a code block. This means +it's also easy to use Markdown to write about Markdown's own syntax.

+

Span Elements

+

Links

+

Markdown supports two style of links: inline and reference.

+

In both styles, the link text is delimited by [square brackets].

+

To create an inline link, use a set of regular parentheses immediately +after the link text's closing square bracket. Inside the parentheses, +put the URL where you want the link to point, along with an optional +title for the link, surrounded in quotes. For example:

+

This is an example inline link.

+

This link has no title attribute.

+

Emphasis

+

single asterisks

+

single underscores

+

double asterisks

+

double underscores

+

Code

+

Unlike a pre-formatted code block, a code span indicates code within a +normal paragraph. For example:

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/hr/dagre/board.exp.json b/e2etests/testdata/stable/hr/dagre/board.exp.json index 8afce2b2e..60aa0984b 100644 --- a/e2etests/testdata/stable/hr/dagre/board.exp.json +++ b/e2etests/testdata/stable/hr/dagre/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 45, + "x": 0, "y": 226 }, - "width": 23, - "height": 24, + "width": 738, + "height": 135, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL](/projects/markdown/syntax.text).\n\n---\n\n## Overview\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 738, + "labelHeight": 135, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 0, + "x": 313, "y": 0 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 0, - "y": 350 + "x": 313, + "y": 461 }, "width": 113, "height": 126, @@ -153,19 +152,19 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, + "x": 369, "y": 126 }, { - "x": 56.5, + "x": 369, "y": 166 }, { - "x": 56.5, + "x": 369, "y": 186 }, { - "x": 56.5, + "x": 369, "y": 226 } ], @@ -201,20 +200,20 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, - "y": 250 + "x": 369, + "y": 361 }, { - "x": 56.5, - "y": 290 + "x": 369, + "y": 401 }, { - "x": 56.5, - "y": 310 + "x": 369, + "y": 421 }, { - "x": 56.5, - "y": 350 + "x": 369, + "y": 461 } ], "isCurve": true, @@ -223,8 +222,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/hr/dagre/sketch.exp.svg b/e2etests/testdata/stable/hr/dagre/sketch.exp.svg index 45afbcef4..03841322b 100644 --- a/e2etests/testdata/stable/hr/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/hr/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-102 -102 317 680">

md

-
ab - +

Note: This document is itself written using Markdown; you +can see the source for it by adding '.text' to the URL.

+
+

Overview

+
ab +

md

-
ab - +

Note: This document is itself written using Markdown; you +can see the source for it by adding '.text' to the URL.

+
+

Overview

+
ab + mixed togethersugarsolution we get - - +mixed togethersugarsolution we get + + mixed togethersugarsolution we get - - +mixed togethersugarsolution we get + +

md

-
ab - +ab +

md

-
ab - +ab +

md

-
ab - +
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/li2/elk/board.exp.json b/e2etests/testdata/stable/li2/elk/board.exp.json index 378f076e0..4692b234c 100644 --- a/e2etests/testdata/stable/li2/elk/board.exp.json +++ b/e2etests/testdata/stable/li2/elk/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 57, + "x": 12, "y": 238 }, - "width": 23, - "height": 24, + "width": 245, + "height": 76, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "\n- [Overview](#overview) ok _this is all measured_\n\t- [Philosophy](#philosophy)\n\t- [Inline HTML](#html)\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 245, + "labelHeight": 76, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 12, + "x": 78, "y": 12 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 12, - "y": 362 + "x": 78, + "y": 414 }, "width": 113, "height": 126, @@ -153,11 +152,11 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, + "x": 134.5, "y": 138 }, { - "x": 68.5, + "x": 134.5, "y": 238 } ], @@ -192,12 +191,12 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, - "y": 262 + "x": 134.5, + "y": 314 }, { - "x": 68.5, - "y": 362 + "x": 134.5, + "y": 414 } ], "animated": false, @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/li2/elk/sketch.exp.svg b/e2etests/testdata/stable/li2/elk/sketch.exp.svg index 4ef05dfe3..ec6e37154 100644 --- a/e2etests/testdata/stable/li2/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/li2/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-90 -90 317 680">

md

-
ab - +
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/li3/dagre/board.exp.json b/e2etests/testdata/stable/li3/dagre/board.exp.json index 8afce2b2e..cf17e57c8 100644 --- a/e2etests/testdata/stable/li3/dagre/board.exp.json +++ b/e2etests/testdata/stable/li3/dagre/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 45, + "x": 0, "y": 226 }, - "width": 23, - "height": 24, + "width": 347, + "height": 512, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n - [Automatic Escaping for Special Characters](#autoescape)\n- [Block Elements](#block)\n - [Paragraphs and Line Breaks](#p)\n - [Headers](#header)\n - [Blockquotes](#blockquote)\n - [Lists](#list)\n - [Code Blocks](#precode)\n - [Horizontal Rules](#hr)\n- [Span Elements](#span)\n - [Links](#link)\n - [Emphasis](#em)\n - [Code](#code)\n - [Images](#img)\n- [Miscellaneous](#misc)\n - [Backslash Escapes](#backslash)\n - [Automatic Links](#autolink)\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 347, + "labelHeight": 512, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 0, + "x": 117, "y": 0 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 0, - "y": 350 + "x": 117, + "y": 838 }, "width": 113, "height": 126, @@ -153,19 +152,19 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, + "x": 173.5, "y": 126 }, { - "x": 56.5, + "x": 173.5, "y": 166 }, { - "x": 56.5, + "x": 173.5, "y": 186 }, { - "x": 56.5, + "x": 173.5, "y": 226 } ], @@ -201,20 +200,20 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, - "y": 250 + "x": 173.5, + "y": 738 }, { - "x": 56.5, - "y": 290 + "x": 173.5, + "y": 778 }, { - "x": 56.5, - "y": 310 + "x": 173.5, + "y": 798 }, { - "x": 56.5, - "y": 350 + "x": 173.5, + "y": 838 } ], "isCurve": true, @@ -223,8 +222,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/li3/dagre/sketch.exp.svg b/e2etests/testdata/stable/li3/dagre/sketch.exp.svg index 45afbcef4..79b6f3dc9 100644 --- a/e2etests/testdata/stable/li3/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/li3/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-102 -102 317 680">

md

-
ab - +ab +

md

-
ab - +ab +

md

-
ab - +

List items may consist of multiple paragraphs. Each subsequent +paragraph in a list item must be indented by either 4 spaces +or one tab:

+
    +
  1. +

    This is a list item with two paragraphs. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit. Aliquam hendrerit +mi posuere lectus.

    +

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet +vitae, risus. Donec sit amet nisl. Aliquam semper ipsum +sit amet velit.

    +
  2. +
  3. +

    Suspendisse id sem consectetuer libero luctus adipiscing.

    +
  4. +
+

It looks nice if you indent every line of the subsequent +paragraphs, but here again, Markdown will allow you to be +lazy:

+
    +
  • +

    This is a list item with two paragraphs.

    +
    This is the second paragraph in the list item. You're
    +
    +

    only required to indent the first line. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit.

    +
  • +
  • +

    Another item in the same list.

    +
  • +
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/li4/elk/board.exp.json b/e2etests/testdata/stable/li4/elk/board.exp.json index 378f076e0..8d7adee0f 100644 --- a/e2etests/testdata/stable/li4/elk/board.exp.json +++ b/e2etests/testdata/stable/li4/elk/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 57, + "x": 12, "y": 238 }, - "width": 23, - "height": 24, + "width": 920, + "height": 376, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be indented by either 4 spaces\nor one tab:\n\n1. This is a list item with two paragraphs. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n mi posuere lectus.\n\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n sit amet velit.\n\n2. Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIt looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:\n\n- This is a list item with two paragraphs.\n\n This is the second paragraph in the list item. You're\n\n only required to indent the first line. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit.\n\n- Another item in the same list.\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 920, + "labelHeight": 376, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 12, + "x": 415, "y": 12 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 12, - "y": 362 + "x": 415, + "y": 714 }, "width": 113, "height": 126, @@ -153,11 +152,11 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, + "x": 472, "y": 138 }, { - "x": 68.5, + "x": 472, "y": 238 } ], @@ -192,12 +191,12 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, - "y": 262 + "x": 472, + "y": 614 }, { - "x": 68.5, - "y": 362 + "x": 472, + "y": 714 } ], "animated": false, @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/li4/elk/sketch.exp.svg b/e2etests/testdata/stable/li4/elk/sketch.exp.svg index 4ef05dfe3..cf54ab731 100644 --- a/e2etests/testdata/stable/li4/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/li4/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-90 -90 317 680">

md

-
ab - +

List items may consist of multiple paragraphs. Each subsequent +paragraph in a list item must be indented by either 4 spaces +or one tab:

+
    +
  1. +

    This is a list item with two paragraphs. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit. Aliquam hendrerit +mi posuere lectus.

    +

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet +vitae, risus. Donec sit amet nisl. Aliquam semper ipsum +sit amet velit.

    +
  2. +
  3. +

    Suspendisse id sem consectetuer libero luctus adipiscing.

    +
  4. +
+

It looks nice if you indent every line of the subsequent +paragraphs, but here again, Markdown will allow you to be +lazy:

+
    +
  • +

    This is a list item with two paragraphs.

    +
    This is the second paragraph in the list item. You're
    +
    +

    only required to indent the first line. Lorem ipsum dolor +sit amet, consectetuer adipiscing elit.

    +
  • +
  • +

    Another item in the same list.

    +
  • +
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/links/dagre/board.exp.json b/e2etests/testdata/stable/links/dagre/board.exp.json index e2a1364d3..4738a11ec 100644 --- a/e2etests/testdata/stable/links/dagre/board.exp.json +++ b/e2etests/testdata/stable/links/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -135,8 +134,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/links/elk/board.exp.json b/e2etests/testdata/stable/links/elk/board.exp.json index 2cfe7e293..983132640 100644 --- a/e2etests/testdata/stable/links/elk/board.exp.json +++ b/e2etests/testdata/stable/links/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -126,8 +125,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/lone_h1/dagre/board.exp.json b/e2etests/testdata/stable/lone_h1/dagre/board.exp.json index 8afce2b2e..41a16bc39 100644 --- a/e2etests/testdata/stable/lone_h1/dagre/board.exp.json +++ b/e2etests/testdata/stable/lone_h1/dagre/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 45, + "x": 0, "y": 226 }, - "width": 23, - "height": 24, + "width": 266, + "height": 51, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "\n# Markdown: Syntax\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 266, + "labelHeight": 51, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 0, + "x": 77, "y": 0 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 0, - "y": 350 + "x": 77, + "y": 377 }, "width": 113, "height": 126, @@ -153,19 +152,19 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, + "x": 133, "y": 126 }, { - "x": 56.5, + "x": 133, "y": 166 }, { - "x": 56.5, + "x": 133, "y": 186 }, { - "x": 56.5, + "x": 133, "y": 226 } ], @@ -201,20 +200,20 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, - "y": 250 + "x": 133, + "y": 277 }, { - "x": 56.5, - "y": 290 + "x": 133, + "y": 317 }, { - "x": 56.5, - "y": 310 + "x": 133, + "y": 337 }, { - "x": 56.5, - "y": 350 + "x": 133, + "y": 377 } ], "isCurve": true, @@ -223,8 +222,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/lone_h1/dagre/sketch.exp.svg b/e2etests/testdata/stable/lone_h1/dagre/sketch.exp.svg index 45afbcef4..9cabf7c54 100644 --- a/e2etests/testdata/stable/lone_h1/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/lone_h1/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-102 -102 317 680">

md

-
ab - +

Markdown: Syntax

+
ab +

md

-
ab - +

Markdown: Syntax

+
ab +

hey

-
xy - +

Every frustum longs to be a cone

+
    +
  • A continuing flow of paper is sufficient to continue the flow of paper
  • +
  • Please remain calm, it's no use both of us being hysterical at the same time
  • +
  • Visits always give pleasure: if not on arrival, then on the departure
  • +
+

Festivity Level 1: Your guests are chatting amiably with each other.

+
xy + \ No newline at end of file diff --git a/e2etests/testdata/stable/markdown/elk/board.exp.json b/e2etests/testdata/stable/markdown/elk/board.exp.json index 3bde502bb..3bfc5104e 100644 --- a/e2etests/testdata/stable/markdown/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown/elk/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", "type": "text", "pos": { - "x": 56, + "x": 12, "y": 238 }, - "width": 25, - "height": 24, + "width": 531, + "height": 187, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "hey", + "label": "# Every frustum longs to be a cone\n\n- A continuing flow of paper is sufficient to continue the flow of paper\n- Please remain calm, it's no use both of us being hysterical at the same time\n- Visits always give pleasure: if not on arrival, then on the departure\n\n*Festivity Level 1*: Your guests are chatting amiably with each other.", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 25, - "labelHeight": 24, + "labelWidth": 531, + "labelHeight": 187, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "x", "type": "rectangle", "pos": { - "x": 12, + "x": 221, "y": 12 }, "width": 113, @@ -88,8 +87,8 @@ "id": "y", "type": "rectangle", "pos": { - "x": 12, - "y": 362 + "x": 220, + "y": 525 }, "width": 114, "height": 126, @@ -153,11 +152,11 @@ "labelPercentage": 0, "route": [ { - "x": 69, + "x": 277.5, "y": 138 }, { - "x": 69, + "x": 277.5, "y": 238 } ], @@ -192,12 +191,12 @@ "labelPercentage": 0, "route": [ { - "x": 69, - "y": 262 + "x": 277.5, + "y": 425 }, { - "x": 69, - "y": 362 + "x": 277.5, + "y": 525 } ], "animated": false, @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/markdown/elk/sketch.exp.svg b/e2etests/testdata/stable/markdown/elk/sketch.exp.svg index 43a84f23d..b4afb768e 100644 --- a/e2etests/testdata/stable/markdown/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="318" height="680" viewBox="-90 -90 318 680">

hey

-
xy - +

Every frustum longs to be a cone

+
    +
  • A continuing flow of paper is sufficient to continue the flow of paper
  • +
  • Please remain calm, it's no use both of us being hysterical at the same time
  • +
  • Visits always give pleasure: if not on arrival, then on the departure
  • +
+

Festivity Level 1: Your guests are chatting amiably with each other.

+
xy + \ No newline at end of file diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json index a401deeef..0a26c1fba 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -10,8 +9,8 @@ "x": 0, "y": 0 }, - "width": 141, - "height": 124, + "width": 312, + "height": 358, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -48,11 +47,11 @@ "id": "container.md", "type": "text", "pos": { - "x": 69, + "x": 50, "y": 50 }, - "width": 23, - "height": 24, + "width": 212, + "height": 258, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -71,7 +70,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "# a header\n\na line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n\nwalk into a bar.", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -79,8 +78,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 212, + "labelHeight": 258, "zIndex": 0, "level": 2 }, @@ -88,10 +87,10 @@ "id": "no container", "type": "text", "pos": { - "x": 37, - "y": 224 + "x": 97, + "y": 458 }, - "width": 86, + "width": 118, "height": 24, "opacity": 1, "strokeDash": 0, @@ -111,7 +110,7 @@ "fields": null, "methods": null, "columns": null, - "label": "no container", + "label": "they did it in style", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -119,7 +118,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 86, + "labelWidth": 118, "labelHeight": 24, "zIndex": 0, "level": 1 @@ -152,20 +151,20 @@ "labelPercentage": 0, "route": [ { - "x": 80, - "y": 124 + "x": 156, + "y": 358 }, { - "x": 80, - "y": 164 + "x": 156, + "y": 398 }, { - "x": 80, - "y": 184 + "x": 156, + "y": 418 }, { - "x": 80, - "y": 224 + "x": 156, + "y": 458 } ], "isCurve": true, @@ -174,8 +173,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg index 12a5a579b..9199fb0e5 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="345" height="452" viewBox="-102 -102 345 452">container

no container

-

md

-
- +container

they did it in style

+

a header

+

a line of text and an

+
{
+	indented: "block",
+	of: "json",
+}
+
+

walk into a bar.

+
+ \ No newline at end of file diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json index 9a8c454f7..483787536 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -10,8 +9,8 @@ "x": 12, "y": 12 }, - "width": 173, - "height": 174, + "width": 362, + "height": 408, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -51,8 +50,8 @@ "x": 87, "y": 87 }, - "width": 23, - "height": 24, + "width": 212, + "height": 258, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -71,7 +70,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "# a header\n\na line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n\nwalk into a bar.", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -79,8 +78,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 212, + "labelHeight": 258, "zIndex": 0, "level": 2 }, @@ -88,10 +87,10 @@ "id": "no container", "type": "text", "pos": { - "x": 55, - "y": 286 + "x": 134, + "y": 520 }, - "width": 86, + "width": 118, "height": 24, "opacity": 1, "strokeDash": 0, @@ -111,7 +110,7 @@ "fields": null, "methods": null, "columns": null, - "label": "no container", + "label": "they did it in style", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -119,7 +118,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 86, + "labelWidth": 118, "labelHeight": 24, "zIndex": 0, "level": 1 @@ -152,12 +151,12 @@ "labelPercentage": 0, "route": [ { - "x": 98.5, - "y": 186 + "x": 193, + "y": 420 }, { - "x": 98.5, - "y": 286 + "x": 193, + "y": 520 } ], "animated": false, @@ -165,8 +164,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg index 2b5c0bdc4..47a616313 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="377" height="502" viewBox="-90 -90 377 502">container

no container

-

md

-
- +container

they did it in style

+

a header

+

a line of text and an

+
{
+	indented: "block",
+	of: "json",
+}
+
+

walk into a bar.

+
+ \ No newline at end of file diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json index 5e6f08b8e..ca068a175 100644 --- a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -10,8 +9,8 @@ "x": 0, "y": 0 }, - "width": 123, - "height": 124, + "width": 559, + "height": 148, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -51,8 +50,8 @@ "x": 50, "y": 50 }, - "width": 23, - "height": 24, + "width": 459, + "height": 48, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -71,7 +70,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -79,14 +78,11 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 459, + "labelHeight": 48, "zIndex": 0, "level": 2 } ], - "connections": [], - "layers": null, - "scenarios": null, - "steps": null + "connections": [] } diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg index f9a7778c1..36ed07dc8 100644 --- a/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="327" height="328" viewBox="-102 -102 327 328">markdown

md

-
- +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
+ markdown

md

-
- +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
+ markdown

md

-
- +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
+ markdown

md

-
- +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
+

md

-
ab - +
{
+	fenced: "block",
+	of: "json",
+}
+
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json index 378f076e0..eb626481e 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 57, + "x": 12, "y": 238 }, - "width": 23, - "height": 24, + "width": 196, + "height": 111, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "```\n{\n\tfenced: \"block\",\n\tof: \"json\",\n}\n```", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 196, + "labelHeight": 111, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 12, + "x": 53, "y": 12 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 12, - "y": 362 + "x": 53, + "y": 449 }, "width": 113, "height": 126, @@ -153,11 +152,11 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, + "x": 110, "y": 138 }, { - "x": 68.5, + "x": 110, "y": 238 } ], @@ -192,12 +191,12 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, - "y": 262 + "x": 110, + "y": 349 }, { - "x": 68.5, - "y": 362 + "x": 110, + "y": 449 } ], "animated": false, @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg b/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg index 4ef05dfe3..be99778e5 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-90 -90 317 680">

md

-
ab - +
{
+	fenced: "block",
+	of: "json",
+}
+
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json index 8afce2b2e..0223e1d15 100644 --- a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 45, + "x": 0, "y": 226 }, - "width": 23, - "height": 24, + "width": 212, + "height": 151, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "a line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 212, + "labelHeight": 151, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 0, + "x": 50, "y": 0 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 0, - "y": 350 + "x": 50, + "y": 477 }, "width": 113, "height": 126, @@ -153,19 +152,19 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, + "x": 106, "y": 126 }, { - "x": 56.5, + "x": 106, "y": 166 }, { - "x": 56.5, + "x": 106, "y": 186 }, { - "x": 56.5, + "x": 106, "y": 226 } ], @@ -201,20 +200,20 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, - "y": 250 + "x": 106, + "y": 377 }, { - "x": 56.5, - "y": 290 + "x": 106, + "y": 417 }, { - "x": 56.5, - "y": 310 + "x": 106, + "y": 437 }, { - "x": 56.5, - "y": 350 + "x": 106, + "y": 477 } ], "isCurve": true, @@ -223,8 +222,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg index 45afbcef4..df307133b 100644 --- a/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_block_indented/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-102 -102 317 680">

md

-
ab - +

a line of text and an

+
{
+	indented: "block",
+	of: "json",
+}
+
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json index 378f076e0..e105f60d9 100644 --- a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 57, + "x": 12, "y": 238 }, - "width": 23, - "height": 24, + "width": 212, + "height": 151, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "a line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 212, + "labelHeight": 151, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 12, + "x": 61, "y": 12 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 12, - "y": 362 + "x": 61, + "y": 489 }, "width": 113, "height": 126, @@ -153,11 +152,11 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, + "x": 118, "y": 138 }, { - "x": 68.5, + "x": 118, "y": 238 } ], @@ -192,12 +191,12 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, - "y": 262 + "x": 118, + "y": 389 }, { - "x": 68.5, - "y": 362 + "x": 118, + "y": 489 } ], "animated": false, @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg b/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg index 4ef05dfe3..72e9523a3 100644 --- a/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_block_indented/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-90 -90 317 680">

md

-
ab - +

a line of text and an

+
{
+	indented: "block",
+	of: "json",
+}
+
+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json index 8afce2b2e..a9a1beafd 100644 --- a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json @@ -1,16 +1,15 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 45, + "x": 34, "y": 226 }, - "width": 23, + "width": 46, "height": 24, "opacity": 1, "strokeDash": 0, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "`code`", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,7 +37,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, + "labelWidth": 46, "labelHeight": 24, "zIndex": 0, "level": 1 @@ -223,8 +222,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg index 45afbcef4..822843aa7 100644 --- a/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg @@ -796,8 +796,8 @@ width="317" height="680" viewBox="-102 -102 317 680">

md

-
ab +

code

+
ab \ No newline at end of file diff --git a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json index 378f076e0..e5e6c9f3a 100644 --- a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json @@ -1,16 +1,15 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 57, + "x": 45, "y": 238 }, - "width": 23, + "width": 46, "height": 24, "opacity": 1, "strokeDash": 0, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "`code`", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,7 +37,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, + "labelWidth": 46, "labelHeight": 24, "zIndex": 0, "level": 1 @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg b/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg index 4ef05dfe3..b6f5cec53 100644 --- a/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg @@ -796,8 +796,8 @@ width="317" height="680" viewBox="-90 -90 317 680">

md

-
ab +

code

+
ab \ No newline at end of file diff --git a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json index 9082b7e6f..e0a5a882b 100644 --- a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json +++ b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -45,8 +44,5 @@ "level": 1 } ], - "connections": [], - "layers": null, - "scenarios": null, - "steps": null + "connections": [] } diff --git a/e2etests/testdata/stable/multiline_text/elk/board.exp.json b/e2etests/testdata/stable/multiline_text/elk/board.exp.json index 1d8fb4a00..01651f58b 100644 --- a/e2etests/testdata/stable/multiline_text/elk/board.exp.json +++ b/e2etests/testdata/stable/multiline_text/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -45,8 +44,5 @@ "level": 1 } ], - "connections": [], - "layers": null, - "scenarios": null, - "steps": null + "connections": [] } diff --git a/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json b/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json index 96e4417e2..df1eabf42 100644 --- a/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json +++ b/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2004,8 +2003,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/multiple_trees/elk/board.exp.json b/e2etests/testdata/stable/multiple_trees/elk/board.exp.json index f78ee4924..13b9ed5d3 100644 --- a/e2etests/testdata/stable/multiple_trees/elk/board.exp.json +++ b/e2etests/testdata/stable/multiple_trees/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -1902,8 +1901,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/n22_e32/dagre/board.exp.json b/e2etests/testdata/stable/n22_e32/dagre/board.exp.json index 76efda9d6..62f4088a9 100644 --- a/e2etests/testdata/stable/n22_e32/dagre/board.exp.json +++ b/e2etests/testdata/stable/n22_e32/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2834,8 +2833,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/n22_e32/elk/board.exp.json b/e2etests/testdata/stable/n22_e32/elk/board.exp.json index 0025e5463..0302d0591 100644 --- a/e2etests/testdata/stable/n22_e32/elk/board.exp.json +++ b/e2etests/testdata/stable/n22_e32/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -2337,8 +2336,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/near-alone/dagre/board.exp.json b/e2etests/testdata/stable/near-alone/dagre/board.exp.json index 7ee1feda1..4b51e2d28 100644 --- a/e2etests/testdata/stable/near-alone/dagre/board.exp.json +++ b/e2etests/testdata/stable/near-alone/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -127,8 +126,5 @@ "level": 1 } ], - "connections": [], - "layers": null, - "scenarios": null, - "steps": null + "connections": [] } diff --git a/e2etests/testdata/stable/near-alone/elk/board.exp.json b/e2etests/testdata/stable/near-alone/elk/board.exp.json index 7ee1feda1..4b51e2d28 100644 --- a/e2etests/testdata/stable/near-alone/elk/board.exp.json +++ b/e2etests/testdata/stable/near-alone/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -127,8 +126,5 @@ "level": 1 } ], - "connections": [], - "layers": null, - "scenarios": null, - "steps": null + "connections": [] } diff --git a/e2etests/testdata/stable/number_connections/dagre/board.exp.json b/e2etests/testdata/stable/number_connections/dagre/board.exp.json index 5ab288a9c..02e7c249c 100644 --- a/e2etests/testdata/stable/number_connections/dagre/board.exp.json +++ b/e2etests/testdata/stable/number_connections/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -265,8 +264,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/number_connections/elk/board.exp.json b/e2etests/testdata/stable/number_connections/elk/board.exp.json index 37ffafb60..1beabe14c 100644 --- a/e2etests/testdata/stable/number_connections/elk/board.exp.json +++ b/e2etests/testdata/stable/number_connections/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -247,8 +246,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json b/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json index b1c4e4696..f294ce8c1 100644 --- a/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json +++ b/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -777,8 +776,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/one_container_loop/elk/board.exp.json b/e2etests/testdata/stable/one_container_loop/elk/board.exp.json index 24fea15c7..3c2ccd4c9 100644 --- a/e2etests/testdata/stable/one_container_loop/elk/board.exp.json +++ b/e2etests/testdata/stable/one_container_loop/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -638,8 +637,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json b/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json index c5a13cebf..5087b5bc6 100644 --- a/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json +++ b/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -580,8 +579,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json b/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json index 6fce66453..25474845d 100644 --- a/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json +++ b/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -558,8 +557,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json b/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json index be13cdf30..8eaefec77 100644 --- a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json +++ b/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -962,8 +961,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json index 32fa96ac3..cfb6d70a0 100644 --- a/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json +++ b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -939,8 +938,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/p/dagre/board.exp.json b/e2etests/testdata/stable/p/dagre/board.exp.json index 8afce2b2e..ced611d99 100644 --- a/e2etests/testdata/stable/p/dagre/board.exp.json +++ b/e2etests/testdata/stable/p/dagre/board.exp.json @@ -1,16 +1,15 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 45, + "x": 0, "y": 226 }, - "width": 23, + "width": 1857, "height": 24, "opacity": 1, "strokeDash": 0, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "\nA paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing but spaces or tabs is considered\nblank.) Normal paragraphs should not be indented with spaces or tabs.\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,7 +37,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, + "labelWidth": 1857, "labelHeight": 24, "zIndex": 0, "level": 1 @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 0, + "x": 872, "y": 0 }, "width": 113, @@ -88,7 +87,7 @@ "id": "b", "type": "rectangle", "pos": { - "x": 0, + "x": 872, "y": 350 }, "width": 113, @@ -153,19 +152,19 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, + "x": 928.5, "y": 126 }, { - "x": 56.5, + "x": 928.5, "y": 166 }, { - "x": 56.5, + "x": 928.5, "y": 186 }, { - "x": 56.5, + "x": 928.5, "y": 226 } ], @@ -201,19 +200,19 @@ "labelPercentage": 0, "route": [ { - "x": 56.5, + "x": 928.5, "y": 250 }, { - "x": 56.5, + "x": 928.5, "y": 290 }, { - "x": 56.5, + "x": 928.5, "y": 310 }, { - "x": 56.5, + "x": 928.5, "y": 350 } ], @@ -223,8 +222,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/p/dagre/sketch.exp.svg b/e2etests/testdata/stable/p/dagre/sketch.exp.svg index 45afbcef4..4ea52597b 100644 --- a/e2etests/testdata/stable/p/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/p/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-102 -102 317 680">

md

-
ab - +

A paragraph is simply one or more consecutive lines of text, separated +by one or more blank lines. (A blank line is any line that looks like a +blank line -- a line containing nothing but spaces or tabs is considered +blank.) Normal paragraphs should not be indented with spaces or tabs.

+
ab +

md

-
ab - +

A paragraph is simply one or more consecutive lines of text, separated +by one or more blank lines. (A blank line is any line that looks like a +blank line -- a line containing nothing but spaces or tabs is considered +blank.) Normal paragraphs should not be indented with spaces or tabs.

+
ab +

md

-
ab - +

Here is an example of AppleScript:

+
tell application "Foo"
+    beep
+end tell
+
+

A code block continues until it reaches a line that is not indented +(or the end of the article).

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/pre/elk/board.exp.json b/e2etests/testdata/stable/pre/elk/board.exp.json index 378f076e0..19f4e87c2 100644 --- a/e2etests/testdata/stable/pre/elk/board.exp.json +++ b/e2etests/testdata/stable/pre/elk/board.exp.json @@ -1,17 +1,16 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", "type": "text", "pos": { - "x": 57, + "x": 12, "y": 238 }, - "width": 23, - "height": 24, + "width": 602, + "height": 170, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +29,7 @@ "fields": null, "methods": null, "columns": null, - "label": "md", + "label": "\nHere is an example of AppleScript:\n\n tell application \"Foo\"\n beep\n end tell\n\nA code block continues until it reaches a line that is not indented\n(or the end of the article).\n", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -38,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 23, - "labelHeight": 24, + "labelWidth": 602, + "labelHeight": 170, "zIndex": 0, "level": 1 }, @@ -47,7 +46,7 @@ "id": "a", "type": "rectangle", "pos": { - "x": 12, + "x": 256, "y": 12 }, "width": 113, @@ -88,8 +87,8 @@ "id": "b", "type": "rectangle", "pos": { - "x": 12, - "y": 362 + "x": 256, + "y": 508 }, "width": 113, "height": 126, @@ -153,11 +152,11 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, + "x": 313, "y": 138 }, { - "x": 68.5, + "x": 313, "y": 238 } ], @@ -192,12 +191,12 @@ "labelPercentage": 0, "route": [ { - "x": 68.5, - "y": 262 + "x": 313, + "y": 408 }, { - "x": 68.5, - "y": 362 + "x": 313, + "y": 508 } ], "animated": false, @@ -205,8 +204,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/pre/elk/sketch.exp.svg b/e2etests/testdata/stable/pre/elk/sketch.exp.svg index 4ef05dfe3..b7c2f8e1d 100644 --- a/e2etests/testdata/stable/pre/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/pre/elk/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="317" height="680" viewBox="-90 -90 317 680">

md

-
ab - +

Here is an example of AppleScript:

+
tell application "Foo"
+    beep
+end tell
+
+

A code block continues until it reaches a line that is not indented +(or the end of the article).

+
ab + \ No newline at end of file diff --git a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json index 7ace108ad..e160e1cf3 100644 --- a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json +++ b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -476,8 +475,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/self-referencing/elk/board.exp.json b/e2etests/testdata/stable/self-referencing/elk/board.exp.json index 573aa1eb6..86753ffd9 100644 --- a/e2etests/testdata/stable/self-referencing/elk/board.exp.json +++ b/e2etests/testdata/stable/self-referencing/elk/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -355,8 +354,5 @@ "icon": null, "zIndex": 0 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json b/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json index 3c820f916..4339763f8 100644 --- a/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence-inter-span-self/dagre/board.exp.json @@ -1,6 +1,5 @@ { "name": "", - "type": "", "fontFamily": "SourceSansPro", "shapes": [ { @@ -89,10 +88,10 @@ "type": "rectangle", "pos": { "x": 93, - "y": 394 + "y": 524 }, "width": 12, - "height": 212, + "height": 82, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -194,19 +193,19 @@ "route": [ { "x": 105, - "y": 330 + "y": 460 }, { "x": 199, - "y": 330 + "y": 460 }, { "x": 199, - "y": 410 + "y": 540 }, { "x": 105, - "y": 410 + "y": 540 } ], "animated": false, @@ -241,11 +240,11 @@ "route": [ { "x": 105, - "y": 460 + "y": 330 }, { "x": 349, - "y": 460 + "y": 330 } ], "animated": false, @@ -291,87 +290,6 @@ "tooltip": "", "icon": null, "zIndex": 4 - }, - { - "id": "(a -- )[0]", - "src": "a", - "srcArrow": "none", - "srcLabel": "", - "dst": "a-lifeline-end-2251863791", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 99, - "y": 200 - }, - { - "x": 99, - "y": 720 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 - }, - { - "id": "(b -- )[0]", - "src": "b", - "srcArrow": "none", - "srcLabel": "", - "dst": "b-lifeline-end-668380428", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 349, - "y": 200 - }, - { - "x": 349, - "y": 720 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 } - ], - "layers": null, - "scenarios": null, - "steps": null + ] } diff --git a/e2etests/testdata/stable/sequence-inter-span-self/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence-inter-span-self/dagre/sketch.exp.svg index 033d298b0..67011eaf3 100644 --- a/e2etests/testdata/stable/sequence-inter-span-self/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence-inter-span-self/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="604" height="848" viewBox="-78 -28 604 848">xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + Office chatterAliceBobbyawkward small talk uhm, hioh, hellowhat did you have for lunch?that's personalok + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/board.exp.json new file mode 100644 index 000000000..42dba2171 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/board.exp.json @@ -0,0 +1,606 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "Office chatter", + "type": "sequence_diagram", + "pos": { + "x": 12, + "y": 12 + }, + "width": 741, + "height": 1166, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Office chatter", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 164, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Office chatter.alice", + "type": "rectangle", + "pos": { + "x": 36, + "y": 122 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Alice", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Office chatter.bob", + "type": "rectangle", + "pos": { + "x": 286, + "y": 122 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Bobby", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Office chatter.awkward small talk", + "type": "rectangle", + "pos": { + "x": 494, + "y": 122 + }, + "width": 235, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "awkward small talk", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 135, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Office chatter.awkward small talk.awkward small talk", + "type": "rectangle", + "pos": { + "x": 605, + "y": 362 + }, + "width": 12, + "height": 158, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 135, + "labelHeight": 26, + "zIndex": 2, + "level": 3 + }, + { + "id": "Office chatter.awkward small talk.awkward small talk.ok", + "type": "page", + "pos": { + "x": 550, + "y": 378 + }, + "width": 122, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "ok", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 22, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 5, + "level": 4 + }, + { + "id": "Office chatter.awkward small talk.icebreaker attempt", + "type": "rectangle", + "pos": { + "x": 605, + "y": -9223372036854775808 + }, + "width": 12, + "height": 80, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 134, + "labelHeight": 26, + "zIndex": 2, + "level": 3 + }, + { + "id": "Office chatter.awkward small talk.unfortunate outcome", + "type": "rectangle", + "pos": { + "x": 605, + "y": -9223372036854775808 + }, + "width": 12, + "height": 80, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 148, + "labelHeight": 26, + "zIndex": 2, + "level": 3 + } + ], + "connections": [ + { + "id": "Office chatter.(alice -> bob)[1]", + "src": "Office chatter.alice", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.bob", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "uhm, hi", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 50, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 634 + }, + { + "x": 361, + "y": 634 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "Office chatter.(bob -> alice)[1]", + "src": "Office chatter.bob", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.alice", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "oh, hello", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 56, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 361, + "y": 764 + }, + { + "x": 111, + "y": 764 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "Office chatter.(alice -> bob)[0]", + "src": "Office chatter.alice", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.bob", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "what did you have for lunch?", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 187, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 894 + }, + { + "x": 361, + "y": 894 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "Office chatter.(bob -> alice)[0]", + "src": "Office chatter.bob", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.alice", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "that's personal", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 99, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 361, + "y": 1024 + }, + { + "x": 111, + "y": 1024 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(Office chatter.alice -- )[0]", + "src": "Office chatter.alice", + "srcArrow": "none", + "srcLabel": "", + "dst": "alice-lifeline-end-3851299086", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 248 + }, + { + "x": 111, + "y": 1154 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(Office chatter.bob -- )[0]", + "src": "Office chatter.bob", + "srcArrow": "none", + "srcLabel": "", + "dst": "bob-lifeline-end-3036726343", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 361, + "y": 248 + }, + { + "x": 361, + "y": 1154 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(Office chatter.awkward small talk -- )[0]", + "src": "Office chatter.awkward small talk", + "srcArrow": "none", + "srcLabel": "", + "dst": "awkward small talk-lifeline-end-861194358", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 611.5, + "y": 248 + }, + { + "x": 611.5, + "y": 1154 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/sketch.exp.svg new file mode 100644 index 000000000..4f4934866 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/sketch.exp.svg @@ -0,0 +1,62 @@ + +Office chatterAliceBobbyawkward small talk uhm, hioh, hellowhat did you have for lunch?that's personalok + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/board.exp.json index 8e59a4826..3f9dcd83c 100644 --- a/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/board.exp.json @@ -248,14 +248,54 @@ "zIndex": 3, "level": 1 }, + { + "id": "a.a", + "type": "rectangle", + "pos": { + "x": 93, + "y": 734 + }, + "width": 12, + "height": 162, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "zIndex": 2, + "level": 2 + }, { "id": "group 4", "type": "rectangle", "pos": { - "x": 49, + "x": 55, "y": 840 }, - "width": 350, + "width": 344, "height": 80, "opacity": 1, "strokeDash": 0, @@ -665,11 +705,11 @@ "zIndex": 4 }, { - "id": "(a -> a)[1]", + "id": "(a -> a.a)[0]", "src": "a", "srcArrow": "none", "srcLabel": "", - "dst": "a", + "dst": "a.a", "dstArrow": "triangle", "dstLabel": "", "opacity": 1, @@ -702,7 +742,7 @@ "y": 750 }, { - "x": 99, + "x": 105, "y": 750 } ], @@ -712,8 +752,8 @@ "zIndex": 4 }, { - "id": "(a -> b)[1]", - "src": "a", + "id": "(a.a -> b)[0]", + "src": "a.a", "srcArrow": "none", "srcLabel": "", "dst": "b", @@ -737,7 +777,7 @@ "labelPercentage": 0, "route": [ { - "x": 99, + "x": 105, "y": 880 }, { @@ -883,6 +923,53 @@ "icon": null, "zIndex": 4 }, + { + "id": "(a -> a)[1]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 1480 + }, + { + "x": 199, + "y": 1480 + }, + { + "x": 199, + "y": 1560 + }, + { + "x": 99, + "y": 1560 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, { "id": "(a -> a)[2]", "src": "a", @@ -907,53 +994,6 @@ "labelHeight": 0, "labelPosition": "", "labelPercentage": 0, - "route": [ - { - "x": 99, - "y": 1480 - }, - { - "x": 199, - "y": 1480 - }, - { - "x": 199, - "y": 1560 - }, - { - "x": 99, - "y": 1560 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 4 - }, - { - "id": "(a -> a)[3]", - "src": "a", - "srcArrow": "none", - "srcLabel": "", - "dst": "a", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, "route": [ { "x": 99, @@ -977,53 +1017,6 @@ "icon": null, "zIndex": 4 }, - { - "id": "(a -> a)[5]", - "src": "a", - "srcArrow": "none", - "srcLabel": "", - "dst": "a", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 99, - "y": 1900 - }, - { - "x": 199, - "y": 1900 - }, - { - "x": 199, - "y": 1980 - }, - { - "x": 99, - "y": 1980 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 4 - }, { "id": "(a -> a)[4]", "src": "a", @@ -1048,6 +1041,53 @@ "labelHeight": 0, "labelPosition": "", "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 1900 + }, + { + "x": 199, + "y": 1900 + }, + { + "x": 199, + "y": 1980 + }, + { + "x": 99, + "y": 1980 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(a -> a)[3]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, "route": [ { "x": 99, @@ -1072,7 +1112,7 @@ "zIndex": 4 }, { - "id": "(a -> a)[6]", + "id": "(a -> a)[5]", "src": "a", "srcArrow": "none", "srcLabel": "", diff --git a/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/sketch.exp.svg index f2bfc06d5..b9a9742f1 100644 --- a/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/sequence_diagram_self_edge_group_overlap/dagre/sketch.exp.svg @@ -39,12 +39,12 @@ width="927" height="3388" viewBox="-78 -28 927 3388">Office chatterAliceBobbyawkward small talkicebreaker attemptunfortunate outcome uhm, hioh, hellowhat did you have for lunch?that's personal + + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/todo/sequence_diagram_edge_group_span_field/elk/board.exp.json b/e2etests/testdata/todo/sequence_diagram_edge_group_span_field/elk/board.exp.json new file mode 100644 index 000000000..4069e2c56 --- /dev/null +++ b/e2etests/testdata/todo/sequence_diagram_edge_group_span_field/elk/board.exp.json @@ -0,0 +1,568 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "Office chatter", + "type": "sequence_diagram", + "pos": { + "x": 12, + "y": 12 + }, + "width": 448, + "height": 910, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Office chatter", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 164, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Office chatter.alice", + "type": "rectangle", + "pos": { + "x": 36, + "y": 122 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Alice", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Office chatter.alice.a", + "type": "rectangle", + "pos": { + "x": 105, + "y": 752 + }, + "width": 12, + "height": 80, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "zIndex": 2, + "level": 3 + }, + { + "id": "Office chatter.bob", + "type": "rectangle", + "pos": { + "x": 286, + "y": 122 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Bobby", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "Office chatter.awkward small talk", + "type": "rectangle", + "pos": { + "x": 37, + "y": 338 + }, + "width": 398, + "height": 494, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "awkward small talk", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 135, + "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, + "level": 2 + }, + { + "id": "Office chatter.awkward small talk.icebreaker attempt", + "type": "rectangle", + "pos": { + "x": 61, + "y": 598 + }, + "width": 350, + "height": 80, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "icebreaker attempt", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 134, + "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, + "level": 3 + }, + { + "id": "Office chatter.awkward small talk.unfortunate outcome", + "type": "rectangle", + "pos": { + "x": 67, + "y": 728 + }, + "width": 338, + "height": 80, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "unfortunate outcome", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 148, + "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, + "level": 3 + }, + { + "id": "Office chatter.bob.a", + "type": "rectangle", + "pos": { + "x": 355, + "y": 752 + }, + "width": 12, + "height": 80, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "zIndex": 2, + "level": 3 + } + ], + "connections": [ + { + "id": "Office chatter.(alice -> bob)[1]", + "src": "Office chatter.alice", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.bob", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "uhm, hi", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 50, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 378 + }, + { + "x": 361, + "y": 378 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "Office chatter.(bob -> alice)[0]", + "src": "Office chatter.bob", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.alice", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "oh, hello", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 56, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 361, + "y": 508 + }, + { + "x": 111, + "y": 508 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "Office chatter.(alice -> bob)[0]", + "src": "Office chatter.alice", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.bob", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "what did you have for lunch?", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 187, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 638 + }, + { + "x": 361, + "y": 638 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "Office chatter.(bob.a -> alice.a)[0]", + "src": "Office chatter.bob.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "Office chatter.alice.a", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "that's personal", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 99, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 355, + "y": 768 + }, + { + "x": 117, + "y": 768 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(Office chatter.alice -- )[0]", + "src": "Office chatter.alice", + "srcArrow": "none", + "srcLabel": "", + "dst": "alice-lifeline-end-3851299086", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 248 + }, + { + "x": 111, + "y": 898 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(Office chatter.bob -- )[0]", + "src": "Office chatter.bob", + "srcArrow": "none", + "srcLabel": "", + "dst": "bob-lifeline-end-3036726343", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 361, + "y": 248 + }, + { + "x": 361, + "y": 898 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/todo/sequence_diagram_edge_group_span_field/elk/sketch.exp.svg b/e2etests/testdata/todo/sequence_diagram_edge_group_span_field/elk/sketch.exp.svg new file mode 100644 index 000000000..f7cd08e57 --- /dev/null +++ b/e2etests/testdata/todo/sequence_diagram_edge_group_span_field/elk/sketch.exp.svg @@ -0,0 +1,65 @@ + +Office chatterAliceBobbyawkward small talkicebreaker attemptunfortunate outcome uhm, hioh, hellowhat did you have for lunch?that's personal + + + + + + + + + \ No newline at end of file diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index d70d98367..3fbf45e67 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -197,6 +197,28 @@ small code: |go width: 4 height: 3 } +`, + }, + { + // issue https://github.com/terrastruct/d2/issues/748 + name: "sequence_diagram_edge_group_span_field", + script: ` +Office chatter: { + shape: sequence_diagram + alice: Alice + bob: Bobby + alice.a + awkward small talk: { + alice -> bob: uhm, hi + bob -> alice: oh, hello + icebreaker attempt: { + alice -> bob: what did you have for lunch? + } + unfortunate outcome: { + bob.a -> alice.a: that's personal + } + } +} `, }, } diff --git a/testdata/d2compiler/TestCompile2/seqdiagrams/errs/sequence_diagram_edge_between_edge_groups.exp.json b/testdata/d2compiler/TestCompile2/seqdiagrams/errs/sequence_diagram_edge_between_edge_groups.exp.json new file mode 100644 index 000000000..f828ca6c3 --- /dev/null +++ b/testdata/d2compiler/TestCompile2/seqdiagrams/errs/sequence_diagram_edge_between_edge_groups.exp.json @@ -0,0 +1,12 @@ +{ + "graph": null, + "err": { + "ioerr": null, + "errs": [ + { + "range": "d2/testdata/d2compiler/TestCompile2/seqdiagrams/errs/sequence_diagram_edge_between_edge_groups.d2,15:2:307-15:91:396", + "errmsg": "d2/testdata/d2compiler/TestCompile2/seqdiagrams/errs/sequence_diagram_edge_between_edge_groups.d2:16:3: edges between edge groups are not allowed" + } + ] + } +} From f3786ba5ec80ee1a09b254e80cbdbf0c0b6b3fe0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 2 Feb 2023 10:48:28 -0800 Subject: [PATCH 55/60] e2etests: Fix --- ci/e2ereport.sh | 2 +- e2etests/e2e_test.go | 15 ++++----------- e2etests/report/main.go | 27 +++++++++++++++------------ 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/ci/e2ereport.sh b/ci/e2ereport.sh index ebf45b912..02500ac58 100755 --- a/ci/e2ereport.sh +++ b/ci/e2ereport.sh @@ -1,7 +1,7 @@ #!/bin/sh set -eu -export REPORT_OUTPUT="out/e2e_report.html" +export REPORT_OUTPUT="./e2etests/out/e2e_report.html" rm -f $REPORT_OUTPUT export E2E_REPORT=1 diff --git a/e2etests/e2e_test.go b/e2etests/e2e_test.go index 749c22d22..b1ac13cc8 100644 --- a/e2etests/e2e_test.go +++ b/e2etests/e2e_test.go @@ -167,26 +167,19 @@ func run(t *testing.T, tc testCase) { assert.Success(t, err) err = ioutil.WriteFile(pathGotSVG, svgBytes, 0600) assert.Success(t, err) - // if running from e2ereport.sh, we want to keep .got.svg on a failure - forReport := os.Getenv("E2E_REPORT") != "" - if !forReport { - defer os.Remove(pathGotSVG) - } // Check that it's valid SVG var xmlParsed interface{} err = xml.Unmarshal(svgBytes, &xmlParsed) assert.Success(t, err) + var err2 error err = diff.TestdataJSON(filepath.Join(dataPath, "board"), diagram) - assert.Success(t, err) if os.Getenv("SKIP_SVG_CHECK") == "" { - err = diff.Testdata(filepath.Join(dataPath, "sketch"), ".svg", svgBytes) - assert.Success(t, err) - } - if forReport { - os.Remove(pathGotSVG) + err2 = diff.Testdata(filepath.Join(dataPath, "sketch"), ".svg", svgBytes) } + assert.Success(t, err) + assert.Success(t, err2) } } diff --git a/e2etests/report/main.go b/e2etests/report/main.go index 42784c3eb..f71c7f1cd 100644 --- a/e2etests/report/main.go +++ b/e2etests/report/main.go @@ -39,6 +39,7 @@ func main() { flag.BoolVar(&deltaFlag, "delta", false, "Generate the report only for cases that changed.") flag.StringVar(&testSetFlag, "test-set", "", "Only run set of tests matching this string. e.g. regressions") flag.StringVar(&testCaseFlag, "test-case", "", "Only run tests matching this string. e.g. all_shapes") + skipTests := flag.Bool("skip-tests", false, "Skip running tests first") flag.BoolVar(&vFlag, "v", false, "verbose") flag.Parse() @@ -53,18 +54,20 @@ func main() { testDir = "./e2etests" } - ctx := log.Stderr(context.Background()) - ctx, cancel := context.WithTimeout(ctx, 2*time.Minute) - defer cancel() - cmd := exec.CommandContext(ctx, "go", "test", testDir, "-run", testMatchString, vString) - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, "FORCE_COLOR=1") - cmd.Env = append(cmd.Env, "DEBUG=1") - cmd.Env = append(cmd.Env, "TEST_MODE=on") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - log.Debug(ctx, cmd.String()) - _ = cmd.Run() + if !*skipTests { + ctx := log.Stderr(context.Background()) + ctx, cancel := context.WithTimeout(ctx, 2*time.Minute) + defer cancel() + cmd := exec.CommandContext(ctx, "go", "test", testDir, "-run", testMatchString, vString) + cmd.Env = os.Environ() + cmd.Env = append(cmd.Env, "FORCE_COLOR=1") + cmd.Env = append(cmd.Env, "DEBUG=1") + cmd.Env = append(cmd.Env, "TEST_MODE=on") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + log.Debug(ctx, cmd.String()) + _ = cmd.Run() + } var tests []TestItem err := filepath.Walk(filepath.Join(testDir, "testdata"), func(path string, info os.FileInfo, err error) error { From 5268829b59fc6f25d88a4f36e5ef7f277ed04f8b Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 2 Feb 2023 11:20:45 -0800 Subject: [PATCH 56/60] e2etests: Update report template --- e2etests/report/template.html | 43 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/e2etests/report/template.html b/e2etests/report/template.html index c982c372a..28ed677ed 100644 --- a/e2etests/report/template.html +++ b/e2etests/report/template.html @@ -1,16 +1,26 @@ E2E report +

Table of Contents

+
{{range .Tests}} -
+

{{.Name}}

{{ if .ExpSVG }} -

Expected

- -

Got

+

Expected

{{ end }} - +

Got

+
+ {{ if .ExpSVG }} + + {{ end }} + +
{{end}}
@@ -20,17 +30,24 @@ flex-wrap: wrap; } .case { - align-items: center; - justify-content: center; + position: relative; padding: 20px; + width: 100%; } - .case svg { - width: 400px; - height: 400px; + .case-img-wrapper { + display: flex; + align-items: center; } - .case pre { - font-size: 10pt; - width: 400px; + .case img { + width: 600px; + } + .case-got { + position: absolute; + left: 600px; + } + .case h2 { + margin: 0; + display: inline; } From 9384800435ae90602f930581bb5de7781acef2f5 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 2 Feb 2023 11:55:12 -0800 Subject: [PATCH 57/60] e2etests/testdata: Fix --- d2graph/seqdiagram.go | 2 +- .../dagre/board.exp.json | 57 +++---------------- .../dagre/sketch.exp.svg | 7 ++- .../elk/board.exp.json | 57 +++---------------- .../elk/sketch.exp.svg | 7 ++- 5 files changed, 27 insertions(+), 103 deletions(-) diff --git a/d2graph/seqdiagram.go b/d2graph/seqdiagram.go index c7497fa9a..b9cddac8d 100644 --- a/d2graph/seqdiagram.go +++ b/d2graph/seqdiagram.go @@ -33,7 +33,7 @@ func (obj *Object) IsSequenceDiagramGroup() bool { return false } } - return len(obj.ChildrenArray) > 0 || obj.ContainsAnyEdge(obj.Graph.Edges) + return obj.ContainsAnyObject(obj.Graph.Objects) || obj.ContainsAnyEdge(obj.Graph.Edges) } // notes are descendant of actors with no edges and no children diff --git a/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json index 8a0bdf5ef..d88f4983a 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json @@ -495,16 +495,16 @@ "id": "choo", "type": "rectangle", "pos": { - "x": 1024, - "y": 74 + "x": 717, + "y": 1846 }, - "width": 150, - "height": 126, + "width": 254, + "height": 216, "opacity": 1, "strokeDash": 0, - "strokeWidth": 2, + "strokeWidth": 0, "borderRadius": 0, - "fill": "#EDF0FD", + "fill": "#DEE1EB", "stroke": "#0D32B2", "shadow": false, "3d": false, @@ -514,7 +514,7 @@ "link": "", "icon": null, "iconPosition": "", - "blend": false, + "blend": true, "fields": null, "methods": null, "columns": null, @@ -528,8 +528,8 @@ "underline": false, "labelWidth": 38, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, "level": 1 }, { @@ -1120,45 +1120,6 @@ "tooltip": "", "icon": null, "zIndex": 1 - }, - { - "id": "(choo -- )[0]", - "src": "choo", - "srcArrow": "none", - "srcLabel": "", - "dst": "choo-lifeline-end-3474163975", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 1099, - "y": 200 - }, - { - "x": 1099, - "y": 2142 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 } ] } diff --git a/e2etests/testdata/stable/sequence_diagram_groups/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_groups/dagre/sketch.exp.svg index 8baf9c609..5f1e317d3 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_groups/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="1354" height="2270" viewBox="-78 -28 1354 2270">