package jetbrains.mps.console.actions; /*Generated by MPS */ import java.util.Map; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.baseLanguage.closures.runtime._FunctionTypes; import java.util.WeakHashMap; import jetbrains.mps.internal.collections.runtime.MapSequence; public class ClosureHoldingNodeUtil { private static ClosureHoldingNodeUtil myInstance; private Map<SNode, _FunctionTypes._void_P0_E0> allActions; private ClosureHoldingNodeUtil() { allActions = new WeakHashMap<SNode, _FunctionTypes._void_P0_E0>(); } public static ClosureHoldingNodeUtil getInstance() { if (myInstance == null) { myInstance = new ClosureHoldingNodeUtil(); } return myInstance; } public void register(SNode node, _FunctionTypes._void_P0_E0 closure) { MapSequence.fromMap(allActions).put(node, closure); } public _FunctionTypes._void_P0_E0 getClosure(SNode node) { return MapSequence.fromMap(allActions).get(node); } public void executeClosure(SNode node) { getClosure(node).invoke(); } }