int extendedStart = astCU.getExtendedStartPosition(pkg);
if (pkgStart != extendedStart) {
// keep the comments associated with package declaration
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=247757
String commentSource = cu.getSource().substring(extendedStart, pkgStart);
ASTNode comment = rewriter.createStringPlaceholder(commentSource, ASTNode.PACKAGE_DECLARATION);
rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, comment, null);
} else {
rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, null, null);
}
}