}
}
}
if (!decls.isEmpty()) {
Statement first = body.children().get(0);
MultiDeclaration md;
if (first instanceof MultiDeclaration) {
md = (MultiDeclaration) first;
} else if (first instanceof Declaration) {
md = new MultiDeclaration(
FilePosition.span(pos, first.getFilePosition()),
Collections.singletonList((Declaration) first));
body.replaceChild(md, first);
} else if (decls.size() == 1) {
body.insertBefore(decls.get(0), first);
return;
} else {
md = new MultiDeclaration(pos, Collections.<Declaration>emptyList());
body.insertBefore(md, first);
}
MutableParseTreeNode.Mutation mut = md.createMutation();
Declaration firstDecl = md.children().get(0);
for (Declaration decl : decls) {
mut = mut.insertBefore(decl, firstDecl);
}
mut.execute();
}