public Node createPackageDeclaration(List<Node> annotations, Node head, List<Node> tail) { PackageDeclaration decl = new PackageDeclaration(); if (annotations != null) for (Node n : annotations) if (n != null) decl.rawAnnotations().addToEnd(n); if (head != null) decl.rawParts().addToEnd(head); if (tail != null) for (Node n : tail) if (n != null) decl.rawParts().addToEnd(n); return posify(decl); }
public Node createAnnotationElementValueArrayInitializer(Node head, List<Node> tail) { ArrayInitializer result = new ArrayInitializer(); if (head != null) result.rawExpressions().addToEnd(head); if (tail != null) for (Node n : tail) if (n != null) result.rawExpressions().addToEnd(n); return posify(result); }
public Node createVariableDefinition(Node type, Node head, List<Node> tail) { VariableDefinition result = new VariableDefinition().rawTypeReference(type); if (head != null) result.rawVariables().addToEnd(head); if (tail != null) for (Node n : tail) if (n != null) result.rawVariables().addToEnd(n); return posify(result); }
public Node createCompilationUnit(Node packageDeclaration, List<Node> importDeclarations, List<Node> typeDeclarations) { CompilationUnit unit = new CompilationUnit().rawPackageDeclaration(packageDeclaration); if (importDeclarations != null) for (Node n : importDeclarations) if (n != null) unit.rawImportDeclarations().addToEnd(n); if (typeDeclarations != null) for (Node n : typeDeclarations) if (n != null) unit.rawTypeDeclarations().addToEnd(n); return posify(unit); }
public Node createNormalTypeBody(List<Node> values) { NormalTypeBody body = new NormalTypeBody(); if (values != null) for (Node n : values) body.rawMembers().addToEnd(n); return posify(body); }
public Node createBlock(List<Node> statements) { Block block = new Block(); if (statements != null) for (Node s : statements) { if (s != null) block.rawContents().addToEnd(s); } return posify(block); }
@Override public P migrateAllFrom(StrictListAccessor<? extends T, ?> otherList) { while (!otherList.isEmpty()) { AbstractNode n = (AbstractNode) otherList.first(); otherList.remove(n); raw.addToEnd(n); } return returnAsParent; }
public Node createNormalTypeBody(List<Node> values) { NormalTypeBody body = new NormalTypeBody(); if (values != null) for (Node n : values) body.rawMembers().addToEnd(n); return posify(body); }
public Node createEnumConstant(List<Node> annotations, Node name, Node arguments, Node body) { EnumConstant result = new EnumConstant().astName(createIdentifierIfNeeded(name, currentPos())).rawBody(body); if (annotations != null) for (Node n : annotations) if (n != null) result.rawAnnotations().addToEnd(n); if (arguments instanceof TemporaryNode.MethodArguments) { for (Node arg : ((TemporaryNode.MethodArguments)arguments).arguments) { result.rawArguments().addToEnd(arg); } } return posify(result); }
public Node createArrayCreationExpression(Node type, List<Node> dimensions, Node initializer) { ArrayCreation ac = new ArrayCreation().rawComponentTypeReference(type).rawInitializer(initializer); if (dimensions != null) for (Node d : dimensions) { if (d != null) ac.rawDimensions().addToEnd(d); } return posify(ac); }
public Node createTryStatement(Node body, List<Node> catches, Node finallyBody) { Try result = new Try().rawBody(body).rawFinally(finallyBody); if (catches != null) for (Node c : catches) if (c != null) result.rawCatches().addToEnd(c); return posify(result); }
public Node createAnnotationFromElement(Node value) { Annotation result = new Annotation(); if (value != null) { result.rawElements().addToEnd(posify(new AnnotationElement().rawValue(value))); } return posify(result); }
public Node createTypeReferencePart(org.parboiled.Node<Node> identifier, Node typeArguments) { TypeReferencePart result = new TypeReferencePart().astIdentifier(createIdentifierIfNeeded(identifier.getValue(), currentPos())); if (typeArguments instanceof TemporaryNode.TypeArguments) { for (Node arg : ((TemporaryNode.TypeArguments)typeArguments).arguments) { result.rawTypeArguments().addToEnd(arg); } } posify(result); //We only care about the end position here. return result.setPosition(new Position(identifier.getStartIndex(), result.getPosition().getEnd())); }
public Node createTypeReferencePart(org.parboiled.Node<Node> identifier, Node typeArguments) { TypeReferencePart result = new TypeReferencePart().astIdentifier(createIdentifierIfNeeded(identifier.getValue(), currentPos())); if (typeArguments instanceof TemporaryNode.TypeArguments) { for (Node arg : ((TemporaryNode.TypeArguments)typeArguments).arguments) { result.rawTypeArguments().addToEnd(arg); } } posify(result); //We only care about the end position here. return result.setPosition(new Position(identifier.getStartIndex(), result.getPosition().getEnd())); }