From c0df120f6c0506f3bf2b39dea80d52fa1aeca297 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 30 Jul 2023 01:15:34 -0700 Subject: [PATCH] d2ir: Make globs more ergonomic in two specific edge cases Were identified from @alixander writing documentation. --- d2ir/d2ir.go | 25 + d2ir/pattern_test.go | 33 + .../double-glob/edge-no-container.exp.json | 1161 +++++++++++++++++ .../TestCompile/patterns/edge-nexus.exp.json | 779 +++++++++++ .../d2ir/TestCompile/patterns/edge/1.exp.json | 234 ---- .../d2ir/TestCompile/patterns/edge/2.exp.json | 274 ---- .../d2ir/TestCompile/patterns/edge/3.exp.json | 354 ----- .../TestCompile/patterns/reserved.exp.json | 402 ------ 8 files changed, 1998 insertions(+), 1264 deletions(-) create mode 100644 testdata/d2ir/TestCompile/patterns/double-glob/edge-no-container.exp.json create mode 100644 testdata/d2ir/TestCompile/patterns/edge-nexus.exp.json diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index 53bb5a499d..531eaea562 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -587,6 +587,19 @@ func (m *Map) FieldCountRecursive() int { return acc } +func (m *Map) IsContainer() bool { + if m == nil { + return false + } + for _, f := range m.Fields { + _, isReserved := d2graph.ReservedKeywords[f.Name] + if !isReserved { + return true + } + } + return false +} + func (m *Map) EdgeCountRecursive() int { if m == nil { return 0 @@ -1066,6 +1079,18 @@ func (m *Map) createEdge(eid *EdgeID, refctx *RefContext, ea *[]*Edge) error { for _, src := range srcFA { for _, dst := range dstFA { + if src == dst && (len(srcFA) > 1 || len(dstFA) > 1) { + // Globs do not make self edges. + continue + } + + // If either has a double glob at the end we only select leafs, those without children. + if srcKP.Path[len(srcKP.Path)-1].ScalarString() == "**" || dstKP.Path[len(dstKP.Path)-1].ScalarString() == "**" { + if src.Map().IsContainer() || dst.Map().IsContainer() { + continue + } + } + eid2 := eid.Copy() eid2.SrcPath = RelIDA(m, src) eid2.DstPath = RelIDA(m, dst) diff --git a/d2ir/pattern_test.go b/d2ir/pattern_test.go index fdcd53af9f..1e5eca1645 100644 --- a/d2ir/pattern_test.go +++ b/d2ir/pattern_test.go @@ -189,6 +189,23 @@ c -> b assertQuery(t, m, 0, 0, "red", "(c -> b)[0].style.fill") }, }, + { + name: "edge-nexus", + run: func(t testing.TB) { + m, err := compile(t, `a +b +c +d +* -> nexus +`) + assert.Success(t, err) + assertQuery(t, m, 5, 4, nil, "") + assertQuery(t, m, 0, 0, nil, "(a -> nexus)[0]") + assertQuery(t, m, 0, 0, nil, "(b -> nexus)[0]") + assertQuery(t, m, 0, 0, nil, "(c -> nexus)[0]") + assertQuery(t, m, 0, 0, nil, "(d -> nexus)[0]") + }, + }, { name: "double-glob/1", run: func(t testing.TB) { @@ -205,6 +222,22 @@ shared.animal assertQuery(t, m, 1, 0, nil, "shared.animal.style") }, }, + { + name: "double-glob/edge-no-container", + run: func(t testing.TB) { + m, err := compile(t, `zone A: { + machine A + machine B: { + submachine A + submachine B + } +} +zone A.** -> load balancer +`) + assert.Success(t, err) + assertQuery(t, m, 6, 3, nil, "") + }, + }, { name: "reserved", run: func(t testing.TB) { diff --git a/testdata/d2ir/TestCompile/patterns/double-glob/edge-no-container.exp.json b/testdata/d2ir/TestCompile/patterns/double-glob/edge-no-container.exp.json new file mode 100644 index 0000000000..9e115779c4 --- /dev/null +++ b/testdata/d2ir/TestCompile/patterns/double-glob/edge-no-container.exp.json @@ -0,0 +1,1161 @@ +{ + "fields": [ + { + "name": "zone A", + "composite": { + "fields": [ + { + "name": "machine A", + "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "value": [ + { + "string": "machine A", + "raw_string": "machine A" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "value": [ + { + "string": "machine A", + "raw_string": "machine A" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "value": [ + { + "string": "machine A", + "raw_string": "machine A" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "name": "machine B", + "composite": { + "fields": [ + { + "name": "submachine A", + "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "value": [ + { + "string": "submachine A", + "raw_string": "submachine A" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "value": [ + { + "string": "submachine A", + "raw_string": "submachine A" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "value": [ + { + "string": "submachine A", + "raw_string": "submachine A" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "name": "submachine B", + "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "value": [ + { + "string": "submachine B", + "raw_string": "submachine B" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "value": [ + { + "string": "submachine B", + "raw_string": "submachine B" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "value": [ + { + "string": "submachine B", + "raw_string": "submachine B" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-2:10:31", + "value": [ + { + "string": "machine B", + "raw_string": "machine B" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-2:10:31", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-2:10:31", + "value": [ + { + "string": "machine B", + "raw_string": "machine B" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-5:2:67", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-2:10:31", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-2:10:31", + "value": [ + { + "string": "machine B", + "raw_string": "machine B" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:12:33-5:2:67", + "nodes": [ + { + "map_key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "value": [ + { + "string": "submachine A", + "raw_string": "submachine A" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "value": [ + { + "string": "submachine B", + "raw_string": "submachine B" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,0:0:0-0:6:6", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,0:0:0-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,0:0:0-0:6:6", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,0:0:0-6:1:69", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,0:0:0-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,0:0:0-0:6:6", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,0:8:8-6:1:69", + "nodes": [ + { + "map_key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,1:1:11-1:10:20", + "value": [ + { + "string": "machine A", + "raw_string": "machine A" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-5:2:67", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-2:10:31", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:1:22-2:10:31", + "value": [ + { + "string": "machine B", + "raw_string": "machine B" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,2:12:33-5:2:67", + "nodes": [ + { + "map_key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,3:2:37-3:14:49", + "value": [ + { + "string": "submachine A", + "raw_string": "submachine A" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,4:2:52-4:14:64", + "value": [ + { + "string": "submachine B", + "raw_string": "submachine B" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + }, + { + "string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "edges": [ + { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "name": "load balancer", + "references": [ + { + "string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "edges": [ + { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "zone A", + "machine A" + ], + "src_arrow": false, + "dst_path": [ + "load balancer" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "edges": [ + { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "zone A", + "machine B", + "submachine A" + ], + "src_arrow": false, + "dst_path": [ + "load balancer" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "edges": [ + { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "zone A", + "machine B", + "submachine B" + ], + "src_arrow": false, + "dst_path": [ + "load balancer" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "edges": [ + { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:26:96", + "src": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:9:79", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:0:70-7:6:76", + "value": [ + { + "string": "zone A", + "raw_string": "zone A" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:7:77-7:9:79", + "value": [ + { + "string": "**", + "raw_string": "**" + } + ], + "pattern": [ + "*", + "", + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/double-glob/edge-no-container.d2,7:13:83-7:26:96", + "value": [ + { + "string": "load balancer", + "raw_string": "load balancer" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + } + ] +} diff --git a/testdata/d2ir/TestCompile/patterns/edge-nexus.exp.json b/testdata/d2ir/TestCompile/patterns/edge-nexus.exp.json new file mode 100644 index 0000000000..ee685d4948 --- /dev/null +++ b/testdata/d2ir/TestCompile/patterns/edge-nexus.exp.json @@ -0,0 +1,779 @@ +{ + "fields": [ + { + "name": "a", + "references": [ + { + "string": { + "range": "TestCompile/patterns/edge-nexus.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/edge-nexus.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,0:0:0-0:1:1", + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,0:0:0-0:1:1", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "name": "b", + "references": [ + { + "string": { + "range": "TestCompile/patterns/edge-nexus.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/edge-nexus.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,1:0:2-1:1:3", + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,1:0:2-1:1:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,1:0:2-1:1:3", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "name": "c", + "references": [ + { + "string": { + "range": "TestCompile/patterns/edge-nexus.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/edge-nexus.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,2:0:4-2:1:5", + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,2:0:4-2:1:5", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,2:0:4-2:1:5", + "value": [ + { + "string": "c", + "raw_string": "c" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "name": "d", + "references": [ + { + "string": { + "range": "TestCompile/patterns/edge-nexus.d2,3:0:6-3:1:7", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/edge-nexus.d2,3:0:6-3:1:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,3:0:6-3:1:7", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "context": { + "edge": null, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,3:0:6-3:1:7", + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,3:0:6-3:1:7", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,3:0:6-3:1:7", + "value": [ + { + "string": "d", + "raw_string": "d" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "name": "nexus", + "references": [ + { + "string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + }, + "key_path": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "context": { + "edge": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "edges": [ + { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "a" + ], + "src_arrow": false, + "dst_path": [ + "nexus" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "edges": [ + { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "b" + ], + "src_arrow": false, + "dst_path": [ + "nexus" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "edges": [ + { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "c" + ], + "src_arrow": false, + "dst_path": [ + "nexus" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "edges": [ + { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + }, + { + "edge_id": { + "src_path": [ + "d" + ], + "src_arrow": false, + "dst_path": [ + "nexus" + ], + "dst_arrow": true, + "index": 0, + "glob": false + }, + "references": [ + { + "context": { + "edge": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + }, + "key": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "edges": [ + { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:10:18", + "src": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:0:8-4:1:9", + "value": [ + { + "string": "*", + "raw_string": "*" + } + ], + "pattern": [ + "*" + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/patterns/edge-nexus.d2,4:5:13-4:10:18", + "value": [ + { + "string": "nexus", + "raw_string": "nexus" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + } + ] + } + ] +} diff --git a/testdata/d2ir/TestCompile/patterns/edge/1.exp.json b/testdata/d2ir/TestCompile/patterns/edge/1.exp.json index 6e38e272d2..087072d2dc 100644 --- a/testdata/d2ir/TestCompile/patterns/edge/1.exp.json +++ b/testdata/d2ir/TestCompile/patterns/edge/1.exp.json @@ -114,123 +114,6 @@ } ], "edges": [ - { - "edge_id": { - "src_path": [ - "animate" - ], - "src_arrow": false, - "dst_path": [ - "animate" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:10:25", - "src": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:10:25", - "edges": [ - { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:10:25", - "src": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - } - ] - }, { "edge_id": { "src_path": [ @@ -464,123 +347,6 @@ } } ] - }, - { - "edge_id": { - "src_path": [ - "animal" - ], - "src_arrow": false, - "dst_path": [ - "animal" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:10:25", - "src": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:10:25", - "edges": [ - { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:10:25", - "src": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:0:15-2:3:18", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/1.d2,2:7:22-2:10:25", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - } - ] } ] } diff --git a/testdata/d2ir/TestCompile/patterns/edge/2.exp.json b/testdata/d2ir/TestCompile/patterns/edge/2.exp.json index 95a956c075..016f524db5 100644 --- a/testdata/d2ir/TestCompile/patterns/edge/2.exp.json +++ b/testdata/d2ir/TestCompile/patterns/edge/2.exp.json @@ -162,143 +162,6 @@ } ], "edges": [ - { - "edge_id": { - "src_path": [ - "animate" - ], - "src_arrow": false, - "dst_path": [ - "animate" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:15:44", - "src": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/edge/2.d2,2:0:29-2:16:45", - "key": { - "range": "TestCompile/patterns/edge/2.d2,2:0:29-2:3:32", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:0:29-2:3:32", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - } - ] - }, - "edges": [ - { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:15:44", - "src": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - } - ] - }, { "edge_id": { "src_path": [ @@ -572,143 +435,6 @@ } } ] - }, - { - "edge_id": { - "src_path": [ - "animal" - ], - "src_arrow": false, - "dst_path": [ - "animal" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:15:44", - "src": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/edge/2.d2,2:0:29-2:16:45", - "key": { - "range": "TestCompile/patterns/edge/2.d2,2:0:29-2:3:32", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:0:29-2:3:32", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - } - ] - }, - "edges": [ - { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:15:44", - "src": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:5:34-2:8:37", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/2.d2,2:12:41-2:15:44", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - } - ] } ] }, diff --git a/testdata/d2ir/TestCompile/patterns/edge/3.exp.json b/testdata/d2ir/TestCompile/patterns/edge/3.exp.json index 3316812a80..a6a0200bc4 100644 --- a/testdata/d2ir/TestCompile/patterns/edge/3.exp.json +++ b/testdata/d2ir/TestCompile/patterns/edge/3.exp.json @@ -162,183 +162,6 @@ } ], "edges": [ - { - "edge_id": { - "src_path": [ - "animate" - ], - "src_arrow": false, - "dst_path": [ - "animate" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:18:47", - "src": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:7:36", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:3:32", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:4:33-2:7:36", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:18:47", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:14:43", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:15:44-2:18:47", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:18:47", - "edges": [ - { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:18:47", - "src": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:7:36", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:3:32", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:4:33-2:7:36", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:18:47", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:14:43", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:15:44-2:18:47", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - } - ] - }, { "edge_id": { "src_path": [ @@ -692,183 +515,6 @@ } } ] - }, - { - "edge_id": { - "src_path": [ - "animal" - ], - "src_arrow": false, - "dst_path": [ - "animal" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:18:47", - "src": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:7:36", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:3:32", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:4:33-2:7:36", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:18:47", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:14:43", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:15:44-2:18:47", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:18:47", - "edges": [ - { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:18:47", - "src": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:7:36", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:0:29-2:3:32", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:4:33-2:7:36", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:18:47", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:11:40-2:14:43", - "value": [ - { - "string": "sh*", - "raw_string": "sh*" - } - ], - "pattern": [ - "sh", - "*" - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/patterns/edge/3.d2,2:15:44-2:18:47", - "value": [ - { - "string": "an*", - "raw_string": "an*" - } - ], - "pattern": [ - "an", - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - } - ] } ] }, diff --git a/testdata/d2ir/TestCompile/patterns/reserved.exp.json b/testdata/d2ir/TestCompile/patterns/reserved.exp.json index 091efd0dfe..01fb1938f7 100644 --- a/testdata/d2ir/TestCompile/patterns/reserved.exp.json +++ b/testdata/d2ir/TestCompile/patterns/reserved.exp.json @@ -476,140 +476,6 @@ } ], "edges": [ - { - "edge_id": { - "src_path": [ - "Spiderman 1" - ], - "src_arrow": false, - "dst_path": [ - "Spiderman 1" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "primary": { - "value": { - "range": "TestCompile/patterns/reserved.d2,10:8:98-10:13:103", - "value": [ - { - "string": "arrow", - "raw_string": "arrow" - } - ] - } - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:6:96", - "src": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:13:103", - "edges": [ - { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:6:96", - "src": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:8:98-10:13:103", - "value": [ - { - "string": "arrow", - "raw_string": "arrow" - } - ] - } - } - } - } - } - ] - }, { "edge_id": { "src_path": [ @@ -1012,140 +878,6 @@ } ] }, - { - "edge_id": { - "src_path": [ - "Spiderman 2" - ], - "src_arrow": false, - "dst_path": [ - "Spiderman 2" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "primary": { - "value": { - "range": "TestCompile/patterns/reserved.d2,10:8:98-10:13:103", - "value": [ - { - "string": "arrow", - "raw_string": "arrow" - } - ] - } - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:6:96", - "src": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:13:103", - "edges": [ - { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:6:96", - "src": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:8:98-10:13:103", - "value": [ - { - "string": "arrow", - "raw_string": "arrow" - } - ] - } - } - } - } - } - ] - }, { "edge_id": { "src_path": [ @@ -1547,140 +1279,6 @@ } } ] - }, - { - "edge_id": { - "src_path": [ - "Spiderman 3" - ], - "src_arrow": false, - "dst_path": [ - "Spiderman 3" - ], - "dst_arrow": true, - "index": 0, - "glob": false - }, - "primary": { - "value": { - "range": "TestCompile/patterns/reserved.d2,10:8:98-10:13:103", - "value": [ - { - "string": "arrow", - "raw_string": "arrow" - } - ] - } - }, - "references": [ - { - "context": { - "edge": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:6:96", - "src": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - }, - "key": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:13:103", - "edges": [ - { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:6:96", - "src": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:0:90-10:1:91", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:5:95-10:6:96", - "value": [ - { - "string": "*", - "raw_string": "*" - } - ], - "pattern": [ - "*" - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/patterns/reserved.d2,10:8:98-10:13:103", - "value": [ - { - "string": "arrow", - "raw_string": "arrow" - } - ] - } - } - } - } - } - ] } ] }