final TypedPosition partition = (TypedPosition) fPartitions.removeFirst();
if (document != null && partition != null) {
try {
JSPTranslationUtil translationUtil = new JSPTranslationUtil(document);
ICompilationUnit cu = translationUtil.getCompilationUnit();
if (cu != null) {
String cuSource = cu.getSource();
TextEdit textEdit = formatString(CodeFormatter.K_COMPILATION_UNIT, cuSource, 0, TextUtilities.getDefaultLineDelimiter(document), getPreferences());
TextEdit jspEdit = translationUtil.getTranslation().getJspEdit(textEdit);
if (jspEdit != null && jspEdit.hasChildren())
jspEdit.apply(document);
}
}