protected void interpolate(final Node node) { final Map<String, String> attributes = node.astGetAttributes(); for (final Map.Entry<String, String> attribute : attributes.entrySet()) { if (attribute.getValue() != null) attribute.setValue(interpolate(node, attribute.getValue())); } node.astSetAttributes(attributes); for (final String subNodeType : node.astGetNodeTypes()) { for (final Node subNode : node.astGetNodes(subNodeType)) { if (subNode != null) interpolate(subNode); } } }
protected void checkAnnotations(final Node container, final Set<Node> visitedNodes, final Map<Object, Object> context) throws ADLException { if (visitedNodes.add(container)) { if (container instanceof AnnotationContainer) { checkAnnotationContainer((AnnotationContainer) container, context); } for (final String nodeType : container.astGetNodeTypes()) { for (final Node subNode : container.astGetNodes(nodeType)) { if (subNode != null) { checkAnnotations(subNode, visitedNodes, context); } } } } }
protected MergeInfo computeMergeInfos(final Node node, final Map<Node, MergeInfo> infos) throws MergeException { MergeInfo info = infos.get(node); if (info == null) { info = new MergeInfo(node); infos.put(node, info); for (final String type : node.astGetNodeTypes()) { for (final Node subNode : node.astGetNodes(type)) { if (subNode != null) { info.addSubNodeInfo(computeMergeInfos(subNode, infos)); } } } } return info; }
final String[] subNodeTypes = node.astGetNodeTypes(); for (final String subNode : subNodeTypes) { final Node[] nodes = node.astGetNodes(subNode); for (final Node n : nodes) { if (n != null) {
@SuppressWarnings("unchecked") protected <T extends Node> T toStringTemplateGraph(final T node, final Map<Node, Node> clonedNodes) { T clone = (T) clonedNodes.get(node); if (clone == null) { clone = toStringTemplateNode(node, clonedNodes); // add sub nodes for (final String subNodeType : node.astGetNodeTypes()) { for (final Node subNode : node.astGetNodes(subNodeType)) { if (subNode != null) clone.astAddNode(toStringTemplateGraph(subNode, clonedNodes)); } } clonedNodes.put(node, clone); // Add the clone itself in the clonedNodes map to avoid to re-clone it in // case of a NodeContainerDecoration that is shared by different nodes. clonedNodes.put(clone, clone); } return clone; }
@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}. 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; }
/** * 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; }
Node[] superNodes = superElem.astGetNodes(nodeType); Node[] nodes = elem.astGetNodes(nodeType);