@Override public Void visitFormalParameterList(FormalParameterList node) { String groupEnd = null; writer.print('('); NodeList<FormalParameter> parameters = node.getParameters(); int size = parameters.size(); for (int i = 0; i < size; i++) { FormalParameter parameter = parameters.get(i); if (i > 0) { writer.print(", "); } if (groupEnd == null && parameter instanceof DefaultFormalParameter) { if (parameter.getKind() == ParameterKind.NAMED) { groupEnd = "}"; writer.print('{'); } else { groupEnd = "]"; writer.print('['); } } parameter.accept(this); } if (groupEnd != null) { writer.print(groupEnd); } writer.print(')'); return null; }
public void test_get_tooBig() { NodeList<ASTNode> list = new NodeList<ASTNode>(argumentList()); try { list.get(1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException exception) { // Expected } }
/** @see org.eclipse.graph.HorizontalPlacement#applyGPrime() */ void applyGPrime() { super.applyGPrime(); NodeList subgraphs = ((CompoundDirectedGraph) graph).subgraphs; for (int i = 0; i < subgraphs.size(); i++) { Subgraph s = (Subgraph) subgraphs.get(i); s.x = s.left.x; s.width = s.right.x + s.right.width - s.x; } }
public void test_set() { ArrayList<ASTNode> nodes = new ArrayList<ASTNode>(); ASTNode firstNode = booleanLiteral(true); ASTNode secondNode = booleanLiteral(false); ASTNode thirdNode = booleanLiteral(true); nodes.add(firstNode); nodes.add(secondNode); nodes.add(thirdNode); NodeList<ASTNode> list = new NodeList<ASTNode>(argumentList()); list.addAll(nodes); assertSize(3, list); ASTNode fourthNode = integer(0); assertSame(secondNode, list.set(1, fourthNode)); assertSize(3, list); assertSame(firstNode, list.get(0)); assertSame(fourthNode, list.get(1)); assertSame(thirdNode, list.get(2)); }
/** * Print a list of nodes, separated by the given separator. * * @param nodes the nodes to be printed * @param separator the separator to be printed between adjacent nodes */ private void visitList(NodeList<? extends ASTNode> nodes, String separator) { if (nodes != null) { int size = nodes.size(); for (int i = 0; i < size; i++) { if (i > 0) { writer.print(separator); } nodes.get(i).accept(this); } } }
private int buildNestingTreeIndices(NodeList nodes, int base) { for (int i = 0; i < nodes.size(); i++) { Node node = (Node) nodes.get(i); if (node instanceof Subgraph) { Subgraph s = (Subgraph) node; s.nestingTreeMin = base; base = buildNestingTreeIndices(s.members, base); } node.nestingIndex = base++; } return base++; }
public void test_addAll() { ASTNode parent = argumentList(); ArrayList<ASTNode> firstNodes = new ArrayList<ASTNode>(); ASTNode firstNode = booleanLiteral(true); ASTNode secondNode = booleanLiteral(false); firstNodes.add(firstNode); firstNodes.add(secondNode); NodeList<ASTNode> list = new NodeList<ASTNode>(parent); list.addAll(firstNodes); assertSize(2, list); assertSame(firstNode, list.get(0)); assertSame(secondNode, list.get(1)); assertSame(parent, firstNode.getParent()); assertSame(parent, secondNode.getParent()); ArrayList<ASTNode> secondNodes = new ArrayList<ASTNode>(); ASTNode thirdNode = booleanLiteral(true); ASTNode fourthNode = booleanLiteral(false); secondNodes.add(thirdNode); secondNodes.add(fourthNode); list.addAll(secondNodes); assertSize(4, list); assertSame(firstNode, list.get(0)); assertSame(secondNode, list.get(1)); assertSame(thirdNode, list.get(2)); assertSame(fourthNode, list.get(3)); assertSame(parent, firstNode.getParent()); assertSame(parent, secondNode.getParent()); assertSame(parent, thirdNode.getParent()); assertSame(parent, fourthNode.getParent()); }
public void test_add() { ASTNode parent = argumentList(); ASTNode firstNode = booleanLiteral(true); ASTNode secondNode = booleanLiteral(false); NodeList<ASTNode> list = new NodeList<ASTNode>(parent); list.add(0, secondNode); list.add(0, firstNode); assertSize(2, list); assertSame(firstNode, list.get(0)); assertSame(secondNode, list.get(1)); assertSame(parent, firstNode.getParent()); assertSame(parent, secondNode.getParent()); ASTNode thirdNode = booleanLiteral(false); list.add(1, thirdNode); assertSize(3, list); assertSame(firstNode, list.get(0)); assertSame(thirdNode, list.get(1)); assertSame(secondNode, list.get(2)); assertSame(parent, firstNode.getParent()); assertSame(parent, secondNode.getParent()); assertSame(parent, thirdNode.getParent()); }
/* * Execution of the modified greedy cycle removal algorithm. */ private void cycleRemove(NodeList children) { NodeList sR = new NodeList(); do { findSinks(children, sR); findSources(children); // all sinks and sources added, find node with highest // outDegree - inDegree Node max = findNodeWithMaxDegree(children); if (max != null) { for (int i = 0; i < children.size(); i++) { Node child = (Node) children.get(i); if (child.flag) continue; if (child == max) restoreSinks(max, sR); else restoreSources(child); } remove(max); } } while (!allFlagged(children)); while (!sR.isEmpty()) sL.add(sR.remove(sR.size() - 1)); }