LineIndentProvider: support declarations with body expression

Part of #KT-22211
This commit is contained in:
Dmitry Gridin
2020-06-09 21:42:56 +07:00
parent 145b2c260b
commit 447549f20d
67 changed files with 611 additions and 93 deletions
@@ -17,4 +17,8 @@ interface KotlinIndentationAdjuster {
// CONTINUATION_INDENT_IN_ELVIS
val continuationIndentInElvis: Boolean
get() = false
// CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
val continuationIndentForExpressionBodies: Boolean
get() = false
}
@@ -98,12 +98,28 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
return factory.createIndentCalculator(indent, after.startOffset)
}
before.isAt(Eq) -> {
val declaration = findFunctionOrPropertyDeclarationBefore(before.copyAnd { it.moveBeforeIgnoringWhiteSpaceOrComment() })
if (declaration != null) {
val indent = if (settings.continuationIndentForExpressionBodies)
Indent.getContinuationIndent()
else
Indent.getNormalIndent()
return factory.createIndentCalculator(indent, declaration.startOffset)
}
}
before.isAt(LeftParenthesis) && after.isAt(RightParenthesis) -> {
val indentCalculator = factory.createIndentCalculatorForParenthesis(before, currentPosition, after, offset, settings)
if (indentCalculator != null) return indentCalculator
}
}
findFunctionOrPropertyDeclarationBefore(before)?.let {
return factory.createIndentCalculator(Indent.getNoneIndent(), it.startOffset)
}
return before.controlFlowStatementBefore()?.let { controlFlowKeywordPosition ->
val indent = when {
controlFlowKeywordPosition.similarToCatchKeyword() -> if (before.isAt(RightParenthesis)) Indent.getNoneIndent() else Indent.getNormalIndent()
@@ -132,9 +148,8 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
if (settings.alignWhenMultilineFunctionParentheses) createAlignMultilineIndent(leftParenthesis) else Indent.getNoneIndent()
}
val functionKeyword = findFunctionDeclarationBefore(leftParenthesis)
if (functionKeyword != null) {
return createIndentCalculator(indentForParentheses, functionKeyword.startOffset)
findFunctionKeywordBeforeIdentifier(leftParenthesis.copyAnd { it.moveBeforeIgnoringWhiteSpaceOrComment() })?.let {
return createIndentCalculator(indentForParentheses, it.startOffset)
}
// NB: this covered [KtTokens.CONSTRUCTOR_KEYWORD], [KtTokens.SET_KEYWORD], [KtTokens.GET_KEYWORD], [KtTokens.INIT_KEYWORD] as well
@@ -163,35 +178,74 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
return null
}
/**
* @param declarationPosition is position before '=' for expression body or '{'
*/
private fun findFunctionOrPropertyDeclarationBefore(declarationPosition: SemanticEditorPosition): SemanticEditorPosition? {
// `val a = 5`
// this is false positive for declaration with explicit return type
if (declarationPosition.isAt(Identifier)) {
findPropertyKeywordBeforeIdentifier(declarationPosition)?.let { return it }
}
return with(declarationPosition.copy()) {
// explicit type `fun a(): String` or `val a: String`
if (moveBeforeTypeQualifierIfPossible(true)) {
if (!isAt(Colon)) return null
moveBeforeIgnoringWhiteSpaceOrComment()
}
if (isAt(RightParenthesis)) {
if (!moveBeforeParenthesesIfPossible()) return null
// destructuring declaration `val (a, b)`
if (isVarOrVal())
this
else
findFunctionKeywordBeforeIdentifier(this)
} else {
findPropertyKeywordBeforeIdentifier(this)
}
}
}
private fun findPropertyKeywordBeforeIdentifier(identifierPosition: SemanticEditorPosition): SemanticEditorPosition? {
if (!identifierPosition.isAt(Identifier)) return null
return with(identifierPosition.copy()) {
if (!moveBeforeTypeQualifierIfPossible(false)) return null
// `val <T> List<T>.prop`
moveBeforeTypeParametersIfPossible()
takeIf { it.isVarOrVal() }
}
}
/**
* @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))
private fun findFunctionKeywordBeforeIdentifier(identifierPosition: SemanticEditorPosition): SemanticEditorPosition? {
// anonymous function `val a = fun() { }`
if (identifierPosition.isAt(FunctionKeyword)) return identifierPosition
moveBeforeIgnoringWhiteSpaceOrComment()
// anonymous function `val a = fun() { }`
if (isAt(FunctionKeyword)) return this
return with(identifierPosition.copy()) {
moveBeforeWhileThisIsWhiteSpaceOrComment()
// anonymous function with receiver `val a = fun String.Companion????.() { }`
if (isAt(Dot)) {
moveBeforeIgnoringWhiteSpaceOrComment()
if (!moveBeforeTypeQualifierIfPossible()) return null
if (!moveBeforeTypeQualifierIfPossible(true)) return null
return if (isAt(FunctionKeyword)) this else null
}
// name of declaration
if (!isAt(Identifier)) return null
if (!moveBeforeTypeQualifierIfPossible()) return null
if (!moveBeforeTypeQualifierIfPossible(false)) return null
moveBeforeTypeParametersIfPossible()
takeIf { it.isAt(FunctionKeyword) }
}
}
private fun isSimilarToFunctionInvocation(leftParenthesis: SemanticEditorPosition): Boolean = with(leftParenthesis.copy()) {
assert(isAt(LeftParenthesis))
@@ -210,9 +264,7 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
moveBeforeIgnoringWhiteSpaceOrComment()
// val (a, b) = 1 to 2
if (isAt(KtTokens.VAR_KEYWORD) || isAt(KtTokens.VAL_KEYWORD)) {
return true
}
if (isVarOrVal()) return true
// in lambda like `val a = { i: Int -> println(i) }`
if (!rightParenthesis.moveBeforeParametersIfPossible()) return false
@@ -242,7 +294,7 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
// ^
if (isAt(RightParenthesis)) return moveBeforeParenthesesIfPossible()
if (!moveBeforeTypeQualifierIfPossible()) return false
if (!moveBeforeTypeQualifierIfPossible(true)) return false
// optional colon
// { a: Int ->
@@ -273,7 +325,9 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
*
* @receiver position of identifier
*/
private fun SemanticEditorPosition.moveBeforeTypeQualifierIfPossible(): Boolean {
private fun SemanticEditorPosition.moveBeforeTypeQualifierIfPossible(canStartWithTypeParameter: Boolean): Boolean {
if (!canStartWithTypeParameter && !isAt(Identifier)) return false
while (!isAtEnd) {
moveBeforeOptionalMix(Quest, *WHITE_SPACE_OR_COMMENT_BIT_SET)
moveBeforeTypeParametersIfPossible()
@@ -363,6 +417,8 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
}
}
private fun SemanticEditorPosition.isVarOrVal(): Boolean = isAtAnyOf(Var, Val)
private fun SemanticEditorPosition.moveBeforeBlockIfPossible(): Boolean = moveBeforeParenthesesIfPossible(
leftParenthesis = BlockOpeningBrace,
rightParenthesis = BlockClosingBrace,
@@ -410,6 +466,10 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
FunctionKeyword,
Dot,
Quest,
Eq,
Val, Var,
}
companion object {
@@ -443,6 +503,11 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
KtTokens.QUEST to Quest,
KtTokens.COMMA to Comma,
KtTokens.COLON to Colon,
KtTokens.EQ to Eq,
KtTokens.VAL_KEYWORD to Val,
KtTokens.VAR_KEYWORD to Var,
)
private val CONTROL_FLOW_KEYWORDS: HashSet<SemanticEditorPosition.SyntaxElement> = hashSetOf(
@@ -88,11 +88,6 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
runTest("idea/testData/indentationOnNewline/FunctionBlock.kt");
}
@TestMetadata("FunctionWithInference.kt")
public void testFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/FunctionWithInference.kt");
}
@TestMetadata("InDelegationListAfterColon.kt")
public void testInDelegationListAfterColon() throws Exception {
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.kt");
@@ -178,26 +173,11 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
runTest("idea/testData/indentationOnNewline/ModifierListInUnfinishedDeclaration.kt");
}
@TestMetadata("MultideclarationAfterEq.kt")
public void testMultideclarationAfterEq() throws Exception {
runTest("idea/testData/indentationOnNewline/MultideclarationAfterEq.kt");
}
@TestMetadata("MultideclarationBeforeEq.kt")
public void testMultideclarationBeforeEq() throws Exception {
runTest("idea/testData/indentationOnNewline/MultideclarationBeforeEq.kt");
}
@TestMetadata("NotFirstParameter.kt")
public void testNotFirstParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/NotFirstParameter.kt");
}
@TestMetadata("PropertyWithInference.kt")
public void testPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/PropertyWithInference.kt");
}
@TestMetadata("ReturnContinue.kt")
public void testReturnContinue() throws Exception {
runTest("idea/testData/indentationOnNewline/ReturnContinue.kt");
@@ -865,6 +845,109 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
}
}
@TestMetadata("idea/testData/indentationOnNewline/expressionBody")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ExpressionBody extends AbstractPerformanceTypingIndentationTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doPerfTest, this, testDataFilePath);
}
@TestMetadata("AfterFunctionWithExplicitType.kt")
public void testAfterFunctionWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithExplicitType.kt");
}
@TestMetadata("AfterFunctionWithInference.kt")
public void testAfterFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithInference.kt");
}
@TestMetadata("AfterFunctionWithTypeParameter.kt")
public void testAfterFunctionWithTypeParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithTypeParameter.kt");
}
@TestMetadata("AfterMultideclaration.kt")
public void testAfterMultideclaration() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterMultideclaration.kt");
}
@TestMetadata("AfterMutableProperty.kt")
public void testAfterMutableProperty() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterMutableProperty.kt");
}
@TestMetadata("AfterPropertyWithExplicitType.kt")
public void testAfterPropertyWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithExplicitType.kt");
}
@TestMetadata("AfterPropertyWithInference.kt")
public void testAfterPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithInference.kt");
}
@TestMetadata("AfterPropertyWithReceiver.kt")
public void testAfterPropertyWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithReceiver.kt");
}
@TestMetadata("AfterPropertyWithTypeParameterReceiver.kt")
public void testAfterPropertyWithTypeParameterReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithTypeParameterReceiver.kt");
}
public void testAllFilesPresentInExpressionBody() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/expressionBody"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true);
}
@TestMetadata("FunctionWithExplicitType.kt")
public void testFunctionWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithExplicitType.kt");
}
@TestMetadata("FunctionWithInference.kt")
public void testFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithInference.kt");
}
@TestMetadata("FunctionWithTypeParameter.kt")
public void testFunctionWithTypeParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithTypeParameter.kt");
}
@TestMetadata("Multideclaration.kt")
public void testMultideclaration() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/Multideclaration.kt");
}
@TestMetadata("MutableProperty.kt")
public void testMutableProperty() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/MutableProperty.kt");
}
@TestMetadata("PropertyWithExplicitType.kt")
public void testPropertyWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithExplicitType.kt");
}
@TestMetadata("PropertyWithInference.kt")
public void testPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithInference.kt");
}
@TestMetadata("PropertyWithReceiver.kt")
public void testPropertyWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithReceiver.kt");
}
@TestMetadata("PropertyWithTypeParameterReceiver.kt")
public void testPropertyWithTypeParameterReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithTypeParameterReceiver.kt");
}
}
@TestMetadata("idea/testData/indentationOnNewline/script")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -31,6 +31,9 @@ class KotlinLineIndentProvider : KotlinLikeLangLineIndentProvider() {
override val continuationIndentInElvis: Boolean
get() = settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_ELVIS
override val continuationIndentForExpressionBodies: Boolean
get() = settings.kotlinCustomSettings.CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
}
companion object {
@@ -1,4 +0,0 @@
fun test() =
<caret>
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -1,3 +0,0 @@
fun test() =<caret>
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -1,6 +0,0 @@
fun test() {
val (a, b) =
<caret>
}
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -1,5 +0,0 @@
fun test() {
val (a, b) = <caret>
}
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -1,6 +0,0 @@
fun test() {
val (a, b)
<caret>
}
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -1,5 +0,0 @@
fun test() {
val (a, b) <caret>
}
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -1,4 +0,0 @@
val a =
<caret>
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -1,3 +0,0 @@
val a =<caret>
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
@@ -0,0 +1,4 @@
fun List<String>?.test(): String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun List<String>?.test(): String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
fun List<String>?.test(): String <caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun test()
<caret>
@@ -0,0 +1,4 @@
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun test()
<caret>
@@ -0,0 +1,3 @@
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun test() <caret>
@@ -0,0 +1,3 @@
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun <T> test(t: T): String
<caret>
@@ -0,0 +1,3 @@
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun <T> test(t: T): String
<caret>
@@ -0,0 +1,2 @@
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun <T> test(t: T): String<caret>
@@ -0,0 +1,6 @@
fun test() {
val (a, b)
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,6 @@
fun test() {
val (a, b)
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,5 @@
fun test() {
val (a, b) <caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,5 @@
fun a() {
var b
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,5 @@
fun a() {
var b
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun a() {
var b<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a: String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a: String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val a: String<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val a<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val List<String>.a: String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val List<String>.a: String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val List<String>.a: String<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val <T> List<T>.a: String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val <T> List<T>.a: String
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val <T> List<T>.a: String<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun List<String>?.test(): String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun List<String>?.test(): String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
fun List<String>?.test(): String =<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun test() =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun test() =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
fun test() =<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun <T> test(t: T): String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun <T> test(t: T): String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
fun <T> test(t: T): String =<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,6 @@
fun test() {
val (a, b) =
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,6 @@
fun test() {
val (a, b) =
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,5 @@
fun test() {
val (a, b) = <caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,5 @@
fun a() {
var b =
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,5 @@
fun a() {
var b =
<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
fun a() {
var b =<caret>
}
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a: String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a: String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val a: String =<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val a =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val a =<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val List<String>.a: String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val List<String>.a: String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val List<String>.a: String = <caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val <T> List<T>.a: String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,4 @@
val <T> List<T>.a: String =
<caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -0,0 +1,3 @@
val <T> List<T>.a: String = <caret>
// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
@@ -90,11 +90,6 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
runTest("idea/testData/indentationOnNewline/FunctionBlock.after.kt");
}
@TestMetadata("FunctionWithInference.after.kt")
public void testFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/FunctionWithInference.after.kt");
}
@TestMetadata("InDelegationListAfterColon.after.kt")
public void testInDelegationListAfterColon() throws Exception {
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.after.kt");
@@ -180,26 +175,11 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
runTest("idea/testData/indentationOnNewline/ModifierListInUnfinishedDeclaration.after.kt");
}
@TestMetadata("MultideclarationAfterEq.after.kt")
public void testMultideclarationAfterEq() throws Exception {
runTest("idea/testData/indentationOnNewline/MultideclarationAfterEq.after.kt");
}
@TestMetadata("MultideclarationBeforeEq.after.kt")
public void testMultideclarationBeforeEq() throws Exception {
runTest("idea/testData/indentationOnNewline/MultideclarationBeforeEq.after.kt");
}
@TestMetadata("NotFirstParameter.after.kt")
public void testNotFirstParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/NotFirstParameter.after.kt");
}
@TestMetadata("PropertyWithInference.after.kt")
public void testPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/PropertyWithInference.after.kt");
}
@TestMetadata("ReturnContinue.after.kt")
public void testReturnContinue() throws Exception {
runTest("idea/testData/indentationOnNewline/ReturnContinue.after.kt");
@@ -862,6 +842,109 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
}
}
@TestMetadata("idea/testData/indentationOnNewline/expressionBody")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ExpressionBody extends AbstractTypingIndentationTestBase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doNewlineTest, this, testDataFilePath);
}
@TestMetadata("AfterFunctionWithExplicitType.after.kt")
public void testAfterFunctionWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithExplicitType.after.kt");
}
@TestMetadata("AfterFunctionWithInference.after.kt")
public void testAfterFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithInference.after.kt");
}
@TestMetadata("AfterFunctionWithTypeParameter.after.kt")
public void testAfterFunctionWithTypeParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithTypeParameter.after.kt");
}
@TestMetadata("AfterMultideclaration.after.kt")
public void testAfterMultideclaration() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterMultideclaration.after.kt");
}
@TestMetadata("AfterMutableProperty.after.kt")
public void testAfterMutableProperty() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterMutableProperty.after.kt");
}
@TestMetadata("AfterPropertyWithExplicitType.after.kt")
public void testAfterPropertyWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithExplicitType.after.kt");
}
@TestMetadata("AfterPropertyWithInference.after.kt")
public void testAfterPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithInference.after.kt");
}
@TestMetadata("AfterPropertyWithReceiver.after.kt")
public void testAfterPropertyWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithReceiver.after.kt");
}
@TestMetadata("AfterPropertyWithTypeParameterReceiver.after.kt")
public void testAfterPropertyWithTypeParameterReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithTypeParameterReceiver.after.kt");
}
public void testAllFilesPresentInExpressionBody() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/expressionBody"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), null, true);
}
@TestMetadata("FunctionWithExplicitType.after.kt")
public void testFunctionWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithExplicitType.after.kt");
}
@TestMetadata("FunctionWithInference.after.kt")
public void testFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithInference.after.kt");
}
@TestMetadata("FunctionWithTypeParameter.after.kt")
public void testFunctionWithTypeParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithTypeParameter.after.kt");
}
@TestMetadata("Multideclaration.after.kt")
public void testMultideclaration() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/Multideclaration.after.kt");
}
@TestMetadata("MutableProperty.after.kt")
public void testMutableProperty() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/MutableProperty.after.kt");
}
@TestMetadata("PropertyWithExplicitType.after.kt")
public void testPropertyWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithExplicitType.after.kt");
}
@TestMetadata("PropertyWithInference.after.kt")
public void testPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithInference.after.kt");
}
@TestMetadata("PropertyWithReceiver.after.kt")
public void testPropertyWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithReceiver.after.kt");
}
@TestMetadata("PropertyWithTypeParameterReceiver.after.kt")
public void testPropertyWithTypeParameterReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithTypeParameterReceiver.after.kt");
}
}
@TestMetadata("idea/testData/indentationOnNewline/script")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1243,6 +1326,109 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
}
}
@TestMetadata("idea/testData/indentationOnNewline/expressionBody")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ExpressionBody extends AbstractTypingIndentationTestBase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doNewlineTestWithInvert, this, testDataFilePath);
}
@TestMetadata("AfterFunctionWithExplicitType.after.inv.kt")
public void testAfterFunctionWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithExplicitType.after.inv.kt");
}
@TestMetadata("AfterFunctionWithInference.after.inv.kt")
public void testAfterFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithInference.after.inv.kt");
}
@TestMetadata("AfterFunctionWithTypeParameter.after.inv.kt")
public void testAfterFunctionWithTypeParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterFunctionWithTypeParameter.after.inv.kt");
}
@TestMetadata("AfterMultideclaration.after.inv.kt")
public void testAfterMultideclaration() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterMultideclaration.after.inv.kt");
}
@TestMetadata("AfterMutableProperty.after.inv.kt")
public void testAfterMutableProperty() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterMutableProperty.after.inv.kt");
}
@TestMetadata("AfterPropertyWithExplicitType.after.inv.kt")
public void testAfterPropertyWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithExplicitType.after.inv.kt");
}
@TestMetadata("AfterPropertyWithInference.after.inv.kt")
public void testAfterPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithInference.after.inv.kt");
}
@TestMetadata("AfterPropertyWithReceiver.after.inv.kt")
public void testAfterPropertyWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithReceiver.after.inv.kt");
}
@TestMetadata("AfterPropertyWithTypeParameterReceiver.after.inv.kt")
public void testAfterPropertyWithTypeParameterReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/AfterPropertyWithTypeParameterReceiver.after.inv.kt");
}
public void testAllFilesPresentInExpressionBody() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/expressionBody"), Pattern.compile("^([^\\.]+)\\.after\\.inv\\.kt.*$"), null, true);
}
@TestMetadata("FunctionWithExplicitType.after.inv.kt")
public void testFunctionWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithExplicitType.after.inv.kt");
}
@TestMetadata("FunctionWithInference.after.inv.kt")
public void testFunctionWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithInference.after.inv.kt");
}
@TestMetadata("FunctionWithTypeParameter.after.inv.kt")
public void testFunctionWithTypeParameter() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/FunctionWithTypeParameter.after.inv.kt");
}
@TestMetadata("Multideclaration.after.inv.kt")
public void testMultideclaration() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/Multideclaration.after.inv.kt");
}
@TestMetadata("MutableProperty.after.inv.kt")
public void testMutableProperty() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/MutableProperty.after.inv.kt");
}
@TestMetadata("PropertyWithExplicitType.after.inv.kt")
public void testPropertyWithExplicitType() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithExplicitType.after.inv.kt");
}
@TestMetadata("PropertyWithInference.after.inv.kt")
public void testPropertyWithInference() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithInference.after.inv.kt");
}
@TestMetadata("PropertyWithReceiver.after.inv.kt")
public void testPropertyWithReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithReceiver.after.inv.kt");
}
@TestMetadata("PropertyWithTypeParameterReceiver.after.inv.kt")
public void testPropertyWithTypeParameterReceiver() throws Exception {
runTest("idea/testData/indentationOnNewline/expressionBody/PropertyWithTypeParameterReceiver.after.inv.kt");
}
}
@TestMetadata("idea/testData/indentationOnNewline/script")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)