d2oracle: fix creating edges in imported objects
This commit is contained in:
parent
4d136e0946
commit
8523641ba8
3 changed files with 534 additions and 10 deletions
|
|
@ -398,7 +398,7 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
|
|||
if baseAST != g.AST || imported {
|
||||
writeableRefs := GetWriteableRefs(obj, baseAST)
|
||||
for _, ref := range writeableRefs {
|
||||
if ref.MapKey != nil && ref.MapKey.Value.Map != nil {
|
||||
if ref.MapKey != nil && ref.MapKey.Value.Map != nil && ref.MapKey.Key == mk.Key {
|
||||
maybeNewScope = ref.MapKey.Value.Map
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -828,16 +828,13 @@ a: {
|
|||
key: `a.b -> a.c`,
|
||||
boardPath: []string{},
|
||||
|
||||
expKey: `d 2`,
|
||||
exp: `a
|
||||
d
|
||||
|
||||
steps: {
|
||||
x: {
|
||||
b
|
||||
d 2
|
||||
}
|
||||
expKey: `a.(b -> c)[0]`,
|
||||
exp: `...@k
|
||||
a.b: {
|
||||
icon: https://icons.terrastruct.com/essentials/004-picture.svg
|
||||
shape: image
|
||||
}
|
||||
a.(b -> c)
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
527
testdata/d2oracle/TestCreate/image-edge.exp.json
generated
vendored
Normal file
527
testdata/d2oracle/TestCreate/image-edge.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,527 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": "index.d2,0:0:0-6:0:106",
|
||||
"nodes": [
|
||||
{
|
||||
"import": {
|
||||
"range": "index.d2,0:0:0-0:5:5",
|
||||
"spread": true,
|
||||
"pre": "",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,0:4:4-0:5:5",
|
||||
"value": [
|
||||
{
|
||||
"string": "k",
|
||||
"raw_string": "k"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "index.d2,1:0:6-4:1:94",
|
||||
"key": {
|
||||
"range": "index.d2,1:0:6-1:3:9",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,1:0:6-1:1:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,1:2:8-1:3:9",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "index.d2,1:5:11-4:1:94",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "index.d2,2:2:15-2:64:77",
|
||||
"key": {
|
||||
"range": "index.d2,2:2:15-2:6:19",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,2:2:15-2:6:19",
|
||||
"value": [
|
||||
{
|
||||
"string": "icon",
|
||||
"raw_string": "icon"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,2:8:21-2:64:77",
|
||||
"value": [
|
||||
{
|
||||
"string": "https://icons.terrastruct.com/essentials/004-picture.svg",
|
||||
"raw_string": "https://icons.terrastruct.com/essentials/004-picture.svg"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "index.d2,3:2:80-3:14:92",
|
||||
"key": {
|
||||
"range": "index.d2,3:2:80-3:7:85",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,3:2:80-3:7:85",
|
||||
"value": [
|
||||
{
|
||||
"string": "shape",
|
||||
"raw_string": "shape"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,3:9:87-3:14:92",
|
||||
"value": [
|
||||
{
|
||||
"string": "image",
|
||||
"raw_string": "image"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "index.d2,5:0:95-5:10:105",
|
||||
"key": {
|
||||
"range": "index.d2,5:0:95-5:1:96",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,5:0:95-5:1:96",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"edges": [
|
||||
{
|
||||
"range": "index.d2,5:3:98-5:9:104",
|
||||
"src": {
|
||||
"range": "index.d2,5:3:98-5:4:99",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,5:3:98-5:4:99",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"src_arrow": "",
|
||||
"dst": {
|
||||
"range": "index.d2,5:8:103-5:9:104",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,5:8:103-5:9:104",
|
||||
"value": [
|
||||
{
|
||||
"string": "c",
|
||||
"raw_string": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"dst_arrow": ">"
|
||||
}
|
||||
],
|
||||
"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": [
|
||||
{
|
||||
"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": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
],
|
||||
"objects": [
|
||||
{
|
||||
"id": "a",
|
||||
"id_val": "a",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "k.d2,1:0:1-1:1:2",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "k.d2,1:0:1-1:1:2",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "index.d2,1:0:6-1:3:9",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,1:0:6-1:1:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,1:2:8-1:3:9",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "index.d2,5:0:95-5:1:96",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,5:0:95-5:1:96",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "a"
|
||||
},
|
||||
"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": "k.d2,2:2:8-2:3:9",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "k.d2,2:2:8-2:3:9",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "index.d2,1:0:6-1:3:9",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,1:0:6-1:1:7",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,1:2:8-1:3:9",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 1,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "index.d2,5:3:98-5:4:99",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,5:3:98-5:4:99",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "b"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"icon": {
|
||||
"Scheme": "https",
|
||||
"Opaque": "",
|
||||
"User": null,
|
||||
"Host": "icons.terrastruct.com",
|
||||
"Path": "/essentials/004-picture.svg",
|
||||
"RawPath": "",
|
||||
"OmitHost": false,
|
||||
"ForceQuery": false,
|
||||
"RawQuery": "",
|
||||
"Fragment": "",
|
||||
"RawFragment": ""
|
||||
},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "image"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
{
|
||||
"id": "c",
|
||||
"id_val": "c",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "k.d2,3:2:12-3:3:13",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "k.d2,3:2:12-3:3:13",
|
||||
"value": [
|
||||
{
|
||||
"string": "c",
|
||||
"raw_string": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "index.d2,5:8:103-5:9:104",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "index.d2,5:8:103-5:9:104",
|
||||
"value": [
|
||||
{
|
||||
"string": "c",
|
||||
"raw_string": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "c"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": "<nil>"
|
||||
}
|
||||
Loading…
Reference in a new issue