CodeFormatter formatter = ToolFactory.createCodeFormatter(null); ISourceRange range = cu.getSourceRange(); TextEdit indent_edit = formatter.format(CodeFormatter.K_COMPILATION_UNIT, cu.getSource(), range.getOffset(), range.getLength(), 0, null); cu.applyTextEdit(indent_edit, null); cu.reconcile();