Auto-indent elvis operator on new line (KT-28371)
#KT-28371 Fixed
This commit is contained in:
@@ -44,10 +44,7 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtQualifiedExpression;
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameStringTemplateEntry;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
|
||||
public class KotlinTypedHandler extends TypedHandlerDelegate {
|
||||
private final static TokenSet CONTROL_FLOW_EXPRESSIONS = TokenSet.create(
|
||||
@@ -242,7 +239,8 @@ public class KotlinTypedHandler extends TypedHandlerDelegate {
|
||||
}
|
||||
}
|
||||
else if (c == ':') {
|
||||
if (autoIndentCase(editor, project, file, KtClassOrObject.class)) {
|
||||
if (autoIndentCase(editor, project, file, KtClassOrObject.class) ||
|
||||
autoIndentCase(editor, project, file, KtOperationReferenceExpression.class)) {
|
||||
return Result.STOP;
|
||||
}
|
||||
}
|
||||
@@ -252,6 +250,7 @@ public class KotlinTypedHandler extends TypedHandlerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Result.CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -584,6 +584,26 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
|
||||
""")
|
||||
}
|
||||
|
||||
fun testContinueWithElvis() {
|
||||
doCharTypeTest(
|
||||
':',
|
||||
"""
|
||||
|fun test(): Any? = null
|
||||
|fun some() {
|
||||
| test()
|
||||
| ?<caret>
|
||||
|}
|
||||
""",
|
||||
"""
|
||||
|fun test(): Any? = null
|
||||
|fun some() {
|
||||
| test()
|
||||
| ?:<caret>
|
||||
|}
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
fun testSpaceAroundRange() {
|
||||
doCharTypeTest(
|
||||
'.',
|
||||
|
||||
Reference in New Issue
Block a user