Better indentation for expressions without parsed errors (KT-12123)

#KT-12123 Fixed
This commit is contained in:
Nikolay Krasko
2017-04-29 15:51:40 +03:00
parent c0b545085a
commit d094854878
2 changed files with 42 additions and 0 deletions
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.idea.formatter
import com.intellij.formatting.*
import com.intellij.formatting.ChildAttributes.DELEGATE_TO_NEXT_CHILD
import com.intellij.lang.ASTNode
import com.intellij.psi.TokenType
import com.intellij.psi.codeStyle.CodeStyleSettings
@@ -195,6 +196,11 @@ abstract class KotlinCommonBlock(
}
}
if (blocks.size > newChildIndex) {
val block = blocks[newChildIndex]
return ChildAttributes(block.indent, block.alignment)
}
ChildAttributes(Indent.getNoneIndent(), null)
}
}
@@ -603,6 +603,42 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
)
}
fun testIndentOnFinishedVariableEndAfterEquals() {
doCharTypeTest(
'\n',
"""
|fun test() {
| val a =<caret>
| foo()
|}
""",
"""
|fun test() {
| val a =
| <caret>
| foo()
|}
"""
)
}
fun testIndentNotFinishedVariableEndAfterEquals() {
doCharTypeTest(
'\n',
"""
|fun test() {
| val a =<caret>
|}
""",
"""
|fun test() {
| val a =
| <caret>
|}
"""
)
}
fun testMoveThroughGT() {
LightPlatformCodeInsightTestCase.configureFromFileText("a.kt", "val a: List<Set<Int<caret>>>")