mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed IDEA-195707 "'case' on new line" setting name is misleading
This commit is contained in:
@@ -550,9 +550,7 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
" while (x < 50000) x++;\n" +
|
||||
" do x++; while (x < 10000);\n" +
|
||||
" switch (a) {\n" +
|
||||
" case 0:\n" +
|
||||
" doCase0();\n" +
|
||||
" break;\n" +
|
||||
" case 0: case 1:\ndoCase0(); break;\ncase 2: case 3: return;" +
|
||||
" default:\n" +
|
||||
" doDefault();\n" +
|
||||
" }\n" +
|
||||
|
||||
@@ -908,12 +908,13 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
myResult = Spacing.createDependentLFSpacing(0, 1, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
|
||||
}
|
||||
}
|
||||
else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT) {
|
||||
else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT ||
|
||||
myChild2.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT) {
|
||||
if (myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT) {
|
||||
myResult = getSpaceBeforeLBrace(myChild2, mySettings.SPACE_BEFORE_SWITCH_LBRACE, null);
|
||||
}
|
||||
else {
|
||||
int lineFeeds = mySettings.CASE_STATEMENT_ON_NEW_LINE ? 1 : 0;
|
||||
int lineFeeds = myChild1.getElementType() != JavaElementType.SWITCH_LABEL_STATEMENT || mySettings.CASE_STATEMENT_ON_NEW_LINE ? 1 : 0;
|
||||
myResult = Spacing.createSpacing(1, 1, lineFeeds, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
"call_parameters_new_line_after_left_paren": false,
|
||||
"call_parameters_right_paren_on_new_line": false,
|
||||
"call_parameters_wrap": "on_every_item",
|
||||
"case_statement_on_new_line": true,
|
||||
"case_statement_on_separate_line": true,,
|
||||
"catch_on_new_line": false,
|
||||
"class_annotation_wrap": "split_into_lines",
|
||||
"class_brace_style": "end_of_line",
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
"call_parameters_new_line_after_left_paren": false,
|
||||
"call_parameters_right_paren_on_new_line": false,
|
||||
"call_parameters_wrap": "on_every_item",
|
||||
"case_statement_on_new_line": true,
|
||||
"case_statement_on_separate_line": true,
|
||||
"catch_on_new_line": false,
|
||||
"class_annotation_wrap": "split_into_lines",
|
||||
"class_brace_style": "end_of_line",
|
||||
|
||||
@@ -3758,4 +3758,78 @@ public enum LevelCode {
|
||||
}
|
||||
|
||||
|
||||
fun testIdea195707() {
|
||||
getSettings().apply {
|
||||
CASE_STATEMENT_ON_NEW_LINE = true
|
||||
KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE = true
|
||||
}
|
||||
|
||||
doTextTest(
|
||||
"""
|
||||
public enum RotationDirection {
|
||||
CLOCKWISE, COUNTERCLOCKWISE;
|
||||
|
||||
public RotationDirection inverse() {
|
||||
switch(this) {
|
||||
case CLOCKWISE: return COUNTERCLOCKWISE; case COUNTERCLOCKWISE: return CLOCKWISE;
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown " + getClass().getSimpleName() + ": " + this);
|
||||
}
|
||||
}
|
||||
""".trimIndent(),
|
||||
|
||||
"""
|
||||
public enum RotationDirection {
|
||||
CLOCKWISE, COUNTERCLOCKWISE;
|
||||
|
||||
public RotationDirection inverse() {
|
||||
switch (this) {
|
||||
case CLOCKWISE:
|
||||
return COUNTERCLOCKWISE;
|
||||
case COUNTERCLOCKWISE:
|
||||
return CLOCKWISE;
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown " + getClass().getSimpleName() + ": " + this);
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
fun testIdea195707_1() {
|
||||
getSettings().apply {
|
||||
CASE_STATEMENT_ON_NEW_LINE = false
|
||||
KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE = true
|
||||
}
|
||||
|
||||
doTextTest(
|
||||
"""
|
||||
public enum RotationDirection {
|
||||
CLOCKWISE, COUNTERCLOCKWISE;
|
||||
|
||||
public RotationDirection inverse() {
|
||||
switch(this) {
|
||||
case CLOCKWISE: return COUNTERCLOCKWISE; case COUNTERCLOCKWISE: return CLOCKWISE;
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown " + getClass().getSimpleName() + ": " + this);
|
||||
}
|
||||
}
|
||||
""".trimIndent(),
|
||||
|
||||
"""
|
||||
public enum RotationDirection {
|
||||
CLOCKWISE, COUNTERCLOCKWISE;
|
||||
|
||||
public RotationDirection inverse() {
|
||||
switch (this) {
|
||||
case CLOCKWISE: return COUNTERCLOCKWISE;
|
||||
case COUNTERCLOCKWISE: return CLOCKWISE;
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown " + getClass().getSimpleName() + ": " + this);
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -394,7 +394,8 @@ public class CommonCodeStyleSettings {
|
||||
public boolean FINALLY_ON_NEW_LINE = false;
|
||||
|
||||
public boolean INDENT_CASE_FROM_SWITCH = true;
|
||||
|
||||
|
||||
@Property(externalName = "case_statement_on_separate_line")
|
||||
public boolean CASE_STATEMENT_ON_NEW_LINE = true;
|
||||
|
||||
/**
|
||||
|
||||
@@ -196,7 +196,7 @@ wrapping.method.parentheses=Method parentheses
|
||||
wrapping.special.else.if.braces.treatment=Special 'else if' treatment
|
||||
wrapping.indent.case.from.switch=Indent 'case' branches
|
||||
wrapping.indent.break.from.case=Indent 'break' from 'case'
|
||||
wrapping.case.statements.on.one.line='case' on new line
|
||||
wrapping.case.statements.on.one.line=Each 'case' on a separate line
|
||||
wrapping.force.braces=Force braces
|
||||
|
||||
wrapping.method.parameters=Method declaration parameters
|
||||
|
||||
Reference in New Issue
Block a user