Merge pull request #2476 from alixander/edge-level

d2ir: filter edge by src/dst non-field properties
This commit is contained in:
Alexander Wang 2025-03-31 11:02:06 -07:00 committed by GitHub
commit 2a0bd22451
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 888 additions and 66 deletions

View file

@ -5653,7 +5653,18 @@ d: {
&level: 1
style.stroke: yellow
}
(** -> **)[*]: {
&src.level: 0
&dst.level: 0
style.stroke: blue
}
a.b.c
x -> y
a: {
1 -> 2
}
a.1 -> x
`, ``)
assert.Equal(t, "a", g.Objects[0].ID)
assert.Equal(t, "red", g.Objects[0].Attributes.Style.Fill.Value)
@ -5666,6 +5677,15 @@ a.b.c
assert.Equal(t, "c", g.Objects[2].ID)
assert.Equal(t, (*d2graph.Scalar)(nil), g.Objects[2].Attributes.Style.Fill)
assert.Equal(t, (*d2graph.Scalar)(nil), g.Objects[2].Attributes.Style.Stroke)
assert.Equal(t, "(x -> y)[0]", g.Edges[0].AbsID())
assert.Equal(t, "blue", g.Edges[0].Attributes.Style.Stroke.Value)
assert.Equal(t, "a.(1 -> 2)[0]", g.Edges[1].AbsID())
assert.Equal(t, (*d2graph.Scalar)(nil), g.Edges[1].Attributes.Style.Stroke)
assert.Equal(t, "(a.1 -> x)[0]", g.Edges[2].AbsID())
assert.Equal(t, (*d2graph.Scalar)(nil), g.Edges[2].Attributes.Style.Stroke)
},
},
{

View file

@ -755,6 +755,13 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool {
return false
}
secondPart := keyPath.Path[1].Unbox().ScalarString()
value := refctx.Key.Value.ScalarBox().Unbox().ScalarString()
if len(keyPath.Path) == 2 && c._ampersandPropertyFilter(secondPart, value, node, refctx.Key) {
return true
}
propKeyPath := &d2ast.KeyPath{
Path: keyPath.Path[1:],
}
@ -840,53 +847,7 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool {
},
}
return c._ampersandFilter(f, refctx)
case "leaf":
raw := refctx.Key.Value.ScalarBox().Unbox().ScalarString()
boolVal, err := strconv.ParseBool(raw)
if err != nil {
c.errorf(refctx.Key, `&leaf must be "true" or "false", got %q`, raw)
return false
}
f := refctx.ScopeMap.Parent().(*Field)
isLeaf := f.Map() == nil || !f.Map().IsContainer()
return isLeaf == boolVal
case "level":
raw := refctx.Key.Value.ScalarBox().Unbox().ScalarString()
levelVal, err := strconv.Atoi(raw)
if err != nil {
c.errorf(refctx.Key, `&level must be a non-negative integer, got %q`, raw)
return false
}
if levelVal < 0 {
c.errorf(refctx.Key, `&level must be a non-negative integer, got %d`, levelVal)
return false
}
f := refctx.ScopeMap.Parent().(*Field)
level := 0
parent := ParentField(f)
for parent != nil && parent.Name.ScalarString() != "root" && NodeBoardKind(parent) == "" {
level++
parent = ParentField(parent)
}
return level == levelVal
case "connected":
raw := refctx.Key.Value.ScalarBox().Unbox().ScalarString()
boolVal, err := strconv.ParseBool(raw)
if err != nil {
c.errorf(refctx.Key, `&connected must be "true" or "false", got %q`, raw)
return false
}
f := refctx.ScopeMap.Parent().(*Field)
isConnected := false
for _, r := range f.References {
if r.InEdge() {
isConnected = true
break
}
}
return isConnected == boolVal
case "label":
f := &Field{}
n := refctx.ScopeMap.Parent()
@ -978,7 +939,10 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool {
return dstPath == filterValue
default:
return false
f := refctx.ScopeMap.Parent().(*Field)
propName := refctx.Key.Key.Last().ScalarString()
value := refctx.Key.Value.ScalarBox().Unbox().ScalarString()
return c._ampersandPropertyFilter(propName, value, f, refctx.Key)
}
}
for _, f := range fa {
@ -990,6 +954,70 @@ func (c *compiler) ampersandFilter(refctx *RefContext) bool {
return true
}
// handles filters that are not based on fields
func (c *compiler) _ampersandPropertyFilter(propName string, value string, node *Field, key *d2ast.Key) bool {
switch propName {
case "level":
levelVal, err := strconv.Atoi(value)
if err != nil {
c.errorf(key, `&level must be a non-negative integer, got %q`, value)
return false
}
if levelVal < 0 {
c.errorf(key, `&level must be a non-negative integer, got %d`, levelVal)
return false
}
level := 0
parent := ParentField(node)
for parent != nil && parent.Name.ScalarString() != "root" && NodeBoardKind(parent) == "" {
level++
parent = ParentField(parent)
}
return level == levelVal
case "leaf":
boolVal, err := strconv.ParseBool(value)
if err != nil {
c.errorf(key, `&leaf must be "true" or "false", got %q`, value)
return false
}
isLeaf := node.Map() == nil || !node.Map().IsContainer()
return isLeaf == boolVal
case "connected":
boolVal, err := strconv.ParseBool(value)
if err != nil {
c.errorf(key, `&connected must be "true" or "false", got %q`, value)
return false
}
isConnected := false
for _, r := range node.References {
if r.InEdge() {
isConnected = true
break
}
}
return isConnected == boolVal
case "label":
f := &Field{}
if node.Primary() == nil {
f.Primary_ = &Scalar{
Value: node.Name,
}
} else {
f.Primary_ = node.Primary()
}
propKey := &d2ast.Key{
Key: key.Key,
Value: key.Value,
}
propRefCtx := &RefContext{
Key: propKey,
}
return c._ampersandFilter(f, propRefCtx)
}
return false
}
func (c *compiler) _ampersandFilter(f *Field, refctx *RefContext) bool {
if refctx.Key.Value.ScalarBox().Unbox() == nil {
c.errorf(refctx.Key, "glob filters cannot be composites")

View file

@ -3,7 +3,7 @@
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,0:0:0-10:0:88",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,0:0:0-21:0:193",
"nodes": [
{
"map_key": {
@ -223,13 +223,206 @@
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-13:1:153",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:1:83-9:9:91",
"src": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:1:83-9:3:85",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:1:83-9:3:85",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:7:89-9:9:91",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:7:89-9:9:91",
"value": [
{
"string": "**",
"raw_string": "**"
}
],
"pattern": [
"*",
"",
"*"
]
}
}
]
},
"dst_arrow": ">"
}
],
"edge_index": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:10:92-9:13:95",
"int": null,
"glob": true
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:15:97-13:1:153",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,10:2:101-10:15:114",
"ampersand": true,
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,10:3:102-10:12:111",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,10:3:102-10:6:105",
"value": [
{
"string": "src",
"raw_string": "src"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,10:7:106-10:12:111",
"value": [
{
"string": "level",
"raw_string": "level"
}
]
}
}
]
},
"primary": {},
"value": {
"number": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,10:14:113-10:15:114",
"raw": "0",
"value": "0"
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,11:2:117-11:15:130",
"ampersand": true,
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,11:3:118-11:12:127",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,11:3:118-11:6:121",
"value": [
{
"string": "dst",
"raw_string": "dst"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,11:7:122-11:12:127",
"value": [
{
"string": "level",
"raw_string": "level"
}
]
}
}
]
},
"primary": {},
"value": {
"number": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,11:14:129-11:15:130",
"raw": "0",
"value": "0"
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,12:2:133-12:20:151",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,12:2:133-12:14:145",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,12:2:133-12:7:138",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,12:8:139-12:14:145",
"value": [
{
"string": "stroke",
"raw_string": "stroke"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,12:16:147-12:20:151",
"value": [
{
"string": "blue",
"raw_string": "blue"
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:5:159",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:5:159",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:1:83",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:1:155",
"value": [
{
"string": "a",
@ -240,7 +433,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:2:84-9:3:85",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:2:156-14:3:157",
"value": [
{
"string": "b",
@ -251,7 +444,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:4:86-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:4:158-14:5:159",
"value": [
{
"string": "c",
@ -265,6 +458,184 @@
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:0:161-16:6:167",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:0:161-16:6:167",
"src": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:0:161-16:1:162",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:0:161-16:1:162",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:5:166-16:6:167",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:5:166-16:6:167",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,17:0:168-19:1:183",
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,17:0:168-17:1:169",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,17:0:168-17:1:169",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,17:3:171-19:1:183",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:2:175-18:8:181",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:2:175-18:8:181",
"src": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:2:175-18:3:176",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:2:175-18:3:176",
"value": [
{
"string": "1",
"raw_string": "1"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:7:180-18:8:181",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:7:180-18:8:181",
"value": [
{
"string": "2",
"raw_string": "2"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:8:192",
"edges": [
{
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:8:192",
"src": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:3:187",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:1:185",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:2:186-20:3:187",
"value": [
{
"string": "1",
"raw_string": "1"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:7:191-20:8:192",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:7:191-20:8:192",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
}
]
},
@ -292,7 +663,108 @@
},
"zIndex": 0
},
"edges": null,
"edges": [
{
"index": 0,
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"references": [
{
"map_key_edge_index": 0
},
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"stroke": {
"value": "blue"
}
},
"iconStyle": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"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": {},
"iconStyle": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"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": {},
"iconStyle": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
],
"objects": [
{
"id": "a",
@ -300,11 +772,11 @@
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:5:159",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:1:83",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:1:155",
"value": [
{
"string": "a",
@ -315,7 +787,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:2:84-9:3:85",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:2:156-14:3:157",
"value": [
{
"string": "b",
@ -326,7 +798,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:4:86-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:4:158-14:5:159",
"value": [
{
"string": "c",
@ -339,6 +811,57 @@
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,17:0:168-17:1:169",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,17:0:168-17:1:169",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:3:187",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:1:185",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:2:186-20:3:187",
"value": [
{
"string": "1",
"raw_string": "1"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
@ -372,11 +895,11 @@
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:5:159",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:1:83",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:1:155",
"value": [
{
"string": "a",
@ -387,7 +910,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:2:84-9:3:85",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:2:156-14:3:157",
"value": [
{
"string": "b",
@ -398,7 +921,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:4:86-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:4:158-14:5:159",
"value": [
{
"string": "c",
@ -444,11 +967,11 @@
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:5:159",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:0:82-9:1:83",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:0:154-14:1:155",
"value": [
{
"string": "a",
@ -459,7 +982,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:2:84-9:3:85",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:2:156-14:3:157",
"value": [
{
"string": "b",
@ -470,7 +993,7 @@
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,9:4:86-9:5:87",
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,14:4:158-14:5:159",
"value": [
{
"string": "c",
@ -505,6 +1028,257 @@
"constraint": null
},
"zIndex": 0
},
{
"id": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:0:161-16:1:162",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:0:161-16:1:162",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:7:191-20:8:192",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:7:191-20:8:192",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "red"
}
},
"iconStyle": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:5:166-16:6:167",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,16:5:166-16:6:167",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "red"
}
},
"iconStyle": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "1",
"id_val": "1",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:2:175-18:3:176",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:2:175-18:3:176",
"value": [
{
"string": "1",
"raw_string": "1"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:3:187",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:0:184-20:1:185",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,20:2:186-20:3:187",
"value": [
{
"string": "1",
"raw_string": "1"
}
]
}
}
]
},
"key_path_index": 1,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "1"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"stroke": {
"value": "yellow"
}
},
"iconStyle": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "2",
"id_val": "2",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:7:180-18:8:181",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/globs/level-filter.d2,18:7:180-18:8:181",
"value": [
{
"string": "2",
"raw_string": "2"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "2"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"stroke": {
"value": "yellow"
}
},
"iconStyle": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},