@@ -199,7 +199,7 @@ func ReconnectEdge(g *d2graph.Graph, boardPath []string, edgeKey string, srcKey,
199
199
200
200
refs := edge .References
201
201
if baseAST != g .AST {
202
- refs = getWriteableEdgeRefs (edge , baseAST )
202
+ refs = GetWriteableEdgeRefs (edge , baseAST )
203
203
if len (refs ) == 0 || refs [0 ].ScopeAST != baseAST {
204
204
// TODO null
205
205
return nil , OutsideScopeError {}
@@ -387,7 +387,7 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
387
387
388
388
var maybeNewScope * d2ast.Map
389
389
if baseAST != g .AST || imported {
390
- writeableRefs := getWriteableRefs (obj , baseAST )
390
+ writeableRefs := GetWriteableRefs (obj , baseAST )
391
391
for _ , ref := range writeableRefs {
392
392
if ref .MapKey != nil && ref .MapKey .Value .Map != nil {
393
393
maybeNewScope = ref .MapKey .Value .Map
@@ -414,7 +414,7 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
414
414
writeableLabelMK := true
415
415
var objK * d2ast.Key
416
416
if baseAST != g .AST || imported {
417
- writeableRefs := getWriteableRefs (obj , baseAST )
417
+ writeableRefs := GetWriteableRefs (obj , baseAST )
418
418
if len (writeableRefs ) > 0 {
419
419
objK = writeableRefs [0 ].MapKey
420
420
}
@@ -497,7 +497,7 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
497
497
imported = IsImportedEdge (baseAST , edge )
498
498
refs := edge .References
499
499
if baseAST != g .AST || imported {
500
- refs = getWriteableEdgeRefs (edge , baseAST )
500
+ refs = GetWriteableEdgeRefs (edge , baseAST )
501
501
}
502
502
onlyInChain := true
503
503
for _ , ref := range refs {
@@ -920,7 +920,7 @@ func Delete(g *d2graph.Graph, boardPath []string, key string) (_ *d2graph.Graph,
920
920
} else {
921
921
refs := e .References
922
922
if len (boardPath ) > 0 {
923
- refs := getWriteableEdgeRefs (e , baseAST )
923
+ refs := GetWriteableEdgeRefs (e , baseAST )
924
924
if len (refs ) != len (e .References ) {
925
925
mk .Value = d2ast .MakeValueBox (& d2ast.Null {})
926
926
}
@@ -991,7 +991,7 @@ func Delete(g *d2graph.Graph, boardPath []string, key string) (_ *d2graph.Graph,
991
991
return g , nil
992
992
}
993
993
if len (boardPath ) > 0 {
994
- writeableRefs := getWriteableRefs (obj , baseAST )
994
+ writeableRefs := GetWriteableRefs (obj , baseAST )
995
995
if len (writeableRefs ) != len (obj .References ) {
996
996
mk .Value = d2ast .MakeValueBox (& d2ast.Null {})
997
997
}
@@ -1759,7 +1759,7 @@ func move(g *d2graph.Graph, boardPath []string, key, newKey string, includeDesce
1759
1759
}
1760
1760
1761
1761
if len (boardPath ) > 0 {
1762
- writeableRefs := getWriteableRefs (obj , baseAST )
1762
+ writeableRefs := GetWriteableRefs (obj , baseAST )
1763
1763
if len (writeableRefs ) != len (obj .References ) {
1764
1764
return nil , OutsideScopeError {}
1765
1765
}
@@ -3226,21 +3226,3 @@ func filterReservedPath(path []*d2ast.StringBox) (filtered []*d2ast.StringBox) {
3226
3226
}
3227
3227
return
3228
3228
}
3229
-
3230
- func getWriteableRefs (obj * d2graph.Object , writeableAST * d2ast.Map ) (out []d2graph.Reference ) {
3231
- for i , ref := range obj .References {
3232
- if ref .ScopeAST == writeableAST && ref .Key .Range .Path == writeableAST .Range .Path {
3233
- out = append (out , obj .References [i ])
3234
- }
3235
- }
3236
- return
3237
- }
3238
-
3239
- func getWriteableEdgeRefs (edge * d2graph.Edge , writeableAST * d2ast.Map ) (out []d2graph.EdgeReference ) {
3240
- for i , ref := range edge .References {
3241
- if ref .ScopeAST == writeableAST {
3242
- out = append (out , edge .References [i ])
3243
- }
3244
- }
3245
- return
3246
- }
0 commit comments