KotlinLikeLangLineIndentProvider: support braces in blocks
Part of #KT-22211 Part of #KT-39353
This commit is contained in:
+5
-4
@@ -68,6 +68,9 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
|
||||
val before = currentPosition.beforeOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET)
|
||||
val after = currentPosition.afterOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET)
|
||||
when {
|
||||
before.isAt(BlockOpeningBrace) && after.isAt(BlockClosingBrace) && !currentPosition.hasLineBreaksAfter(offset) ->
|
||||
return factory.createIndentCalculator(Indent.getNoneIndent(), before.startOffset)
|
||||
|
||||
after.isAt(Quest) && after.after().isAt(Colon) -> {
|
||||
val indent = if (settings.continuationIndentInElvis)
|
||||
Indent.getContinuationIndent()
|
||||
@@ -110,10 +113,8 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
|
||||
}
|
||||
}
|
||||
|
||||
before.isAt(LeftParenthesis) && after.isAt(RightParenthesis) -> {
|
||||
val indentCalculator = factory.createIndentCalculatorForParenthesis(before, currentPosition, after, offset, settings)
|
||||
if (indentCalculator != null) return indentCalculator
|
||||
}
|
||||
before.isAt(LeftParenthesis) && after.isAt(RightParenthesis) ->
|
||||
factory.createIndentCalculatorForParenthesis(before, currentPosition, after, offset, settings)?.let { return it }
|
||||
}
|
||||
|
||||
findFunctionOrPropertyDeclarationBefore(before)?.let {
|
||||
|
||||
+5
@@ -88,6 +88,11 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
|
||||
runTest("idea/testData/indentationOnNewline/FunctionBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionBlock2.kt")
|
||||
public void testFunctionBlock2() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/FunctionBlock2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InDelegationListAfterColon.kt")
|
||||
public void testInDelegationListAfterColon() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.kt");
|
||||
|
||||
@@ -7,5 +7,3 @@ fun main(args: Array<String>) {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
@@ -5,5 +5,3 @@ private fun <T> times(times : Int, body : () -> T) {}
|
||||
fun main(args: Array<String>) {
|
||||
times(3) {<caret>}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
@@ -0,0 +1,13 @@
|
||||
package testing
|
||||
|
||||
private fun <T> times(times : Int, body : () -> T) {}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
times(3) {
|
||||
|
||||
|
||||
|
||||
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package testing
|
||||
|
||||
private fun <T> times(times : Int, body : () -> T) {}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
times(3) {
|
||||
|
||||
|
||||
|
||||
<caret>}
|
||||
}
|
||||
@@ -7,5 +7,3 @@ fun test() {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
@@ -5,5 +5,3 @@ class Test {
|
||||
fun test() {
|
||||
val abc = Test().foo()?.foo({ "str" }).foo {<caret>}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
-2
@@ -7,5 +7,3 @@ fun test() {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
-2
@@ -5,5 +5,3 @@ class Test {
|
||||
fun test() {
|
||||
val abc = Test().foo()?.foo({ "str" }).foo { <caret> }
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
-2
@@ -9,5 +9,3 @@ fun test() {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
@@ -7,5 +7,3 @@ fun test() {
|
||||
.foo { "Str" }
|
||||
.foo {<caret>}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
-2
@@ -9,5 +9,3 @@ fun test() {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
-2
@@ -7,5 +7,3 @@ fun test() {
|
||||
.foo { "Str" }
|
||||
.foo { <caret> }
|
||||
}
|
||||
|
||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||
+5
@@ -90,6 +90,11 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
||||
runTest("idea/testData/indentationOnNewline/FunctionBlock.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionBlock2.after.kt")
|
||||
public void testFunctionBlock2() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/FunctionBlock2.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InDelegationListAfterColon.after.kt")
|
||||
public void testInDelegationListAfterColon() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.after.kt");
|
||||
|
||||
Reference in New Issue
Block a user