}
public Node createMethodDeclaration(Node modifiers, Node typeParameters, Node resultType, Node name,
Node params, List<org.parboiled.Node<Node>> dims, Node throwsHead, List<Node> throwsTail, Node body) {
MethodDeclaration decl = new MethodDeclaration();
if (params instanceof TemporaryNode.MethodParameters) {
for (Node param : ((TemporaryNode.MethodParameters)params).parameters) {
decl.rawParameters().addToEnd(param);
}
} else DanglingNodes.addDanglingNode(decl, params);
decl.astMethodName(createIdentifierIfNeeded(name, currentPos())).rawBody(body);
if (modifiers != null) decl.astModifiers(createModifiersIfNeeded(modifiers, currentPos()));
int extraDims = dims == null ? 0 : dims.size();
Node returnType = resultType;
if (extraDims > 0 && returnType instanceof TypeReference) {
((TypeReference)returnType).astArrayDimensions(((TypeReference)returnType).astArrayDimensions() + extraDims);
}
decl.rawReturnTypeReference(returnType);
if (typeParameters instanceof TemporaryNode.OrphanedTypeVariables) {
TemporaryNode.OrphanedTypeVariables otv = (TemporaryNode.OrphanedTypeVariables)typeParameters;
if (otv.variables != null) for (Node typeParameter : otv.variables) {
if (typeParameter != null) decl.rawTypeVariables().addToEnd(typeParameter);
}
}
for (org.parboiled.Node<Node> dim : dims) {
for (org.parboiled.Node<Node> dimSub : dim.getChildren()) {
source.registerStructure(decl, dimSub);
}
}
if (throwsHead != null) decl.rawThrownTypeReferences().addToEnd(throwsHead);
if (throwsTail != null) for (Node n : throwsTail) if (n != null) decl.rawThrownTypeReferences().addToEnd(n);
return posify(decl);
}