d2oracle: exclude edges from writeable object refs
This commit is contained in:
parent
d9f6320585
commit
a68ab3bb7c
3 changed files with 698 additions and 1 deletions
|
|
@ -2666,6 +2666,31 @@ scenarios: {
|
|||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "step-connection",
|
||||
|
||||
text: `steps: {
|
||||
1: {
|
||||
Modules -- Metricbeat: {
|
||||
style.stroke-width: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
key: `Metricbeat.style.stroke`,
|
||||
value: go2.Pointer(`red`),
|
||||
boardPath: []string{"1"},
|
||||
exp: `steps: {
|
||||
1: {
|
||||
Modules -- Metricbeat: {
|
||||
style.stroke-width: 1
|
||||
}
|
||||
Metricbeat.style.stroke: red
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ func GetID(key string) string {
|
|||
|
||||
func GetWriteableRefs(obj *d2graph.Object, writeableAST *d2ast.Map) (out []d2graph.Reference) {
|
||||
for i, ref := range obj.References {
|
||||
if ref.ScopeAST == writeableAST && ref.Key.Range.Path == writeableAST.Range.Path {
|
||||
if ref.ScopeAST == writeableAST && ref.Key.Range.Path == writeableAST.Range.Path && len(ref.MapKey.Edges) == 0 {
|
||||
out = append(out, obj.References[i])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
672
testdata/d2oracle/TestSet/step-connection.exp.json
generated
vendored
Normal file
672
testdata/d2oracle/TestSet/step-connection.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,672 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": true,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,0:0:0-8:0:118",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,0:0:0-7:1:117",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,0:0:0-0:5:5",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,0:0:0-0:5:5",
|
||||
"value": [
|
||||
{
|
||||
"string": "steps",
|
||||
"raw_string": "steps"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,0:7:7-7:1:117",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,1:2:11-6:3:115",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,1:2:11-1:3:12",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,1:2:11-1:3:12",
|
||||
"value": [
|
||||
{
|
||||
"string": "1",
|
||||
"raw_string": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,1:5:14-6:3:115",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:4:20-4:5:78",
|
||||
"edges": [
|
||||
{
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:4:20-2:25:41",
|
||||
"src": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:4:20-2:11:27",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:4:20-2:11:27",
|
||||
"value": [
|
||||
{
|
||||
"string": "Modules",
|
||||
"raw_string": "Modules"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"src_arrow": "",
|
||||
"dst": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:15:31-2:25:41",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:15:31-2:25:41",
|
||||
"value": [
|
||||
{
|
||||
"string": "Metricbeat",
|
||||
"raw_string": "Metricbeat"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"dst_arrow": ""
|
||||
}
|
||||
],
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:27:43-4:5:78",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:6:51-3:27:72",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:6:51-3:24:69",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:6:51-3:11:56",
|
||||
"value": [
|
||||
{
|
||||
"string": "style",
|
||||
"raw_string": "style"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:12:57-3:24:69",
|
||||
"value": [
|
||||
{
|
||||
"string": "stroke-width",
|
||||
"raw_string": "stroke-width"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"number": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:26:71-3:27:72",
|
||||
"raw": "1",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:4:83-5:32:111",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:4:83-5:27:106",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:4:83-5:14:93",
|
||||
"value": [
|
||||
{
|
||||
"string": "Metricbeat",
|
||||
"raw_string": "Metricbeat"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:15:94-5:20:99",
|
||||
"value": [
|
||||
{
|
||||
"string": "style",
|
||||
"raw_string": "style"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:21:100-5:27:106",
|
||||
"value": [
|
||||
{
|
||||
"string": "stroke",
|
||||
"raw_string": "stroke"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:29:108-5:32:111",
|
||||
"value": [
|
||||
{
|
||||
"string": "red",
|
||||
"raw_string": "red"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"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": null,
|
||||
"steps": [
|
||||
{
|
||||
"name": "1",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": ",0:0:0-1:0:0",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:4:20-2:11:27",
|
||||
"value": [
|
||||
{
|
||||
"string": "Modules",
|
||||
"raw_string": "Modules"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:15:31-2:25:41",
|
||||
"value": [
|
||||
{
|
||||
"string": "Metricbeat",
|
||||
"raw_string": "Metricbeat"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": ",0:0:0-1:0:0",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:15:94-5:20:99",
|
||||
"value": [
|
||||
{
|
||||
"string": "style",
|
||||
"raw_string": "style"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": ",0:0:0-1:0:0",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:21:100-5:27:106",
|
||||
"value": [
|
||||
{
|
||||
"string": "stroke",
|
||||
"raw_string": "stroke"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:29:108-5:32:111",
|
||||
"value": [
|
||||
{
|
||||
"string": "red",
|
||||
"raw_string": "red"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"edges": [
|
||||
{
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"src": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"value": [
|
||||
{
|
||||
"string": "Modules"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"src_arrow": "",
|
||||
"dst": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"value": [
|
||||
{
|
||||
"string": "Metricbeat"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"dst_arrow": ""
|
||||
}
|
||||
],
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": ",0:0:0-1:0:0",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:6:51-3:11:56",
|
||||
"value": [
|
||||
{
|
||||
"string": "style",
|
||||
"raw_string": "style"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": ",0:0:0-1:0:0",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:12:57-3:24:69",
|
||||
"value": [
|
||||
{
|
||||
"string": "stroke-width",
|
||||
"raw_string": "stroke-width"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {
|
||||
"number": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,3:26:71-3:27:72",
|
||||
"raw": "1",
|
||||
"value": "1"
|
||||
}
|
||||
},
|
||||
"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": false,
|
||||
"references": [
|
||||
{
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": ""
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {
|
||||
"strokeWidth": {
|
||||
"value": "1"
|
||||
}
|
||||
},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
],
|
||||
"objects": [
|
||||
{
|
||||
"id": "Modules",
|
||||
"id_val": "Modules",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:4:20-2:11:27",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:4:20-2:11:27",
|
||||
"value": [
|
||||
{
|
||||
"string": "Modules",
|
||||
"raw_string": "Modules"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "Modules"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
{
|
||||
"id": "Metricbeat",
|
||||
"id_val": "Metricbeat",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:15:31-2:25:41",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,2:15:31-2:25:41",
|
||||
"value": [
|
||||
{
|
||||
"string": "Metricbeat",
|
||||
"raw_string": "Metricbeat"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": 0
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:4:83-5:27:106",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:4:83-5:14:93",
|
||||
"value": [
|
||||
{
|
||||
"string": "Metricbeat",
|
||||
"raw_string": "Metricbeat"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:15:94-5:20:99",
|
||||
"value": [
|
||||
{
|
||||
"string": "style",
|
||||
"raw_string": "style"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/step-connection.d2,5:21:100-5:27:106",
|
||||
"value": [
|
||||
{
|
||||
"string": "stroke",
|
||||
"raw_string": "stroke"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "Metricbeat"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"value": "red"
|
||||
}
|
||||
},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": "<nil>"
|
||||
}
|
||||
Loading…
Reference in a new issue