save
This commit is contained in:
parent
08cc907f07
commit
e7e2566564
3 changed files with 204 additions and 2 deletions
|
|
@ -3242,9 +3242,7 @@ hi: {
|
|||
},
|
||||
},
|
||||
{
|
||||
// TODO: text before/after substitutions
|
||||
name: "combined",
|
||||
skip: true,
|
||||
run: func(t *testing.T) {
|
||||
g := assertCompile(t, `
|
||||
vars: {
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) {
|
|||
}
|
||||
|
||||
func (c *compiler) compileKey(refctx *RefContext) {
|
||||
// resolve substitutions here
|
||||
if len(refctx.Key.Edges) == 0 {
|
||||
c.compileField(refctx.ScopeMap, refctx.Key.Key, refctx)
|
||||
} else {
|
||||
|
|
@ -325,6 +326,8 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext)
|
|||
parent: f,
|
||||
Value: refctx.Key.Value.ScalarBox().Unbox(),
|
||||
}
|
||||
|
||||
// InterpolationBox within any of these values can be substitutions too
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
201
testdata/d2compiler/TestCompile2/vars/basic/combined.exp.json
generated
vendored
Normal file
201
testdata/d2compiler/TestCompile2/vars/basic/combined.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,0:0:0-5:0:38",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,1:0:1-3:1:24",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,1:0:1-1:4:5",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,1:0:1-1:4:5",
|
||||
"value": [
|
||||
{
|
||||
"string": "vars",
|
||||
"raw_string": "vars"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,1:6:7-3:1:24",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,2:2:11-2:13:22",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,2:2:11-2:3:12",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,2:2:11-2:3:12",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,2:5:14-2:13:22",
|
||||
"value": [
|
||||
{
|
||||
"string": "im a var",
|
||||
"raw_string": "im a var"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:0:25-4:12:37",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:0:25-4:2:27",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:0:25-4:2:27",
|
||||
"value": [
|
||||
{
|
||||
"string": "hi",
|
||||
"raw_string": "hi"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:4:29-4:12:37",
|
||||
"value": [
|
||||
{
|
||||
"string": "1 ",
|
||||
"raw_string": "1 "
|
||||
},
|
||||
{
|
||||
"substitution": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:6:31-4:10:35",
|
||||
"spread": false,
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:8:33-4:9:34",
|
||||
"value": [
|
||||
{
|
||||
"string": "x",
|
||||
"raw_string": "x"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"string": " 2",
|
||||
"raw_string": "1 2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"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": "hi",
|
||||
"id_val": "hi",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:0:25-4:2:27",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/combined.d2,4:0:25-4:2:27",
|
||||
"value": [
|
||||
{
|
||||
"string": "hi",
|
||||
"raw_string": "hi"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "1 "
|
||||
},
|
||||
"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