Formatter: left brace formatting for "for in ..."
This commit is contained in:
@@ -225,6 +225,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
||||
inPosition(parent = IF, right = THEN).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||
inPosition(parent = IF, right = ELSE).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||
|
||||
inPosition(parent = FOR, right = BODY).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||
inPosition(parent = WHILE, right = BODY).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||
inPosition(parent = DO_WHILE, right = BODY).customRule(leftBraceRuleIfBlockIsWrapped)
|
||||
|
||||
@@ -232,6 +233,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
||||
inPosition(parent = CATCH, right = BLOCK).customRule(leftBraceRule)
|
||||
inPosition(parent = FINALLY, right = BLOCK).customRule(leftBraceRule)
|
||||
|
||||
|
||||
val spacesInSimpleFunction = if (jetSettings.INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD) 1 else 0
|
||||
inPosition(parent = FUNCTION_LITERAL,
|
||||
left = LBRACE,
|
||||
|
||||
@@ -4,8 +4,7 @@ fun main(args: Array<String>) {
|
||||
val project = file.getProject()
|
||||
val converter = Converter(project, J2kPackage.getPluginSettings())
|
||||
val result = StringBuilder()
|
||||
for (e in buffer)
|
||||
{
|
||||
for (e in buffer) {
|
||||
result.append(converter.elementToKotlin(e))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
fun main() {
|
||||
for (a in b) {
|
||||
}
|
||||
|
||||
for (a in b) {
|
||||
}
|
||||
|
||||
for (a in b) {
|
||||
}
|
||||
|
||||
for (a in b) //eol comment
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b) //eol comment
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// SET_TRUE: LBRACE_ON_NEXT_LINE
|
||||
@@ -0,0 +1,23 @@
|
||||
fun main() {
|
||||
for (a in b)
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b)
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b)
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b) //eol comment
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b) //eol comment
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// SET_TRUE: LBRACE_ON_NEXT_LINE
|
||||
@@ -0,0 +1,24 @@
|
||||
fun main() {
|
||||
for (a in b) {
|
||||
}
|
||||
|
||||
for (a in b)
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b) //eol comment
|
||||
{
|
||||
}
|
||||
|
||||
for (a in b) //eol comment
|
||||
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// SET_TRUE: LBRACE_ON_NEXT_LINE
|
||||
@@ -11,8 +11,6 @@ fun f() {
|
||||
|
||||
for (i in array(1, 2)) continue
|
||||
|
||||
for (i in array(1, 2))
|
||||
|
||||
{
|
||||
for (i in array(1, 2)) {
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
|
||||
doTest("idea/testData/formatter/EmptyLineAfterPackage.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForLineBreak.after.kt")
|
||||
public void testForLineBreak() throws Exception {
|
||||
doTest("idea/testData/formatter/ForLineBreak.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForNoBraces.after.kt")
|
||||
public void testForNoBraces() throws Exception {
|
||||
doTest("idea/testData/formatter/ForNoBraces.after.kt");
|
||||
@@ -362,6 +367,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
|
||||
doTestInverted("idea/testData/formatter/DoWhileLineBreak.after.inv.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForLineBreak.after.inv.kt")
|
||||
public void testForLineBreak() throws Exception {
|
||||
doTestInverted("idea/testData/formatter/ForLineBreak.after.inv.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionalType.after.inv.kt")
|
||||
public void testFunctionalType() throws Exception {
|
||||
doTestInverted("idea/testData/formatter/FunctionalType.after.inv.kt");
|
||||
|
||||
@@ -4,12 +4,10 @@ public class ForEach() {
|
||||
public fun test() {
|
||||
val xs = ArrayList<Any>()
|
||||
val ys = LinkedList<Any>()
|
||||
for (x in xs)
|
||||
{
|
||||
for (x in xs) {
|
||||
ys.add(x)
|
||||
}
|
||||
for (y in ys)
|
||||
{
|
||||
for (y in ys) {
|
||||
xs.add(y)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@ public open class ForEach() {
|
||||
public open fun test() {
|
||||
var xs: ArrayList<Any?>? = ArrayList<Any?>()
|
||||
var ys: MutableList<Any?>? = LinkedList<Any?>()
|
||||
for (x in xs!!)
|
||||
{
|
||||
for (x in xs!!) {
|
||||
ys?.add(x)
|
||||
}
|
||||
for (y in ys!!)
|
||||
{
|
||||
for (y in ys!!) {
|
||||
xs?.add(y)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user