From 0002817b0a9621741195d49dc4661acbfb9baf05 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 29 Jul 2023 15:09:29 -0700 Subject: [PATCH 1/8] d2ir: Implement ampersand filters --- d2ast/d2ast.go | 2 +- d2ir/compile.go | 25 + d2ir/compile_test.go | 1 + d2ir/filter_test.go | 36 + .../d2ir/TestCompile/filters/escaped.exp.json | 637 ++++++++++++++++++ 5 files changed, 700 insertions(+), 1 deletion(-) create mode 100644 d2ir/filter_test.go create mode 100644 testdata/d2ir/TestCompile/filters/escaped.exp.json diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 6b6f47389..102429b7a 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -610,7 +610,7 @@ func (m *Map) IsFileMap() bool { type Key struct { Range Range `json:"range"` - // Indicates this MapKey is an override selector. + // Indicates this MapKey is a filter selector. Ampersand bool `json:"ampersand,omitempty"` // At least one of Key and Edges will be set but all four can also be set. diff --git a/d2ir/compile.go b/d2ir/compile.go index 43763139d..c422eaa79 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -408,6 +408,31 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) } func (c *compiler) _compileField(f *Field, refctx *RefContext) { + if refctx.Key.Ampersand { + f2 := ParentMap(f).Map().GetField(refctx.Key.Key.IDA()...) + if f2 == nil { + return + } + if refctx.Key.Primary.Unbox() != nil { + if f2.Primary_ == nil { + return + } + if refctx.Key.Primary.Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { + return + } + } + if refctx.Key.Value.ScalarBox().Unbox() != nil { + if f2.Primary_ == nil { + return + } + if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { + println(refctx.Key.Value.ScalarBox().Unbox().ScalarString()) + println(f2.Primary_.Value.ScalarString()) + return + } + } + } + if len(refctx.Key.Edges) == 0 && refctx.Key.Value.Null != nil { // For vars, if we delete the field, it may just resolve to an outer scope var of the same name // Instead we keep it around, so that resolveSubstitutions can find it diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index 64d16ad8d..9fc96b228 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -27,6 +27,7 @@ func TestCompile(t *testing.T) { t.Run("steps", testCompileSteps) t.Run("imports", testCompileImports) t.Run("patterns", testCompilePatterns) + t.Run("filters", testCompileFilters) } type testCase struct { diff --git a/d2ir/filter_test.go b/d2ir/filter_test.go new file mode 100644 index 000000000..9ba4c3559 --- /dev/null +++ b/d2ir/filter_test.go @@ -0,0 +1,36 @@ +package d2ir_test + +import ( + "testing" + + "oss.terrastruct.com/util-go/assert" +) + +func testCompileFilters(t *testing.T) { + t.Parallel() + + tca := []testCase{ + { + name: "escaped", + run: func(t testing.TB) { + m, err := compile(t, `jacob: { + shape: circle +} +jeremy: { + shape: rectangle +} +*: { + &shape: rectangle + label: I'm a rectangle +}`) + assert.Success(t, err) + t.Log(m.String()) + assertQuery(t, m, 1, 0, nil, "jacob") + assertQuery(t, m, 2, 0, "", "jeremy") + assertQuery(t, m, 0, 0, "I'm a rectangle", "jeremy.label") + }, + }, + } + + runa(t, tca) +} diff --git a/testdata/d2ir/TestCompile/filters/escaped.exp.json b/testdata/d2ir/TestCompile/filters/escaped.exp.json new file mode 100644 index 000000000..6553327a5 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/escaped.exp.json @@ -0,0 +1,637 @@ +{ + "fields": [ + { + "name": "jacob", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/escaped.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,7:1:62-7:18:79", + "ampersand": true, + "key": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + }, + { + "name": "label", + "primary": { + "value": { + "range": "TestCompile/filters/escaped.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:23:103", + "key": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/escaped.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,0:0:0-2:1:25", + "key": { + "range": "TestCompile/filters/escaped.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/escaped.d2,0:7:7-2:1:25", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "jeremy", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/escaped.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,7:1:62-7:18:79", + "ampersand": true, + "key": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + }, + { + "name": "label", + "primary": { + "value": { + "range": "TestCompile/filters/escaped.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:23:103", + "key": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/escaped.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/escaped.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/escaped.d2,3:0:26-5:1:55", + "key": { + "range": "TestCompile/filters/escaped.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/escaped.d2,3:8:34-5:1:55", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/escaped.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +} From 43166110b89dc537638f6e3be0fcac633abf5664 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 29 Jul 2023 16:32:30 -0700 Subject: [PATCH 2/8] d2ir: Add single field filtering See test. --- d2ir/compile.go | 81 ++- d2ir/filter_test.go | 24 +- .../d2ir/TestCompile/filters/base#01.exp.json | 560 ++++++++++++++++ .../d2ir/TestCompile/filters/base.exp.json | 622 ++++++++++++++++++ .../d2ir/TestCompile/filters/escaped.exp.json | 77 --- .../d2ir/TestCompile/filters/order.exp.json | 622 ++++++++++++++++++ 6 files changed, 1885 insertions(+), 101 deletions(-) create mode 100644 testdata/d2ir/TestCompile/filters/base#01.exp.json create mode 100644 testdata/d2ir/TestCompile/filters/base.exp.json create mode 100644 testdata/d2ir/TestCompile/filters/order.exp.json diff --git a/d2ir/compile.go b/d2ir/compile.go index c422eaa79..b2e4752b0 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -344,6 +344,20 @@ func (c *compiler) overlay(base *Map, f *Field) { } func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) { + for _, n := range ast.Nodes { + switch { + case n.MapKey != nil: + ok := c.ampersandFilter(&RefContext{ + Key: n.MapKey, + Scope: ast, + ScopeMap: dst, + ScopeAST: scopeAST, + }) + if !ok { + return + } + } + } for _, n := range ast.Nodes { switch { case n.MapKey != nil: @@ -407,32 +421,57 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) } } -func (c *compiler) _compileField(f *Field, refctx *RefContext) { - if refctx.Key.Ampersand { - f2 := ParentMap(f).Map().GetField(refctx.Key.Key.IDA()...) - if f2 == nil { - return +func (c *compiler) ampersandFilter(refctx *RefContext) bool { + if !refctx.Key.Ampersand { + return true + } + if len(refctx.Key.Edges) > 0 { + return true + } + + fa, err := refctx.ScopeMap.EnsureField(refctx.Key.Key, refctx, false) + if err != nil { + c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) + return false + } + if len(fa) == 0 { + return false + } + for _, f := range fa { + ok := c._ampersandFilter(f, refctx) + if !ok { + return false } - if refctx.Key.Primary.Unbox() != nil { - if f2.Primary_ == nil { - return - } - if refctx.Key.Primary.Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { - return - } + } + return true +} + +func (c *compiler) _ampersandFilter(f *Field, refctx *RefContext) bool { + f2 := ParentMap(f).Map().GetField(refctx.Key.Key.IDA()...) + if f2 == nil { + return false + } + if refctx.Key.Primary.Unbox() != nil { + if f2.Primary_ == nil { + return false } - if refctx.Key.Value.ScalarBox().Unbox() != nil { - if f2.Primary_ == nil { - return - } - if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { - println(refctx.Key.Value.ScalarBox().Unbox().ScalarString()) - println(f2.Primary_.Value.ScalarString()) - return - } + if refctx.Key.Primary.Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { + return false + } + } + if refctx.Key.Value.ScalarBox().Unbox() != nil { + if f2.Primary_ == nil { + return false + } + if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { + return false } } + return true +} + +func (c *compiler) _compileField(f *Field, refctx *RefContext) { if len(refctx.Key.Edges) == 0 && refctx.Key.Value.Null != nil { // For vars, if we delete the field, it may just resolve to an outer scope var of the same name // Instead we keep it around, so that resolveSubstitutions can find it diff --git a/d2ir/filter_test.go b/d2ir/filter_test.go index 9ba4c3559..fa9d80761 100644 --- a/d2ir/filter_test.go +++ b/d2ir/filter_test.go @@ -11,7 +11,7 @@ func testCompileFilters(t *testing.T) { tca := []testCase{ { - name: "escaped", + name: "base", run: func(t testing.TB) { m, err := compile(t, `jacob: { shape: circle @@ -24,9 +24,27 @@ jeremy: { label: I'm a rectangle }`) assert.Success(t, err) - t.Log(m.String()) assertQuery(t, m, 1, 0, nil, "jacob") - assertQuery(t, m, 2, 0, "", "jeremy") + assertQuery(t, m, 2, 0, nil, "jeremy") + assertQuery(t, m, 0, 0, "I'm a rectangle", "jeremy.label") + }, + }, + { + name: "order", + run: func(t testing.TB) { + m, err := compile(t, `jacob: { + shape: circle +} +jeremy: { + shape: rectangle +} +*: { + label: I'm a rectangle + &shape: rectangle +}`) + assert.Success(t, err) + assertQuery(t, m, 1, 0, nil, "jacob") + assertQuery(t, m, 2, 0, nil, "jeremy") assertQuery(t, m, 0, 0, "I'm a rectangle", "jeremy.label") }, }, diff --git a/testdata/d2ir/TestCompile/filters/base#01.exp.json b/testdata/d2ir/TestCompile/filters/base#01.exp.json new file mode 100644 index 000000000..0521ab4f3 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/base#01.exp.json @@ -0,0 +1,560 @@ +{ + "fields": [ + { + "name": "jacob", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/base#01.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base#01.d2,7:1:62-7:18:79", + "ampersand": true, + "key": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base#01.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base#01.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base#01.d2,0:0:0-2:1:25", + "key": { + "range": "TestCompile/filters/base#01.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/base#01.d2,0:7:7-2:1:25", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "jeremy", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/base#01.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base#01.d2,7:1:62-7:18:79", + "ampersand": true, + "key": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + }, + { + "name": "label", + "primary": { + "value": { + "range": "TestCompile/filters/base#01.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base#01.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base#01.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base#01.d2,8:1:81-8:23:103", + "key": { + "range": "TestCompile/filters/base#01.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base#01.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base#01.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base#01.d2,3:0:26-5:1:55", + "key": { + "range": "TestCompile/filters/base#01.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/base#01.d2,3:8:34-5:1:55", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base#01.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/filters/base.exp.json b/testdata/d2ir/TestCompile/filters/base.exp.json new file mode 100644 index 000000000..7e7ac0481 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/base.exp.json @@ -0,0 +1,622 @@ +{ + "fields": [ + { + "name": "jacob", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/base.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/base.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,7:1:62-7:18:79", + "ampersand": true, + "key": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,0:0:0-2:1:25", + "key": { + "range": "TestCompile/filters/base.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/base.d2,0:7:7-2:1:25", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/base.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/base.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "jeremy", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/base.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/base.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,7:1:62-7:18:79", + "ampersand": true, + "key": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,7:1:62-7:18:79", + "ampersand": true, + "key": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,7:9:70-7:18:79", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + }, + { + "name": "label", + "primary": { + "value": { + "range": "TestCompile/filters/base.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,8:1:81-8:23:103", + "key": { + "range": "TestCompile/filters/base.d2,8:1:81-8:6:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,8:1:81-8:6:86", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,8:8:88-8:23:103", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/base.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/base.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/base.d2,3:0:26-5:1:55", + "key": { + "range": "TestCompile/filters/base.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/base.d2,3:8:34-5:1:55", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/base.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/base.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/base.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/filters/escaped.exp.json b/testdata/d2ir/TestCompile/filters/escaped.exp.json index 6553327a5..c6257902d 100644 --- a/testdata/d2ir/TestCompile/filters/escaped.exp.json +++ b/testdata/d2ir/TestCompile/filters/escaped.exp.json @@ -142,83 +142,6 @@ } } ] - }, - { - "name": "label", - "primary": { - "value": { - "range": "TestCompile/filters/escaped.d2,8:8:88-8:23:103", - "value": [ - { - "string": "I'm a rectangle", - "raw_string": "I'm a rectangle" - } - ] - } - }, - "references": [ - { - "string": { - "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", - "value": [ - { - "string": "label", - "raw_string": "label" - } - ] - }, - "key_path": { - "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", - "value": [ - { - "string": "label", - "raw_string": "label" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/filters/escaped.d2,8:1:81-8:23:103", - "key": { - "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/filters/escaped.d2,8:1:81-8:6:86", - "value": [ - { - "string": "label", - "raw_string": "label" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/filters/escaped.d2,8:8:88-8:23:103", - "value": [ - { - "string": "I'm a rectangle", - "raw_string": "I'm a rectangle" - } - ] - } - } - } - } - } - ] } ], "edges": null diff --git a/testdata/d2ir/TestCompile/filters/order.exp.json b/testdata/d2ir/TestCompile/filters/order.exp.json new file mode 100644 index 000000000..68d9f7314 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/order.exp.json @@ -0,0 +1,622 @@ +{ + "fields": [ + { + "name": "jacob", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/order.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/order.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/order.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,8:1:86-8:18:103", + "ampersand": true, + "key": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:9:94-8:18:103", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/order.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,0:0:0-2:1:25", + "key": { + "range": "TestCompile/filters/order.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/order.d2,0:7:7-2:1:25", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/order.d2,1:1:10-1:14:23", + "key": { + "range": "TestCompile/filters/order.d2,1:1:10-1:6:15", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,1:1:10-1:6:15", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,1:8:17-1:14:23", + "value": [ + { + "string": "circle", + "raw_string": "circle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "jeremy", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/order.d2,8:9:94-8:18:103", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/order.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/order.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,8:1:86-8:18:103", + "ampersand": true, + "key": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:9:94-8:18:103", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,8:1:86-8:18:103", + "ampersand": true, + "key": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,8:9:94-8:18:103", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + } + ] + }, + { + "name": "label", + "primary": { + "value": { + "range": "TestCompile/filters/order.d2,7:8:69-7:23:84", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/order.d2,7:1:62-7:6:67", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,7:1:62-7:6:67", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,7:1:62-7:6:67", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,7:1:62-7:23:84", + "key": { + "range": "TestCompile/filters/order.d2,7:1:62-7:6:67", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,7:1:62-7:6:67", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,7:8:69-7:23:84", + "value": [ + { + "string": "I'm a rectangle", + "raw_string": "I'm a rectangle" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/order.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/order.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/order.d2,3:0:26-5:1:55", + "key": { + "range": "TestCompile/filters/order.d2,3:0:26-3:6:32", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,3:0:26-3:6:32", + "value": [ + { + "string": "jeremy", + "raw_string": "jeremy" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/order.d2,3:8:34-5:1:55", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/order.d2,4:1:37-4:17:53", + "key": { + "range": "TestCompile/filters/order.d2,4:1:37-4:6:42", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,4:1:37-4:6:42", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/order.d2,4:8:44-4:17:53", + "value": [ + { + "string": "rectangle", + "raw_string": "rectangle" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +} From 6b73a61bd298f1522104ddcb19f6e33312be62f2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 29 Jul 2023 17:09:20 -0700 Subject: [PATCH 3/8] d2ir: Add filter error tests --- d2ir/compile.go | 3 + d2ir/filter_test.go | 40 + d2ir/pattern_test.go | 3 +- d2parser/parse.go | 2 +- .../filters/errors/bad-syntax.exp.json | 749 ++++++++++++++++++ .../filters/errors/composite.exp.json | 449 +++++++++++ 6 files changed, 1243 insertions(+), 3 deletions(-) create mode 100644 testdata/d2ir/TestCompile/filters/errors/bad-syntax.exp.json create mode 100644 testdata/d2ir/TestCompile/filters/errors/composite.exp.json diff --git a/d2ir/compile.go b/d2ir/compile.go index b2e4752b0..0c08f2086 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -466,6 +466,9 @@ func (c *compiler) _ampersandFilter(f *Field, refctx *RefContext) bool { if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { return false } + } else if refctx.Key.Value.Unbox() != nil { + c.errorf(refctx.Key, "ampersand filters cannot be composites") + return false } return true diff --git a/d2ir/filter_test.go b/d2ir/filter_test.go index fa9d80761..39f938cd0 100644 --- a/d2ir/filter_test.go +++ b/d2ir/filter_test.go @@ -51,4 +51,44 @@ jeremy: { } runa(t, tca) + + t.Run("errors", func(t *testing.T) { + tca := []testCase{ + { + name: "bad-syntax", + run: func(t testing.TB) { + _, err := compile(t, `jacob.style: { + fill: red + multiple: true +} + +*.&style: { + fill: red + multiple: true +} +`) + assert.ErrorString(t, err, `TestCompile/filters/errors/bad-syntax.d2:6:3: unexpected text after map key +TestCompile/filters/errors/bad-syntax.d2:9:1: unexpected map termination character } in file map`) + }, + }, + { + name: "composite", + run: func(t testing.TB) { + _, err := compile(t, `jacob.style: { + fill: red + multiple: true +} +*: { + &style: { + fill: red + multiple: true + } +} +`) + assert.ErrorString(t, err, `TestCompile/filters/errors/composite.d2:6:2: ampersand filters cannot be composites`) + }, + }, + } + runa(t, tca) + }) } diff --git a/d2ir/pattern_test.go b/d2ir/pattern_test.go index aabd8be58..613751ab3 100644 --- a/d2ir/pattern_test.go +++ b/d2ir/pattern_test.go @@ -323,10 +323,9 @@ task.** -> fast { name: "glob-edge-glob-index", run: func(t testing.TB) { - m, err := compile(t, `(* -> b)[*].style.fill: red + _, err := compile(t, `(* -> b)[*].style.fill: red `) assert.ErrorString(t, err, `TestCompile/patterns/errors/glob-edge-glob-index.d2:1:2: indexed edge does not exist`) - assertQuery(t, m, 0, 0, nil, "") }, }, } diff --git a/d2parser/parse.go b/d2parser/parse.go index 6f792d374..50f6c91c1 100644 --- a/d2parser/parse.go +++ b/d2parser/parse.go @@ -1098,7 +1098,7 @@ func (p *parser) parseUnquotedString(inKey bool) (s *d2ast.UnquotedString) { } if inKey { switch r { - case ':', '.', '<', '>': + case ':', '.', '<', '>', '&': p.rewind() return s case '-': diff --git a/testdata/d2ir/TestCompile/filters/errors/bad-syntax.exp.json b/testdata/d2ir/TestCompile/filters/errors/bad-syntax.exp.json new file mode 100644 index 000000000..a91868c61 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/errors/bad-syntax.exp.json @@ -0,0 +1,749 @@ +{ + "fields": [ + { + "name": "jacob", + "composite": { + "fields": [ + { + "name": "style", + "composite": { + "fields": [ + { + "name": "fill", + "primary": { + "value": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:10:25", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + } + ] + }, + { + "name": "multiple", + "primary": { + "value": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:11:37-2:15:41", + "value": true + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:15:41", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:11:37-2:15:41", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-3:1:43", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:13:13-3:1:43", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:10:25", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:15:41", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:11:37-2:15:41", + "value": true + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "&style", + "composite": { + "fields": [ + { + "name": "fill", + "primary": { + "value": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:8:65-6:11:68", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:6:63", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:6:63", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:6:63", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:11:68", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:6:63", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:6:63", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:8:65-6:11:68", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + } + ] + }, + { + "name": "multiple", + "primary": { + "value": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:12:81-7:16:85", + "value": true + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:10:79", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:10:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:10:79", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:16:85", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:10:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:10:79", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:12:81-7:16:85", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:2:47-5:8:53", + "value": [ + { + "string": "&style", + "raw_string": "&style" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:0:45-5:8:53", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:0:45-5:1:46", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:2:47-5:8:53", + "value": [ + { + "string": "&style", + "raw_string": "&style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:0:45-8:1:87", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:0:45-5:8:53", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:0:45-5:1:46", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:2:47-5:8:53", + "value": [ + { + "string": "&style", + "raw_string": "&style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/bad-syntax.d2,5:10:55-8:1:87", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:11:68", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:6:63", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:2:59-6:6:63", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,6:8:65-6:11:68", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:16:85", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:10:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:2:71-7:10:79", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/bad-syntax.d2,7:12:81-7:16:85", + "value": true + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-3:1:43", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/bad-syntax.d2,0:13:13-3:1:43", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:10:25", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:15:41", + "key": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/bad-syntax.d2,2:11:37-2:15:41", + "value": true + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/filters/errors/composite.exp.json b/testdata/d2ir/TestCompile/filters/errors/composite.exp.json new file mode 100644 index 000000000..8aa7bec36 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/errors/composite.exp.json @@ -0,0 +1,449 @@ +{ + "fields": [ + { + "name": "jacob", + "composite": { + "fields": [ + { + "name": "style", + "composite": { + "fields": [ + { + "name": "fill", + "primary": { + "value": { + "range": "TestCompile/filters/errors/composite.d2,8:7:73-8:10:76", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:10:76", + "key": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,8:7:73-8:10:76", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + } + ] + }, + { + "name": "multiple", + "primary": { + "value": { + "range": "TestCompile/filters/errors/composite.d2,9:11:88-9:15:92", + "value": true + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:15:92", + "key": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/composite.d2,9:11:88-9:15:92", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/composite.d2,7:6:57-7:11:62", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:11:62", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:5:56", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:6:57-7:11:62", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-10:1:94", + "key": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:11:62", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:5:56", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:6:57-7:11:62", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/composite.d2,7:13:64-10:1:94", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:10:76", + "key": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,8:7:73-8:10:76", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:15:92", + "key": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/composite.d2,9:11:88-9:15:92", + "value": true + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:5:56", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:11:62", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:5:56", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:6:57-7:11:62", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-10:1:94", + "key": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:11:62", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:0:51-7:5:56", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,7:6:57-7:11:62", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/composite.d2,7:13:64-10:1:94", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:10:76", + "key": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,8:1:67-8:5:71", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,8:7:73-8:10:76", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:15:92", + "key": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/composite.d2,9:1:78-9:9:86", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/composite.d2,9:11:88-9:15:92", + "value": true + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +} From 60a19cffde14420073fc032da18853f8f8ffb188 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 29 Jul 2023 17:15:03 -0700 Subject: [PATCH 4/8] e2etests: Fix ampersand-escape test --- e2etests/regression_test.go | 4 +- .../ampersand-escape/dagre/board.exp.json | 84 +-------- .../ampersand-escape/dagre/sketch.exp.svg | 160 +++++++++--------- .../ampersand-escape/elk/board.exp.json | 84 +-------- .../ampersand-escape/elk/sketch.exp.svg | 160 +++++++++--------- 5 files changed, 161 insertions(+), 331 deletions(-) diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 55bc62b14..24a0d0edd 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -648,11 +648,9 @@ group: { }, { name: "ampersand-escape", - script: `h&y: &∈ { + script: `hy: &∈ { tooltip: beans & rice } -&foo -&&bar `, }, { diff --git a/e2etests/testdata/regression/ampersand-escape/dagre/board.exp.json b/e2etests/testdata/regression/ampersand-escape/dagre/board.exp.json index 924c38e6b..f5f27d395 100644 --- a/e2etests/testdata/regression/ampersand-escape/dagre/board.exp.json +++ b/e2etests/testdata/regression/ampersand-escape/dagre/board.exp.json @@ -4,7 +4,7 @@ "fontFamily": "SourceSansPro", "shapes": [ { - "id": "h&y", + "id": "hy", "type": "rectangle", "pos": { "x": 0, @@ -43,88 +43,6 @@ "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 1 - }, - { - "id": "foo", - "type": "rectangle", - "pos": { - "x": 158, - "y": 0 - }, - "width": 69, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B6", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "foo", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 24, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "\"&bar\"", - "type": "rectangle", - "pos": { - "x": 287, - "y": 0 - }, - "width": 81, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B6", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "&bar", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 36, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 } ], "connections": [], diff --git a/e2etests/testdata/regression/ampersand-escape/dagre/sketch.exp.svg b/e2etests/testdata/regression/ampersand-escape/dagre/sketch.exp.svg index 34b6f853f..8f189785c 100644 --- a/e2etests/testdata/regression/ampersand-escape/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/ampersand-escape/dagre/sketch.exp.svg @@ -1,13 +1,13 @@ -&∈beans & ricefoo&barbeans & rice + .d2-1658760307 .fill-N1{fill:#0A0F25;} + .d2-1658760307 .fill-N2{fill:#676C7E;} + .d2-1658760307 .fill-N3{fill:#9499AB;} + .d2-1658760307 .fill-N4{fill:#CFD2DD;} + .d2-1658760307 .fill-N5{fill:#DEE1EB;} + .d2-1658760307 .fill-N6{fill:#EEF1F8;} + .d2-1658760307 .fill-N7{fill:#FFFFFF;} + .d2-1658760307 .fill-B1{fill:#0D32B2;} + .d2-1658760307 .fill-B2{fill:#0D32B2;} + .d2-1658760307 .fill-B3{fill:#E3E9FD;} + .d2-1658760307 .fill-B4{fill:#E3E9FD;} + .d2-1658760307 .fill-B5{fill:#EDF0FD;} + .d2-1658760307 .fill-B6{fill:#F7F8FE;} + .d2-1658760307 .fill-AA2{fill:#4A6FF3;} + .d2-1658760307 .fill-AA4{fill:#EDF0FD;} + .d2-1658760307 .fill-AA5{fill:#F7F8FE;} + .d2-1658760307 .fill-AB4{fill:#EDF0FD;} + .d2-1658760307 .fill-AB5{fill:#F7F8FE;} + .d2-1658760307 .stroke-N1{stroke:#0A0F25;} + .d2-1658760307 .stroke-N2{stroke:#676C7E;} + .d2-1658760307 .stroke-N3{stroke:#9499AB;} + .d2-1658760307 .stroke-N4{stroke:#CFD2DD;} + .d2-1658760307 .stroke-N5{stroke:#DEE1EB;} + .d2-1658760307 .stroke-N6{stroke:#EEF1F8;} + .d2-1658760307 .stroke-N7{stroke:#FFFFFF;} + .d2-1658760307 .stroke-B1{stroke:#0D32B2;} + .d2-1658760307 .stroke-B2{stroke:#0D32B2;} + .d2-1658760307 .stroke-B3{stroke:#E3E9FD;} + .d2-1658760307 .stroke-B4{stroke:#E3E9FD;} + .d2-1658760307 .stroke-B5{stroke:#EDF0FD;} + .d2-1658760307 .stroke-B6{stroke:#F7F8FE;} + .d2-1658760307 .stroke-AA2{stroke:#4A6FF3;} + .d2-1658760307 .stroke-AA4{stroke:#EDF0FD;} + .d2-1658760307 .stroke-AA5{stroke:#F7F8FE;} + .d2-1658760307 .stroke-AB4{stroke:#EDF0FD;} + .d2-1658760307 .stroke-AB5{stroke:#F7F8FE;} + .d2-1658760307 .background-color-N1{background-color:#0A0F25;} + .d2-1658760307 .background-color-N2{background-color:#676C7E;} + .d2-1658760307 .background-color-N3{background-color:#9499AB;} + .d2-1658760307 .background-color-N4{background-color:#CFD2DD;} + .d2-1658760307 .background-color-N5{background-color:#DEE1EB;} + .d2-1658760307 .background-color-N6{background-color:#EEF1F8;} + .d2-1658760307 .background-color-N7{background-color:#FFFFFF;} + .d2-1658760307 .background-color-B1{background-color:#0D32B2;} + .d2-1658760307 .background-color-B2{background-color:#0D32B2;} + .d2-1658760307 .background-color-B3{background-color:#E3E9FD;} + .d2-1658760307 .background-color-B4{background-color:#E3E9FD;} + .d2-1658760307 .background-color-B5{background-color:#EDF0FD;} + .d2-1658760307 .background-color-B6{background-color:#F7F8FE;} + .d2-1658760307 .background-color-AA2{background-color:#4A6FF3;} + .d2-1658760307 .background-color-AA4{background-color:#EDF0FD;} + .d2-1658760307 .background-color-AA5{background-color:#F7F8FE;} + .d2-1658760307 .background-color-AB4{background-color:#EDF0FD;} + .d2-1658760307 .background-color-AB5{background-color:#F7F8FE;} + .d2-1658760307 .color-N1{color:#0A0F25;} + .d2-1658760307 .color-N2{color:#676C7E;} + .d2-1658760307 .color-N3{color:#9499AB;} + .d2-1658760307 .color-N4{color:#CFD2DD;} + .d2-1658760307 .color-N5{color:#DEE1EB;} + .d2-1658760307 .color-N6{color:#EEF1F8;} + .d2-1658760307 .color-N7{color:#FFFFFF;} + .d2-1658760307 .color-B1{color:#0D32B2;} + .d2-1658760307 .color-B2{color:#0D32B2;} + .d2-1658760307 .color-B3{color:#E3E9FD;} + .d2-1658760307 .color-B4{color:#E3E9FD;} + .d2-1658760307 .color-B5{color:#EDF0FD;} + .d2-1658760307 .color-B6{color:#F7F8FE;} + .d2-1658760307 .color-AA2{color:#4A6FF3;} + .d2-1658760307 .color-AA4{color:#EDF0FD;} + .d2-1658760307 .color-AA5{color:#F7F8FE;} + .d2-1658760307 .color-AB4{color:#EDF0FD;} + .d2-1658760307 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]>&∈beans & ricebeans & rice @@ -105,9 +105,7 @@ - - + + - - \ No newline at end of file diff --git a/e2etests/testdata/regression/ampersand-escape/elk/board.exp.json b/e2etests/testdata/regression/ampersand-escape/elk/board.exp.json index 29afa3817..c135331d8 100644 --- a/e2etests/testdata/regression/ampersand-escape/elk/board.exp.json +++ b/e2etests/testdata/regression/ampersand-escape/elk/board.exp.json @@ -4,7 +4,7 @@ "fontFamily": "SourceSansPro", "shapes": [ { - "id": "h&y", + "id": "hy", "type": "rectangle", "pos": { "x": 12, @@ -43,88 +43,6 @@ "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 1 - }, - { - "id": "foo", - "type": "rectangle", - "pos": { - "x": 130, - "y": 12 - }, - "width": 69, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B6", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "foo", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 24, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "\"&bar\"", - "type": "rectangle", - "pos": { - "x": 219, - "y": 12 - }, - "width": 81, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "B6", - "stroke": "B1", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "&bar", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "N1", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 36, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 } ], "connections": [], diff --git a/e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg b/e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg index 90424ee6b..eff889432 100644 --- a/e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg @@ -1,13 +1,13 @@ -&∈beans & ricefoo&barbeans & rice + .d2-616571211 .fill-N1{fill:#0A0F25;} + .d2-616571211 .fill-N2{fill:#676C7E;} + .d2-616571211 .fill-N3{fill:#9499AB;} + .d2-616571211 .fill-N4{fill:#CFD2DD;} + .d2-616571211 .fill-N5{fill:#DEE1EB;} + .d2-616571211 .fill-N6{fill:#EEF1F8;} + .d2-616571211 .fill-N7{fill:#FFFFFF;} + .d2-616571211 .fill-B1{fill:#0D32B2;} + .d2-616571211 .fill-B2{fill:#0D32B2;} + .d2-616571211 .fill-B3{fill:#E3E9FD;} + .d2-616571211 .fill-B4{fill:#E3E9FD;} + .d2-616571211 .fill-B5{fill:#EDF0FD;} + .d2-616571211 .fill-B6{fill:#F7F8FE;} + .d2-616571211 .fill-AA2{fill:#4A6FF3;} + .d2-616571211 .fill-AA4{fill:#EDF0FD;} + .d2-616571211 .fill-AA5{fill:#F7F8FE;} + .d2-616571211 .fill-AB4{fill:#EDF0FD;} + .d2-616571211 .fill-AB5{fill:#F7F8FE;} + .d2-616571211 .stroke-N1{stroke:#0A0F25;} + .d2-616571211 .stroke-N2{stroke:#676C7E;} + .d2-616571211 .stroke-N3{stroke:#9499AB;} + .d2-616571211 .stroke-N4{stroke:#CFD2DD;} + .d2-616571211 .stroke-N5{stroke:#DEE1EB;} + .d2-616571211 .stroke-N6{stroke:#EEF1F8;} + .d2-616571211 .stroke-N7{stroke:#FFFFFF;} + .d2-616571211 .stroke-B1{stroke:#0D32B2;} + .d2-616571211 .stroke-B2{stroke:#0D32B2;} + .d2-616571211 .stroke-B3{stroke:#E3E9FD;} + .d2-616571211 .stroke-B4{stroke:#E3E9FD;} + .d2-616571211 .stroke-B5{stroke:#EDF0FD;} + .d2-616571211 .stroke-B6{stroke:#F7F8FE;} + .d2-616571211 .stroke-AA2{stroke:#4A6FF3;} + .d2-616571211 .stroke-AA4{stroke:#EDF0FD;} + .d2-616571211 .stroke-AA5{stroke:#F7F8FE;} + .d2-616571211 .stroke-AB4{stroke:#EDF0FD;} + .d2-616571211 .stroke-AB5{stroke:#F7F8FE;} + .d2-616571211 .background-color-N1{background-color:#0A0F25;} + .d2-616571211 .background-color-N2{background-color:#676C7E;} + .d2-616571211 .background-color-N3{background-color:#9499AB;} + .d2-616571211 .background-color-N4{background-color:#CFD2DD;} + .d2-616571211 .background-color-N5{background-color:#DEE1EB;} + .d2-616571211 .background-color-N6{background-color:#EEF1F8;} + .d2-616571211 .background-color-N7{background-color:#FFFFFF;} + .d2-616571211 .background-color-B1{background-color:#0D32B2;} + .d2-616571211 .background-color-B2{background-color:#0D32B2;} + .d2-616571211 .background-color-B3{background-color:#E3E9FD;} + .d2-616571211 .background-color-B4{background-color:#E3E9FD;} + .d2-616571211 .background-color-B5{background-color:#EDF0FD;} + .d2-616571211 .background-color-B6{background-color:#F7F8FE;} + .d2-616571211 .background-color-AA2{background-color:#4A6FF3;} + .d2-616571211 .background-color-AA4{background-color:#EDF0FD;} + .d2-616571211 .background-color-AA5{background-color:#F7F8FE;} + .d2-616571211 .background-color-AB4{background-color:#EDF0FD;} + .d2-616571211 .background-color-AB5{background-color:#F7F8FE;} + .d2-616571211 .color-N1{color:#0A0F25;} + .d2-616571211 .color-N2{color:#676C7E;} + .d2-616571211 .color-N3{color:#9499AB;} + .d2-616571211 .color-N4{color:#CFD2DD;} + .d2-616571211 .color-N5{color:#DEE1EB;} + .d2-616571211 .color-N6{color:#EEF1F8;} + .d2-616571211 .color-N7{color:#FFFFFF;} + .d2-616571211 .color-B1{color:#0D32B2;} + .d2-616571211 .color-B2{color:#0D32B2;} + .d2-616571211 .color-B3{color:#E3E9FD;} + .d2-616571211 .color-B4{color:#E3E9FD;} + .d2-616571211 .color-B5{color:#EDF0FD;} + .d2-616571211 .color-B6{color:#F7F8FE;} + .d2-616571211 .color-AA2{color:#4A6FF3;} + .d2-616571211 .color-AA4{color:#EDF0FD;} + .d2-616571211 .color-AA5{color:#F7F8FE;} + .d2-616571211 .color-AB4{color:#EDF0FD;} + .d2-616571211 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]>&∈beans & ricebeans & rice @@ -105,9 +105,7 @@ - - + + - - \ No newline at end of file From 0f45d2b08274ec9bc096d6b9204d28315b3b957d Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 29 Jul 2023 17:50:40 -0700 Subject: [PATCH 5/8] d2ast: Fix RawString test with ampersand --- d2ast/d2ast.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 102429b7a..3f9c99ad1 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -1099,12 +1099,11 @@ type InterpolationBox struct { // & is only special if it begins a key. // - is only special if followed by another - in a key. // ' " and | are only special if they begin an unquoted key or value. -var UnquotedKeySpecials = string([]rune{'#', ';', '\n', '\\', '{', '}', '[', ']', '\'', '"', '|', ':', '.', '-', '<', '>', '*', '&', '(', ')', '@'}) +var UnquotedKeySpecials = string([]rune{'#', ';', '\n', '\\', '{', '}', '[', ']', '\'', '"', '|', ':', '.', '-', '<', '>', '*', '&', '(', ')', '@', '&'}) var UnquotedValueSpecials = string([]rune{'#', ';', '\n', '\\', '{', '}', '[', ']', '\'', '"', '|', '$', '@'}) // RawString returns s in a AST String node that can format s in the most aesthetically // pleasing way. -// TODO: Return StringBox func RawString(s string, inKey bool) String { if s == "" { return FlatDoubleQuotedString(s) @@ -1117,10 +1116,6 @@ func RawString(s string, inKey bool) String { if i+1 < len(s) && s[i+1] != '-' { continue } - case '&': - if i > 0 { - continue - } } if strings.ContainsRune(UnquotedKeySpecials, r) { if !strings.ContainsRune(s, '"') { From 7ae2d788348ad00d4330ecb1fcc835ccb92de608 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 29 Jul 2023 18:02:09 -0700 Subject: [PATCH 6/8] d2ir: Add filtering on class arrays --- d2ir/compile.go | 37 +- d2ir/filter_test.go | 26 + .../d2ir/TestCompile/filters/array.exp.json | 1229 +++++++++++++++++ .../d2ir/TestCompile/filters/base.exp.json | 64 +- .../d2ir/TestCompile/filters/order.exp.json | 64 +- 5 files changed, 1279 insertions(+), 141 deletions(-) create mode 100644 testdata/d2ir/TestCompile/filters/array.exp.json diff --git a/d2ir/compile.go b/d2ir/compile.go index 0c08f2086..f88a4abdf 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -410,6 +410,10 @@ func (c *compiler) compileKey(refctx *RefContext) { } func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext) { + if refctx.Key.Ampersand { + return + } + fa, err := dst.EnsureField(kp, refctx, true) if err != nil { c.err.Errors = append(c.err.Errors, err.(d2ast.Error)) @@ -451,23 +455,26 @@ func (c *compiler) _ampersandFilter(f *Field, refctx *RefContext) bool { if f2 == nil { return false } - if refctx.Key.Primary.Unbox() != nil { - if f2.Primary_ == nil { - return false - } - if refctx.Key.Primary.Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { - return false + if refctx.Key.Value.ScalarBox().Unbox() == nil { + c.errorf(refctx.Key, "ampersand filters cannot be composites") + return false + } + + if a, ok := f2.Composite.(*Array); ok { + for _, v := range a.Values { + if s, ok := v.(*Scalar); ok { + if refctx.Key.Value.ScalarBox().Unbox().ScalarString() == s.Value.ScalarString() { + return true + } + } } } - if refctx.Key.Value.ScalarBox().Unbox() != nil { - if f2.Primary_ == nil { - return false - } - if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { - return false - } - } else if refctx.Key.Value.Unbox() != nil { - c.errorf(refctx.Key, "ampersand filters cannot be composites") + + if f2.Primary_ == nil { + return false + } + + if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { return false } diff --git a/d2ir/filter_test.go b/d2ir/filter_test.go index 39f938cd0..54cfdba21 100644 --- a/d2ir/filter_test.go +++ b/d2ir/filter_test.go @@ -43,11 +43,37 @@ jeremy: { &shape: rectangle }`) assert.Success(t, err) + assertQuery(t, m, 5, 0, nil, "") assertQuery(t, m, 1, 0, nil, "jacob") assertQuery(t, m, 2, 0, nil, "jeremy") assertQuery(t, m, 0, 0, "I'm a rectangle", "jeremy.label") }, }, + { + name: "array", + run: func(t testing.TB) { + m, err := compile(t, `the-little-cannon: { + class: [server; deployed] +} +dino: { + class: [internal; deployed] +} +catapult: { + class: [jacob; server] +} + +*: { + &class: server + style.multiple: true +} +`) + assert.Success(t, err) + assertQuery(t, m, 10, 0, nil, "") + assertQuery(t, m, 3, 0, nil, "the-little-cannon") + assertQuery(t, m, 1, 0, nil, "dino") + assertQuery(t, m, 3, 0, nil, "catapult") + }, + }, } runa(t, tca) diff --git a/testdata/d2ir/TestCompile/filters/array.exp.json b/testdata/d2ir/TestCompile/filters/array.exp.json new file mode 100644 index 000000000..1fc271233 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/array.exp.json @@ -0,0 +1,1229 @@ +{ + "fields": [ + { + "name": "the-little-cannon", + "composite": { + "fields": [ + { + "name": "class", + "composite": { + "values": [ + { + "value": { + "range": "TestCompile/filters/array.d2,1:9:30-1:15:36", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + }, + { + "value": { + "range": "TestCompile/filters/array.d2,1:17:38-1:25:46", + "value": [ + { + "string": "deployed", + "raw_string": "deployed" + } + ] + } + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,1:1:22-1:6:27", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,1:1:22-1:6:27", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,1:1:22-1:6:27", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,1:1:22-1:26:47", + "key": { + "range": "TestCompile/filters/array.d2,1:1:22-1:6:27", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,1:1:22-1:6:27", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/filters/array.d2,1:8:29-1:25:46", + "nodes": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,1:9:30-1:15:36", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,1:17:38-1:25:46", + "value": [ + { + "string": "deployed", + "raw_string": "deployed" + } + ] + } + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,11:1:134-11:15:148", + "ampersand": true, + "key": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:9:142-11:15:148", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + } + } + } + } + ] + }, + { + "name": "style", + "composite": { + "fields": [ + { + "name": "multiple", + "primary": { + "value": { + "range": "TestCompile/filters/array.d2,12:17:166-12:21:170", + "value": true + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:21:170", + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/array.d2,12:17:166-12:21:170", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:21:170", + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/array.d2,12:17:166-12:21:170", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,0:0:0-0:17:17", + "value": [ + { + "string": "the-little-cannon", + "raw_string": "the-little-cannon" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,0:0:0-0:17:17", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,0:0:0-0:17:17", + "value": [ + { + "string": "the-little-cannon", + "raw_string": "the-little-cannon" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,0:0:0-2:1:49", + "key": { + "range": "TestCompile/filters/array.d2,0:0:0-0:17:17", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,0:0:0-0:17:17", + "value": [ + { + "string": "the-little-cannon", + "raw_string": "the-little-cannon" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/array.d2,0:19:19-2:1:49", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/array.d2,1:1:22-1:26:47", + "key": { + "range": "TestCompile/filters/array.d2,1:1:22-1:6:27", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,1:1:22-1:6:27", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/filters/array.d2,1:8:29-1:25:46", + "nodes": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,1:9:30-1:15:36", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,1:17:38-1:25:46", + "value": [ + { + "string": "deployed", + "raw_string": "deployed" + } + ] + } + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "dino", + "composite": { + "fields": [ + { + "name": "class", + "composite": { + "values": [ + { + "value": { + "range": "TestCompile/filters/array.d2,4:9:67-4:17:75", + "value": [ + { + "string": "internal", + "raw_string": "internal" + } + ] + } + }, + { + "value": { + "range": "TestCompile/filters/array.d2,4:19:77-4:27:85", + "value": [ + { + "string": "deployed", + "raw_string": "deployed" + } + ] + } + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,4:1:59-4:6:64", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,4:1:59-4:6:64", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,4:1:59-4:6:64", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,4:1:59-4:28:86", + "key": { + "range": "TestCompile/filters/array.d2,4:1:59-4:6:64", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,4:1:59-4:6:64", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/filters/array.d2,4:8:66-4:27:85", + "nodes": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,4:9:67-4:17:75", + "value": [ + { + "string": "internal", + "raw_string": "internal" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,4:19:77-4:27:85", + "value": [ + { + "string": "deployed", + "raw_string": "deployed" + } + ] + } + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,11:1:134-11:15:148", + "ampersand": true, + "key": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:9:142-11:15:148", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,3:0:50-3:4:54", + "value": [ + { + "string": "dino", + "raw_string": "dino" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,3:0:50-3:4:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,3:0:50-3:4:54", + "value": [ + { + "string": "dino", + "raw_string": "dino" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,3:0:50-5:1:88", + "key": { + "range": "TestCompile/filters/array.d2,3:0:50-3:4:54", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,3:0:50-3:4:54", + "value": [ + { + "string": "dino", + "raw_string": "dino" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/array.d2,3:6:56-5:1:88", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/array.d2,4:1:59-4:28:86", + "key": { + "range": "TestCompile/filters/array.d2,4:1:59-4:6:64", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,4:1:59-4:6:64", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/filters/array.d2,4:8:66-4:27:85", + "nodes": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,4:9:67-4:17:75", + "value": [ + { + "string": "internal", + "raw_string": "internal" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,4:19:77-4:27:85", + "value": [ + { + "string": "deployed", + "raw_string": "deployed" + } + ] + } + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "catapult", + "composite": { + "fields": [ + { + "name": "class", + "composite": { + "values": [ + { + "value": { + "range": "TestCompile/filters/array.d2,7:9:110-7:14:115", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "value": { + "range": "TestCompile/filters/array.d2,7:16:117-7:22:123", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,7:1:102-7:6:107", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,7:1:102-7:6:107", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,7:1:102-7:6:107", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,7:1:102-7:23:124", + "key": { + "range": "TestCompile/filters/array.d2,7:1:102-7:6:107", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,7:1:102-7:6:107", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/filters/array.d2,7:8:109-7:22:123", + "nodes": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,7:9:110-7:14:115", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,7:16:117-7:22:123", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,11:1:134-11:15:148", + "ampersand": true, + "key": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:2:135-11:7:140", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,11:9:142-11:15:148", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + } + } + } + } + ] + }, + { + "name": "style", + "composite": { + "fields": [ + { + "name": "multiple", + "primary": { + "value": { + "range": "TestCompile/filters/array.d2,12:17:166-12:21:170", + "value": true + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:21:170", + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/array.d2,12:17:166-12:21:170", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:21:170", + "key": { + "range": "TestCompile/filters/array.d2,12:1:150-12:15:164", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:1:150-12:6:155", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,12:7:156-12:15:164", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/array.d2,12:17:166-12:21:170", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/array.d2,6:0:89-6:8:97", + "value": [ + { + "string": "catapult", + "raw_string": "catapult" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/array.d2,6:0:89-6:8:97", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,6:0:89-6:8:97", + "value": [ + { + "string": "catapult", + "raw_string": "catapult" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/array.d2,6:0:89-8:1:126", + "key": { + "range": "TestCompile/filters/array.d2,6:0:89-6:8:97", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,6:0:89-6:8:97", + "value": [ + { + "string": "catapult", + "raw_string": "catapult" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/array.d2,6:10:99-8:1:126", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/array.d2,7:1:102-7:23:124", + "key": { + "range": "TestCompile/filters/array.d2,7:1:102-7:6:107", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,7:1:102-7:6:107", + "value": [ + { + "string": "class", + "raw_string": "class" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/filters/array.d2,7:8:109-7:22:123", + "nodes": [ + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,7:9:110-7:14:115", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/array.d2,7:16:117-7:22:123", + "value": [ + { + "string": "server", + "raw_string": "server" + } + ] + } + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +} diff --git a/testdata/d2ir/TestCompile/filters/base.exp.json b/testdata/d2ir/TestCompile/filters/base.exp.json index 7e7ac0481..c8a934bbc 100644 --- a/testdata/d2ir/TestCompile/filters/base.exp.json +++ b/testdata/d2ir/TestCompile/filters/base.exp.json @@ -247,7 +247,7 @@ "name": "shape", "primary": { "value": { - "range": "TestCompile/filters/base.d2,7:9:70-7:18:79", + "range": "TestCompile/filters/base.d2,4:8:44-4:17:53", "value": [ { "string": "rectangle", @@ -318,68 +318,6 @@ } } }, - { - "string": { - "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - }, - "key_path": { - "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/filters/base.d2,7:1:62-7:18:79", - "ampersand": true, - "key": { - "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/filters/base.d2,7:9:70-7:18:79", - "value": [ - { - "string": "rectangle", - "raw_string": "rectangle" - } - ] - } - } - } - } - }, { "string": { "range": "TestCompile/filters/base.d2,7:2:63-7:7:68", diff --git a/testdata/d2ir/TestCompile/filters/order.exp.json b/testdata/d2ir/TestCompile/filters/order.exp.json index 68d9f7314..d7a77a374 100644 --- a/testdata/d2ir/TestCompile/filters/order.exp.json +++ b/testdata/d2ir/TestCompile/filters/order.exp.json @@ -247,7 +247,7 @@ "name": "shape", "primary": { "value": { - "range": "TestCompile/filters/order.d2,8:9:94-8:18:103", + "range": "TestCompile/filters/order.d2,4:8:44-4:17:53", "value": [ { "string": "rectangle", @@ -318,68 +318,6 @@ } } }, - { - "string": { - "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - }, - "key_path": { - "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - } - } - ] - }, - "context": { - "edge": null, - "key": { - "range": "TestCompile/filters/order.d2,8:1:86-8:18:103", - "ampersand": true, - "key": { - "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", - "value": [ - { - "string": "shape", - "raw_string": "shape" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/filters/order.d2,8:9:94-8:18:103", - "value": [ - { - "string": "rectangle", - "raw_string": "rectangle" - } - ] - } - } - } - } - }, { "string": { "range": "TestCompile/filters/order.d2,8:2:87-8:7:92", From 6358a44fcbcffddb2f3c19a73a6cccff20b3a7d2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 29 Jul 2023 21:39:41 -0700 Subject: [PATCH 7/8] changelogs/next.md: Update --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 4a15bc469..bd1d4c41c 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -10,6 +10,7 @@ Layout capability also takes a subtle but important step forward: you can now cu - `null` keyword can be used to un-declare. See [docs](https://d2lang.com/tour/overrides#null) [#1446](https://github.com/terrastruct/d2/pull/1446) - Develop multi-board diagrams in watch mode (links to layers/scenarios/steps work in `--watch`) [#1503](https://github.com/terrastruct/d2/pull/1503) - Glob patterns have been implemented. See [docs](https://d2lang.com/tour/globs). [#1479](https://github.com/terrastruct/d2/pull/1479) +- Ampersand filters have been implemented. See [docs](https://d2lang.com/tour/filters). [#1509](https://github.com/terrastruct/d2/pull/1509) #### Improvements 🧹 From d0d3ebe17e2f10618450b2ea13cf5f436da3e0fa Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 30 Jul 2023 13:16:56 -0700 Subject: [PATCH 8/8] d2ir: Fix filters on nested fields See test on edges --- d2ast/d2ast.go | 19 + d2ir/compile.go | 22 +- d2ir/filter_test.go | 40 +- .../d2ir/TestCompile/filters/edge.exp.json | 2696 +++++++++++++++++ .../filters/errors/no-glob.exp.json | 750 +++++ 5 files changed, 3518 insertions(+), 9 deletions(-) create mode 100644 testdata/d2ir/TestCompile/filters/edge.exp.json create mode 100644 testdata/d2ir/TestCompile/filters/errors/no-glob.exp.json diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 3f9c99ad1..fdbe9c9c3 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -720,6 +720,19 @@ func (mk *Key) SetScalar(scalar ScalarBox) { } } +func (mk *Key) HasQueryGlob() bool { + if mk.Key.HasGlob() && len(mk.Edges) == 0 { + return true + } + if mk.EdgeIndex != nil && mk.EdgeIndex.Glob && mk.EdgeKey == nil { + return true + } + if mk.EdgeKey.HasGlob() { + return true + } + return false +} + type KeyPath struct { Range Range `json:"range"` Path []*StringBox `json:"path"` @@ -748,6 +761,9 @@ func (kp *KeyPath) Copy() *KeyPath { } func (kp *KeyPath) HasDoubleGlob() bool { + if kp == nil { + return false + } for _, el := range kp.Path { if el.UnquotedString != nil && el.ScalarString() == "**" { return true @@ -757,6 +773,9 @@ func (kp *KeyPath) HasDoubleGlob() bool { } func (kp *KeyPath) HasGlob() bool { + if kp == nil { + return false + } for _, el := range kp.Path { if el.UnquotedString != nil && len(el.UnquotedString.Pattern) > 0 { return true diff --git a/d2ir/compile.go b/d2ir/compile.go index f88a4abdf..a0783923e 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -22,6 +22,8 @@ type compiler struct { // importCache enables reuse of files imported multiple times. importCache map[string]*Map utf16 bool + + globStack []bool } type CompileOptions struct { @@ -429,6 +431,10 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool { if !refctx.Key.Ampersand { return true } + if len(c.globStack) == 0 || !c.globStack[len(c.globStack)-1] { + c.errorf(refctx.Key, "glob filters cannot be used outside globs") + return false + } if len(refctx.Key.Edges) > 0 { return true } @@ -451,16 +457,12 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool { } func (c *compiler) _ampersandFilter(f *Field, refctx *RefContext) bool { - f2 := ParentMap(f).Map().GetField(refctx.Key.Key.IDA()...) - if f2 == nil { - return false - } if refctx.Key.Value.ScalarBox().Unbox() == nil { - c.errorf(refctx.Key, "ampersand filters cannot be composites") + c.errorf(refctx.Key, "glob filters cannot be composites") return false } - if a, ok := f2.Composite.(*Array); ok { + if a, ok := f.Composite.(*Array); ok { for _, v := range a.Values { if s, ok := v.(*Scalar); ok { if refctx.Key.Value.ScalarBox().Unbox().ScalarString() == s.Value.ScalarString() { @@ -470,11 +472,11 @@ func (c *compiler) _ampersandFilter(f *Field, refctx *RefContext) bool { } } - if f2.Primary_ == nil { + if f.Primary_ == nil { return false } - if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f2.Primary_.Value.ScalarString() { + if refctx.Key.Value.ScalarBox().Unbox().ScalarString() != f.Primary_.Value.ScalarString() { return false } @@ -530,7 +532,9 @@ func (c *compiler) _compileField(f *Field, refctx *RefContext) { // If new board type, use that as the new scope AST, otherwise, carry on scopeAST = refctx.ScopeAST } + c.globStack = append(c.globStack, refctx.Key.HasQueryGlob()) c.compileMap(f.Map(), refctx.Key.Value.Map, scopeAST) + c.globStack = c.globStack[:len(c.globStack)-1] switch NodeBoardKind(f) { case BoardScenario, BoardStep: c.overlayClasses(f.Map()) @@ -767,7 +771,9 @@ func (c *compiler) _compileEdges(refctx *RefContext) { parent: e, } } + c.globStack = append(c.globStack, refctx.Key.HasQueryGlob()) c.compileMap(e.Map_, refctx.Key.Value.Map, refctx.ScopeAST) + c.globStack = c.globStack[:len(c.globStack)-1] } else if refctx.Key.Value.ScalarBox().Unbox() != nil { e.Primary_ = &Scalar{ parent: e, diff --git a/d2ir/filter_test.go b/d2ir/filter_test.go index 54cfdba21..710ba0803 100644 --- a/d2ir/filter_test.go +++ b/d2ir/filter_test.go @@ -74,6 +74,28 @@ catapult: { assertQuery(t, m, 3, 0, nil, "catapult") }, }, + { + name: "edge", + run: func(t testing.TB) { + m, err := compile(t, `x -> y: { + source-arrowhead.shape: diamond + target-arrowhead.shape: diamond +} +x -> y + +(x -> *)[*]: { + &source-arrowhead.shape: diamond + &target-arrowhead.shape: diamond + label: diamond shape arrowheads +} +`) + assert.Success(t, err) + assertQuery(t, m, 7, 2, nil, "") + assertQuery(t, m, 5, 0, nil, "(x -> y)[0]") + assertQuery(t, m, 0, 0, "diamond shape arrowheads", "(x -> y)[0].label") + assertQuery(t, m, 0, 0, nil, "(x -> y)[1]") + }, + }, } runa(t, tca) @@ -97,6 +119,22 @@ catapult: { TestCompile/filters/errors/bad-syntax.d2:9:1: unexpected map termination character } in file map`) }, }, + { + name: "no-glob", + run: func(t testing.TB) { + _, err := compile(t, `jacob.style: { + fill: red + multiple: true +} + +jasmine.style: { + &fill: red + multiple: false +} +`) + assert.ErrorString(t, err, `TestCompile/filters/errors/no-glob.d2:7:3: glob filters cannot be used outside globs`) + }, + }, { name: "composite", run: func(t testing.TB) { @@ -111,7 +149,7 @@ TestCompile/filters/errors/bad-syntax.d2:9:1: unexpected map termination charact } } `) - assert.ErrorString(t, err, `TestCompile/filters/errors/composite.d2:6:2: ampersand filters cannot be composites`) + assert.ErrorString(t, err, `TestCompile/filters/errors/composite.d2:6:2: glob filters cannot be composites`) }, }, } diff --git a/testdata/d2ir/TestCompile/filters/edge.exp.json b/testdata/d2ir/TestCompile/filters/edge.exp.json new file mode 100644 index 000000000..7e65c4f85 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/edge.exp.json @@ -0,0 +1,2696 @@ +{ + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,0:0:0-3:1:77", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/edge.d2,0:8:8-3:1:77", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:32:42", + "key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:23:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:25:35-1:32:42", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:32:75", + "key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:23:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:25:68-2:32:75", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "src": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "src": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,6:0:86-10:1:203", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "TestCompile/filters/edge.d2,6:8:94-6:11:97", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/edge.d2,6:13:99-10:1:203", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/edge.d2,7:1:102-7:33:134", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:26:127-7:33:134", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,8:1:136-8:33:168", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:26:161-8:33:168", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:32:201", + "key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:8:177-9:32:201", + "value": [ + { + "string": "diamond shape arrowheads", + "raw_string": "diamond shape arrowheads" + } + ] + } + } + } + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,6:0:86-10:1:203", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "TestCompile/filters/edge.d2,6:8:94-6:11:97", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/edge.d2,6:13:99-10:1:203", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/edge.d2,7:1:102-7:33:134", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:26:127-7:33:134", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,8:1:136-8:33:168", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:26:161-8:33:168", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:32:201", + "key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:8:177-9:32:201", + "value": [ + { + "string": "diamond shape arrowheads", + "raw_string": "diamond shape arrowheads" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,0:0:0-3:1:77", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/edge.d2,0:8:8-3:1:77", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:32:42", + "key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:23:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:25:35-1:32:42", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:32:75", + "key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:23:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:25:68-2:32:75", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "src": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "src": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "map": { + "fields": [ + { + "name": "source-arrowhead", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/edge.d2,1:25:35-1:32:42", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:23:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:32:42", + "key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:23:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:25:35-1:32:42", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,7:1:102-7:33:134", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:26:127-7:33:134", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:23:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:32:42", + "key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:23:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:25:35-1:32:42", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,7:1:102-7:33:134", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:26:127-7:33:134", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + } + ] + }, + { + "name": "target-arrowhead", + "composite": { + "fields": [ + { + "name": "shape", + "primary": { + "value": { + "range": "TestCompile/filters/edge.d2,2:25:68-2:32:75", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:23:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:32:75", + "key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:23:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:25:68-2:32:75", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,8:1:136-8:33:168", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:26:161-8:33:168", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:23:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:32:75", + "key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:23:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:25:68-2:32:75", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,8:1:136-8:33:168", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:26:161-8:33:168", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + } + ] + }, + { + "name": "label", + "primary": { + "value": { + "range": "TestCompile/filters/edge.d2,9:8:177-9:32:201", + "value": [ + { + "string": "diamond shape arrowheads", + "raw_string": "diamond shape arrowheads" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:32:201", + "key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:8:177-9:32:201", + "value": [ + { + "string": "diamond shape arrowheads", + "raw_string": "diamond shape arrowheads" + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,0:0:0-3:1:77", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/edge.d2,0:8:8-3:1:77", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:32:42", + "key": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:23:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:1:11-1:17:27", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:18:28-1:23:33", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,1:25:35-1:32:42", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:32:75", + "key": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:23:66", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:1:44-2:17:60", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:18:61-2:23:66", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,2:25:68-2:32:75", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + } + ] + } + } + } + } + }, + { + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,6:0:86-10:1:203", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "TestCompile/filters/edge.d2,6:8:94-6:11:97", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/edge.d2,6:13:99-10:1:203", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/edge.d2,7:1:102-7:33:134", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:26:127-7:33:134", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,8:1:136-8:33:168", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:26:161-8:33:168", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:32:201", + "key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:8:177-9:32:201", + "value": [ + { + "string": "diamond shape arrowheads", + "raw_string": "diamond shape arrowheads" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 1, + "glob": false + }, + "map": { + "fields": null, + "edges": null + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "src": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,4:0:78-4:6:84", + "src": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:0:78-4:1:79", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,4:5:83-4:6:84", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + }, + { + "context": { + "edge": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/filters/edge.d2,6:0:86-10:1:203", + "edges": [ + { + "range": "TestCompile/filters/edge.d2,6:1:87-6:7:93", + "src": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:1:87-6:2:88", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,6:6:92-6:7:93", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "edge_index": { + "range": "TestCompile/filters/edge.d2,6:8:94-6:11:97", + "int": null, + "glob": true + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/edge.d2,6:13:99-10:1:203", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/edge.d2,7:1:102-7:33:134", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:24:125", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:2:103-7:18:119", + "value": [ + { + "string": "source-arrowhead", + "raw_string": "source-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:19:120-7:24:125", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,7:26:127-7:33:134", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,8:1:136-8:33:168", + "ampersand": true, + "key": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:24:159", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:2:137-8:18:153", + "value": [ + { + "string": "target-arrowhead", + "raw_string": "target-arrowhead" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:19:154-8:24:159", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,8:26:161-8:33:168", + "value": [ + { + "string": "diamond", + "raw_string": "diamond" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:32:201", + "key": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:1:170-9:6:175", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/edge.d2,9:8:177-9:32:201", + "value": [ + { + "string": "diamond shape arrowheads", + "raw_string": "diamond shape arrowheads" + } + ] + } + } + } + } + ] + } + } + } + } + } + ] + } + ] +} diff --git a/testdata/d2ir/TestCompile/filters/errors/no-glob.exp.json b/testdata/d2ir/TestCompile/filters/errors/no-glob.exp.json new file mode 100644 index 000000000..549e146b6 --- /dev/null +++ b/testdata/d2ir/TestCompile/filters/errors/no-glob.exp.json @@ -0,0 +1,750 @@ +{ + "fields": [ + { + "name": "jacob", + "composite": { + "fields": [ + { + "name": "style", + "composite": { + "fields": [ + { + "name": "fill", + "primary": { + "value": { + "range": "TestCompile/filters/errors/no-glob.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:10:25", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + } + } + ] + }, + { + "name": "multiple", + "primary": { + "value": { + "range": "TestCompile/filters/errors/no-glob.d2,2:11:37-2:15:41", + "value": true + } + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:15:41", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/no-glob.d2,2:11:37-2:15:41", + "value": true + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-3:1:43", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/no-glob.d2,0:13:13-3:1:43", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:10:25", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:15:41", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/no-glob.d2,2:11:37-2:15:41", + "value": true + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-3:1:43", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:11:11", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:0:0-0:5:5", + "value": [ + { + "string": "jacob", + "raw_string": "jacob" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,0:6:6-0:11:11", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/no-glob.d2,0:13:13-3:1:43", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:10:25", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:1:16-1:5:20", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,1:7:22-1:10:25", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:15:41", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,2:1:27-2:9:35", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/no-glob.d2,2:11:37-2:15:41", + "value": true + } + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "jasmine", + "composite": { + "fields": [ + { + "name": "style", + "composite": { + "fields": null, + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:8:53-5:13:58", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:13:58", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:7:52", + "value": [ + { + "string": "jasmine", + "raw_string": "jasmine" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:8:53-5:13:58", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-8:1:94", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:13:58", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:7:52", + "value": [ + { + "string": "jasmine", + "raw_string": "jasmine" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:8:53-5:13:58", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/no-glob.d2,5:15:60-8:1:94", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,6:2:64-6:12:74", + "ampersand": true, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,6:3:65-6:7:69", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,6:3:65-6:7:69", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,6:9:71-6:12:74", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,7:2:77-7:17:92", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,7:2:77-7:10:85", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,7:2:77-7:10:85", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/no-glob.d2,7:12:87-7:17:92", + "value": false + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:7:52", + "value": [ + { + "string": "jasmine", + "raw_string": "jasmine" + } + ] + }, + "key_path": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:13:58", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:7:52", + "value": [ + { + "string": "jasmine", + "raw_string": "jasmine" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:8:53-5:13:58", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-8:1:94", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:13:58", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:0:45-5:7:52", + "value": [ + { + "string": "jasmine", + "raw_string": "jasmine" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,5:8:53-5:13:58", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/filters/errors/no-glob.d2,5:15:60-8:1:94", + "nodes": [ + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,6:2:64-6:12:74", + "ampersand": true, + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,6:3:65-6:7:69", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,6:3:65-6:7:69", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,6:9:71-6:12:74", + "value": [ + { + "string": "red", + "raw_string": "red" + } + ] + } + } + } + }, + { + "map_key": { + "range": "TestCompile/filters/errors/no-glob.d2,7:2:77-7:17:92", + "key": { + "range": "TestCompile/filters/errors/no-glob.d2,7:2:77-7:10:85", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/filters/errors/no-glob.d2,7:2:77-7:10:85", + "value": [ + { + "string": "multiple", + "raw_string": "multiple" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "TestCompile/filters/errors/no-glob.d2,7:12:87-7:17:92", + "value": false + } + } + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null +}