fix: cr, validateNear outside connection
This commit is contained in:
parent
d85bb2d16f
commit
b9dd247c75
1 changed files with 5 additions and 21 deletions
|
|
@ -736,12 +736,14 @@ func (c *compiler) validateNear(g *d2graph.Graph) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
descendantsMap := getNearDescendants(obj)
|
|
||||||
connectToOutside := false
|
connectToOutside := false
|
||||||
for _, edge := range g.Edges {
|
for _, edge := range g.Edges {
|
||||||
if (descendantsMap[edge.Src] && !descendantsMap[edge.Dst]) ||
|
srcNearContainer := edge.Src.OuterNearContainer()
|
||||||
(!descendantsMap[edge.Src] && descendantsMap[edge.Dst]) {
|
dstNearContainer := edge.Dst.OuterNearContainer()
|
||||||
|
|
||||||
|
if srcNearContainer != dstNearContainer {
|
||||||
connectToOutside = true
|
connectToOutside = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -757,24 +759,6 @@ func (c *compiler) validateNear(g *d2graph.Graph) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNearDescendants(nearObj *d2graph.Object) map[*d2graph.Object]bool {
|
|
||||||
descendantsMap := make(map[*d2graph.Object]bool)
|
|
||||||
|
|
||||||
var helper func(obj *d2graph.Object)
|
|
||||||
|
|
||||||
helper = func(obj *d2graph.Object) {
|
|
||||||
if obj.ChildrenArray != nil {
|
|
||||||
for _, child := range obj.ChildrenArray {
|
|
||||||
descendantsMap[child] = true
|
|
||||||
helper(child)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
helper(nearObj)
|
|
||||||
return descendantsMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *compiler) validateBoardLinks(g *d2graph.Graph) {
|
func (c *compiler) validateBoardLinks(g *d2graph.Graph) {
|
||||||
for _, obj := range g.Objects {
|
for _, obj := range g.Objects {
|
||||||
if obj.Attributes.Link == nil {
|
if obj.Attributes.Link == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue