ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(new char[0]);
CompilationUnit unit = (CompilationUnit) parser.createAST(null);
// 変更点を保存する設定
unit.recordModifications();
AST ast = unit.getAST();
Name pkg = ast.newName("org.ashikunep.irenka.eclipse.ast");
PackageDeclaration pdecl = ast.newPackageDeclaration();
pdecl.setName(pkg);
unit.setPackage(pdecl);
Document doc = new Document();
TextEdit edit = unit.rewrite(doc, null);
// 変更点*だけ*をダンプする
edit.apply(doc);
System.out.println(doc.get());