do not apply lazily
This commit is contained in:
parent
4520ec2c43
commit
d17a6e395c
3 changed files with 372 additions and 9 deletions
|
|
@ -5471,6 +5471,22 @@ a.width: 339
|
||||||
assert.Equal(t, 5, len(g.Objects))
|
assert.Equal(t, 5, len(g.Objects))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "suspension-restore-edge",
|
||||||
|
run: func(t *testing.T) {
|
||||||
|
g, _ := assertCompile(t, `
|
||||||
|
a -> b
|
||||||
|
c
|
||||||
|
**: suspend
|
||||||
|
(** -> **)[*]: suspend
|
||||||
|
d
|
||||||
|
|
||||||
|
# Also restores the objects connected
|
||||||
|
(** -> b)[*]: restore
|
||||||
|
`, ``)
|
||||||
|
assert.Equal(t, 3, len(g.Objects))
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tca {
|
for _, tc := range tca {
|
||||||
|
|
|
||||||
|
|
@ -868,11 +868,13 @@ func (c *compiler) _compileField(f *Field, refctx *RefContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(refctx.Key.Edges) == 0 && (refctx.Key.Primary.Suspension != nil || refctx.Key.Value.Suspension != nil) {
|
if len(refctx.Key.Edges) == 0 && (refctx.Key.Primary.Suspension != nil || refctx.Key.Value.Suspension != nil) {
|
||||||
|
if !c.lazyGlobBeingApplied {
|
||||||
if refctx.Key.Primary.Suspension != nil {
|
if refctx.Key.Primary.Suspension != nil {
|
||||||
f.suspended = refctx.Key.Primary.Suspension.Value
|
f.suspended = refctx.Key.Primary.Suspension.Value
|
||||||
} else {
|
} else {
|
||||||
f.suspended = refctx.Key.Value.Suspension.Value
|
f.suspended = refctx.Key.Value.Suspension.Value
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1176,12 +1178,13 @@ func (c *compiler) _compileEdges(refctx *RefContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if refctx.Key.Primary.Suspension != nil || refctx.Key.Value.Suspension != nil {
|
if refctx.Key.Primary.Suspension != nil || refctx.Key.Value.Suspension != nil {
|
||||||
|
if !c.lazyGlobBeingApplied {
|
||||||
if refctx.Key.Primary.Suspension != nil {
|
if refctx.Key.Primary.Suspension != nil {
|
||||||
e.suspended = refctx.Key.Primary.Suspension.Value
|
e.suspended = refctx.Key.Primary.Suspension.Value
|
||||||
} else {
|
} else {
|
||||||
e.suspended = refctx.Key.Value.Suspension.Value
|
e.suspended = refctx.Key.Value.Suspension.Value
|
||||||
}
|
}
|
||||||
continue
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.References = append(e.References, &EdgeReference{
|
e.References = append(e.References, &EdgeReference{
|
||||||
|
|
@ -1322,6 +1325,9 @@ func (m *Map) removeSuspendedFields() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := len(m.Fields) - 1; i >= 0; i-- {
|
for i := len(m.Fields) - 1; i >= 0; i-- {
|
||||||
|
if m.Fields[i].Name == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
_, isReserved := d2ast.ReservedKeywords[m.Fields[i].Name.ScalarString()]
|
_, isReserved := d2ast.ReservedKeywords[m.Fields[i].Name.ScalarString()]
|
||||||
if isReserved {
|
if isReserved {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
341
testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.exp.json
generated
vendored
Normal file
341
testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,341 @@
|
||||||
|
{
|
||||||
|
"graph": {
|
||||||
|
"name": "",
|
||||||
|
"isFolderOnly": false,
|
||||||
|
"ast": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,0:0:0-9:0:108",
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,1:0:1-1:6:7",
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,1:0:1-1:6:7",
|
||||||
|
"src": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,1:0:1-1:1:2",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,1:0:1-1:1:2",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "a",
|
||||||
|
"raw_string": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,1:5:6-1:6:7",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,1:5:6-1:6:7",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,2:0:8-2:1:9",
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,2:0:8-2:1:9",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,2:0:8-2:1:9",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "c",
|
||||||
|
"raw_string": "c"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,3:0:10-3:11:21",
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,3:0:10-3:2:12",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,3:0:10-3:2:12",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "**",
|
||||||
|
"raw_string": "**"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pattern": [
|
||||||
|
"*",
|
||||||
|
"",
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {
|
||||||
|
"suspension": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,3:4:14-3:11:21",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:0:22-4:22:44",
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:1:23-4:9:31",
|
||||||
|
"src": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:1:23-4:3:25",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:1:23-4:3:25",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "**",
|
||||||
|
"raw_string": "**"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pattern": [
|
||||||
|
"*",
|
||||||
|
"",
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:7:29-4:9:31",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:7:29-4:9:31",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "**",
|
||||||
|
"raw_string": "**"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pattern": [
|
||||||
|
"*",
|
||||||
|
"",
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"edge_index": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:10:32-4:13:35",
|
||||||
|
"int": null,
|
||||||
|
"glob": true
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {
|
||||||
|
"suspension": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,4:15:37-4:22:44",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,5:0:45-5:1:46",
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,5:0:45-5:1:46",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,5:0:45-5:1:46",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "d",
|
||||||
|
"raw_string": "d"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,7:0:48-7:37:85",
|
||||||
|
"value": "Also restores the objects connected"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map_key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:0:86-8:21:107",
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:1:87-8:8:94",
|
||||||
|
"src": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:1:87-8:3:89",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:1:87-8:3:89",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "**",
|
||||||
|
"raw_string": "**"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pattern": [
|
||||||
|
"*",
|
||||||
|
"",
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"src_arrow": "",
|
||||||
|
"dst": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:7:93-8:8:94",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:7:93-8:8:94",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "b",
|
||||||
|
"raw_string": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dst_arrow": ">"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"edge_index": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:9:95-8:12:98",
|
||||||
|
"int": null,
|
||||||
|
"glob": true
|
||||||
|
},
|
||||||
|
"primary": {},
|
||||||
|
"value": {
|
||||||
|
"suspension": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,8:14:100-8:21:107",
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"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": "d",
|
||||||
|
"id_val": "d",
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,5:0:45-5:1:46",
|
||||||
|
"path": [
|
||||||
|
{
|
||||||
|
"unquoted_string": {
|
||||||
|
"range": "d2/testdata/d2compiler/TestCompile2/globs/suspension-restore-edge.d2,5:0:45-5:1:46",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"string": "d",
|
||||||
|
"raw_string": "d"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"key_path_index": 0,
|
||||||
|
"map_key_edge_index": -1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attributes": {
|
||||||
|
"label": {
|
||||||
|
"value": "d"
|
||||||
|
},
|
||||||
|
"labelDimensions": {
|
||||||
|
"width": 0,
|
||||||
|
"height": 0
|
||||||
|
},
|
||||||
|
"style": {},
|
||||||
|
"near_key": null,
|
||||||
|
"shape": {
|
||||||
|
"value": "rectangle"
|
||||||
|
},
|
||||||
|
"direction": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"constraint": null
|
||||||
|
},
|
||||||
|
"zIndex": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"err": null
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue