From 33ae53dc7525869cb845acb86687a9c5de9df528 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 17 Jan 2023 21:30:28 -0800 Subject: [PATCH] d2ir: IR Root wip --- d2ir/d2ir.go | 10 +- .../d2ir/TestCompile/edge/nested.exp.json | 638 +++++++++++++++++- testdata/d2ir/TestCompile/edge/root.exp.json | 252 ++++++- .../d2ir/TestCompile/edge/underscore.exp.json | 300 +++++++- .../d2ir/TestCompile/field/array.exp.json | 58 ++ .../d2ir/TestCompile/field/label.exp.json | 34 + .../d2ir/TestCompile/field/nested.exp.json | 90 +++ .../TestCompile/field/primary/nested.exp.json | 172 +++++ .../TestCompile/field/primary/root.exp.json | 87 +++ testdata/d2ir/TestCompile/field/root.exp.json | 24 + 10 files changed, 1657 insertions(+), 8 deletions(-) diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index b3983548d..2b73eae3d 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -321,7 +321,7 @@ type FieldReference struct { String *d2ast.StringBox `json:"string"` KeyPath *d2ast.KeyPath `json:"key_path"` - Context *RefContext `json:"-"` + Context *RefContext `json:"context"` } func (kr FieldReference) KeyPathIndex() int { @@ -342,13 +342,13 @@ func (kr FieldReference) InEdge() bool { } type EdgeReference struct { - Context *RefContext `json:"-"` + Context *RefContext `json:"context"` } type RefContext struct { - Key *d2ast.Key - Edge *d2ast.Edge - Scope *d2ast.Map + Key *d2ast.Key `json:"key"` + Edge *d2ast.Edge `json:"edge"` + Scope *d2ast.Map `json:"-"` } func (rc *RefContext) Copy() *RefContext { diff --git a/testdata/d2ir/TestCompile/edge/nested.exp.json b/testdata/d2ir/TestCompile/edge/nested.exp.json index e3ae5deca..bad3e6fa4 100644 --- a/testdata/d2ir/TestCompile/edge/nested.exp.json +++ b/testdata/d2ir/TestCompile/edge/nested.exp.json @@ -119,6 +119,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -165,6 +292,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -214,6 +468,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -260,6 +641,133 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -281,7 +789,135 @@ "index": 0 }, "references": [ - {} + { + "context": { + "key": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } ] } ] diff --git a/testdata/d2ir/TestCompile/edge/root.exp.json b/testdata/d2ir/TestCompile/edge/root.exp.json index 2e9d3451b..c38220c0b 100644 --- a/testdata/d2ir/TestCompile/edge/root.exp.json +++ b/testdata/d2ir/TestCompile/edge/root.exp.json @@ -82,6 +82,89 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -116,6 +199,89 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -135,7 +301,91 @@ "index": 0 }, "references": [ - {} + { + "context": { + "key": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edge/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } ] } ] diff --git a/testdata/d2ir/TestCompile/edge/underscore.exp.json b/testdata/d2ir/TestCompile/edge/underscore.exp.json index 720a7ec8d..fc8d86fea 100644 --- a/testdata/d2ir/TestCompile/edge/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edge/underscore.exp.json @@ -126,6 +126,111 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } } } ] @@ -161,6 +266,93 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/edge/underscore.d2,0:3:3-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] @@ -184,7 +376,113 @@ "index": 0 }, "references": [ - {} + { + "context": { + "key": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edge/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edge/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } ] } ] diff --git a/testdata/d2ir/TestCompile/field/array.exp.json b/testdata/d2ir/TestCompile/field/array.exp.json index 99972608e..68ffe36cc 100644 --- a/testdata/d2ir/TestCompile/field/array.exp.json +++ b/testdata/d2ir/TestCompile/field/array.exp.json @@ -125,6 +125,64 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/array.d2,0:0:0-0:12:12", + "key": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/field/array.d2,0:3:3-0:11:11", + "nodes": [ + { + "number": { + "range": "TestCompile/field/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "number": { + "range": "TestCompile/field/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" + } + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/label.exp.json b/testdata/d2ir/TestCompile/field/label.exp.json index f7e0f8f67..305f3aef1 100644 --- a/testdata/d2ir/TestCompile/field/label.exp.json +++ b/testdata/d2ir/TestCompile/field/label.exp.json @@ -80,6 +80,40 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/label.d2,0:0:0-0:6:6", + "key": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/nested.exp.json b/testdata/d2ir/TestCompile/field/nested.exp.json index 68cced08d..5cddad1b9 100644 --- a/testdata/d2ir/TestCompile/field/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/nested.exp.json @@ -106,6 +106,51 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } } ] @@ -152,6 +197,51 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/field/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/field/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/primary/nested.exp.json b/testdata/d2ir/TestCompile/field/primary/nested.exp.json index c3237d7d9..ebd8af9a3 100644 --- a/testdata/d2ir/TestCompile/field/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/nested.exp.json @@ -128,6 +128,30 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null } } ] @@ -174,6 +198,80 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] @@ -220,6 +318,80 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/primary/root.exp.json b/testdata/d2ir/TestCompile/field/primary/root.exp.json index 86a8ee87a..595bf1ea9 100644 --- a/testdata/d2ir/TestCompile/field/primary/root.exp.json +++ b/testdata/d2ir/TestCompile/field/primary/root.exp.json @@ -113,6 +113,30 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null } } ] @@ -148,6 +172,69 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/field/primary/root.d2,0:7:7-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "key": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } ] diff --git a/testdata/d2ir/TestCompile/field/root.exp.json b/testdata/d2ir/TestCompile/field/root.exp.json index bed994d89..01ab1fa88 100644 --- a/testdata/d2ir/TestCompile/field/root.exp.json +++ b/testdata/d2ir/TestCompile/field/root.exp.json @@ -59,6 +59,30 @@ } } ] + }, + "context": { + "key": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "key": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/field/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null } } ]