throw new FormatterException(source, null); throw new FormatterException(source, e);
/** * Format the given {@link String} as a Java source type, using the given Eclipse code format {@link Properties}. */ public static String format(Properties prefs, String source) { CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(prefs); IDocument doc = new Document(source); try { TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, source, 0, source.length(), 0, null); if (edit != null) { edit.apply(doc); } else { throw new FormatterException(source, null); } } catch (BadLocationException e) { throw new FormatterException(source, e); } return ensureCorrectNewLines(doc.get()); }