updating compile edge validation

This commit is contained in:
Gavin Nishizawa 2023-09-27 17:51:39 -07:00
parent 3aed2c4110
commit bb79c30fd8
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -1092,35 +1092,34 @@ func (c *compiler) validateEdges(g *d2graph.Graph) {
srcGrid := edge.Src.Parent.ClosestGridDiagram() srcGrid := edge.Src.Parent.ClosestGridDiagram()
dstGrid := edge.Dst.Parent.ClosestGridDiagram() dstGrid := edge.Dst.Parent.ClosestGridDiagram()
if srcGrid != nil || dstGrid != nil { if srcGrid != nil || dstGrid != nil {
// TODO cleanup
// if top := srcGrid.TopGridDiagram(); srcGrid != top {
// // valid: grid.child1 -> grid.child2
// // invalid: grid.childGrid.child1 -> grid.childGrid.child2
// c.errorf(edge.GetAstEdge(), "edge must be on direct child of grid diagram %#v", top.AbsID())
// continue
// }
// if top := dstGrid.TopGridDiagram(); dstGrid != top {
// // valid: grid.child1 -> grid.child2
// // invalid: grid.childGrid.child1 -> grid.childGrid.child2
// c.errorf(edge.GetAstEdge(), "edge must be on direct child of grid diagram %#v", top.AbsID())
// continue
// }
if srcGrid != dstGrid { if srcGrid != dstGrid {
// valid: a -> grid // valid: a -> grid
// invalid: a -> grid.child // invalid: a -> grid.child
c.errorf(edge.GetAstEdge(), "edges into grid diagrams are not supported yet") c.errorf(edge.GetAstEdge(), "edges into grid diagrams are not supported yet")
continue continue
} }
}
// TODO cleanup // edges within a grid cell are ok now
if srcGrid != edge.Src.Parent || dstGrid != edge.Dst.Parent { // edges between grid cells are ok now
// valid: grid.child1 -> grid.child2 // edges from a grid to something outside is ok
// invalid: grid.child1 -> grid.child2.child1 // but edges from a grid cell must be to another grid cell
// c.errorf(edge.GetAstEdge(), "grid diagrams can only have edges between children right now") // TODO
// grid -> outside : ok
// grid -> grid.cell : not ok
// grid.cell -> grid.cell2 : ok
// grid.cell -> grid.cell2.inside : not ok
if edge.Src.IsGridDiagram() {
// TODO
c.errorf(edge.GetAstEdge(), "edges from grid diagram must be external")
continue continue
} }
if edge.Dst.IsGridDiagram() {
// TODO
c.errorf(edge.GetAstEdge(), "edges from grid diagram must be external")
continue
} }
} }
} }