/** * Visits {@link ComponentContainer} nodes and creates a task that writes the * source code containing the initialization of the binding controller data * structure. */ public Component visit(final List<Node> path, final ComponentContainer container, final Map<Object, Object> context) throws ADLException, TaskException { final BindingContainer bindingContainer = castNodeError(container, BindingContainer.class); return createTask(container, bindingContainer.getBindings()); }
@SuppressWarnings("unchecked") private static <T extends Node> T cloneGraph(final T node, final Map<Node, Node> clonedNodes) { T clone = (T) clonedNodes.get(node); if (clone == null) { clone = cloneNodeState(node); // add sub nodes for (final String subNodeType : node.astGetNodeTypes()) { for (final Node subNode : node.astGetNodes(subNodeType)) { if (subNode != null) clone.astAddNode(cloneGraph(subNode, clonedNodes)); } } clonedNodes.put(node, clone); } return clone; }
/** * Clone the given {@link Node} and its sub nodes recursively. <br> * <b>Warning</b>: this method consider that the given node is the root of a * <b>tree graph</b> (i.e. any transitive sub node of the given node is the * sub node of one and only one node). Use {@link #cloneGraph(Node)} method if * this condition is not true. * * @param <T> The type of the node. * @param node the root of the tree to clone. * @return a clone of the given tree of node. * @see #cloneGraph(Node) */ public static <T extends Node> T cloneTree(final T node) { final T newNode = cloneNodeState(node); // add sub nodes for (final String subNodeType : node.astGetNodeTypes()) { for (final Node subNode : node.astGetNodes(subNodeType)) { if (subNode != null) newNode.astAddNode(cloneTree(subNode)); } } return newNode; }
/** * Clone the given {@link Node} and its sub nodes recursively. This method * handles shared nodes correctly. * * @param <T> The type of the node. * @param node the root of the graph to clone. * @return a clone of the given graph of node. */ public static <T extends Node> T cloneGraph(final T node) { return cloneGraph(node, new IdentityHashMap<Node, Node>()); }
/** * Clone the given {@link Node}. Sub nodes of the given node are not * recursively cloned. This imply that the returned node has the same sub * nodes as the given node. * * @param <T> The type of the node. * @param node the node to clone. * @return a clone of the given node. */ public static <T extends Node> T cloneNode(final T node) { final T newNode = cloneNodeState(node); // add sub nodes for (final String subNodeType : node.astGetNodeTypes()) { for (final Node subNode : node.astGetNodes(subNodeType)) { if (subNode != null) newNode.astAddNode(subNode); } } return newNode; }
/** * Creates a task that writes the source code containing the definition of the * interfaces of the component. */ @Override protected Component createTask(final ComponentContainer container, final List<TypeInterface> itfs) throws ADLException, TaskException { final List<IDLDefinition> itfDefinitions = new ArrayList<IDLDefinition>(); for (final Interface itf : itfs) { itfDefinitions.add(castNodeError(itf, IDLDefinitionContainer.class) .getIDLDefinition()); } return taskFactoryItf.newPrimitiveTask(new InterfaceDefinitonTask( itfDefinitions), container, itfDefinitions); }
public Component visit(final List<Node> path, final ComponentContainer node, final Map<Object, Object> context) throws ADLException, TaskException { final Implementation impl = castNodeError(node, ImplementationContainer.class).getImplementation(); if (impl == null) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, "This visitor is only applicable for primitive component."); } return createImplementationTask(node, impl); }
@Override public Node visit(final SuperTemplateDefinition n, final Node argu) { assert argu != null; final TemplateComponent template = castNodeError(argu, TemplateComponent.class); final SuperTemplate superTemplate = (SuperTemplate) newNode( "superTemplate", n.f0); superTemplate.setName(fullyQualifiedName(n.f1)); template.setSuperTemplate(superTemplate); return template; }
public void visit(final IDLDefinition idlDefinition) throws Exception { final InterfaceDefinition itf = castNodeError(idlDefinition, InterfaceDefinition.class); enterInterface(itf); if (itf instanceof FieldContainer) { for (final Field field : ((FieldContainer) itf).getFields()) visitField(field); } if (itf instanceof MethodContainer) { for (final Method method : ((MethodContainer) itf).getMethods()) visitMethod(method); } leaveInterface(itf); }
@Override public Node visit(final ImplementsDefinitions n, final Node argu) { assert argu != null; final TemplateComponent template = castNodeError(argu, TemplateComponent.class); final ServerInterface si = (ServerInterface) newNode("serverInterface", n.f0); si.setSignature(fullyQualifiedName(n.f1)); template.addServerInterface(si); for (final org.objectweb.fractal.mind.st.templates.jtb.syntaxtree.Node node : n.f2.nodes) { final ServerInterface sitf = (ServerInterface) newNode("serverInterface", n.f0); sitf .setSignature(fullyQualifiedName((FullyQualifiedName) ((NodeSequence) node) .elementAt(1))); template.addServerInterface(sitf); } return template; }
@Override public Node visit(final RequiresDefinitions n, final Node argu) { assert argu != null; final TemplateComponent template = castNodeError(argu, TemplateComponent.class); for (final org.objectweb.fractal.mind.st.templates.jtb.syntaxtree.Node node : n.f0.nodes) {