fullstack-lang / gongdoc

A gong stack for editing UML diagrams of gong code
MIT License
1 stars 0 forks source link

Separates NodeImplInterface into NodeImplInterface and NodeInterface #153

Closed thomaspeugeot closed 1 year ago

thomaspeugeot commented 1 year ago

Situation:

The NodeImplInterface is supposed to implement the control flow from the Node to its implementation.

type NodeImplInterface interface {
    OnAfterUpdate(stage *StageStruct, stagedNode, frontNode *Node)
    OnAfterDelete(stage *StageStruct, stagedNode, frontNode *Node)
...
}

Problem:

There are other functions in this interface that seem to fullfill control in the other direction.

...
    HasToBeChecked() bool
    SetHasToBeCheckedValue(value bool)
    HasToBeDisabled() bool
    SetHasToBeDisabledValue(value bool)

Solution

Rename function

Notes that GongNodes are DSL Nodes

Clarify the control flow from the node to the node implementation and from the node implementation to the node

When the control computing the configuration of the gong nodes, it computes the "disabled".

So the control flow goes

gong object --> BackPointer (the impl) SetHasToBeDisabled

then later

Impl --> Node IsDisabled

This is unecessary complication

Steps

    HasToBeChecked() bool
    SetHasToBeCheckedValue(value bool)
    HasToBeDisabled() bool
    SetHasToBeDisabledValue(value bool)
    // now, parse again the tree of nodes and set the IsChecked according to the
    // the node implementation
    for _, rootNode := range nodeCb.treeOfGongObjects.RootNodes {
        for _, node := range rootNode.Children {
            node.IsCheckboxDisabled = node.Impl.HasToBeDisabled()
            node.IsChecked = node.Impl.HasToBeChecked()

            for _, node := range node.Children {
                node.IsCheckboxDisabled = node.Impl.HasToBeDisabled()
                node.IsChecked = node.Impl.HasToBeChecked()
            }
        }
    }
    if nodeImpl != nil {
        nodeImpl.SetHasToBeCheckedValue(false)
        nodeImpl.SetHasToBeDisabledValue(hasToBeDisabledValue)
    }

Cleanup contructors....