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",