[Java. Code Formatting] Add tests for idempontent formatting for java method declarations

IDEA-165216

GitOrigin-RevId: cc5cd68d5c16b737052765809c075d4a473fa7ad
This commit is contained in:
Georgii Ustinov
2024-07-29 12:15:09 +03:00
committed by intellij-monorepo-bot
parent 0aee70350c
commit 5813964716
13 changed files with 82 additions and 7 deletions

View File

@@ -3,4 +3,7 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {
}
}

View File

@@ -8,4 +8,12 @@ public class Main {
1,
2,
3);
public void foo(
int longArgument1,
int longArgument2,
int longArgument3,
int short4,
int receiver1) {
}
}

View File

@@ -3,4 +3,6 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {}
}

View File

@@ -3,4 +3,7 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {
}
}

View File

@@ -15,4 +15,13 @@ public class Test {
public void fooBarBaz(int... args) {
fooBarBaz(100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000);
}
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {
}
static void vertLongMethodName(int longArgument1, int longArgument2, int longArgument3, int short4) {
}
public <T, V extends Test> void typedMethod(@Deprecated List<? extends T> field1, @Deprecated List<? super T> field2) {
}
}

View File

@@ -41,4 +41,24 @@ public class Test {
100000,
100000);
}
public void foo(
int longArgument1,
int longArgument2,
int longArgument3,
int short4,
int receiver1) {
}
static void vertLongMethodName(
int longArgument1,
int longArgument2,
int longArgument3,
int short4) {
}
public <T, V extends Test> void typedMethod(
@Deprecated List<? extends T> field1,
@Deprecated List<? super T> field2) {
}
}

View File

@@ -3,4 +3,7 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1, int receiver3) {
}
}

View File

@@ -8,4 +8,13 @@ public class Main {
1,
2,
3);
public void foo(
int longArgument1,
int longArgument2,
int longArgument3,
int short4,
int receiver1,
int receiver3) {
}
}

View File

@@ -3,4 +3,7 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {
}
}

View File

@@ -4,4 +4,8 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(
2017, Month.NOVEMBER, 1, 2, 3);
public void foo(
int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {
}
}

View File

@@ -3,4 +3,6 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {}
}

View File

@@ -3,4 +3,7 @@ import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {
}
}

View File

@@ -13,32 +13,33 @@ class JavaFormatterNewLineAfterLBraceTest : JavaFormatterTestCase() {
override fun setUp() {
super.setUp()
commonSettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true
commonSettings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = true
commonSettings.RIGHT_MARGIN = 100
}
fun testWrapAlways() {
commonSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS
setupWrapType(CommonCodeStyleSettings.WRAP_ALWAYS)
doIdempotentTest()
}
fun testChopDownIfLongMultipleLines() {
commonSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM
setupWrapType(CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM)
doIdempotentTest()
}
fun testChopDownIfLongSingleLine() {
commonSettings.RIGHT_MARGIN = 200
commonSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM
setupWrapType(CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM)
doIdempotentTest()
}
fun testDoNotWrap() {
commonSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP
setupWrapType(CommonCodeStyleSettings.DO_NOT_WRAP)
doTest()
}
fun testWrapAsNeedSingleLine() {
commonSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED
setupWrapType(CommonCodeStyleSettings.WRAP_AS_NEEDED)
doIdempotentTest()
}
@@ -48,7 +49,7 @@ class JavaFormatterNewLineAfterLBraceTest : JavaFormatterTestCase() {
}
fun testMultipleCalls() {
commonSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM
setupWrapType(CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM)
doIdempotentTest()
}
@@ -57,4 +58,9 @@ class JavaFormatterNewLineAfterLBraceTest : JavaFormatterTestCase() {
doTest(testName, "${testName}_after")
doTest("${testName}_after", "${testName}_after")
}
}
private fun setupWrapType(wrapType: Int) {
commonSettings.CALL_PARAMETERS_WRAP = wrapType
commonSettings.METHOD_PARAMETERS_WRAP = wrapType
}
}