diff --git a/d2ir/compile.go b/d2ir/compile.go index 0d57b8383a..3153be4a9d 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 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 + + 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 + } + } } - } 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 39f938cd0e..54cfdba21c 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 0000000000..1fc2712333 --- /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 7e7ac04810..c8a934bbc6 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 68d9f7314f..d7a77a3745 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",