use of org.eclipse.jdt.core.formatter.CodeFormatter in project AutoRefactor by JnRouvignac.
the class TestHelper method normalizeJavaSourceCode.
public static String normalizeJavaSourceCode(String source) {
final CodeFormatter codeFormatter = createCodeFormatter(getJava7Options());
final TextEdit edit = codeFormatter.format(K_COMPILATION_UNIT, // source to format
source, // source to format
0, // source to format
source.length(), // initial indentation and line separator
0, // initial indentation and line separator
System.getProperty("line.separator"));
try {
final IDocument document = new Document(source);
edit.apply(document);
return document.get();
} catch (MalformedTreeException e) {
throw new RuntimeException(e);
} catch (BadLocationException e) {
throw new RuntimeException(e);
}
}
Aggregations