add error for dagre container-child edge
This commit is contained in:
parent
cb48ebdb81
commit
a346542465
3 changed files with 21 additions and 0 deletions
|
|
@ -1586,3 +1586,13 @@ func (g *Graph) SortEdgesByAST() {
|
||||||
})
|
})
|
||||||
g.Edges = edges
|
g.Edges = edges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj *Object) IsDescendantOf(ancestor *Object) bool {
|
||||||
|
if obj == ancestor {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if obj.Parent == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return obj.Parent.IsDescendantOf(ancestor)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ func (p elkPlugin) Info(ctx context.Context) (*PluginInfo, error) {
|
||||||
Type: "bundled",
|
Type: "bundled",
|
||||||
Features: []PluginFeature{
|
Features: []PluginFeature{
|
||||||
CONTAINER_DIMENSIONS,
|
CONTAINER_DIMENSIONS,
|
||||||
|
DESCENDANT_EDGES,
|
||||||
},
|
},
|
||||||
ShortHelp: "Eclipse Layout Kernel (ELK) with the Layered algorithm.",
|
ShortHelp: "Eclipse Layout Kernel (ELK) with the Layered algorithm.",
|
||||||
LongHelp: fmt.Sprintf(`ELK is a layout engine offered by Eclipse.
|
LongHelp: fmt.Sprintf(`ELK is a layout engine offered by Eclipse.
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ const CONTAINER_DIMENSIONS PluginFeature = "container_dimensions"
|
||||||
// When this is true, objects can specify their `top` and `left` keywords
|
// When this is true, objects can specify their `top` and `left` keywords
|
||||||
const TOP_LEFT PluginFeature = "top_left"
|
const TOP_LEFT PluginFeature = "top_left"
|
||||||
|
|
||||||
|
// When this is true, containers can have connections to descendants
|
||||||
|
const DESCENDANT_EDGES PluginFeature = "descendant_edges"
|
||||||
|
|
||||||
func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error {
|
func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error {
|
||||||
// Older version of plugin. Skip checking.
|
// Older version of plugin. Skip checking.
|
||||||
if info.Features == nil {
|
if info.Features == nil {
|
||||||
|
|
@ -50,5 +53,12 @@ func FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if _, ok := featureMap[DESCENDANT_EDGES]; !ok {
|
||||||
|
for _, e := range g.Edges {
|
||||||
|
if e.Src.IsDescendantOf(e.Dst) || e.Dst.IsDescendantOf(e.Src) {
|
||||||
|
return fmt.Errorf(`Connection "%s" goes from a container to a descendant, but layout engine "%s" does not support this.`, e.AbsID(), info.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue