final ICProject project = tu.getCProject();
final Map<String, Object> options = new HashMap<String, Object>(project.getOptions(true));
options.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
// Allow all comments to be indented.
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
final CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
code = document.get();
TextEdit[] formatEdits = formatter.format(CodeFormatter.K_TRANSLATION_UNIT, code, regions, TextUtilities.getDefaultLineDelimiter(document));
TextEdit combinedFormatEdit = new MultiTextEdit();
for (final TextEdit formatEdit : formatEdits) {
combinedFormatEdit = TextEditUtil.merge(combinedFormatEdit, formatEdit);
}