Formatter: left brace formatting for "do while"
This commit is contained in:
@@ -164,7 +164,6 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
|||||||
betweenInside(WHILE_KEYWORD, LPAR, DO_WHILE).spacing(1, 1, 0, false, 0)
|
betweenInside(WHILE_KEYWORD, LPAR, DO_WHILE).spacing(1, 1, 0, false, 0)
|
||||||
|
|
||||||
aroundInside(WHILE_KEYWORD, DO_WHILE).spaces(1)
|
aroundInside(WHILE_KEYWORD, DO_WHILE).spaces(1)
|
||||||
afterInside(DO_KEYWORD, DO_WHILE).spaces(1)
|
|
||||||
|
|
||||||
// TODO: Ask for better API
|
// TODO: Ask for better API
|
||||||
// Type of the declaration colon
|
// Type of the declaration colon
|
||||||
@@ -225,7 +224,10 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
|||||||
|
|
||||||
inPosition(parent = IF, right = THEN).customRule(leftBraceRuleIfBlockIsWrapped)
|
inPosition(parent = IF, right = THEN).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||||
inPosition(parent = IF, right = ELSE).customRule(leftBraceRuleIfBlockIsWrapped)
|
inPosition(parent = IF, right = ELSE).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||||
|
|
||||||
inPosition(parent = WHILE, right = BODY).customRule(leftBraceRuleIfBlockIsWrapped)
|
inPosition(parent = WHILE, right = BODY).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||||
|
inPosition(parent = DO_WHILE, right = BODY).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||||
|
|
||||||
inPosition(parent = TRY, right = BLOCK).customRule(leftBraceRule)
|
inPosition(parent = TRY, right = BLOCK).customRule(leftBraceRule)
|
||||||
inPosition(parent = CATCH, right = BLOCK).customRule(leftBraceRule)
|
inPosition(parent = CATCH, right = BLOCK).customRule(leftBraceRule)
|
||||||
inPosition(parent = FINALLY, right = BLOCK).customRule(leftBraceRule)
|
inPosition(parent = FINALLY, right = BLOCK).customRule(leftBraceRule)
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
fun main() {
|
||||||
|
do {
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do //eol comment
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do //eol comment
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: LBRACE_ON_NEXT_LINE
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
fun main() {
|
||||||
|
do
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do //eol comment
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do //eol comment
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: LBRACE_ON_NEXT_LINE
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
fun main() {
|
||||||
|
do {
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do //eol comment
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
|
||||||
|
do //eol comment
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: LBRACE_ON_NEXT_LINE
|
||||||
@@ -5,13 +5,11 @@ fun test() {
|
|||||||
do {
|
do {
|
||||||
} while (true)
|
} while (true)
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
while (true)
|
while (true)
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
while (true)
|
while (true)
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
|
|||||||
doTest("idea/testData/formatter/ConsecutiveCalls.after.kt");
|
doTest("idea/testData/formatter/ConsecutiveCalls.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DoWhileLineBreak.after.kt")
|
||||||
|
public void testDoWhileLineBreak() throws Exception {
|
||||||
|
doTest("idea/testData/formatter/DoWhileLineBreak.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("DoWhileSpacing.after.kt")
|
@TestMetadata("DoWhileSpacing.after.kt")
|
||||||
public void testDoWhileSpacing() throws Exception {
|
public void testDoWhileSpacing() throws Exception {
|
||||||
doTest("idea/testData/formatter/DoWhileSpacing.after.kt");
|
doTest("idea/testData/formatter/DoWhileSpacing.after.kt");
|
||||||
@@ -352,6 +357,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/formatter"), Pattern.compile("^([^\\.]+)\\.after.inv.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/formatter"), Pattern.compile("^([^\\.]+)\\.after.inv.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DoWhileLineBreak.after.inv.kt")
|
||||||
|
public void testDoWhileLineBreak() throws Exception {
|
||||||
|
doTestInverted("idea/testData/formatter/DoWhileLineBreak.after.inv.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("FunctionalType.after.inv.kt")
|
@TestMetadata("FunctionalType.after.inv.kt")
|
||||||
public void testFunctionalType() throws Exception {
|
public void testFunctionalType() throws Exception {
|
||||||
doTestInverted("idea/testData/formatter/FunctionalType.after.inv.kt");
|
doTestInverted("idea/testData/formatter/FunctionalType.after.inv.kt");
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ class Test() {
|
|||||||
while (One.myContainer.myBoolean)
|
while (One.myContainer.myBoolean)
|
||||||
System.out.println("Ok")
|
System.out.println("Ok")
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
System.out.println("Ok")
|
System.out.println("Ok")
|
||||||
}
|
}
|
||||||
while (One.myContainer.myBoolean)
|
while (One.myContainer.myBoolean)
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ open class Test() {
|
|||||||
while (One.myContainer?.myBoolean!!)
|
while (One.myContainer?.myBoolean!!)
|
||||||
System.out?.println("Ok")
|
System.out?.println("Ok")
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
System.out?.println("Ok")
|
System.out?.println("Ok")
|
||||||
}
|
}
|
||||||
while (One.myContainer?.myBoolean!!)
|
while (One.myContainer?.myBoolean!!)
|
||||||
|
|||||||
Reference in New Issue
Block a user