d2ir: fix glob applications to multiple scenarios

This commit is contained in:
Alexander Wang 2024-07-27 10:01:21 -06:00
parent a7b55fc830
commit 32ece4a642
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
6 changed files with 1905 additions and 4 deletions

View file

@ -4700,10 +4700,31 @@ z.link: https://yahoo.com
},
},
{
name: "double-glob-second-scenario",
name: "reapply-scenario",
run: func(t *testing.T) {
g, _ := assertCompile(t, `
**.b*.shape: circle
*.b*.shape: circle
x: {
b
}
scenarios: {
k: {
x: {
b
}
}
}
`, ``)
assert.Equal(t, "circle", g.Objects[1].Attributes.Shape.Value)
assert.Equal(t, "circle", g.Scenarios[0].Objects[1].Attributes.Shape.Value)
},
},
{
name: "second-scenario",
run: func(t *testing.T) {
g, _ := assertCompile(t, `
*.b*.shape: circle
scenarios: {
k: {

View file

@ -24,6 +24,17 @@ type globContext struct {
appliedEdges map[string]struct{}
}
func (g *globContext) copyApplied(from *globContext) {
g.appliedFields = make(map[string]struct{})
for k, v := range from.appliedFields {
g.appliedFields[k] = v
}
g.appliedEdges = make(map[string]struct{})
for k, v := range from.appliedEdges {
g.appliedEdges[k] = v
}
}
type compiler struct {
err *d2parser.ParseError
@ -379,11 +390,13 @@ func (c *compiler) overlay(base *Map, f *Field) {
func (g *globContext) copy() *globContext {
g2 := *g
g2.refctx = g.root.refctx.Copy()
return &g2
}
func (g *globContext) prefixed(dst *Map) *globContext {
g2 := g.copy()
prefix := d2ast.MakeKeyPath(RelIDA(g2.refctx.ScopeMap, dst))
g2.refctx.Key = g2.refctx.Key.Copy()
if g2.refctx.Key.Key != nil {
@ -447,8 +460,19 @@ func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) {
globs = append(globs, g.prefixed(dst))
}
}
} else if NodeBoardKind(dst) != "" {
// Make all globs relative to the scenario or step.
} else if NodeBoardKind(dst) == BoardScenario {
for _, g := range previousGlobs {
g2 := g.prefixed(dst)
// We don't want globs applied in a given scenario to affect future boards
// Copying the applied fields and edges keeps the applications scoped to this board
// Note that this is different from steps, where applications carry over
if !g.refctx.Key.HasTripleGlob() {
// Triple globs already apply independently to each board
g2.copyApplied(g)
}
globs = append(globs, g2)
}
} else if NodeBoardKind(dst) == BoardStep {
for _, g := range previousGlobs {
globs = append(globs, g.prefixed(dst))
}

View file

@ -0,0 +1,607 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,0:0:0-13:0:81",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,1:0:1-1:18:19",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,1:0:1-1:10:11",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,1:0:1-1:1:2",
"value": [
{
"string": "*",
"raw_string": "*"
}
],
"pattern": [
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,1:2:3-1:4:5",
"value": [
{
"string": "b*",
"raw_string": "b*"
}
],
"pattern": [
"b",
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,1:5:6-1:10:11",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,1:12:13-1:18:19",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,2:0:20-4:1:30",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,2:0:20-2:1:21",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,2:0:20-2:1:21",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,2:3:23-4:1:30",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,3:2:27-3:3:28",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,3:2:27-3:3:28",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,3:2:27-3:3:28",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,6:0:32-12:1:80",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,6:0:32-6:9:41",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,6:0:32-6:9:41",
"value": [
{
"string": "scenarios",
"raw_string": "scenarios"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,6:11:43-12:1:80",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,7:2:47-11:3:78",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,7:2:47-7:3:48",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,7:2:47-7:3:48",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,7:5:50-11:3:78",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,8:4:56-10:5:74",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,8:4:56-8:5:57",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,8:4:56-8:5:57",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,8:7:59-10:5:74",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,9:6:67-9:7:68",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,9:6:67-9:7:68",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,9:6:67-9:7:68",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"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/reapply-scenario.d2,2:0:20-2:1:21",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,2:0:20-2:1:21",
"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": {},
"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/reapply-scenario.d2,3:2:27-3:3:28",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,3:2:27-3:3:28",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "circle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"scenarios": [
{
"name": "k",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1: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": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1: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": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1: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": "shape"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,1:12:13-1:18:19",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
},
"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/reapply-scenario.d2,2:0:20-2:1:21",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,2:0:20-2:1:21",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,8:4:56-8:5:57",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,8:4:56-8:5:57",
"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": {},
"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/reapply-scenario.d2,3:2:27-3:3:28",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,3:2:27-3:3:28",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,9:6:67-9:7:68",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/reapply-scenario.d2,9:6:67-9:7:68",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "circle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -0,0 +1,718 @@
{
"graph": {
"name": "",
"isFolderOnly": true,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,0:0:0-15:0:104",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:0:1-1:18:19",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:0:1-1:10:11",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:0:1-1:1:2",
"value": [
{
"string": "*",
"raw_string": "*"
}
],
"pattern": [
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:2:3-1:4:5",
"value": [
{
"string": "b*",
"raw_string": "b*"
}
],
"pattern": [
"b",
"*"
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:5:6-1:10:11",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:12:13-1:18:19",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,3:0:21-14:1:103",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,3:0:21-3:9:30",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,3:0:21-3:9:30",
"value": [
{
"string": "scenarios",
"raw_string": "scenarios"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,3:11:32-14:1:103",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,4:2:36-8:3:67",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,4:2:36-4:3:37",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,4:2:36-4:3:37",
"value": [
{
"string": "k",
"raw_string": "k"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,4:5:39-8:3:67",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,5:4:45-7:5:63",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,5:4:45-5:5:46",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,5:4:45-5:5:46",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,5:7:48-7:5:63",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,6:6:56-6:7:57",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,6:6:56-6:7:57",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,6:6:56-6:7:57",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,9:2:70-13:3:101",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,9:2:70-9:3:71",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,9:2:70-9:3:71",
"value": [
{
"string": "z",
"raw_string": "z"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,9:5:73-13:3:101",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,10:4:79-12:5:97",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,10:4:79-10:5:80",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,10:4:79-10:5:80",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,10:7:82-12:5:97",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,11:6:90-11:7:91",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,11:6:90-11:7:91",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,11:6:90-11:7:91",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"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": "k",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1: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": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1: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": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1: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": "shape"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:12:13-1:18:19",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
},
"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/second-scenario.d2,5:4:45-5:5:46",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,5:4:45-5:5:46",
"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": {},
"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/second-scenario.d2,6:6:56-6:7:57",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,6:6:56-6:7:57",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "circle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
{
"name": "z",
"isFolderOnly": false,
"ast": {
"range": ",0:0:0-1: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": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1: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": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": ",0:0:0-1: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": "shape"
}
]
}
}
]
},
"primary": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,1:12:13-1:18:19",
"value": [
{
"string": "circle",
"raw_string": "circle"
}
]
}
},
"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/second-scenario.d2,10:4:79-10:5:80",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,10:4:79-10:5:80",
"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": {},
"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/second-scenario.d2,11:6:90-11:7:91",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/second-scenario.d2,11:6:90-11:7:91",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "circle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -186,6 +186,240 @@
},
"due_to_glob": true,
"due_to_lazy_glob": true
},
{
"string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
},
"key_path": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19",
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
},
"due_to_glob": true,
"due_to_lazy_glob": true
},
{
"string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
},
"key_path": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19",
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
},
"due_to_glob": true,
"due_to_lazy_glob": true
}
]
}
@ -1353,6 +1587,240 @@
},
"due_to_glob": true,
"due_to_lazy_glob": true
},
{
"string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
},
"key_path": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19",
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
},
"due_to_glob": true,
"due_to_lazy_glob": true
},
{
"string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
},
"key_path": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"context": {
"edge": null,
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:18:19",
"key": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:13:14",
"path": [
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:0:1-1:2:3",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:3:4-1:8:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:9:10-1:13:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "TestCompile/patterns/alixander-review/5.d2,1:15:16-1:18:19",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
},
"due_to_glob": true,
"due_to_lazy_glob": true
}
]
}

View file

@ -1162,6 +1162,69 @@
}
},
"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"
}
]
}
}
}
},
"due_to_glob": true,
"due_to_lazy_glob": true
},
{
"string": {
"range": "TestCompile/patterns/double-glob/defaults.d2,1:1:7-1:6:12",