Partial fix for IDEA-117025 Eclipse code style import: Blank Lines: some categories are not applied

This commit is contained in:
Rustam Vishnyakov
2014-02-13 19:48:10 +04:00
parent 48c22612a3
commit 7a166170d5
5 changed files with 32 additions and 6 deletions
@@ -246,6 +246,17 @@ public class EclipseCodeStyleSchemeImporter implements SchemeImporter<CodeStyleS
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 (object instanceof CommonCodeStyleSettings.IndentOptions) {
CommonCodeStyleSettings.IndentOptions indentOptions = (CommonCodeStyleSettings.IndentOptions)object;
@@ -86,7 +86,7 @@ org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_refer
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=Java:SPACE_WITHIN_PARENTHESES
#org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=
#org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaratio n=
#org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=Java:<Programmatic>
#org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=
org.eclipse.jdt.core.formatter.indentation.size=Java:IndentOptions:INDENT_SIZE
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=Java:SPACE_WITHIN_EMPTY_METHOD_PARENTHESES
@@ -167,7 +167,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=Java:SPACE_AFTER_TYPE_CAST
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=Java:SPACE_AFTER_COMMA
#org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=Java:KEEP_BLANK_LINES_IN_CODE
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=Java:<Programmatic>
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=Java:SPACE_BEFORE_METHOD_PARENTHESES
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=Java:SPACE_WITHIN_CATCH_PARENTHESES
#org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=
@@ -219,7 +219,7 @@ org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=J
#org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=Java:BINARY_OPERATION_SIGN_ON_NEXT_LINE
#org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=
#org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=Java:BLANK_LINES_AROUND_CLASS
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=Java:SPACE_WITHIN_SYNCHRONIZED_PARENTHESES
#org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=
#org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=
@@ -63,6 +63,9 @@ public interface EclipseXmlProfileElements {
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";
int WRAP_MASK = 0x70;
int DO_NOT_WRAP = 0x00;
@@ -80,7 +80,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
@@ -164,7 +164,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="5"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
@@ -217,7 +217,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="3"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
@@ -119,6 +119,12 @@ public class EclipseSettingsImportTest extends PlatformTestCase {
javaSettings.ALIGN_MULTILINE_CHAINED_METHODS = false;
javaSettings.TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
javaSettings.ALIGN_MULTILINE_TERNARY_OPERATION = false;
javaSettings.BLANK_LINES_AFTER_CLASS_HEADER = -1;
javaSettings.BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER = -1;
javaSettings.BLANK_LINES_AROUND_CLASS = -1;
javaSettings.KEEP_BLANK_LINES_IN_CODE = -1;
javaSettings.KEEP_BLANK_LINES_BEFORE_RBRACE = -1;
javaSettings.KEEP_BLANK_LINES_IN_DECLARATIONS = -1;
indentOptions.USE_TAB_CHARACTER = false;
indentOptions.SMART_TABS = false;
indentOptions.TAB_SIZE = 3;
@@ -217,6 +223,12 @@ public class EclipseSettingsImportTest extends PlatformTestCase {
assertTrue(javaSettings.ALIGN_MULTILINE_CHAINED_METHODS);
assertEquals(CommonCodeStyleSettings.WRAP_AS_NEEDED, javaSettings.TERNARY_OPERATION_WRAP);
assertTrue(javaSettings.ALIGN_MULTILINE_TERNARY_OPERATION);
assertEquals(2, javaSettings.BLANK_LINES_AFTER_CLASS_HEADER);
assertEquals(2, javaSettings.BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER);
assertEquals(3, javaSettings.BLANK_LINES_AROUND_CLASS);
assertEquals(5, javaSettings.KEEP_BLANK_LINES_IN_CODE);
assertEquals(5, javaSettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
assertEquals(5, javaSettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
finally {
inputStream.close();