mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[Java. Formatting] Move semicolon to the new line with long chain calls. Add tests.
IDEA-291765 GitOrigin-RevId: a6a8db1ecf9f066b2958dc67cdcb14c216bd8594
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9cf690d4e1
commit
b11ea4bb77
@@ -276,6 +276,7 @@
|
||||
"while_on_new_line": false,
|
||||
"wrap_comments": false,
|
||||
"wrap_first_method_in_call_chain": false,
|
||||
"wrap_semicolon_after_call_chair": false,
|
||||
"wrap_long_lines": false,
|
||||
"wrap_on_typing": true
|
||||
}
|
||||
|
||||
@@ -1096,4 +1096,115 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
|
||||
"for (Rec(): foo)",
|
||||
"for (Rec() : foo)");
|
||||
}
|
||||
|
||||
public void testSemicolOnNewLineInLongCallChainWithWrapping() {
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
|
||||
getJavaSettings().WRAP_SEMICOLON_AFTER_CALL_CHAIN = true;
|
||||
|
||||
doTextTest("""
|
||||
class Foo {
|
||||
int x = new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
void foo() {
|
||||
new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
int i = new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
class Foo {
|
||||
int x = new Summator().reallyLongLongLongAddOperation(1)
|
||||
.reallyLongLongLongAddOperation(1)
|
||||
.get()
|
||||
;
|
||||
|
||||
void foo() {
|
||||
new Summator().reallyLongLongLongAddOperation(1)
|
||||
.reallyLongLongLongAddOperation(1)
|
||||
.get()
|
||||
;
|
||||
|
||||
int i = new Summator().reallyLongLongLongAddOperation(1)
|
||||
.reallyLongLongLongAddOperation(1)
|
||||
.get()
|
||||
;
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
}
|
||||
|
||||
public void testSemicolonOnNewLineInLongCallChainNoWrapping() {
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
|
||||
getJavaSettings().WRAP_SEMICOLON_AFTER_CALL_CHAIN = true;
|
||||
doTextTest("""
|
||||
class Foo {
|
||||
int x = new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
void foo() {
|
||||
new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
int i = new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
class Foo {
|
||||
int x = new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
void foo() {
|
||||
new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
int i = new Summator().reallyLongLongLongAddOperation(1).reallyLongLongLongAddOperation(1).get();
|
||||
}
|
||||
}
|
||||
""");
|
||||
}
|
||||
|
||||
public void testSemicolonOnNewLineInShortCallChainWithWrapping() {
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
|
||||
getJavaSettings().WRAP_SEMICOLON_AFTER_CALL_CHAIN = true;
|
||||
doTextTest("""
|
||||
class Foo {
|
||||
int x = new Summator().reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
void foo() {
|
||||
new Summator().reallyLongLongLongAddOperation(1).get();
|
||||
|
||||
int i = new Summator().reallyLongLongLongAddOperation(1).get();
|
||||
}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
class Foo {
|
||||
int x = new Summator().reallyLongLongLongAddOperation(1)
|
||||
.get();
|
||||
|
||||
void foo() {
|
||||
new Summator().reallyLongLongLongAddOperation(1)
|
||||
.get();
|
||||
|
||||
int i = new Summator().reallyLongLongLongAddOperation(1)
|
||||
.get();
|
||||
}
|
||||
}
|
||||
""");
|
||||
}
|
||||
|
||||
public void testSemicolonOnNewLineInLongCallChainWithWrappingInForStatement() {
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
|
||||
getJavaSettings().WRAP_SEMICOLON_AFTER_CALL_CHAIN = true;
|
||||
doMethodTest("""
|
||||
for (int i = new Summator().add(1).add(1).get(); i < new Summator().add(1).add(10).get(); ++i) {}
|
||||
""",
|
||||
"""
|
||||
for (int i = new Summator().add(1)
|
||||
.add(1)
|
||||
.get(); i < new Summator().add(1)
|
||||
.add(10)
|
||||
.get(); ++i) {
|
||||
}
|
||||
""");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user