d2ir: More alixander identified lazy glob bugs

This commit is contained in:
Anmol Sethi 2023-08-16 19:17:41 -07:00
parent d90f8253df
commit aba28d365a
No known key found for this signature in database
GPG key ID: 8CEF1878FF10ADEB
14 changed files with 8416 additions and 5122 deletions

View file

@ -4042,7 +4042,7 @@ func testGlobs(t *testing.T) {
run func(t *testing.T)
}{
{
name: "alixander-lazy-globs-review",
name: "alixander-lazy-globs-review/1",
run: func(t *testing.T) {
assertCompile(t, `
***.style.fill: yellow
@ -4058,6 +4058,20 @@ layers: {
a
}
}
`, "")
},
},
{
name: "alixander-lazy-globs-review/2",
run: func(t *testing.T) {
assertCompile(t, `
**.style.fill: yellow
scenarios: {
b: {
a -> b
}
}
`, "")
},
},

View file

@ -15,7 +15,9 @@ import (
)
type globContext struct {
root *globContext
refctx *RefContext
// Set of BoardIDA that this glob has already applied to.
appliedFields map[string]struct{}
// Set of Edge IDs that this glob has already applied to.
@ -361,7 +363,7 @@ func (c *compiler) overlay(base *Map, f *Field) {
func (g *globContext) prefixed(dst *Map) *globContext {
g2 := *g
g2.refctx = g.refctx.Copy()
g2.refctx = g.root.refctx.Copy()
prefix := d2ast.MakeKeyPath(RelIDA(g2.refctx.ScopeMap, dst))
g2.refctx.Key = g2.refctx.Key.Copy()
if g2.refctx.Key.Key != nil {
@ -477,6 +479,7 @@ func (c *compiler) ensureGlobContext(refctx *RefContext) *globContext {
appliedFields: make(map[string]struct{}),
appliedEdges: make(map[string]struct{}),
}
gctx.root = gctx
c.globContextStack[len(c.globContextStack)-1] = append(c.globContexts(), gctx)
return gctx
}
@ -829,7 +832,7 @@ func (c *compiler) _compileEdges(refctx *RefContext) {
var ea []*Edge
if eid.Index != nil || eid.Glob {
ea = refctx.ScopeMap.GetEdges(eid, refctx)
ea = refctx.ScopeMap.GetEdges(eid, refctx, c)
if len(ea) == 0 {
if !eid.Glob {
c.errorf(refctx.Edge, "indexed edge does not exist")

View file

@ -929,10 +929,14 @@ func (m *Map) DeleteField(ida ...string) *Field {
return nil
}
func (m *Map) GetEdges(eid *EdgeID, refctx *RefContext) []*Edge {
func (m *Map) GetEdges(eid *EdgeID, refctx *RefContext, c *compiler) []*Edge {
if refctx != nil {
var gctx *globContext
if refctx.Key.HasGlob() && c != nil {
gctx = c.ensureGlobContext(refctx)
}
var ea []*Edge
m.getEdges(eid, refctx, &ea)
m.getEdges(eid, refctx, gctx, &ea)
return ea
}
@ -946,7 +950,7 @@ func (m *Map) GetEdges(eid *EdgeID, refctx *RefContext) []*Edge {
return nil
}
if f.Map() != nil {
return f.Map().GetEdges(eid, nil)
return f.Map().GetEdges(eid, nil, nil)
}
return nil
}
@ -960,7 +964,7 @@ func (m *Map) GetEdges(eid *EdgeID, refctx *RefContext) []*Edge {
return ea
}
func (m *Map) getEdges(eid *EdgeID, refctx *RefContext, ea *[]*Edge) error {
func (m *Map) getEdges(eid *EdgeID, refctx *RefContext, gctx *globContext, ea *[]*Edge) error {
eid, m, common, err := eid.resolve(m)
if err != nil {
return err
@ -991,7 +995,7 @@ func (m *Map) getEdges(eid *EdgeID, refctx *RefContext, ea *[]*Edge) error {
parent: f,
}
}
err = f.Map().getEdges(eid, refctx, ea)
err = f.Map().getEdges(eid, refctx, gctx, ea)
if err != nil {
return err
}
@ -1014,8 +1018,22 @@ func (m *Map) getEdges(eid *EdgeID, refctx *RefContext, ea *[]*Edge) error {
eid2.SrcPath = RelIDA(m, src)
eid2.DstPath = RelIDA(m, dst)
ea2 := m.GetEdges(eid2, nil)
*ea = append(*ea, ea2...)
ea2 := m.GetEdges(eid2, nil, nil)
for _, e := range ea2 {
if gctx != nil {
var ks string
if refctx.Key.HasTripleGlob() {
ks = d2format.Format(d2ast.MakeKeyPath(IDA(e)))
} else {
ks = d2format.Format(d2ast.MakeKeyPath(BoardIDA(e)))
}
if _, ok := gctx.appliedEdges[ks]; ok {
continue
}
gctx.appliedEdges[ks] = struct{}{}
}
*ea = append(*ea, ea2...)
}
}
}
return nil
@ -1155,7 +1173,7 @@ func (m *Map) createEdge2(eid *EdgeID, refctx *RefContext, gctx *globContext, sr
eid.Index = nil
eid.Glob = true
ea := m.GetEdges(eid, nil)
ea := m.GetEdges(eid, nil, nil)
index := len(ea)
eid.Index = &index
eid.Glob = false
@ -1234,6 +1252,13 @@ func (e *Edge) AST() d2ast.Node {
return k
}
func (e *Edge) IDString() string {
ast := e.AST().(*d2ast.Key)
ast.Primary = d2ast.ScalarBox{}
ast.Value = d2ast.ValueBox{}
return d2format.Format(ast)
}
func (a *Array) AST() d2ast.Node {
if a == nil {
return nil
@ -1419,7 +1444,7 @@ func BoardIDA(n Node) (ida []string) {
}
ida = append(ida, n.Name)
case *Edge:
ida = append(ida, n.String())
ida = append(ida, n.IDString())
}
n = n.Parent()
if n == nil {
@ -1440,7 +1465,7 @@ func IDA(n Node) (ida []string) {
return ida
}
case *Edge:
ida = append(ida, n.String())
ida = append(ida, n.IDString())
}
n = n.Parent()
if n == nil {

View file

@ -11,7 +11,7 @@ func OverlayMap(base, overlay *Map) {
}
for _, oe := range overlay.Edges {
bea := base.GetEdges(oe.ID, nil)
bea := base.GetEdges(oe.ID, nil, nil)
if len(bea) == 0 {
base.Edges = append(base.Edges, oe.Copy(base).(*Edge))
continue

View file

@ -29,8 +29,15 @@ func (m *Map) _doubleGlob(fa *[]*Field) {
if _, ok := d2graph.BoardKeywords[f.Name]; !ok {
continue
}
// We don't ever want to append layers, scenarios or steps directly.
if f.Map() != nil {
f.Map()._tripleGlob(fa)
}
continue
}
if NodeBoardKind(f) == "" {
*fa = append(*fa, f)
}
*fa = append(*fa, f)
if f.Map() != nil {
f.Map()._doubleGlob(fa)
}

View file

@ -355,7 +355,7 @@ scenarios.x: { p }
layers.x: { p }
`)
assert.Success(t, err)
assertQuery(t, m, 25, 0, nil, "")
assertQuery(t, m, 23, 0, nil, "")
assertQuery(t, m, 0, 0, "page", "a.shape")
assertQuery(t, m, 0, 0, "page", "b.shape")
assertQuery(t, m, 0, 0, "page", "c.shape")
@ -482,6 +482,24 @@ c
assertQuery(t, m, 6, 0, nil, "")
},
},
{
name: "alixander-review/5",
run: func(t testing.TB) {
m, err := compile(t, `
**.style.fill: red
scenarios: {
b: {
a -> b
}
}
`)
assert.Success(t, err)
assertQuery(t, m, 8, 1, nil, "")
assertQuery(t, m, 0, 0, "red", "scenarios.b.a.style.fill")
assertQuery(t, m, 0, 0, "red", "scenarios.b.b.style.fill")
},
},
{
name: "override/1",
run: func(t testing.TB) {
@ -515,6 +533,33 @@ layers: {
assertQuery(t, m, 0, 0, "red", "layers.hi.a.style.fill")
},
},
{
name: "override/3",
run: func(t testing.TB) {
m, err := compile(t, `
(*** -> ***)[*].label: hi
a -> b
layers: {
hi: {
(*** -> ***)[*].label: bye
scenarios: {
b: {
# This label is "hi", but it should be "bye"
a -> b
}
}
}
}
`)
assert.Success(t, err)
assertQuery(t, m, 10, 2, nil, "")
assertQuery(t, m, 0, 0, "hi", "(a -> b)[0].label")
assertQuery(t, m, 0, 0, "bye", "layers.hi.scenarios.b.(a -> b)[0].label")
},
},
}
runa(t, tca)

View file

@ -36,7 +36,7 @@ func (m *Map) QueryAll(idStr string) (na []Node, _ error) {
ScopeMap: m,
Edge: k.Edges[i],
}
ea := m.GetEdges(eid, refctx)
ea := m.GetEdges(eid, refctx, nil)
for _, e := range ea {
if k.EdgeKey == nil {
na = append(na, e)

View file

@ -0,0 +1,610 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,0:0:0-14:0:109",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,1:0:1-1:22:23",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,1:0:1-1:14:15",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,1:0:1-1:3:4",
"value": [
{
"string": "***",
"raw_string": "***"
}
],
"pattern": [
"*",
"",
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,1:4:5-1:9:10",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,1:10:11-1:14:15",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,1:16:17-1:22:23",
"value": [
{
"string": "yellow",
"raw_string": "yellow"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,2:0:24-2:16:40",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,2:0:24-2:8:32",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,2:0:24-2:2:26",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,2:3:27-2:8:32",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,2:10:34-2:16:40",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,3:0:41-3:22:63",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,3:0:41-3:16:57",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,3:0:41-3:1:42",
"value": [
{
"string": "*",
"raw_string": "*"
}
],
"pattern": [
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,3:2:43-3:7:48",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,3:8:49-3:16:57",
"value": [
{
"string": "multiple",
"raw_string": "multiple"
}
]
}
}
]
},
"primary": {},
"value": {
"boolean": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,3:18:59-3:22:63",
"value": true
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,5:0:65-7:1:75",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,5:0:65-5:1:66",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,5:0:65-5:1:66",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,5:3:68-7:1:75",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,6:2:72-6:3:73",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,6:2:72-6:3:73",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,6:2:72-6:3:73",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,9:0:77-13:1:108",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,9:0:77-9:6:83",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,9:0:77-9:6:83",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,9:8:85-13:1:108",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,10:2:89-12:3:106",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,10:2:89-10:6:93",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,10:2:89-10:6:93",
"value": [
{
"string": "next",
"raw_string": "next"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,10:8:95-12:3:106",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,11:4:101-11:5:102",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,11:4:101-11:5:102",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,11:4:101-11:5:102",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,5:0:65-5:1:66",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,5:0:65-5:1:66",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "x"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "yellow"
},
"multiple": {
"value": "true"
}
},
"near_key": null,
"shape": {
"value": "circle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,6:2:72-6:3:73",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,6:2:72-6:3:73",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "y"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "yellow"
}
},
"near_key": null,
"shape": {
"value": "circle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"layers": [
{
"name": "next",
"isFolderOnly": false,
"ast": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "style"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "fill"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,1:16:17-1:22:23",
"value": [
{
"string": "yellow",
"raw_string": "yellow"
}
]
}
},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,11:4:101-11:5:102",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/1.d2,11:4:101-11:5:102",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "yellow"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -0,0 +1,587 @@
{
"graph": {
"name": "",
"isFolderOnly": true,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,0:0:0-8:0:61",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:0:1-1:21:22",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:15:16-1:21:22",
"value": [
{
"string": "yellow",
"raw_string": "yellow"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,3:0:24-7:1:60",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,3:0:24-3:9:33",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,3:0:24-3:9:33",
"value": [
{
"string": "scenarios",
"raw_string": "scenarios"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,3:11:35-7:1:60",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,4:2:39-6:3:58",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,4:2:39-4:3:40",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,4:2:39-4:3:40",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,4:5:42-6:3:58",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:4:48-5:10:54",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:4:48-5:10:54",
"src": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:4:48-5:5:49",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:4:48-5:5:49",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:9:53-5:10:54",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:9:53-5:10:54",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": null,
"objects": null,
"scenarios": [
{
"name": "b",
"isFolderOnly": false,
"ast": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "style"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "fill"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:15:16-1:21:22",
"value": [
{
"string": "yellow",
"raw_string": "yellow"
}
]
}
},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "style"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",1:0:0-2:0:0",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "fill"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,1:15:16-1:21:22",
"value": [
{
"string": "yellow",
"raw_string": "yellow"
}
]
}
},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": ",0:0:0-0:0:0",
"edges": [
{
"range": ",0:0:0-0:0:0",
"src": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "a"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "b"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": [
{
"index": 0,
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:4:48-5:5:49",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:4:48-5:5:49",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "yellow"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:9:53-5:10:54",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/alixander-lazy-globs-review/2.d2,5:9:53-5:10:54",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "yellow"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

File diff suppressed because it is too large Load diff

View file

@ -578,67 +578,6 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
@ -706,57 +645,6 @@
"edges": null
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,4:0:22-4:1:23",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,4:0:22-4:1:23",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,4:0:22-4:1:23",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,4:0:22-4:1:23",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,4:0:22-4:1:23",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,4:0:22-4:1:23",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,4:0:22-4:1:23",
@ -828,67 +716,6 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
@ -956,57 +783,6 @@
"edges": null
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,5:0:24-5:1:25",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,5:0:24-5:1:25",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,5:0:24-5:1:25",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,5:0:24-5:1:25",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,5:0:24-5:1:25",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,5:0:24-5:1:25",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,5:0:24-5:1:25",
@ -1078,67 +854,6 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
@ -1206,57 +921,6 @@
"edges": null
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,6:0:26-6:1:27",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,6:0:26-6:1:27",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,6:0:26-6:1:27",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,6:0:26-6:1:27",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,6:0:26-6:1:27",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,6:0:26-6:1:27",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,6:0:26-6:1:27",
@ -1328,67 +992,6 @@
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
@ -1456,57 +1059,6 @@
"edges": null
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,7:0:28-7:1:29",
"value": [
{
"string": "d",
"raw_string": "d"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,7:0:28-7:1:29",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,7:0:28-7:1:29",
"value": [
{
"string": "d",
"raw_string": "d"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,7:0:28-7:1:29",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,7:0:28-7:1:29",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,7:0:28-7:1:29",
"value": [
{
"string": "d",
"raw_string": "d"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,7:0:28-7:1:29",
@ -1697,83 +1249,6 @@
}
}
]
},
{
"name": "shape",
"primary": {
"value": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
}
]
}
],
"edges": null
@ -2021,83 +1496,6 @@
}
}
]
},
{
"name": "shape",
"primary": {
"value": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
},
"references": [
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
},
"key_path": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
}
]
}
],
"edges": null
@ -2343,145 +1741,6 @@
}
}
}
},
{
"string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "scenarios"
}
]
},
"key_path": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "scenarios"
}
]
}
},
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:0:0-0:2:2",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:0:0-2:1:20",
"key": {
"range": ",0:0:0-0:0:0",
"path": [
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "scenarios"
}
]
}
},
{
"unquoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "x"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:0:0-0:2:2",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "TestCompile/patterns/double-glob/defaults.d2,0:4:4-2:1:20",
"nodes": [
{
"map_key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:12:18",
"key": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:8:14-1:12:18",
"value": [
{
"string": "page",
"raw_string": "page"
}
]
}
}
}
}
]
}
}
}
}
}
]
},

4606
testdata/d2ir/TestCompile/patterns/override/3.exp.json generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,32 +2,10 @@
"fields": [
{
"name": "scenarios",
"primary": {
"value": {
"range": "TestCompile/patterns/scenarios.d2,16:4:57-16:13:66",
"value": [
{
"string": "something",
"raw_string": "something"
}
]
}
},
"composite": {
"fields": [
{
"name": "meow",
"primary": {
"value": {
"range": "TestCompile/patterns/scenarios.d2,16:4:57-16:13:66",
"value": [
{
"string": "something",
"raw_string": "something"
}
]
}
},
"composite": {
"fields": [
{

File diff suppressed because it is too large Load diff