/** * @return Returns the settings for the new eclipse profile. */ public static Map<String, String> getEclipseSettings() { return DefaultCodeFormatterConstants.getEclipseDefaultSettings(); }
/** * Return the options to be passed when creating {@link CodeFormatter} * instance. * * @return */ private Map<String, String> getFormattingOptions() { @SuppressWarnings("unchecked") Map<String, String> options = DefaultCodeFormatterConstants .getEclipseDefaultSettings(); options.put(JavaCore.COMPILER_SOURCE, JAVA_COMPILER_SOURCE_VERSION); options.put(JavaCore.COMPILER_COMPLIANCE, JAVA_COMPILER_COMPLIANCE_VERSION); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JAVA_COMPILER_CODEGEN_TARGET_PLATFORM_VERSION); return options; }
/** * @return Returns the settings for the new eclipse profile. */ public static Map getEclipseSettings() { final Map options= DefaultCodeFormatterConstants.getEclipseDefaultSettings(); ProfileVersioner.setLatestCompliance(options); return options; }
/** * @return Returns the settings for the new eclipse profile. */ public static Map<String, String> getEclipseSettings() { final Map<String, String> options= DefaultCodeFormatterConstants.getEclipseDefaultSettings(); ProfileVersioner.setLatestCompliance(options); return options; }
@SuppressWarnings({"unchecked", "deprecation"}) public void setFormatterSettings(List<Setting> settings) { // // change the option to wrap each enum constant on a new line // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, // DefaultCodeFormatterConstants.createAlignmentValue(true, // DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, // DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); // if (settings != null) { options = newHashMap(); for (Setting s : settings) { options.put(s.getId(), s.getValue()); } } else { options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); options.put(JavaCore.FORMATTER_LINE_SPLIT, "160"); options.put(JavaCore.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(JavaCore.FORMATTER_TAB_SIZE, "4"); } // instanciate the default code formatter with the given options codeFormatter = ToolFactory.createCodeFormatter(options); }
defaultOptionsMap.putAll(DefaultCodeFormatterConstants.getEclipseDefaultSettings());
defaultOptionsMap.putAll(DefaultCodeFormatterConstants.getEclipseDefaultSettings());
defaultOptionsMap.putAll(DefaultCodeFormatterConstants.getEclipseDefaultSettings());
defaultOptionsMap.putAll(DefaultCodeFormatterConstants.getEclipseDefaultSettings());
defaultOptionsMap.putAll(DefaultCodeFormatterConstants.getEclipseDefaultSettings());
@SuppressWarnings({"unchecked", "deprecation"}) public void setFormatterSettings(List<Setting> settings) { // // change the option to wrap each enum constant on a new line // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, // DefaultCodeFormatterConstants.createAlignmentValue(true, // DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, // DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); // if (settings != null) { options = newHashMap(); for (Setting s : settings) { options.put(s.getId(), s.getValue()); } } else { options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); options.put(JavaCore.FORMATTER_LINE_SPLIT, "160"); options.put(JavaCore.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(JavaCore.FORMATTER_TAB_SIZE, "4"); } // instanciate the default code formatter with the given options codeFormatter = ToolFactory.createCodeFormatter(options); }
defaultOptionsMap.putAll(DefaultCodeFormatterConstants.getEclipseDefaultSettings());
Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next();
Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next();
Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next();
Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next();
Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next();
Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next();
/** * Format java code for given input * * @param source source to format * @return formatted source code or original on error */ @SuppressWarnings({RAWTYPES, UNCHECKED}) public static String formatCode(final String source) { final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); final String alignmentValue = DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, alignmentValue); final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options); final TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, source, 0, source.length(), 0, System.getProperty("line.separator")); final ASTParser parser = ASTParser.newParser(AST.JLS3); final IDocument document = new Document(source); parser.setSource(document.get().toCharArray()); try { edit.apply(document); return document.get(); } catch (BadLocationException e) { log.error("Error formatting java code", e); } return source; }
/** * Format java code for given input * * @param source source to format * @return formatted source code or original on error */ @SuppressWarnings({RAWTYPES, UNCHECKED}) public static String formatCode(final String source) { final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); final String alignmentValue = DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, alignmentValue); final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options); final TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, source, 0, source.length(), 0, System.getProperty("line.separator")); final ASTParser parser = ASTParser.newParser(AST.JLS3); final IDocument document = new Document(source); parser.setSource(document.get().toCharArray()); try { edit.apply(document); return document.get(); } catch (BadLocationException e) { log.error("Error formatting java code", e); } return source; }