private DefaultCodeFormatter getCommentCodeFormatter() { if (this.commentCodeFormatter == null) { Map<String, String> options2 = this.options.getMap(); options2.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, String.valueOf(this.options.comment_line_length - this.commentIndent - COMMENT_LINE_SEPARATOR_LENGTH)); options2.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(this.options.page_width - this.commentIndent - COMMENT_LINE_SEPARATOR_LENGTH)); options2.put(CompilerOptions.OPTION_Source, this.sourceLevel); this.commentCodeFormatter = new DefaultCodeFormatter(options2); } return this.commentCodeFormatter; }
private DefaultCodeFormatter getCommentCodeFormatter() { if (this.commentCodeFormatter == null) { Map<String, String> options2 = this.options.getMap(); options2.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, String.valueOf(this.options.comment_line_length - this.commentIndent - COMMENT_LINE_SEPARATOR_LENGTH)); options2.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(this.options.page_width - this.commentIndent - COMMENT_LINE_SEPARATOR_LENGTH)); options2.put(CompilerOptions.OPTION_Source, this.sourceLevel); this.commentCodeFormatter = new DefaultCodeFormatter(options2); } return this.commentCodeFormatter; }
private DefaultCodeFormatter getCommentCodeFormatter() { if (this.commentCodeFormatter == null) { Map<String, String> options2 = this.options.getMap(); options2.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, String.valueOf(this.options.comment_line_length - this.commentIndent - COMMENT_LINE_SEPARATOR_LENGTH)); options2.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(this.options.page_width - this.commentIndent - COMMENT_LINE_SEPARATOR_LENGTH)); options2.put(CompilerOptions.OPTION_Source, this.sourceLevel); this.commentCodeFormatter = new DefaultCodeFormatter(options2); } return this.commentCodeFormatter; }
currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE); return new DefaultCodeFormatter(currentOptions);
currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE); return new DefaultCodeFormatter(currentOptions);
currentOptions.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE); return new DefaultCodeFormatter(currentOptions);
String code = "public class geo{public static void main(String[] args){System.out.println(\"geo\");}}"; CodeFormatter cf = new DefaultCodeFormatter(); TextEdit te = cf.format(CodeFormatter.K_UNKNOWN, code, 0,code.length(),0,null); IDocument dc = new Document(code); try { te.apply(dc); System.out.println(dc.get()); } catch (MalformedTreeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (BadLocationException e) { // TODO Auto-generated catch block e.printStackTrace(); }
"Unable to instantiate formatter extension '" + formatterId + "', returning built-in formatter."); //$NON-NLS-1$ //$NON-NLS-2$ return new DefaultCodeFormatter(currentOptions);
"Unable to instantiate formatter extension '" + formatterId + "', returning built-in formatter."); //$NON-NLS-1$ //$NON-NLS-2$ return new DefaultCodeFormatter(currentOptions);
"Unable to instantiate formatter extension '" + formatterId + "', returning built-in formatter."); //$NON-NLS-1$ //$NON-NLS-2$ return new DefaultCodeFormatter(currentOptions);
newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions); TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator); if (positions != null && textEdit != null) {
newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions); TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator); if (positions != null && textEdit != null) {
newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions); TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator); if (positions != null && textEdit != null) {
newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions); TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator); if (positions != null && textEdit != null) {
newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions); TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator); if (positions != null && textEdit != null) {
newOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter(newOptions); TextEdit textEdit = defaultCodeFormatter.format(org.eclipse.jdt.core.formatter.CodeFormatter.K_UNKNOWN, string, 0, string.length(), indentLevel, lineSeparator); if (positions != null && textEdit != null) {
public static String format(String code, Map<String, String> options) { DefaultCodeFormatterOptions cfOptions = DefaultCodeFormatterOptions.getJavaConventionsSettings(); cfOptions.tab_char = DefaultCodeFormatterOptions.TAB; CodeFormatter cf = new DefaultCodeFormatter(cfOptions, options); TextEdit te = cf.format(CodeFormatter.K_UNKNOWN, code, 0, code.length(), 0, null); IDocument dc = new Document(code); try { te.apply(dc); } catch (Exception e) { throw new MinnalGeneratorException("Failed while formatting the code", e); } return dc.get(); } }