mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-63820 Allow "throws" to be placed on the new line without indent
1. Added ability to configure java formatter in a way to align 'throws' keyword to method start; 2. Corresponding tests are added;
This commit is contained in:
@@ -215,7 +215,8 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
" x--;\n" +
|
||||
" } while (x > 10) \n" +
|
||||
" }\n" +
|
||||
" public static void test() { \n" +
|
||||
" public static void test() \n" +
|
||||
" throws Exception { \n" +
|
||||
" foo.foo().bar(\"arg1\", \n" +
|
||||
" \"arg2\"); \n" +
|
||||
" } \n" +
|
||||
|
||||
@@ -823,6 +823,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
if (role == ChildRole.TYPE_PARAMETER_LIST) return defaultAlignment;
|
||||
if (role == ChildRole.TYPE) return defaultAlignment;
|
||||
if (role == ChildRole.NAME) return defaultAlignment;
|
||||
if (role == ChildRole.THROWS_LIST && mySettings.ALIGN_THROWS_KEYWORD) return defaultAlignment;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+22
@@ -251,4 +251,26 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest {
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
public void testAlignThrowsKeyword() throws Exception {
|
||||
// Inspired by IDEA-63820
|
||||
|
||||
getSettings().ALIGN_THROWS_KEYWORD = true;
|
||||
doClassTest(
|
||||
"public void test()\n" +
|
||||
" throws Exception {}",
|
||||
"public void test()\n" +
|
||||
"throws Exception {\n" +
|
||||
"}"
|
||||
);
|
||||
|
||||
getSettings().ALIGN_THROWS_KEYWORD = false;
|
||||
doClassTest(
|
||||
"public void test()\n" +
|
||||
" throws Exception {}",
|
||||
"public void test()\n" +
|
||||
" throws Exception {\n" +
|
||||
"}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,6 +299,7 @@ public class CommonCodeStyleSettings {
|
||||
public boolean ALIGN_MULTILINE_ASSIGNMENT = false;
|
||||
public boolean ALIGN_MULTILINE_TERNARY_OPERATION = false;
|
||||
public boolean ALIGN_MULTILINE_THROWS_LIST = false;
|
||||
public boolean ALIGN_THROWS_KEYWORD = false;
|
||||
|
||||
public boolean ALIGN_MULTILINE_EXTENDS_LIST = false;
|
||||
public boolean ALIGN_MULTILINE_METHOD_BRACKETS = false;
|
||||
|
||||
+1
@@ -49,6 +49,7 @@ public class WrappingAndBracesPanel extends OptionTableWithPreviewPanel {
|
||||
|
||||
addOption("THROWS_LIST_WRAP", WRAPPING_THROWS_LIST, WRAP_OPTIONS, WRAP_VALUES);
|
||||
addOption("ALIGN_MULTILINE_THROWS_LIST", ApplicationBundle.message("wrapping.align.when.multiline"), WRAPPING_THROWS_LIST);
|
||||
addOption("ALIGN_THROWS_KEYWORD", ApplicationBundle.message("wrapping.align.throws.keyword"), WRAPPING_THROWS_LIST);
|
||||
addOption("THROWS_KEYWORD_WRAP", WRAPPING_THROWS_KEYWORD, WRAP_OPTIONS_FOR_SINGLETON, WRAP_VALUES_FOR_SINGLETON);
|
||||
|
||||
addOption("METHOD_PARAMETERS_WRAP", WRAPPING_METHOD_PARAMETERS, WRAP_OPTIONS, WRAP_VALUES);
|
||||
|
||||
@@ -180,6 +180,7 @@ wrapping.extends.implements.list=Extends/implements list
|
||||
wrapping.extends.implements.keyword=Extends/implements keyword
|
||||
wrapping.throws.list=Throws list
|
||||
wrapping.throws.keyword=Throws keyword
|
||||
wrapping.align.throws.keyword=Align 'throws' to method start
|
||||
wrapping.ternary.operation=Ternary operation
|
||||
wrapping.assignment.variables.groups=Fields/variables groups
|
||||
wrapping.assignment.statement=Assignment statement
|
||||
|
||||
Reference in New Issue
Block a user