Skip to content

Commit b175c03

Browse files
committed
fix edge glob ampersand filters
1 parent 3bf7b49 commit b175c03

File tree

8 files changed

+1075
-2289
lines changed

8 files changed

+1075
-2289
lines changed

d2compiler/compile_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -5633,6 +5633,21 @@ c
56335633
assert.Equal(t, "hello", g.Edges[0].Label.Value)
56345634
},
56355635
},
5636+
{
5637+
name: "unsuspend-edge-filter",
5638+
run: func(t *testing.T) {
5639+
g, _ := assertCompile(t, `
5640+
a -> b
5641+
**: suspend
5642+
(** -> **)[*]: suspend
5643+
(* -> *)[*]: unsuspend {
5644+
&dst: a
5645+
}
5646+
`, ``)
5647+
assert.Equal(t, 0, len(g.Objects))
5648+
assert.Equal(t, 0, len(g.Edges))
5649+
},
5650+
},
56365651
{
56375652
name: "unsuspend-shape-label",
56385653
run: func(t *testing.T) {

d2ir/compile.go

+14
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,20 @@ func (c *compiler) _compileEdges(refctx *RefContext) {
12731273
continue
12741274
}
12751275

1276+
if refctx.Key.Value.Map != nil && refctx.Key.Value.Map.HasFilter() {
1277+
if e.Map_ == nil {
1278+
e.Map_ = &Map{
1279+
parent: e,
1280+
}
1281+
}
1282+
c.mapRefContextStack = append(c.mapRefContextStack, refctx)
1283+
ok := c.ampersandFilterMap(e.Map_, refctx.Key.Value.Map, refctx.ScopeAST)
1284+
c.mapRefContextStack = c.mapRefContextStack[:len(c.mapRefContextStack)-1]
1285+
if !ok {
1286+
continue
1287+
}
1288+
}
1289+
12761290
if refctx.Key.Primary.Suspension != nil || refctx.Key.Value.Suspension != nil {
12771291
if !c.lazyGlobBeingApplied {
12781292
var suspensionValue bool

testdata/d2compiler/TestCompile2/globs/edge-glob-ampersand-filter/1.exp.json

-144
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testdata/d2compiler/TestCompile2/globs/edge-glob-ampersand-filter/2.exp.json

-144
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)