KotlinLikeLangLineIndentProvider: support options for parentheses

Part of #KT-22211
Part of #KT-39353
This commit is contained in:
Dmitry Gridin
2020-06-08 19:39:35 +07:00
parent a8cb6b2ede
commit cf655a829c
120 changed files with 1566 additions and 19 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.idea.formatter
import com.intellij.formatting.*
import com.intellij.formatting.blocks.prev
import com.intellij.lang.ASTNode
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiComment
@@ -1038,7 +1039,7 @@ private val INDENT_RULES = arrayOf(
strategy("Closing parenthesis for conditions")
.forType(RPAR)
.forElement { node -> !hasErrorElementBefore(node) }
.forElement { node -> !hasErrorElementBefore(node) || node.prev()?.textLength == 0 }
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE, FOR, WHEN)
.set(Indent.getNoneIndent()),
@@ -15,6 +15,7 @@ import com.intellij.psi.impl.source.codeStyle.lineIndent.IndentCalculator
import com.intellij.psi.impl.source.codeStyle.lineIndent.JavaLikeLangLineIndentProvider
import com.intellij.psi.impl.source.codeStyle.lineIndent.JavaLikeLangLineIndentProvider.JavaLikeElement.*
import com.intellij.psi.tree.IElementType
import com.intellij.util.text.CharArrayUtil
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.formatter.lineIndent.KotlinLikeLangLineIndentProvider.KotlinElement.*
import org.jetbrains.kotlin.lexer.KtTokens
@@ -56,6 +57,7 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
override fun getIndent(project: Project, editor: Editor, language: Language?, offset: Int): IndentCalculator? {
val factory = IndentCalculatorFactory(project, editor)
val settings = indentionSettings(project)
val currentPosition = getPosition(editor, offset)
if (!currentPosition.matchesRule { it.isAt(Whitespace) && it.isAtMultiline }) return null
@@ -85,6 +87,11 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
after.moveBeforeParentheses(TemplateEntryOpen, TemplateEntryClose)
return factory.createIndentCalculator(indent, after.startOffset)
}
before.isAt(LeftParenthesis) && after.isAt(RightParenthesis) -> {
val indentCalculator = factory.createIndentCalculatorForParenthesis(before, currentPosition, after, offset, settings)
if (indentCalculator != null) return indentCalculator
}
}
return before.controlFlowStatementBefore()?.let { controlFlowKeywordPosition ->
@@ -99,6 +106,182 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
}
}
private fun IndentCalculatorFactory.createIndentCalculatorForParenthesis(
leftParenthesis: SemanticEditorPosition,
currentPosition: SemanticEditorPosition,
rightParenthesis: SemanticEditorPosition,
offset: Int,
settings: KotlinIndentationAdjuster,
): IndentCalculator? {
assert(leftParenthesis.isAt(LeftParenthesis))
assert(rightParenthesis.isAt(RightParenthesis))
// case only for caret before [RightParenthesis]
if (!currentPosition.hasLineBreaksAfter(offset)) {
val indentForParentheses by lazy {
if (settings.alignWhenMultilineFunctionParentheses) createAlignMultilineIndent(leftParenthesis) else Indent.getNoneIndent()
}
val functionKeyword = findFunctionDeclarationBefore(leftParenthesis)
if (functionKeyword != null) {
return createIndentCalculator(indentForParentheses, functionKeyword.startOffset)
}
// NB: this covered [KtTokens.CONSTRUCTOR_KEYWORD], [KtTokens.SET_KEYWORD], [KtTokens.GET_KEYWORD], [KtTokens.INIT_KEYWORD] as well
if (isSimilarToFunctionInvocation(leftParenthesis)) {
return createIndentCalculator(indentForParentheses, leftParenthesis.startOffset)
}
if (isDestructuringDeclaration(leftParenthesis, rightParenthesis)) {
return createIndentCalculator(Indent.getNoneIndent(), leftParenthesis.startOffset)
}
leftParenthesis.copyAnd { it.moveBeforeIgnoringWhiteSpaceOrComment() }.let { keyword ->
if (keyword.isControlFlowKeyword()) {
return createIndentCalculator(Indent.getNoneIndent(), keyword.startOffset)
}
}
val indentForBinaryExpression = if (settings.alignWhenMultilineBinaryExpression)
createAlignMultilineIndent(leftParenthesis)
else
Indent.getContinuationIndent()
return createIndentCalculator(indentForBinaryExpression, leftParenthesis.startOffset)
}
return null
}
/**
* @return position of `fun` keyword before the declaration or null
* TODO: support [KtTokens.CONSTRUCTOR_KEYWORD], [KtTokens.INIT_KEYWORD]. Maybe [KtTokens.SET_KEYWORD], [KtTokens.GET_KEYWORD] (related to KT-39444)
*/
private fun findFunctionDeclarationBefore(leftParenthesis: SemanticEditorPosition): SemanticEditorPosition? =
with(leftParenthesis.copy()) {
assert(leftParenthesis.isAt(LeftParenthesis))
moveBeforeIgnoringWhiteSpaceOrComment()
// anonymous function `val a = fun() { }`
if (isAt(FunctionKeyword)) return this
moveBeforeWhileThisIsWhiteSpaceOrComment()
// anonymous function with receiver `val a = fun String.Companion????.() { }`
if (isAt(Dot)) {
moveBeforeIgnoringWhiteSpaceOrComment()
if (!moveBeforeTypeQualifierIfPossible()) return null
return if (isAt(FunctionKeyword)) this else null
}
// name of declaration
if (!isAt(Identifier)) return null
if (!moveBeforeTypeQualifierIfPossible()) return null
moveBeforeTypeParametersIfPossible()
takeIf { it.isAt(FunctionKeyword) }
}
private fun isSimilarToFunctionInvocation(leftParenthesis: SemanticEditorPosition): Boolean = with(leftParenthesis.copy()) {
assert(isAt(LeftParenthesis))
moveBeforeIgnoringWhiteSpaceOrComment()
// calls with types e.g. `test<Int>()`
moveBeforeTypeParametersIfPossible()
return isAt(Identifier) || isAt(KtTokens.THIS_KEYWORD)
}
private fun isDestructuringDeclaration(
leftParenthesis: SemanticEditorPosition,
rightParenthesis: SemanticEditorPosition
): Boolean = with(leftParenthesis.copy()) {
moveBeforeIgnoringWhiteSpaceOrComment()
// val (a, b) = 1 to 2
if (isAt(KtTokens.VAR_KEYWORD) || isAt(KtTokens.VAL_KEYWORD)) {
return true
}
// in lambda like `val a = { i: Int -> println(i) }`
if (!rightParenthesis.moveBeforeParametersIfPossible()) return false
return isAt(BlockOpeningBrace)
}
/**
* @receiver start position of any parameter
*/
private fun SemanticEditorPosition.moveBeforeParametersIfPossible(): Boolean {
while (!isAtEnd) {
if (!moveBeforeParameterIfPossible()) return false
if (!isAt(Comma)) return true
moveBeforeIgnoringWhiteSpaceOrComment()
}
return false
}
/**
* @receiver start position of any parameter
*/
private fun SemanticEditorPosition.moveBeforeParameterIfPossible(): Boolean {
// destructuring declaration in lambda parameters without type
// { a, (b, c), d ->
// ^
if (isAt(RightParenthesis)) return moveBeforeParenthesesIfPossible()
if (!moveBeforeTypeQualifierIfPossible()) return false
// optional colon
// { a: Int ->
// ^
// (a: Int)
// ^
if (isAt(Colon)) {
moveBeforeIgnoringWhiteSpaceOrComment()
// destructuring declaration in lambda parameters with type
// { a, b, (c, d): Pair<Long, Long>, e ->
// ^
if (isAt(RightParenthesis)) return moveBeforeParenthesesIfPossible()
// { a: Int ->
// ^
// (a: Int)
// ^
if (!isAt(Identifier)) return false
moveBeforeIgnoringWhiteSpaceOrComment()
}
return true
}
/***
* Constructions like `OuterClass/* */.MiddleClass<String>?????`, `String.Companion.testName`
*
* @receiver position of identifier
*/
private fun SemanticEditorPosition.moveBeforeTypeQualifierIfPossible(): Boolean {
while (!isAtEnd) {
moveBeforeOptionalMix(Quest, *WHITE_SPACE_OR_COMMENT_BIT_SET)
moveBeforeTypeParametersIfPossible()
if (!isAt(Identifier)) return false
moveBeforeIgnoringWhiteSpaceOrComment()
if (!isAt(Dot)) return true
moveBeforeIgnoringWhiteSpaceOrComment()
}
return false
}
private fun createAlignMultilineIndent(position: SemanticEditorPosition): Indent {
val beforeLineStart = CharArrayUtil.shiftBackwardUntil(position.chars, position.startOffset, "\n") + 1
val beforeLineWithoutIndentStart = CharArrayUtil.shiftForward(position.chars, beforeLineStart, " \t")
return Indent.getSpaceIndent(position.startOffset - beforeLineWithoutIndentStart)
}
private fun SemanticEditorPosition.isWhileInsideDoWhile(): Boolean {
if (!isAt(WhileKeyword)) return false
with(copy()) {
@@ -139,7 +322,7 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
private fun SemanticEditorPosition.isCatchKeyword(): Boolean = with(copy()) {
// try-catch-*-catch
do {
if (!isAt(KtTokens.IDENTIFIER)) return false
if (!isAt(Identifier)) return false
if (!similarToCatchKeyword()) return false
moveBeforeIgnoringWhiteSpaceOrComment()
@@ -154,7 +337,7 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
}
private fun SemanticEditorPosition.isFinallyKeyword(): Boolean {
if (!isAt(KtTokens.IDENTIFIER)) return false
if (!isAt(Identifier)) return false
if (textOfCurrentPosition() != KtTokens.FINALLY_KEYWORD.value) return false
with(copy()) {
moveBeforeIgnoringWhiteSpaceOrComment()
@@ -172,12 +355,17 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
private fun SemanticEditorPosition.moveBeforeBlockIfPossible(): Boolean = moveBeforeParenthesesIfPossible(
leftParenthesis = BlockOpeningBrace,
rightParenthesis = BlockClosingBrace
rightParenthesis = BlockClosingBrace,
)
private fun SemanticEditorPosition.moveBeforeTypeParametersIfPossible(): Boolean = moveBeforeParenthesesIfPossible(
leftParenthesis = OpenTypeBrace,
rightParenthesis = CloseTypeBrace,
)
private fun SemanticEditorPosition.moveBeforeParenthesesIfPossible(): Boolean = moveBeforeParenthesesIfPossible(
leftParenthesis = LeftParenthesis,
rightParenthesis = RightParenthesis
rightParenthesis = RightParenthesis,
)
private fun SemanticEditorPosition.moveBeforeParenthesesIfPossible(
@@ -187,15 +375,15 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
if (!isAt(rightParenthesis)) return false
moveBeforeParentheses(leftParenthesis, rightParenthesis)
moveBeforeIfThisIsWhiteSpaceOrComment()
moveBeforeWhileThisIsWhiteSpaceOrComment()
return true
}
private fun SemanticEditorPosition.moveBeforeIfThisIsWhiteSpaceOrComment() = moveBeforeOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET)
private fun SemanticEditorPosition.moveBeforeWhileThisIsWhiteSpaceOrComment() = moveBeforeOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET)
private fun SemanticEditorPosition.moveBeforeIgnoringWhiteSpaceOrComment() {
moveBefore()
moveBeforeIfThisIsWhiteSpaceOrComment()
moveBeforeWhileThisIsWhiteSpaceOrComment()
}
private enum class KotlinElement : SemanticEditorPosition.SyntaxElement {
@@ -206,6 +394,12 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
WhileKeyword,
RegularStringPart,
KDoc,
Identifier,
OpenTypeBrace,
CloseTypeBrace,
FunctionKeyword,
Dot,
Quest,
}
companion object {
@@ -231,6 +425,14 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
KtTokens.REGULAR_STRING_PART to RegularStringPart,
KtTokens.LBRACKET to ArrayOpeningBracket,
KtTokens.RBRACKET to ArrayClosingBracket,
KtTokens.IDENTIFIER to Identifier,
KtTokens.LT to OpenTypeBrace,
KtTokens.GT to CloseTypeBrace,
KtTokens.FUN_KEYWORD to FunctionKeyword,
KtTokens.DOT to Dot,
KtTokens.QUEST to Quest,
KtTokens.COMMA to Comma,
KtTokens.COLON to Colon,
)
private val CONTROL_FLOW_KEYWORDS: HashSet<SemanticEditorPosition.SyntaxElement> = hashSetOf(
@@ -252,9 +454,10 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
}
private fun JavaLikeLangLineIndentProvider.IndentCalculatorFactory.createIndentCalculator(
indent: Indent?,
baseLineOffset: Int
): IndentCalculator? = createIndentCalculator(indent) { baseLineOffset }
indent: Indent,
baseLineOffset: Int,
): IndentCalculator =
createIndentCalculator(indent) { baseLineOffset } ?: error("Contract (null, _ -> null) is broken")
private fun SemanticEditorPosition.textOfCurrentPosition(): String =
if (isAtEnd) "" else chars.subSequence(startOffset, after().startOffset).toString()
@@ -208,11 +208,271 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
runTest("idea/testData/indentationOnNewline/ElseWithoutBrace2.kt");
}
@TestMetadata("EmptyArgumentInCallByReference.kt")
public void testEmptyArgumentInCallByReference() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReference.kt");
}
@TestMetadata("EmptyArgumentInCallByReference2.kt")
public void testEmptyArgumentInCallByReference2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReference2.kt");
}
@TestMetadata("EmptyArgumentInCallByReferenceInSuperType.kt")
public void testEmptyArgumentInCallByReferenceInSuperType() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReferenceInSuperType.kt");
}
@TestMetadata("EmptyArgumentInCallByReferenceInSuperType2.kt")
public void testEmptyArgumentInCallByReferenceInSuperType2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReferenceInSuperType2.kt");
}
@TestMetadata("EmptyArgumentInCallByReferenceInSuperTypeWithTypeArguments.kt")
public void testEmptyArgumentInCallByReferenceInSuperTypeWithTypeArguments() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReferenceInSuperTypeWithTypeArguments.kt");
}
@TestMetadata("EmptyArgumentInCallByReferenceInSuperTypeWithTypeArguments2.kt")
public void testEmptyArgumentInCallByReferenceInSuperTypeWithTypeArguments2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReferenceInSuperTypeWithTypeArguments2.kt");
}
@TestMetadata("EmptyArgumentInCallByReferenceWithTypeArguments.kt")
public void testEmptyArgumentInCallByReferenceWithTypeArguments() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReferenceWithTypeArguments.kt");
}
@TestMetadata("EmptyArgumentInCallByReferenceWithTypeArguments2.kt")
public void testEmptyArgumentInCallByReferenceWithTypeArguments2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInCallByReferenceWithTypeArguments2.kt");
}
@TestMetadata("EmptyArgumentInThisAsClassicFunction.kt")
public void testEmptyArgumentInThisAsClassicFunction() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInThisAsClassicFunction.kt");
}
@TestMetadata("EmptyArgumentInThisAsConstructor.kt")
public void testEmptyArgumentInThisAsConstructor() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInThisAsConstructor.kt");
}
@TestMetadata("EmptyArgumentInThisAsConstructor2.kt")
public void testEmptyArgumentInThisAsConstructor2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyArgumentInThisAsConstructor2.kt");
}
@TestMetadata("EmptyConditionInCatch.kt")
public void testEmptyConditionInCatch() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyConditionInCatch.kt");
}
@TestMetadata("EmptyConditionInCatch2.kt")
public void testEmptyConditionInCatch2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyConditionInCatch2.kt");
}
@TestMetadata("EmptyConditionInDoWhile.kt")
public void testEmptyConditionInDoWhile() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyConditionInDoWhile.kt");
}
@TestMetadata("EmptyConditionInFor.kt")
public void testEmptyConditionInFor() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyConditionInFor.kt");
}
@TestMetadata("EmptyConditionInIf.kt")
public void testEmptyConditionInIf() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyConditionInIf.kt");
}
@TestMetadata("EmptyConditionInWhen.kt")
public void testEmptyConditionInWhen() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyConditionInWhen.kt");
}
@TestMetadata("EmptyConditionInWhile.kt")
public void testEmptyConditionInWhile() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyConditionInWhile.kt");
}
@TestMetadata("EmptyParameterInAnnonymousFunction.kt")
public void testEmptyParameterInAnnonymousFunction() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInAnnonymousFunction.kt");
}
@TestMetadata("EmptyParameterInAnnonymousFunction2.kt")
public void testEmptyParameterInAnnonymousFunction2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInAnnonymousFunction2.kt");
}
@TestMetadata("EmptyParameterInAnnonymousFunctionWithNullableReceiver.kt")
public void testEmptyParameterInAnnonymousFunctionWithNullableReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInAnnonymousFunctionWithNullableReceiver.kt");
}
@TestMetadata("EmptyParameterInAnnonymousFunctionWithNullableReceiver2.kt")
public void testEmptyParameterInAnnonymousFunctionWithNullableReceiver2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInAnnonymousFunctionWithNullableReceiver2.kt");
}
@TestMetadata("EmptyParameterInAnnonymousFunctionWithReceiver.kt")
public void testEmptyParameterInAnnonymousFunctionWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInAnnonymousFunctionWithReceiver.kt");
}
@TestMetadata("EmptyParameterInAnnonymousFunctionWithReceiver2.kt")
public void testEmptyParameterInAnnonymousFunctionWithReceiver2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInAnnonymousFunctionWithReceiver2.kt");
}
@TestMetadata("EmptyParameterInDestructuringDeclaration.kt")
public void testEmptyParameterInDestructuringDeclaration() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInDestructuringDeclaration.kt");
}
@TestMetadata("EmptyParameterInDestructuringDeclaration2.kt")
public void testEmptyParameterInDestructuringDeclaration2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInDestructuringDeclaration2.kt");
}
@TestMetadata("EmptyParameterInDestructuringDeclaration3.kt")
public void testEmptyParameterInDestructuringDeclaration3() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInDestructuringDeclaration3.kt");
}
@TestMetadata("EmptyParameterInExplicitPrimaryConstructor.kt")
public void testEmptyParameterInExplicitPrimaryConstructor() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInExplicitPrimaryConstructor.kt");
}
@TestMetadata("EmptyParameterInExplicitPrimaryConstructor2.kt")
public void testEmptyParameterInExplicitPrimaryConstructor2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInExplicitPrimaryConstructor2.kt");
}
@TestMetadata("EmptyParameterInFunction.kt")
public void testEmptyParameterInFunction() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunction.kt");
}
@TestMetadata("EmptyParameterInFunction2.kt")
public void testEmptyParameterInFunction2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunction2.kt");
}
@TestMetadata("EmptyParameterInFunctionWithReceiver.kt")
public void testEmptyParameterInFunctionWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithReceiver.kt");
}
@TestMetadata("EmptyParameterInFunctionWithReceiver2.kt")
public void testEmptyParameterInFunctionWithReceiver2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithReceiver2.kt");
}
@TestMetadata("EmptyParameterInFunctionWithTypeParameters.kt")
public void testEmptyParameterInFunctionWithTypeParameters() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithTypeParameters.kt");
}
@TestMetadata("EmptyParameterInFunctionWithTypeParameters2.kt")
public void testEmptyParameterInFunctionWithTypeParameters2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithTypeParameters2.kt");
}
@TestMetadata("EmptyParameterInFunctionWithTypeParametersAndReceiver.kt")
public void testEmptyParameterInFunctionWithTypeParametersAndReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithTypeParametersAndReceiver.kt");
}
@TestMetadata("EmptyParameterInFunctionWithTypeParametersAndReceiver2.kt")
public void testEmptyParameterInFunctionWithTypeParametersAndReceiver2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithTypeParametersAndReceiver2.kt");
}
@TestMetadata("EmptyParameterInFunctionWithTypeParametersAndReceiver3.kt")
public void testEmptyParameterInFunctionWithTypeParametersAndReceiver3() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithTypeParametersAndReceiver3.kt");
}
@TestMetadata("EmptyParameterInFunctionWithTypeParametersAndReceiver4.kt")
public void testEmptyParameterInFunctionWithTypeParametersAndReceiver4() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInFunctionWithTypeParametersAndReceiver4.kt");
}
@TestMetadata("EmptyParameterInGetter.kt")
public void testEmptyParameterInGetter() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInGetter.kt");
}
@TestMetadata("EmptyParameterInGetter2.kt")
public void testEmptyParameterInGetter2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInGetter2.kt");
}
@TestMetadata("EmptyParameterInImplicitPrimaryConstructor.kt")
public void testEmptyParameterInImplicitPrimaryConstructor() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInImplicitPrimaryConstructor.kt");
}
@TestMetadata("EmptyParameterInImplicitPrimaryConstructor2.kt")
public void testEmptyParameterInImplicitPrimaryConstructor2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInImplicitPrimaryConstructor2.kt");
}
@TestMetadata("EmptyParameterInImplicitPrimaryConstructorWithTypeParameters.kt")
public void testEmptyParameterInImplicitPrimaryConstructorWithTypeParameters() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInImplicitPrimaryConstructorWithTypeParameters.kt");
}
@TestMetadata("EmptyParameterInImplicitPrimaryConstructorWithTypeParameters2.kt")
public void testEmptyParameterInImplicitPrimaryConstructorWithTypeParameters2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInImplicitPrimaryConstructorWithTypeParameters2.kt");
}
@TestMetadata("EmptyParameterInInnerAnnonymousFunction.kt")
public void testEmptyParameterInInnerAnnonymousFunction() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInInnerAnnonymousFunction.kt");
}
@TestMetadata("EmptyParameterInInnerAnnonymousFunction2.kt")
public void testEmptyParameterInInnerAnnonymousFunction2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInInnerAnnonymousFunction2.kt");
}
@TestMetadata("EmptyParameterInSecondaryConstructor.kt")
public void testEmptyParameterInSecondaryConstructor() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInSecondaryConstructor.kt");
}
@TestMetadata("EmptyParameterInSecondaryConstructor2.kt")
public void testEmptyParameterInSecondaryConstructor2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInSecondaryConstructor2.kt");
}
@TestMetadata("EmptyParameterInSetter.kt")
public void testEmptyParameterInSetter() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInSetter.kt");
}
@TestMetadata("EmptyParameterInSetter2.kt")
public void testEmptyParameterInSetter2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameterInSetter2.kt");
}
@TestMetadata("EmptyParameters.kt")
public void testEmptyParameters() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameters.kt");
}
@TestMetadata("EmptyParameters2.kt")
public void testEmptyParameters2() throws Exception {
runTest("idea/testData/indentationOnNewline/EmptyParameters2.kt");
}
@TestMetadata("Finally.kt")
public void testFinally() throws Exception {
runTest("idea/testData/indentationOnNewline/Finally.kt");
@@ -4,5 +4,4 @@ fun test(i: Int) {
)
}
// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS
@@ -4,5 +4,4 @@ fun test(i: Int) {
)
}
// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS
@@ -2,5 +2,4 @@ fun test(i: Int) {
test(<caret>)
}
// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS
@@ -0,0 +1,7 @@
fun a() {
a(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
a(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,9 @@
fun a() {
a(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
fun a() {
a(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
open class A
class B : A(
<caret>
)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
open class A
class B : A(<caret>)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,9 @@
open class A
class B : A(
<caret>
)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
open class A
class B : A(<caret>)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
open class A<T, C, D<T>>
class B : A<Int, Long, List<Int>>(
<caret>
)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
open class A<T, C, D<T>>
class B : A<Int, Long, List<Int>>(<caret>)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,9 @@
open class A<T, C, D<T>>
class B : A<Int, Long, List<Int>>(
<caret>
)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
open class A<T, C, D<T>>
class B : A<Int, Long, List<Int>>(<caret>)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
fun <T, V> test() {
test<Int, Long>(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun <T, V> test() {
test<Int, Long>(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,9 @@
fun <T, V> test() {
test<Int, Long>(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
fun <T, V> test() {
test<Int, Long>(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,9 @@
class A {
operator fun invoke() = Unit
fun a() {
this(<caret>)
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
class A(a: Int) {
constructor() : this(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
class A(a: Int) {
constructor() : this(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,9 @@
class A(a: Int) {
constructor() : this(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
class A(a: Int) {
constructor() : this(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,9 @@
fun a() {
try {
} catch(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
try {
} catch(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,11 @@
fun a() {
try {
} catch(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,9 @@
fun a() {
try {
} catch(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
fun a() {
do println() while (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
do println() while (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
do println() while (<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
for (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
for (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
for (<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
if (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
if (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
if (<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
when (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
when (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
when (<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
while (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
while (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
while (<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,8 @@
class Test {
val a = fun(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,6 @@
class Test {
val a = fun(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,10 @@
class Test {
val a = fun(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class Test {
val a = fun(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class Test {
val a = fun String.Companion????.(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,6 @@
class Test {
val a = fun String.Companion????.(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,10 @@
class Test {
val a = fun String.Companion????.(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class Test {
val a = fun String.Companion????.(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class Test {
val a = fun String.Companion.(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,6 @@
class Test {
val a = fun String.Companion.(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,10 @@
class Test {
val a = fun String.Companion.(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class Test {
val a = fun String.Companion.(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
fun a() {
val (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
val (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
val (<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
var (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
var (
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
var (<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
a.forEach { (
<caret>
)}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a() {
a.forEach { (
<caret>
)}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
fun a() {
a.forEach { (<caret>)}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
class A private constructor(
<caret>
)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,3 @@
class A private constructor(<caret>)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
class A private constructor(
<caret>
)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,5 @@
class A private constructor(<caret>)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun testParam(
<caret>
) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,6 @@
class A {
fun testParam(<caret>) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,10 @@
class A {
fun testParam(
<caret>
) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun testParam(<caret>) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun String.Companion.testParam(
<caret>
) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,6 @@
class A {
fun String.Companion.testParam(<caret>) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,10 @@
class A {
fun String.Companion.testParam(
<caret>
) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun String.Companion.testParam(<caret>) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun <T, V> testParam(
<caret>
) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,6 @@
class A {
fun <T, V> testParam(<caret>) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,10 @@
class A {
fun <T, V> testParam(
<caret>
) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun <T, V> testParam(<caret>) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun <T, V> Int.Companion.testParam(
<caret>
) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,6 @@
class A {
fun <T, V> Int.Companion.testParam(<caret>) {
}
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
class A {
fun <T> List<T>?.testFunction(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,5 @@
class A {
fun <T> List<T>?.testFunction(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,10 @@
class A {
fun <T, V> Int.Companion.testParam(
<caret>
) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class A {
fun <T, V> Int.Companion.testParam(<caret>) {
}
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,9 @@
class A {
fun <T> List<T>?.testFunction(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,7 @@
class A {
fun <T> List<T>?.testFunction(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,8 @@
class Test {
val a: Boolean get(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
// KT-39444
@@ -0,0 +1,6 @@
class Test {
val a: Boolean get(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
// KT-39444
@@ -0,0 +1,9 @@
class Test {
val a: Boolean get(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39444
@@ -0,0 +1,7 @@
class Test {
val a: Boolean get(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39444
@@ -0,0 +1,5 @@
class A(
<caret>
)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,3 @@
class A(<caret>)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
class A(
<caret>
)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,5 @@
class A(<caret>)
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
// KT-39459
@@ -0,0 +1,5 @@
class A<T, V>(
<caret>
)
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS

Some files were not shown because too many files have changed in this diff Show More