diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseCodeStyleImportWorker.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseCodeStyleImportWorker.java index 669cea0b5846..d4066783c764 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseCodeStyleImportWorker.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseCodeStyleImportWorker.java @@ -15,33 +15,22 @@ */ package org.jetbrains.idea.eclipse.importer; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.options.SchemeImportException; import com.intellij.psi.codeStyle.CodeStyleScheme; import com.intellij.psi.codeStyle.CodeStyleSettings; -import com.intellij.psi.codeStyle.CommonCodeStyleSettings; -import com.intellij.psi.codeStyle.JavaCodeStyleSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Field; +import java.util.Properties; /** * @author Irina.Chernushina on 4/21/2015. */ -public class EclipseCodeStyleImportWorker implements EclipseXmlProfileElements { - private static final Logger LOG = Logger.getInstance(EclipseCodeStyleImportWorker.class); - - final static String PROGRAMMATIC_IMPORT_KEY = ""; - - private final EclipseImportMap myImportMap; - - public EclipseCodeStyleImportWorker() { - myImportMap = new EclipseImportMap(); - myImportMap.load(); - } +public class EclipseCodeStyleImportWorker + extends EclipseFormatterOptionsHandler + implements EclipseXmlProfileElements, EclipseFormatterOptions { public void importScheme(@NotNull InputStream inputStream, final @Nullable String sourceScheme, final CodeStyleScheme scheme) throws SchemeImportException { @@ -63,289 +52,4 @@ public class EclipseCodeStyleImportWorker implements EclipseXmlProfileElements { reader.readSettings(inputStream); } - private void setCodeStyleOption(@NotNull CodeStyleSettings settings, @NotNull String key, @NotNull String value) - throws SchemeImportException { - EclipseImportMap.ImportDescriptor importDescriptor = myImportMap.getImportDescriptor(key); - if (importDescriptor != null) { - try { - if (importDescriptor.isLanguageSpecific()) { - if (importDescriptor.isCustomField()) { - JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class); - setValue(javaSettings, key, importDescriptor.getFieldName(), value); - } - else { - CommonCodeStyleSettings languageSettings = settings.getCommonSettings(importDescriptor.getLanguage()); - if (languageSettings != null) { - if (importDescriptor.isIndentOptions()) { - CommonCodeStyleSettings.IndentOptions indentOptions = languageSettings.getIndentOptions(); - if (indentOptions != null) { - setValue(indentOptions, key, importDescriptor.getFieldName(), value); - } - } - else { - setValue(languageSettings, key, importDescriptor.getFieldName(), value); - } - } - } - } - else { - setValue(settings, key, importDescriptor.getFieldName(), value); - } - } - catch (Exception e) { - throw new SchemeImportException(e); - } - } - } - - private static void setValue(Object object, String key, String fieldName, String value) throws SchemeImportException { - if (PROGRAMMATIC_IMPORT_KEY.equalsIgnoreCase(fieldName)) { - setProgrammatically(object, key, value); - return; - } - try { - Field targetField = object.getClass().getField(fieldName); - Class fieldType = targetField.getType(); - if (fieldType.isPrimitive()) { - if (Boolean.TYPE.equals(fieldType)) { - targetField.setBoolean(object, valueToBoolean(key, value)); - } - else if (Integer.TYPE.equals(fieldType)) { - targetField.setInt(object, valueToInt(value)); - } - } - else if (fieldType.equals(String.class)) { - targetField.set(object, value); - } - } - catch (IllegalAccessException e) { - LOG.error(e); - } - catch (NoSuchFieldException e) { - LOG.error("Field '" + fieldName + "' does not exist in " + object.getClass().getName(), e); - } - } - - private static boolean valueToBoolean(@NotNull String key, @NotNull String value) throws SchemeImportException { - if (VALUE_INSERT.equals(value) || - VALUE_TRUE.equals(value)) { - return true; - } - if (!(VALUE_DO_NOT_INSERT.equals(value) || - VALUE_FALSE.equals(value))) { - throw new SchemeImportException("Unrecognized boolean value: " + value + ", key: " + key); - } - return false; - } - - private static int valueToInt(@NotNull String value) { - if (VALUE_END_OF_LINE.equals(value)) return CommonCodeStyleSettings.END_OF_LINE; - if (VALUE_NEXT_LINE.equals(value)) return CommonCodeStyleSettings.NEXT_LINE; - if (VALUE_NEXT_LINE_SHIFTED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_SHIFTED; - if (VALUE_NEXT_LINE_IF_WRAPPED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED; - return Integer.parseInt(value); - } - - private static class AlignmentAndWrapValueDecoder { - int myEncodedValue; - - public AlignmentAndWrapValueDecoder(int encodedValue) { - myEncodedValue = encodedValue; - } - - public int getWrapType() { - switch (getEclipseWrap()) { - case WRAP_WHERE_NECESSARY: - case WRAP_FIRST_OTHERS_WHERE_NECESSARY: - return CommonCodeStyleSettings.WRAP_AS_NEEDED; - case WRAP_ALL_EXCEPT_FIRST: - case WRAP_ALL_INDENT_EXCEPT_FIRST: - case WRAP_ALL_ON_NEW_LINE_EACH: - return CommonCodeStyleSettings.WRAP_AS_NEEDED | CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; - } - return CommonCodeStyleSettings.DO_NOT_WRAP; - } - - public int getFirstElementWrapType() { - return isNewLineBeforeFirst() ? CommonCodeStyleSettings.WRAP_ALWAYS : - getEclipseWrap() == WRAP_ALL_EXCEPT_FIRST ? CommonCodeStyleSettings.DO_NOT_WRAP : - CommonCodeStyleSettings.WRAP_AS_NEEDED; - } - - public boolean isFirstElementWrapped() { - int eclipseWrapValue = getEclipseWrap(); - return eclipseWrapValue == WRAP_FIRST_OTHERS_WHERE_NECESSARY || - eclipseWrapValue == WRAP_ALL_INDENT_EXCEPT_FIRST || - eclipseWrapValue == WRAP_ALL_ON_NEW_LINE_EACH || - isNewLineBeforeFirst(); - } - - public boolean isNewLineBeforeFirst() { - return (myEncodedValue & 1) != 0; - } - - public boolean isAlignmentOn() { - return (myEncodedValue & 2) != 0; - } - - public int getEclipseWrap() { - return myEncodedValue & WRAP_MASK; - } - } - - private static void setProgrammatically(@NotNull Object object, @NotNull String key, @NotNull String value) throws SchemeImportException { - if (key.contains("alignment") && value.matches("\\d*") && object instanceof CommonCodeStyleSettings) { - if (setAlignmentAndWrappingOptions((CommonCodeStyleSettings)object, key, value)) return; - } - if (object instanceof CodeStyleSettings) { - CodeStyleSettings settings = (CodeStyleSettings)object; - if (OPTION_REMOVE_JAVADOC_BLANK_LINES.equals(key)) { - settings.getCustomSettings(JavaCodeStyleSettings.class).JD_KEEP_EMPTY_LINES = !valueToBoolean(key, value); - } - else if (OPTION_NEW_LINE_AT_EOF.equals(key)) { - EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); - editorSettings.setEnsureNewLineAtEOF(valueToBoolean(key, value)); - } - } - else if (object instanceof CommonCodeStyleSettings) { - CommonCodeStyleSettings commonSettings = (CommonCodeStyleSettings)object; - if (OPTION_SPACE_AFTER_BINARY_OPERATOR.equals(key)) { - boolean addSpace = valueToBoolean(key, value); - commonSettings.SPACE_AROUND_ADDITIVE_OPERATORS = - commonSettings.SPACE_AROUND_BITWISE_OPERATORS = - commonSettings.SPACE_AROUND_LOGICAL_OPERATORS = - commonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS = - commonSettings.SPACE_AROUND_RELATIONAL_OPERATORS = - commonSettings.SPACE_AROUND_SHIFT_OPERATORS = - commonSettings.SPACE_AROUND_EQUALITY_OPERATORS = - addSpace; - } - else if (OPTION_INDENT_CLASS_BODY_DECL.equals(key)) { - commonSettings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS = !valueToBoolean(key, value); - } - else if (OPTION_BLANK_LINES_BEFORE_FIRST_DECLARATION_IN_CLASS.equals(key)) { - int intValue = valueToInt(value); - commonSettings.BLANK_LINES_AFTER_CLASS_HEADER = intValue; - commonSettings.BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER = intValue; - } - else if (OPTION_EMPTY_LINES_TO_PRESERVE.equals(key)) { - int intValue = valueToInt(value); - commonSettings.KEEP_BLANK_LINES_IN_CODE = intValue; - commonSettings.KEEP_BLANK_LINES_IN_DECLARATIONS = intValue; - commonSettings.KEEP_BLANK_LINES_BEFORE_RBRACE = intValue; - } - else if (OPTION_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK.equals(key)) { - boolean insertSpace = valueToBoolean(key, value); - commonSettings.SPACE_BEFORE_ELSE_KEYWORD = insertSpace; - commonSettings.SPACE_BEFORE_CATCH_KEYWORD = insertSpace; - commonSettings.SPACE_BEFORE_FINALLY_KEYWORD = insertSpace; - } - else if (OPTION_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK.equals(key)) { - boolean insertSpace = valueToBoolean(key, value); - commonSettings.SPACE_BEFORE_IF_LBRACE = insertSpace; - commonSettings.SPACE_BEFORE_FOR_LBRACE = insertSpace; - commonSettings.SPACE_BEFORE_WHILE_LBRACE = insertSpace; - commonSettings.SPACE_BEFORE_DO_LBRACE = insertSpace; - commonSettings.SPACE_BEFORE_TRY_LBRACE = insertSpace; - commonSettings.SPACE_BEFORE_CATCH_LBRACE = insertSpace; - commonSettings.SPACE_BEFORE_FINALLY_LBRACE = insertSpace; - commonSettings.SPACE_BEFORE_SYNCHRONIZED_LBRACE = insertSpace; - } - else if (OPTION_JOIN_WRAPPED_LINES.equals(key)) { - commonSettings.KEEP_LINE_BREAKS = !valueToBoolean(key, value); - } - } - else if (object instanceof CommonCodeStyleSettings.IndentOptions) { - CommonCodeStyleSettings.IndentOptions indentOptions = (CommonCodeStyleSettings.IndentOptions)object; - if (OPTION_TAB_CHAR.equals(key)) { - if (TAB_CHAR_TAB.equals(value) || TAB_CHAR_MIXED.equals(value)) { - indentOptions.USE_TAB_CHARACTER = true; - } - else if (TAB_CHAR_SPACE.equals(value)) { - indentOptions.USE_TAB_CHARACTER = false; - } - } - else if (OPTION_CONTINUATION_INDENT.equals(key)) { - indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.TAB_SIZE * valueToInt(value); - } - else if (OPTION_TAB_SIZE.equals(key)) { - int newTabSize = valueToInt(value); - int continuationTabs = indentOptions.TAB_SIZE > 0 ? indentOptions.CONTINUATION_INDENT_SIZE / indentOptions.TAB_SIZE : -1; - indentOptions.TAB_SIZE = newTabSize; - if (continuationTabs >= 0) { - indentOptions.CONTINUATION_INDENT_SIZE = continuationTabs * newTabSize; - } - } - } - } - - private static boolean setAlignmentAndWrappingOptions(@NotNull CommonCodeStyleSettings settings, - @NotNull String key, - @NotNull String value) { - int encodedValue = Integer.parseInt(value); - AlignmentAndWrapValueDecoder decoder = new AlignmentAndWrapValueDecoder(encodedValue); - if (OPTION_ALIGN_ARGS_IN_ANNOTATION.equals(key)) { - settings.FIELD_ANNOTATION_WRAP = - settings.METHOD_ANNOTATION_WRAP = - settings.PARAMETER_ANNOTATION_WRAP = - settings.VARIABLE_ANNOTATION_WRAP = - settings.CLASS_ANNOTATION_WRAP = decoder.getWrapType(); - return true; - } - else if (OPTION_ALIGN_EXPR_IN_ARRAY_INITIALIZER.equals(key)) { - settings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION = decoder.isAlignmentOn(); - settings.ARRAY_INITIALIZER_WRAP = decoder.getWrapType(); - settings.ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE = decoder.isFirstElementWrapped(); - return true; - } - else if (OPTION_ALIGN_ARGS_IN_METHOD_INVOCATION.equals(key)) { - settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = decoder.isAlignmentOn(); - settings.CALL_PARAMETERS_WRAP = decoder.getWrapType(); - settings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = decoder.isFirstElementWrapped(); - return true; - } - else if (OPTION_ALIGN_INTERFACES_IN_TYPE_DECL.equals(key)) { - settings.ALIGN_MULTILINE_EXTENDS_LIST = decoder.isAlignmentOn(); - settings.EXTENDS_KEYWORD_WRAP = decoder.getFirstElementWrapType(); - settings.EXTENDS_LIST_WRAP = decoder.getWrapType(); - return true; - } - else if (OPTION_ALIGN_ASSIGNMENT.equals(key)) { - settings.ALIGN_MULTILINE_ASSIGNMENT = decoder.isAlignmentOn(); - settings.ASSIGNMENT_WRAP = decoder.getWrapType(); - return true; - } - else if (OPTION_ALIGN_METHOD_DECL_PARAMETERS.equals(key)) { - settings.ALIGN_MULTILINE_PARAMETERS = decoder.isAlignmentOn(); - settings.METHOD_PARAMETERS_WRAP = decoder.getWrapType(); - settings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = decoder.isFirstElementWrapped(); - return true; - } - else if (OPTION_ALIGN_BINARY_EXPR.equals(key)) { - settings.ALIGN_MULTILINE_BINARY_OPERATION = decoder.isAlignmentOn(); - settings.BINARY_OPERATION_WRAP = decoder.getWrapType(); - return true; - } - else if (OPTION_ALIGN_THROWS_IN_METHOD_DECL.equals(key)) { - settings.ALIGN_MULTILINE_THROWS_LIST = decoder.isAlignmentOn(); - settings.THROWS_KEYWORD_WRAP = decoder.getFirstElementWrapType(); - settings.THROWS_LIST_WRAP = decoder.getWrapType(); - return true; - } - else if (OPTION_ALIGN_RESOURCES_IN_TRY.equals(key)) { - settings.ALIGN_MULTILINE_RESOURCES = decoder.isAlignmentOn(); - settings.RESOURCE_LIST_WRAP = decoder.getWrapType(); - settings.RESOURCE_LIST_LPAREN_ON_NEXT_LINE = decoder.isFirstElementWrapped(); - return true; - } - else if (OPTION_ALIGN_CHAINED_CALLS.equals(key)) { - settings.METHOD_CALL_CHAIN_WRAP = decoder.getWrapType(); - settings.ALIGN_MULTILINE_CHAINED_METHODS = decoder.isAlignmentOn(); - } - else if (OPTION_ALIGN_CONDITIONALS.equals(key)) { - settings.TERNARY_OPERATION_WRAP = decoder.getWrapType(); - settings.ALIGN_MULTILINE_TERNARY_OPERATION = decoder.isAlignmentOn(); - } - return false; - } } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseCodeStylePropertiesImporter.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseCodeStylePropertiesImporter.java new file mode 100644 index 000000000000..e6b491ead464 --- /dev/null +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseCodeStylePropertiesImporter.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + */ +package org.jetbrains.idea.eclipse.importer; + +import com.intellij.openapi.options.SchemeImportException; +import com.intellij.psi.codeStyle.CodeStyleSettings; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +public class EclipseCodeStylePropertiesImporter extends EclipseFormatterOptionsHandler { + + public final static String CODE_STYLE_PROPERTY_FILE = "org.eclipse.jdt.core.prefs"; + + public void importProperties(@NotNull InputStream inputStream, @NotNull CodeStyleSettings settings) throws IOException, + SchemeImportException { + Properties properties = new Properties(); + properties.load(inputStream); + for (String key : properties.stringPropertyNames()) { + String value = properties.getProperty(key); + if (value != null) { + setCodeStyleOption(settings, key, value); + } + } + } +} diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseFormatterOptions.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseFormatterOptions.java new file mode 100644 index 000000000000..d06caf6d84d6 --- /dev/null +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseFormatterOptions.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + */ +package org.jetbrains.idea.eclipse.importer; + +public interface EclipseFormatterOptions { + String VALUE_INSERT = "insert"; + String VALUE_DO_NOT_INSERT = "do not insert"; + String VALUE_FALSE = "false"; + String VALUE_TRUE = "true"; + + String VALUE_NEXT_LINE = "next_line"; + String VALUE_NEXT_LINE_SHIFTED = "next_line_shifted"; + String VALUE_END_OF_LINE = "end_of_line"; + String VALUE_NEXT_LINE_IF_WRAPPED = "next_line_on_wrap"; + + String TAB_CHAR_TAB = "tab"; + String TAB_CHAR_SPACE = "space"; + String TAB_CHAR_MIXED = "mixed"; + + String OPTION_SPACE_AFTER_BINARY_OPERATOR = "org.eclipse.jdt.core.formatter.insert_space_after_binary_operator"; + String OPTION_REMOVE_JAVADOC_BLANK_LINES = "org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment"; + String OPTION_NEW_LINE_AT_EOF = "org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing"; + String OPTION_INDENT_CLASS_BODY_DECL = "org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header"; + String OPTION_TAB_CHAR = "org.eclipse.jdt.core.formatter.tabulation.char"; + String OPTION_CONTINUATION_INDENT = "org.eclipse.jdt.core.formatter.continuation_indentation"; + String OPTION_TAB_SIZE = "org.eclipse.jdt.core.formatter.tabulation.size"; + + String OPTION_ALIGN_EXPR_IN_ARRAY_INITIALIZER = "org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer"; + String OPTION_ALIGN_ARGS_IN_ANNOTATION = "org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation"; + String OPTION_ALIGN_ARGS_IN_METHOD_INVOCATION = "org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation"; + String OPTION_ALIGN_SUPERCLASS_IN_TYPE_DECL = "org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration"; + String OPTION_ALIGN_INTERFACES_IN_TYPE_DECL = "org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration"; + String OPTION_ALIGN_ASSIGNMENT = "org.eclipse.jdt.core.formatter.alignment_for_assignment"; + String OPTION_ALIGN_METHOD_DECL_PARAMETERS = "org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration"; + String OPTION_ALIGN_BINARY_EXPR = "org.eclipse.jdt.core.formatter.alignment_for_binary_expression"; + String OPTION_ALIGN_THROWS_IN_METHOD_DECL = "org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration"; + String OPTION_ALIGN_RESOURCES_IN_TRY = "org.eclipse.jdt.core.formatter.alignment_for_resources_in_try"; + String OPTION_ALIGN_METHOD_DECL = "org.eclipse.jdt.core.formatter.alignment_for_method_declaration"; + String OPTION_ALIGN_CHAINED_CALLS = "org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation"; + String OPTION_ALIGN_CONDITIONALS = "org.eclipse.jdt.core.formatter.alignment_for_conditional_expression"; + + String OPTION_BLANK_LINES_BEFORE_FIRST_DECLARATION_IN_CLASS = "org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration"; + String OPTION_EMPTY_LINES_TO_PRESERVE = "org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve"; + + String OPTION_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK = "org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block"; + String OPTION_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK = "org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block"; + + String OPTION_JOIN_WRAPPED_LINES = "org.eclipse.jdt.core.formatter.join_wrapped_lines"; + + int WRAP_MASK = 0x70; + + int DO_NOT_WRAP = 0x00; + int WRAP_WHERE_NECESSARY = 0x10; + int WRAP_FIRST_OTHERS_WHERE_NECESSARY = 0x20; + int WRAP_ALL_ON_NEW_LINE_EACH = 0x30; + int WRAP_ALL_INDENT_EXCEPT_FIRST = 0x40; + int WRAP_ALL_EXCEPT_FIRST = 0x50; +} diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseFormatterOptionsHandler.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseFormatterOptionsHandler.java new file mode 100644 index 000000000000..bcd47c0e79c4 --- /dev/null +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseFormatterOptionsHandler.java @@ -0,0 +1,313 @@ +/* + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + */ +package org.jetbrains.idea.eclipse.importer; + +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; +import com.intellij.openapi.options.SchemeImportException; +import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; +import com.intellij.psi.codeStyle.JavaCodeStyleSettings; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Field; + +public class EclipseFormatterOptionsHandler implements EclipseFormatterOptions { + final static String PROGRAMMATIC_IMPORT_KEY = ""; + + private static final Logger LOG = Logger.getInstance(EclipseFormatterOptionsHandler.class); + + private final EclipseImportMap myImportMap; + + public EclipseFormatterOptionsHandler() { + myImportMap = new EclipseImportMap(); + myImportMap.load(); + } + + protected void setCodeStyleOption(@NotNull CodeStyleSettings settings, @NotNull String key, @NotNull String value) + throws SchemeImportException { + EclipseImportMap.ImportDescriptor importDescriptor = myImportMap.getImportDescriptor(key); + if (importDescriptor != null) { + try { + if (importDescriptor.isLanguageSpecific()) { + if (importDescriptor.isCustomField()) { + JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class); + setValue(javaSettings, key, importDescriptor.getFieldName(), value); + } + else { + CommonCodeStyleSettings languageSettings = settings.getCommonSettings(importDescriptor.getLanguage()); + if (languageSettings != null) { + if (importDescriptor.isIndentOptions()) { + CommonCodeStyleSettings.IndentOptions indentOptions = languageSettings.getIndentOptions(); + if (indentOptions != null) { + setValue(indentOptions, key, importDescriptor.getFieldName(), value); + } + } + else { + setValue(languageSettings, key, importDescriptor.getFieldName(), value); + } + } + } + } + else { + setValue(settings, key, importDescriptor.getFieldName(), value); + } + } + catch (Exception e) { + throw new SchemeImportException(e); + } + } + } + + private static void setValue(Object object, String key, String fieldName, String value) throws SchemeImportException { + if (PROGRAMMATIC_IMPORT_KEY.equalsIgnoreCase(fieldName)) { + setProgrammatically(object, key, value); + return; + } + try { + Field targetField = object.getClass().getField(fieldName); + Class fieldType = targetField.getType(); + if (fieldType.isPrimitive()) { + if (Boolean.TYPE.equals(fieldType)) { + targetField.setBoolean(object, valueToBoolean(key, value)); + } + else if (Integer.TYPE.equals(fieldType)) { + targetField.setInt(object, valueToInt(value)); + } + } + else if (fieldType.equals(String.class)) { + targetField.set(object, value); + } + } + catch (IllegalAccessException e) { + LOG.error(e); + } + catch (NoSuchFieldException e) { + LOG.error("Field '" + fieldName + "' does not exist in " + object.getClass().getName(), e); + } + } + + private static boolean valueToBoolean(@NotNull String key, @NotNull String value) throws SchemeImportException { + if (VALUE_INSERT.equals(value) || + VALUE_TRUE.equals(value)) { + return true; + } + if (!(VALUE_DO_NOT_INSERT.equals(value) || + VALUE_FALSE.equals(value))) { + throw new SchemeImportException("Unrecognized boolean value: " + value + ", key: " + key); + } + return false; + } + + private static int valueToInt(@NotNull String value) { + if (VALUE_END_OF_LINE.equals(value)) return CommonCodeStyleSettings.END_OF_LINE; + if (VALUE_NEXT_LINE.equals(value)) return CommonCodeStyleSettings.NEXT_LINE; + if (VALUE_NEXT_LINE_SHIFTED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_SHIFTED; + if (VALUE_NEXT_LINE_IF_WRAPPED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED; + return Integer.parseInt(value); + } + + private static class AlignmentAndWrapValueDecoder { + int myEncodedValue; + + public AlignmentAndWrapValueDecoder(int encodedValue) { + myEncodedValue = encodedValue; + } + + public int getWrapType() { + switch (getEclipseWrap()) { + case WRAP_WHERE_NECESSARY: + case WRAP_FIRST_OTHERS_WHERE_NECESSARY: + return CommonCodeStyleSettings.WRAP_AS_NEEDED; + case WRAP_ALL_EXCEPT_FIRST: + case WRAP_ALL_INDENT_EXCEPT_FIRST: + case WRAP_ALL_ON_NEW_LINE_EACH: + return CommonCodeStyleSettings.WRAP_AS_NEEDED | CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; + } + return CommonCodeStyleSettings.DO_NOT_WRAP; + } + + public int getFirstElementWrapType() { + return isNewLineBeforeFirst() ? CommonCodeStyleSettings.WRAP_ALWAYS : + getEclipseWrap() == WRAP_ALL_EXCEPT_FIRST ? CommonCodeStyleSettings.DO_NOT_WRAP : + CommonCodeStyleSettings.WRAP_AS_NEEDED; + } + + public boolean isFirstElementWrapped() { + int eclipseWrapValue = getEclipseWrap(); + return eclipseWrapValue == WRAP_FIRST_OTHERS_WHERE_NECESSARY || + eclipseWrapValue == WRAP_ALL_INDENT_EXCEPT_FIRST || + eclipseWrapValue == WRAP_ALL_ON_NEW_LINE_EACH || + isNewLineBeforeFirst(); + } + + public boolean isNewLineBeforeFirst() { + return (myEncodedValue & 1) != 0; + } + + public boolean isAlignmentOn() { + return (myEncodedValue & 2) != 0; + } + + public int getEclipseWrap() { + return myEncodedValue & WRAP_MASK; + } + } + + private static void setProgrammatically(@NotNull Object object, @NotNull String key, @NotNull String value) throws SchemeImportException { + if (key.contains("alignment") && value.matches("\\d*") && object instanceof CommonCodeStyleSettings) { + if (setAlignmentAndWrappingOptions((CommonCodeStyleSettings)object, key, value)) return; + } + if (object instanceof CodeStyleSettings) { + CodeStyleSettings settings = (CodeStyleSettings)object; + if (OPTION_REMOVE_JAVADOC_BLANK_LINES.equals(key)) { + settings.getCustomSettings(JavaCodeStyleSettings.class).JD_KEEP_EMPTY_LINES = !valueToBoolean(key, value); + } + else if (OPTION_NEW_LINE_AT_EOF.equals(key)) { + EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); + editorSettings.setEnsureNewLineAtEOF(valueToBoolean(key, value)); + } + } + else if (object instanceof CommonCodeStyleSettings) { + CommonCodeStyleSettings commonSettings = (CommonCodeStyleSettings)object; + if (OPTION_SPACE_AFTER_BINARY_OPERATOR.equals(key)) { + boolean addSpace = valueToBoolean(key, value); + commonSettings.SPACE_AROUND_ADDITIVE_OPERATORS = + commonSettings.SPACE_AROUND_BITWISE_OPERATORS = + commonSettings.SPACE_AROUND_LOGICAL_OPERATORS = + commonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS = + commonSettings.SPACE_AROUND_RELATIONAL_OPERATORS = + commonSettings.SPACE_AROUND_SHIFT_OPERATORS = + commonSettings.SPACE_AROUND_EQUALITY_OPERATORS = + addSpace; + } + else if (OPTION_INDENT_CLASS_BODY_DECL.equals(key)) { + commonSettings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS = !valueToBoolean(key, value); + } + else if (OPTION_BLANK_LINES_BEFORE_FIRST_DECLARATION_IN_CLASS.equals(key)) { + int intValue = valueToInt(value); + commonSettings.BLANK_LINES_AFTER_CLASS_HEADER = intValue; + commonSettings.BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER = intValue; + } + else if (OPTION_EMPTY_LINES_TO_PRESERVE.equals(key)) { + int intValue = valueToInt(value); + commonSettings.KEEP_BLANK_LINES_IN_CODE = intValue; + commonSettings.KEEP_BLANK_LINES_IN_DECLARATIONS = intValue; + commonSettings.KEEP_BLANK_LINES_BEFORE_RBRACE = intValue; + } + else if (OPTION_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK.equals(key)) { + boolean insertSpace = valueToBoolean(key, value); + commonSettings.SPACE_BEFORE_ELSE_KEYWORD = insertSpace; + commonSettings.SPACE_BEFORE_CATCH_KEYWORD = insertSpace; + commonSettings.SPACE_BEFORE_FINALLY_KEYWORD = insertSpace; + } + else if (OPTION_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK.equals(key)) { + boolean insertSpace = valueToBoolean(key, value); + commonSettings.SPACE_BEFORE_IF_LBRACE = insertSpace; + commonSettings.SPACE_BEFORE_FOR_LBRACE = insertSpace; + commonSettings.SPACE_BEFORE_WHILE_LBRACE = insertSpace; + commonSettings.SPACE_BEFORE_DO_LBRACE = insertSpace; + commonSettings.SPACE_BEFORE_TRY_LBRACE = insertSpace; + commonSettings.SPACE_BEFORE_CATCH_LBRACE = insertSpace; + commonSettings.SPACE_BEFORE_FINALLY_LBRACE = insertSpace; + commonSettings.SPACE_BEFORE_SYNCHRONIZED_LBRACE = insertSpace; + } + else if (OPTION_JOIN_WRAPPED_LINES.equals(key)) { + commonSettings.KEEP_LINE_BREAKS = !valueToBoolean(key, value); + } + } + else if (object instanceof CommonCodeStyleSettings.IndentOptions) { + CommonCodeStyleSettings.IndentOptions indentOptions = (CommonCodeStyleSettings.IndentOptions)object; + if (OPTION_TAB_CHAR.equals(key)) { + if (TAB_CHAR_TAB.equals(value) || TAB_CHAR_MIXED.equals(value)) { + indentOptions.USE_TAB_CHARACTER = true; + } + else if (TAB_CHAR_SPACE.equals(value)) { + indentOptions.USE_TAB_CHARACTER = false; + } + } + else if (OPTION_CONTINUATION_INDENT.equals(key)) { + indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.TAB_SIZE * valueToInt(value); + } + else if (OPTION_TAB_SIZE.equals(key)) { + int newTabSize = valueToInt(value); + int continuationTabs = indentOptions.TAB_SIZE > 0 ? indentOptions.CONTINUATION_INDENT_SIZE / indentOptions.TAB_SIZE : -1; + indentOptions.TAB_SIZE = newTabSize; + if (continuationTabs >= 0) { + indentOptions.CONTINUATION_INDENT_SIZE = continuationTabs * newTabSize; + } + } + } + } + + private static boolean setAlignmentAndWrappingOptions(@NotNull CommonCodeStyleSettings settings, + @NotNull String key, + @NotNull String value) { + int encodedValue = Integer.parseInt(value); + AlignmentAndWrapValueDecoder decoder = new AlignmentAndWrapValueDecoder(encodedValue); + if (OPTION_ALIGN_ARGS_IN_ANNOTATION.equals(key)) { + settings.FIELD_ANNOTATION_WRAP = + settings.METHOD_ANNOTATION_WRAP = + settings.PARAMETER_ANNOTATION_WRAP = + settings.VARIABLE_ANNOTATION_WRAP = + settings.CLASS_ANNOTATION_WRAP = decoder.getWrapType(); + return true; + } + else if (OPTION_ALIGN_EXPR_IN_ARRAY_INITIALIZER.equals(key)) { + settings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION = decoder.isAlignmentOn(); + settings.ARRAY_INITIALIZER_WRAP = decoder.getWrapType(); + settings.ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE = decoder.isFirstElementWrapped(); + return true; + } + else if (OPTION_ALIGN_ARGS_IN_METHOD_INVOCATION.equals(key)) { + settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = decoder.isAlignmentOn(); + settings.CALL_PARAMETERS_WRAP = decoder.getWrapType(); + settings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = decoder.isFirstElementWrapped(); + return true; + } + else if (OPTION_ALIGN_INTERFACES_IN_TYPE_DECL.equals(key)) { + settings.ALIGN_MULTILINE_EXTENDS_LIST = decoder.isAlignmentOn(); + settings.EXTENDS_KEYWORD_WRAP = decoder.getFirstElementWrapType(); + settings.EXTENDS_LIST_WRAP = decoder.getWrapType(); + return true; + } + else if (OPTION_ALIGN_ASSIGNMENT.equals(key)) { + settings.ALIGN_MULTILINE_ASSIGNMENT = decoder.isAlignmentOn(); + settings.ASSIGNMENT_WRAP = decoder.getWrapType(); + return true; + } + else if (OPTION_ALIGN_METHOD_DECL_PARAMETERS.equals(key)) { + settings.ALIGN_MULTILINE_PARAMETERS = decoder.isAlignmentOn(); + settings.METHOD_PARAMETERS_WRAP = decoder.getWrapType(); + settings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = decoder.isFirstElementWrapped(); + return true; + } + else if (OPTION_ALIGN_BINARY_EXPR.equals(key)) { + settings.ALIGN_MULTILINE_BINARY_OPERATION = decoder.isAlignmentOn(); + settings.BINARY_OPERATION_WRAP = decoder.getWrapType(); + return true; + } + else if (OPTION_ALIGN_THROWS_IN_METHOD_DECL.equals(key)) { + settings.ALIGN_MULTILINE_THROWS_LIST = decoder.isAlignmentOn(); + settings.THROWS_KEYWORD_WRAP = decoder.getFirstElementWrapType(); + settings.THROWS_LIST_WRAP = decoder.getWrapType(); + return true; + } + else if (OPTION_ALIGN_RESOURCES_IN_TRY.equals(key)) { + settings.ALIGN_MULTILINE_RESOURCES = decoder.isAlignmentOn(); + settings.RESOURCE_LIST_WRAP = decoder.getWrapType(); + settings.RESOURCE_LIST_LPAREN_ON_NEXT_LINE = decoder.isFirstElementWrapped(); + return true; + } + else if (OPTION_ALIGN_CHAINED_CALLS.equals(key)) { + settings.METHOD_CALL_CHAIN_WRAP = decoder.getWrapType(); + settings.ALIGN_MULTILINE_CHAINED_METHODS = decoder.isAlignmentOn(); + } + else if (OPTION_ALIGN_CONDITIONALS.equals(key)) { + settings.TERNARY_OPERATION_WRAP = decoder.getWrapType(); + settings.ALIGN_MULTILINE_TERNARY_OPERATION = decoder.isAlignmentOn(); + } + return false; + } +} diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileElements.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileElements.java index fa867ef8087d..a4f378d1a88b 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileElements.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileElements.java @@ -26,57 +26,4 @@ public interface EclipseXmlProfileElements { String SETTING_TAG = "setting"; String ID_ATTR = "id"; String VALUE_ATTR = "value"; - - String VALUE_INSERT = "insert"; - String VALUE_DO_NOT_INSERT = "do not insert"; - String VALUE_FALSE = "false"; - String VALUE_TRUE = "true"; - - String VALUE_NEXT_LINE = "next_line"; - String VALUE_NEXT_LINE_SHIFTED = "next_line_shifted"; - String VALUE_END_OF_LINE = "end_of_line"; - String VALUE_NEXT_LINE_IF_WRAPPED = "next_line_on_wrap"; - - String TAB_CHAR_TAB = "tab"; - String TAB_CHAR_SPACE = "space"; - String TAB_CHAR_MIXED = "mixed"; - - String OPTION_SPACE_AFTER_BINARY_OPERATOR = "org.eclipse.jdt.core.formatter.insert_space_after_binary_operator"; - String OPTION_REMOVE_JAVADOC_BLANK_LINES = "org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment"; - String OPTION_NEW_LINE_AT_EOF = "org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing"; - String OPTION_INDENT_CLASS_BODY_DECL = "org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header"; - String OPTION_TAB_CHAR = "org.eclipse.jdt.core.formatter.tabulation.char"; - String OPTION_CONTINUATION_INDENT = "org.eclipse.jdt.core.formatter.continuation_indentation"; - String OPTION_TAB_SIZE = "org.eclipse.jdt.core.formatter.tabulation.size"; - - String OPTION_ALIGN_EXPR_IN_ARRAY_INITIALIZER = "org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer"; - String OPTION_ALIGN_ARGS_IN_ANNOTATION = "org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation"; - String OPTION_ALIGN_ARGS_IN_METHOD_INVOCATION = "org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation"; - String OPTION_ALIGN_SUPERCLASS_IN_TYPE_DECL = "org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration"; - String OPTION_ALIGN_INTERFACES_IN_TYPE_DECL = "org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration"; - String OPTION_ALIGN_ASSIGNMENT = "org.eclipse.jdt.core.formatter.alignment_for_assignment"; - String OPTION_ALIGN_METHOD_DECL_PARAMETERS = "org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration"; - String OPTION_ALIGN_BINARY_EXPR = "org.eclipse.jdt.core.formatter.alignment_for_binary_expression"; - String OPTION_ALIGN_THROWS_IN_METHOD_DECL = "org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration"; - String OPTION_ALIGN_RESOURCES_IN_TRY = "org.eclipse.jdt.core.formatter.alignment_for_resources_in_try"; - String OPTION_ALIGN_METHOD_DECL = "org.eclipse.jdt.core.formatter.alignment_for_method_declaration"; - String OPTION_ALIGN_CHAINED_CALLS = "org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation"; - String OPTION_ALIGN_CONDITIONALS = "org.eclipse.jdt.core.formatter.alignment_for_conditional_expression"; - - String OPTION_BLANK_LINES_BEFORE_FIRST_DECLARATION_IN_CLASS = "org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration"; - String OPTION_EMPTY_LINES_TO_PRESERVE = "org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve"; - - String OPTION_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK = "org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block"; - String OPTION_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK = "org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block"; - - String OPTION_JOIN_WRAPPED_LINES = "org.eclipse.jdt.core.formatter.join_wrapped_lines"; - - int WRAP_MASK = 0x70; - - int DO_NOT_WRAP = 0x00; - int WRAP_WHERE_NECESSARY = 0x10; - int WRAP_FIRST_OTHERS_WHERE_NECESSARY = 0x20; - int WRAP_ALL_ON_NEW_LINE_EACH = 0x30; - int WRAP_ALL_INDENT_EXCEPT_FIRST = 0x40; - int WRAP_ALL_EXCEPT_FIRST = 0x50; } diff --git a/plugins/eclipse/testData/import/settings/org.eclipse.jdt.core.prefs b/plugins/eclipse/testData/import/settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..ad466d2359b2 --- /dev/null +++ b/plugins/eclipse/testData/import/settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,326 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter \ No newline at end of file diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseSettingsImportTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseSettingsImportTest.java index 3d45212c0c1d..7dabae167256 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseSettingsImportTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseSettingsImportTest.java @@ -2,12 +2,16 @@ package org.jetbrains.idea.eclipse; import com.intellij.openapi.application.PluginPathManager; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; +import com.intellij.openapi.options.SchemeImportException; import com.intellij.psi.codeStyle.*; import com.intellij.testFramework.PlatformTestCase; import org.jetbrains.idea.eclipse.importer.EclipseCodeStyleImportWorker; +import org.jetbrains.idea.eclipse.importer.EclipseCodeStylePropertiesImporter; +import org.jetbrains.idea.eclipse.importer.EclipseCodeStyleSchemeImporter; import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; /** @@ -263,4 +267,22 @@ public class EclipseSettingsImportTest extends PlatformTestCase { editorSettings.setEnsureNewLineAtEOF(currAddLineFeed); } } + + public void testImportCodeStyleProperties() throws IOException, SchemeImportException { + File input = new File(getTestDataPath() + EclipseCodeStylePropertiesImporter.CODE_STYLE_PROPERTY_FILE); + CodeStyleSettings settings = new CodeStyleSettings(); + CommonCodeStyleSettings javaSettings = settings.getCommonSettings("Java"); + CommonCodeStyleSettings.IndentOptions indentOptions = javaSettings.getIndentOptions(); + JavaCodeStyleSettings javaCustomSettings = settings.getCustomSettings(JavaCodeStyleSettings.class); + javaSettings.BLANK_LINES_AFTER_IMPORTS = 0; + indentOptions.CONTINUATION_INDENT_SIZE = 2; + javaCustomSettings.ENABLE_JAVADOC_FORMATTING = false; + + try (InputStream stream = new FileInputStream(input)) { + new EclipseCodeStylePropertiesImporter().importProperties(stream, settings); + assertEquals(1, javaSettings.BLANK_LINES_AFTER_IMPORTS); + assertEquals(8, indentOptions.CONTINUATION_INDENT_SIZE); + assertTrue(javaCustomSettings.ENABLE_JAVADOC_FORMATTING); + } + } }