mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
added separate option for lambdas braces style [IDEA-116736]
This commit is contained in:
@@ -145,6 +145,7 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
"BRACE_STYLE",
|
||||
"CLASS_BRACE_STYLE",
|
||||
"METHOD_BRACE_STYLE",
|
||||
"LAMBDA_BRACE_STYLE",
|
||||
"USE_FLYING_GEESE_BRACES",
|
||||
"FLYING_GEESE_BRACES_GAP",
|
||||
"DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS",
|
||||
|
||||
@@ -1301,12 +1301,12 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
}
|
||||
else if (myRole1 == ChildRole.ARROW) {
|
||||
if (myRole2 == ChildRole.LBRACE) {
|
||||
switch (mySettings.BRACE_STYLE) {
|
||||
switch (mySettings.LAMBDA_BRACE_STYLE) {
|
||||
case NEXT_LINE:
|
||||
case NEXT_LINE_SHIFTED:
|
||||
case NEXT_LINE_SHIFTED2:
|
||||
int space = spaceAroundArrow ? 1 : 0;
|
||||
myResult = Spacing.createSpacing(space, space, 1, false, 0);
|
||||
myResult = Spacing.createSpacing(space, space, 1, mySettings.KEEP_LINE_BREAKS, 0);
|
||||
break;
|
||||
default:
|
||||
createSpaceInCode(spaceAroundArrow);
|
||||
|
||||
+12
-1
@@ -374,7 +374,7 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testLambdaBrace() {
|
||||
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
getSettings().LAMBDA_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doMethodTest(
|
||||
"Runnable r = () -> {\n" +
|
||||
"};",
|
||||
@@ -383,5 +383,16 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest {
|
||||
"};"
|
||||
);
|
||||
}
|
||||
|
||||
public void testLambdaBraceMoveToPrevLine() {
|
||||
getSettings().LAMBDA_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
|
||||
getSettings().KEEP_LINE_BREAKS = false;
|
||||
doMethodTest(
|
||||
"Runnable r = () ->\n" +
|
||||
"{\n" +
|
||||
"};",
|
||||
"Runnable r = () -> {\n" +
|
||||
"};");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ public interface CodeStyleSettingsCustomizable {
|
||||
BRACE_STYLE,
|
||||
CLASS_BRACE_STYLE,
|
||||
METHOD_BRACE_STYLE,
|
||||
LAMBDA_BRACE_STYLE,
|
||||
USE_FLYING_GEESE_BRACES,
|
||||
FLYING_GEESE_BRACES_GAP,
|
||||
DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS,
|
||||
|
||||
@@ -324,6 +324,7 @@ public class CommonCodeStyleSettings {
|
||||
@BraceStyleConstant public int BRACE_STYLE = END_OF_LINE;
|
||||
@BraceStyleConstant public int CLASS_BRACE_STYLE = END_OF_LINE;
|
||||
@BraceStyleConstant public int METHOD_BRACE_STYLE = END_OF_LINE;
|
||||
@BraceStyleConstant public int LAMBDA_BRACE_STYLE = END_OF_LINE;
|
||||
|
||||
/**
|
||||
* Defines if 'flying geese' style should be used for curly braces formatting, e.g. if we want to format code like
|
||||
|
||||
+2
-1
@@ -328,9 +328,10 @@ public class CodeStyleSettingPresentation {
|
||||
new CodeStyleSelectSettingPresentation("METHOD_BRACE_STYLE",
|
||||
ApplicationBundle.message("wrapping.brace.placement.method.declaration"),
|
||||
BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS),
|
||||
new CodeStyleSelectSettingPresentation("LAMBDA_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.lambda"),
|
||||
BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS),
|
||||
new CodeStyleSelectSettingPresentation("BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.other"),
|
||||
BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS)
|
||||
|
||||
));
|
||||
|
||||
putGroupTop(result, "EXTENDS_LIST_WRAP", WRAPPING_EXTENDS_LIST, WRAP_VALUES, WRAP_OPTIONS);
|
||||
|
||||
@@ -165,6 +165,7 @@ wrapping.brace.placement=Braces placement
|
||||
wrapping.brace.placement.class.declaration=In class declaration
|
||||
wrapping.brace.placement.method.declaration=In method declaration
|
||||
wrapping.brace.placement.other=Other
|
||||
wrapping.brace.placement.lambda=In lambda declaration
|
||||
wrapping.brace.placement.end.of.line=End of line
|
||||
wrapping.brace.placement.next.line.if.wrapped=Next line if wrapped
|
||||
wrapping.brace.placement.next.line=Next line
|
||||
|
||||
Reference in New Issue
Block a user