ASTNode root= rootNode.getRoot();
if (!(root instanceof CompilationUnit)) {
throw new IllegalArgumentException("This API can only be used if the AST is created from a compilation unit or class file"); //$NON-NLS-1$
}
CompilationUnit astRoot= (CompilationUnit) root;
ITypeRoot typeRoot = astRoot.getTypeRoot();
if (typeRoot == null || typeRoot.getBuffer() == null) {
throw new IllegalArgumentException("This API can only be used if the AST is created from a compilation unit or class file"); //$NON-NLS-1$
}
char[] content= typeRoot.getBuffer().getCharacters();
LineInformation lineInfo= LineInformation.create(astRoot);
String lineDelim= typeRoot.findRecommendedLineSeparator();
Map options= typeRoot.getJavaProject().getOptions(true);
return internalRewriteAST(content, lineInfo, lineDelim, astRoot.getCommentList(), options, rootNode);
}