Add space between 'when' and '('

This commit is contained in:
Nikolay Krasko
2014-05-12 14:13:07 +04:00
parent 6b8ab1a604
commit 3d588acd2d
23 changed files with 115 additions and 30 deletions
@@ -113,6 +113,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
betweenInside(IF_KEYWORD, LPAR, IF).spacing(1, 1, 0, false, 0)
betweenInside(WHILE_KEYWORD, LPAR, WHILE).spacing(1, 1, 0, false, 0)
betweenInside(WHILE_KEYWORD, LPAR, DO_WHILE).spacing(1, 1, 0, false, 0)
betweenInside(WHEN_KEYWORD, LPAR, WHEN).spacing(1, 1, 0, false, 0)
val TYPE_COLON_ELEMENTS = TokenSet.create(PROPERTY, FUN, VALUE_PARAMETER, MULTI_VARIABLE_DECLARATION_ENTRY, FUNCTION_LITERAL)
beforeInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(jetSettings.SPACE_BEFORE_TYPE_COLON) }
@@ -5,7 +5,7 @@ enum class MyEnum {
fun foo() {
val a = MyEnum.FIRST
when(a) {
when (a) {
<caret> -> {
}
}
@@ -1,6 +1,6 @@
fun foo() {
val a = "aa"
when(a.capitalize()) {
when (a.capitalize()) {
<caret> -> {
}
else -> {
@@ -1,6 +1,6 @@
fun foo() {
val a = "aa"
when(a) {
when (a) {
<caret> -> {
}
else -> {
+25
View File
@@ -3,6 +3,31 @@ fun some(x: Any) {
is Number -> 0
else -> 1
}
when {
}
when {
}
when {
}
when (true) {
}
when (true) {
}
when (true) {
}
when (true) {
}
}
// SET_FALSE: ALIGN_IN_COLUMNS_CASE_BRANCH
+25
View File
@@ -3,6 +3,31 @@ fun some(x: Any) {
is Number -> 0
else -> 1
}
when {
}
when {
}
when {
}
when (true) {
}
when (true) {
}
when (true) {
}
when (true) {
}
}
// SET_FALSE: ALIGN_IN_COLUMNS_CASE_BRANCH
+36
View File
@@ -3,6 +3,42 @@ when (x) {
is Number -> 0
else->1
}
when {
}
when{
}
when
{
}
when (true) {
}
when(true){
}
when
(true)
{
}
when
(true)
{
}
}
// SET_FALSE: ALIGN_IN_COLUMNS_CASE_BRANCH
@@ -1,5 +1,5 @@
fun f() {
when(c) {
when (c) {
a -> {
}
b -> j
@@ -7,7 +7,7 @@ fun f() {
}
}
when(c) {
when (c) {
a -> {
}
b -> j
@@ -15,7 +15,7 @@ fun f() {
}
}
when(c) {
when (c) {
a -> {
}
b -> j
@@ -23,7 +23,7 @@ fun f() {
}
}
when(c) //eol comment
when (c) //eol comment
{
a -> //eol comment
{
@@ -1,6 +1,6 @@
fun f()
{
when(c)
when (c)
{
a ->
{
@@ -11,7 +11,7 @@ fun f()
}
}
when(c)
when (c)
{
a ->
{
@@ -22,7 +22,7 @@ fun f()
}
}
when(c)
when (c)
{
a ->
{
@@ -33,7 +33,7 @@ fun f()
}
}
when(c) //eol comment
when (c) //eol comment
{
a -> //eol comment
{
+4 -4
View File
@@ -1,6 +1,6 @@
fun f()
{
when(c) {
when (c) {
a -> {
}
b -> j
@@ -8,7 +8,7 @@ fun f()
}
}
when(c)
when (c)
{
a ->
{
@@ -19,7 +19,7 @@ fun f()
}
}
when(c)
when (c)
{
a ->
@@ -33,7 +33,7 @@ fun f()
}
}
when(c) //eol comment
when (c) //eol comment
{
a -> //eol comment
{
@@ -4,7 +4,7 @@ fun test(n: Int): String {
var res: String
if (3 > 2) {
<caret>when(n) {
<caret>when (n) {
1 -> {
doSomething("***")
res = "one"
@@ -4,7 +4,7 @@ fun test(n: Int): String {
var res: String
if (3 > 2) {
<caret>res = when(n) {
<caret>res = when (n) {
1 -> {
doSomething("***")
"one"
@@ -1,7 +1,7 @@
fun test(n: Int): String {
var res: String
<caret>when(n) {
<caret>when (n) {
1 -> res = "one"
else -> res = "two"
}
@@ -1,7 +1,7 @@
fun test(n: Int): String {
var res: String
<caret>res = when(n) {
<caret>res = when (n) {
1 -> "one"
else -> "two"
}
@@ -1,7 +1,7 @@
fun doSomething<T>(a: T) {}
fun test(n: Int): String {
<caret>when(n) {
<caret>when (n) {
1 -> {
doSomething("***")
return "one"
@@ -1,7 +1,7 @@
fun doSomething<T>(a: T) {}
fun test(n: Int): String {
<caret>return when(n) {
<caret>return when (n) {
1 -> {
doSomething("***")
"one"
@@ -1,5 +1,5 @@
fun test(n: Int): String? {
val res<caret> = when(n) {
val res<caret> = when (n) {
1 -> "one"
2 -> "two"
else -> null
@@ -1,6 +1,6 @@
fun test(n: Int): String? {
val res: String?
<caret>when(n) {
<caret>when (n) {
1 -> res = "one"
2 -> res = "two"
else -> res = null
@@ -1,5 +1,5 @@
fun test(n: Int): String? {
var res<caret> = when(n) {
var res<caret> = when (n) {
1 -> "one"
2 -> "two"
else -> null
@@ -1,6 +1,6 @@
fun test(n: Int): String? {
var res: String?
<caret>when(n) {
<caret>when (n) {
1 -> res = "one"
2 -> res = "two"
else -> res = null
@@ -1,5 +1,5 @@
fun test(n: Int): String? {
val res<caret>: String? = when(n) {
val res<caret>: String? = when (n) {
1 -> "one"
2 -> "two"
else -> null
@@ -1,6 +1,6 @@
fun test(n: Int): String? {
val res: String?
<caret>when(n) {
<caret>when (n) {
1 -> res = "one"
2 -> res = "two"
else -> res = null
@@ -61,9 +61,7 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde
}
public void testAllFilesPresentInDirectSettings() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage",
new File("idea/testData/indentationOnNewline"),
Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), true);
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/indentationOnNewline"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), true);
}
@TestMetadata("ConsecutiveCallsAfterDot.after.kt")