LineIndentProvider: support control flow constructions
Part of #KT-22211
This commit is contained in:
@@ -178,7 +178,7 @@ abstract class KotlinCommonBlock(
|
|||||||
if (node.wrapForFirstCallInChainIsAllowed && node.receiverIsCall())
|
if (node.wrapForFirstCallInChainIsAllowed && node.receiverIsCall())
|
||||||
Wrap.createWrap(
|
Wrap.createWrap(
|
||||||
settings.kotlinCommonSettings.METHOD_CALL_CHAIN_WRAP,
|
settings.kotlinCommonSettings.METHOD_CALL_CHAIN_WRAP,
|
||||||
true /* wrapFirstElement */,
|
true, /* wrapFirstElement */
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
@@ -339,7 +339,7 @@ abstract class KotlinCommonBlock(
|
|||||||
null,
|
null,
|
||||||
)
|
)
|
||||||
|
|
||||||
TRY -> ChildAttributes(Indent.getNoneIndent(), null)
|
TRY, CATCH, FINALLY -> ChildAttributes(Indent.getNoneIndent(), null)
|
||||||
|
|
||||||
in QUALIFIED_EXPRESSIONS -> ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null)
|
in QUALIFIED_EXPRESSIONS -> ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null)
|
||||||
|
|
||||||
@@ -924,11 +924,6 @@ private val INDENT_RULES = arrayOf(
|
|||||||
.within(BODY).notForType(BLOCK)
|
.within(BODY).notForType(BLOCK)
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("For WHEN content")
|
|
||||||
.within(WHEN)
|
|
||||||
.notForType(RBRACE, LBRACE, WHEN_KEYWORD)
|
|
||||||
.set(Indent.getNormalIndent()),
|
|
||||||
|
|
||||||
strategy("For single statement in THEN and ELSE")
|
strategy("For single statement in THEN and ELSE")
|
||||||
.within(THEN, ELSE).notForType(BLOCK)
|
.within(THEN, ELSE).notForType(BLOCK)
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
@@ -1038,21 +1033,26 @@ private val INDENT_RULES = arrayOf(
|
|||||||
|
|
||||||
strategy("Opening parenthesis for conditions")
|
strategy("Opening parenthesis for conditions")
|
||||||
.forType(LPAR)
|
.forType(LPAR)
|
||||||
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE)
|
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE, FOR, WHEN)
|
||||||
.set(Indent.getContinuationWithoutFirstIndent(true)),
|
.set(Indent.getContinuationWithoutFirstIndent(true)),
|
||||||
|
|
||||||
strategy("Closing parenthesis for conditions")
|
strategy("Closing parenthesis for conditions")
|
||||||
.forType(RPAR)
|
.forType(RPAR)
|
||||||
.forElement { node -> !hasErrorElementBefore(node) }
|
.forElement { node -> !hasErrorElementBefore(node) }
|
||||||
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE)
|
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE, FOR, WHEN)
|
||||||
.set(Indent.getNoneIndent()),
|
.set(Indent.getNoneIndent()),
|
||||||
|
|
||||||
strategy("Closing parenthesis for incomplete conditions")
|
strategy("Closing parenthesis for incomplete conditions")
|
||||||
.forType(RPAR)
|
.forType(RPAR)
|
||||||
.forElement { node -> hasErrorElementBefore(node) }
|
.forElement { node -> hasErrorElementBefore(node) }
|
||||||
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE)
|
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE, FOR, WHEN)
|
||||||
.set(Indent.getContinuationWithoutFirstIndent()),
|
.set(Indent.getContinuationWithoutFirstIndent()),
|
||||||
|
|
||||||
|
strategy("For WHEN content")
|
||||||
|
.within(WHEN)
|
||||||
|
.notForType(RBRACE, LBRACE, WHEN_KEYWORD)
|
||||||
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("KDoc comment indent")
|
strategy("KDoc comment indent")
|
||||||
.within(KDOC_CONTENT)
|
.within(KDOC_CONTENT)
|
||||||
.forType(KDocTokens.LEADING_ASTERISK, KDocTokens.END)
|
.forType(KDocTokens.LEADING_ASTERISK, KDocTokens.END)
|
||||||
|
|||||||
+85
-7
@@ -63,42 +63,120 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
|
|||||||
// println(debugInfo(currentPosition))
|
// println(debugInfo(currentPosition))
|
||||||
// ~~~ TESTING ~~~
|
// ~~~ TESTING ~~~
|
||||||
|
|
||||||
currentPosition.beforeOptionalMix(Whitespace, LineComment)
|
val before = currentPosition.beforeWhitespacesAndComments()
|
||||||
.takeIf { it.isAt(TemplateEntryOpen) }
|
when {
|
||||||
?.let { templateEntryPosition ->
|
before.isAt(TemplateEntryOpen) -> {
|
||||||
val baseLineOffset = templateEntryPosition.startOffset
|
val baseLineOffset = before.startOffset
|
||||||
return factory.createIndentCalculator(Indent.getNormalIndent()) { baseLineOffset }
|
return factory.createIndentCalculator(Indent.getNormalIndent()) { baseLineOffset }
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPosition.afterOptionalMix(Whitespace, LineComment)
|
before.isAtAnyOf(TryKeyword, FinallyKeyword) -> return factory.createIndentCalculator(
|
||||||
|
Indent.getNoneIndent(),
|
||||||
|
IndentCalculator.LINE_BEFORE,
|
||||||
|
)
|
||||||
|
|
||||||
|
before.isInControlFlowStatement() -> {
|
||||||
|
val afterWhitespacesAndComments = currentPosition.afterWhitespacesAndComments()
|
||||||
|
return factory.createIndentCalculator(
|
||||||
|
when {
|
||||||
|
afterWhitespacesAndComments.isAt(LeftParenthesis) -> Indent.getContinuationIndent()
|
||||||
|
afterWhitespacesAndComments.isAtAnyOf(BlockOpeningBrace, Arrow) -> Indent.getNoneIndent()
|
||||||
|
else -> Indent.getNormalIndent()
|
||||||
|
},
|
||||||
|
IndentCalculator.LINE_BEFORE,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentPosition.afterWhitespacesAndComments()
|
||||||
.takeIf { it.isAt(TemplateEntryClose) }
|
.takeIf { it.isAt(TemplateEntryClose) }
|
||||||
?.let { templateEntryPosition ->
|
?.let { templateEntryPosition ->
|
||||||
val baseLineOffset = templateEntryPosition.beforeParentheses(TemplateEntryOpen, TemplateEntryClose).startOffset
|
|
||||||
val indent = if (currentPosition.hasEmptyLineAfter(offset)) Indent.getNormalIndent() else Indent.getNoneIndent()
|
val indent = if (currentPosition.hasEmptyLineAfter(offset)) Indent.getNormalIndent() else Indent.getNoneIndent()
|
||||||
|
templateEntryPosition.moveBeforeParentheses(TemplateEntryOpen, TemplateEntryClose)
|
||||||
|
val baseLineOffset = templateEntryPosition.startOffset
|
||||||
return factory.createIndentCalculator(indent) { baseLineOffset }
|
return factory.createIndentCalculator(indent) { baseLineOffset }
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun SemanticEditorPosition.beforeWhitespacesAndComments(): SemanticEditorPosition = beforeOptionalMix(
|
||||||
|
Whitespace,
|
||||||
|
LineComment,
|
||||||
|
BlockComment,
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun SemanticEditorPosition.afterWhitespacesAndComments(): SemanticEditorPosition = afterOptionalMix(
|
||||||
|
Whitespace,
|
||||||
|
LineComment,
|
||||||
|
BlockComment,
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun SemanticEditorPosition.moveBeforeWhitespacesAndComments(): SemanticEditorPosition = apply {
|
||||||
|
moveBeforeOptionalMix(Whitespace, LineComment, BlockComment)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun SemanticEditorPosition.isInControlFlowStatement(): Boolean = with(copy()) {
|
||||||
|
if (isAt(BlockOpeningBrace)) {
|
||||||
|
moveBefore()
|
||||||
|
moveBeforeParentheses(LeftParenthesis, RightParenthesis)
|
||||||
|
moveBeforeWhitespacesAndComments()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currElement in CONTROL_FLOW_CONSTRUCTIONS) return true
|
||||||
|
if (!isAt(RightParenthesis)) return false
|
||||||
|
|
||||||
|
moveBeforeParentheses(LeftParenthesis, RightParenthesis)
|
||||||
|
moveBeforeWhitespacesAndComments()
|
||||||
|
|
||||||
|
return currElement in CONTROL_FLOW_CONSTRUCTIONS
|
||||||
|
}
|
||||||
|
|
||||||
enum class KotlinElement : SemanticEditorPosition.SyntaxElement {
|
enum class KotlinElement : SemanticEditorPosition.SyntaxElement {
|
||||||
TemplateEntryOpen,
|
TemplateEntryOpen,
|
||||||
TemplateEntryClose,
|
TemplateEntryClose,
|
||||||
Arrow,
|
Arrow,
|
||||||
WhenKeyword,
|
WhenKeyword,
|
||||||
|
CatchKeyword,
|
||||||
|
FinallyKeyword,
|
||||||
|
WhileKeyword,
|
||||||
|
RegularStringPart,
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val SYNTAX_MAP: LinkedHashMap<IElementType, SemanticEditorPosition.SyntaxElement> = linkedMapOf(
|
private val SYNTAX_MAP: Map<IElementType, SemanticEditorPosition.SyntaxElement> = hashMapOf(
|
||||||
KtTokens.WHITE_SPACE to Whitespace,
|
KtTokens.WHITE_SPACE to Whitespace,
|
||||||
KtTokens.LONG_TEMPLATE_ENTRY_START to TemplateEntryOpen,
|
KtTokens.LONG_TEMPLATE_ENTRY_START to TemplateEntryOpen,
|
||||||
KtTokens.LONG_TEMPLATE_ENTRY_END to TemplateEntryClose,
|
KtTokens.LONG_TEMPLATE_ENTRY_END to TemplateEntryClose,
|
||||||
KtTokens.EOL_COMMENT to LineComment,
|
KtTokens.EOL_COMMENT to LineComment,
|
||||||
|
KtTokens.BLOCK_COMMENT to BlockComment,
|
||||||
KtTokens.ARROW to Arrow,
|
KtTokens.ARROW to Arrow,
|
||||||
KtTokens.LBRACE to BlockOpeningBrace,
|
KtTokens.LBRACE to BlockOpeningBrace,
|
||||||
KtTokens.RBRACE to BlockClosingBrace,
|
KtTokens.RBRACE to BlockClosingBrace,
|
||||||
|
KtTokens.LPAR to LeftParenthesis,
|
||||||
|
KtTokens.RPAR to RightParenthesis,
|
||||||
|
KtTokens.IF_KEYWORD to IfKeyword,
|
||||||
KtTokens.ELSE_KEYWORD to ElseKeyword,
|
KtTokens.ELSE_KEYWORD to ElseKeyword,
|
||||||
KtTokens.WHEN_KEYWORD to WhenKeyword,
|
KtTokens.WHEN_KEYWORD to WhenKeyword,
|
||||||
|
KtTokens.TRY_KEYWORD to TryKeyword,
|
||||||
|
KtTokens.CATCH_KEYWORD to CatchKeyword,
|
||||||
|
KtTokens.FINALLY_KEYWORD to FinallyKeyword,
|
||||||
|
KtTokens.WHILE_KEYWORD to WhileKeyword,
|
||||||
|
KtTokens.DO_KEYWORD to DoKeyword,
|
||||||
|
KtTokens.FOR_KEYWORD to ForKeyword,
|
||||||
|
KtTokens.REGULAR_STRING_PART to RegularStringPart,
|
||||||
|
)
|
||||||
|
|
||||||
|
private val CONTROL_FLOW_CONSTRUCTIONS: HashSet<SemanticEditorPosition.SyntaxElement> = hashSetOf(
|
||||||
|
WhenKeyword,
|
||||||
|
IfKeyword,
|
||||||
|
ElseKeyword,
|
||||||
|
DoKeyword,
|
||||||
|
WhileKeyword,
|
||||||
|
ForKeyword,
|
||||||
|
TryKeyword,
|
||||||
|
CatchKeyword,
|
||||||
|
FinallyKeyword,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+180
@@ -78,6 +78,21 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
|
|||||||
runTest("idea/testData/indentationOnNewline/BinaryWithTypeExpressions.kt");
|
runTest("idea/testData/indentationOnNewline/BinaryWithTypeExpressions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Catch.kt")
|
||||||
|
public void testCatch() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Catch.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Catch2.kt")
|
||||||
|
public void testCatch2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Catch2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Catch3.kt")
|
||||||
|
public void testCatch3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Catch3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ConsecutiveCallsAfterDot.kt")
|
@TestMetadata("ConsecutiveCallsAfterDot.kt")
|
||||||
public void testConsecutiveCallsAfterDot() throws Exception {
|
public void testConsecutiveCallsAfterDot() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsAfterDot.kt");
|
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsAfterDot.kt");
|
||||||
@@ -93,21 +108,106 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
|
|||||||
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsInSafeCallsEnd.kt");
|
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsInSafeCallsEnd.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Do2.kt")
|
||||||
|
public void testDo2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Do2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("DoInFun.kt")
|
@TestMetadata("DoInFun.kt")
|
||||||
public void testDoInFun() throws Exception {
|
public void testDoInFun() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/DoInFun.kt");
|
runTest("idea/testData/indentationOnNewline/DoInFun.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DoWithBraces.kt")
|
||||||
|
public void testDoWithBraces() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/DoWithBraces.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DoWithBraces2.kt")
|
||||||
|
public void testDoWithBraces2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/DoWithBraces2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseIf.kt")
|
||||||
|
public void testElseIf() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseIf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseInWhenWithOption.kt")
|
||||||
|
public void testElseInWhenWithOption() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseInWhenWithOption.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseInWhenWithoutOption.kt")
|
||||||
|
public void testElseInWhenWithoutOption() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseInWhenWithoutOption.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithBrace.kt")
|
||||||
|
public void testElseWithBrace() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithBrace.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithBraceAndComment.kt")
|
||||||
|
public void testElseWithBraceAndComment() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithBraceAndComment.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithBraceAndComment2.kt")
|
||||||
|
public void testElseWithBraceAndComment2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithBraceAndComment2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithoutBrace.kt")
|
||||||
|
public void testElseWithoutBrace() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithoutBrace.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithoutBrace2.kt")
|
||||||
|
public void testElseWithoutBrace2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithoutBrace2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("EmptyParameters.kt")
|
@TestMetadata("EmptyParameters.kt")
|
||||||
public void testEmptyParameters() throws Exception {
|
public void testEmptyParameters() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/EmptyParameters.kt");
|
runTest("idea/testData/indentationOnNewline/EmptyParameters.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Finally.kt")
|
||||||
|
public void testFinally() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Finally.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Finally2.kt")
|
||||||
|
public void testFinally2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Finally2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Finally3.kt")
|
||||||
|
public void testFinally3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Finally3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("For.kt")
|
@TestMetadata("For.kt")
|
||||||
public void testFor() throws Exception {
|
public void testFor() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/For.kt");
|
runTest("idea/testData/indentationOnNewline/For.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ForWithBlock.kt")
|
||||||
|
public void testForWithBlock() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ForWithBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ForWithCondition.kt")
|
||||||
|
public void testForWithCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ForWithCondition.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ForWithoutCondition.kt")
|
||||||
|
public void testForWithoutCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ForWithoutCondition.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("FunctionBlock.kt")
|
@TestMetadata("FunctionBlock.kt")
|
||||||
public void testFunctionBlock() throws Exception {
|
public void testFunctionBlock() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/FunctionBlock.kt");
|
runTest("idea/testData/indentationOnNewline/FunctionBlock.kt");
|
||||||
@@ -123,6 +223,36 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
|
|||||||
runTest("idea/testData/indentationOnNewline/If.kt");
|
runTest("idea/testData/indentationOnNewline/If.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition.kt")
|
||||||
|
public void testIfBeforeCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition2.kt")
|
||||||
|
public void testIfBeforeCondition2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition3.kt")
|
||||||
|
public void testIfBeforeCondition3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition4.kt")
|
||||||
|
public void testIfBeforeCondition4() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition4.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfWithBraces.kt")
|
||||||
|
public void testIfWithBraces() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfWithBraces.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfWithBraces2.kt")
|
||||||
|
public void testIfWithBraces2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfWithBraces2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InBinaryExpressionInMiddle.kt")
|
@TestMetadata("InBinaryExpressionInMiddle.kt")
|
||||||
public void testInBinaryExpressionInMiddle() throws Exception {
|
public void testInBinaryExpressionInMiddle() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/InBinaryExpressionInMiddle.kt");
|
runTest("idea/testData/indentationOnNewline/InBinaryExpressionInMiddle.kt");
|
||||||
@@ -398,11 +528,61 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
|
|||||||
runTest("idea/testData/indentationOnNewline/TemplateEntryOpenWithoutContent5.kt");
|
runTest("idea/testData/indentationOnNewline/TemplateEntryOpenWithoutContent5.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Try.kt")
|
||||||
|
public void testTry() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Try.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Try2.kt")
|
||||||
|
public void testTry2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Try2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithCondition.kt")
|
||||||
|
public void testWhenWithCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhenWithCondition.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithCondition2.kt")
|
||||||
|
public void testWhenWithCondition2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhenWithCondition2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithoutCondition.kt")
|
||||||
|
public void testWhenWithoutCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhenWithoutCondition.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("While.kt")
|
@TestMetadata("While.kt")
|
||||||
public void testWhile() throws Exception {
|
public void testWhile() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/While.kt");
|
runTest("idea/testData/indentationOnNewline/While.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("While2.kt")
|
||||||
|
public void testWhile2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/While2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("While3.kt")
|
||||||
|
public void testWhile3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/While3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhileWithBlock.kt")
|
||||||
|
public void testWhileWithBlock() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhileWithBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhileWithCondition.kt")
|
||||||
|
public void testWhileWithCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhileWithCondition.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhileWithoutCondition.kt")
|
||||||
|
public void testWhileWithoutCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhileWithoutCondition.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/indentationOnNewline/script")
|
@TestMetadata("idea/testData/indentationOnNewline/script")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+2
-2
@@ -4,11 +4,11 @@ fun f() {
|
|||||||
for (i in array(1, 2)) {
|
for (i in array(1, 2)) {
|
||||||
}
|
}
|
||||||
for
|
for
|
||||||
(i in array(1, 2)) {
|
(i in array(1, 2)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for
|
for
|
||||||
(i in array(1, 2)) {
|
(i in array(1, 2)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in array(1, 2)) continue
|
for (i in array(1, 2)) continue
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ fun foo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for
|
for
|
||||||
(i in 0..42) {
|
(i in 0..42) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -22,14 +22,14 @@ fun some(x: Any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when
|
when
|
||||||
(true) {
|
(true) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
when
|
when
|
||||||
|
|
||||||
|
|
||||||
(true) {
|
(true) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -22,14 +22,14 @@ fun some(x: Any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when
|
when
|
||||||
(true) {
|
(true) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
when
|
when
|
||||||
|
|
||||||
|
|
||||||
(true) {
|
(true) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ fun test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when (var i = 2
|
when (var i = 2
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} catch (e: Exception)
|
||||||
|
<caret>
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} catch (e: Exception)<caret>
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} catch (e: Exception) {
|
||||||
|
<caret>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} catch (e: Exception) {<caret>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} catch
|
||||||
|
<caret>(e: Exception) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} catch <caret>(e: Exception) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun some() {
|
||||||
|
do
|
||||||
|
<caret>println() while (true)
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun some() {
|
||||||
|
do<caret> println() while (true)
|
||||||
|
}
|
||||||
@@ -2,5 +2,3 @@ fun some() {
|
|||||||
do
|
do
|
||||||
<caret>
|
<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
fun some() {
|
fun some() {
|
||||||
do<caret>
|
do<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
do
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
do<caret> {
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun some() {
|
||||||
|
do
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun some() {
|
||||||
|
do
|
||||||
|
|
||||||
|
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
<caret>if (false)
|
||||||
|
false
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else<caret> if (false)
|
||||||
|
false
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun some() {
|
||||||
|
when {
|
||||||
|
true && true ->
|
||||||
|
else
|
||||||
|
<caret>-> Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: ALIGN_IN_COLUMNS_CASE_BRANCH
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun some() {
|
||||||
|
when {
|
||||||
|
true && true ->
|
||||||
|
else <caret>-> Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: ALIGN_IN_COLUMNS_CASE_BRANCH
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun some() {
|
||||||
|
when {
|
||||||
|
true && false ->
|
||||||
|
else
|
||||||
|
<caret>-> Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_FALSE: ALIGN_IN_COLUMNS_CASE_BRANCH
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun some() {
|
||||||
|
when {
|
||||||
|
true && false ->
|
||||||
|
else <caret>-> Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_FALSE: ALIGN_IN_COLUMNS_CASE_BRANCH
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else<caret> {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
<caret>// smth
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else<caret> // smth
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else // smth
|
||||||
|
<caret>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IGNORE_FORMATTER
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else // smth<caret>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IGNORE_FORMATTER
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
if (true)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} finally
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun a() = try {
|
||||||
|
// do smth
|
||||||
|
} finally<caret> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fun a() {
|
||||||
|
try {
|
||||||
|
dos()
|
||||||
|
} finally {
|
||||||
|
<caret>
|
||||||
|
a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun a() {
|
||||||
|
try {
|
||||||
|
dos()
|
||||||
|
} finally {<caret>
|
||||||
|
a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun a() {
|
||||||
|
try {
|
||||||
|
dos()
|
||||||
|
} finally
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun a() {
|
||||||
|
try {
|
||||||
|
dos()
|
||||||
|
} finally<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
fun some() {
|
fun some() {
|
||||||
for (var i in 1..10)
|
for (var i in 1..10)
|
||||||
<caret>
|
<caret>
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
-2
@@ -1,4 +1,2 @@
|
|||||||
fun some() {
|
fun some() {
|
||||||
for (var i in 1..10)<caret>
|
for (var i in 1..10)<caret>
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
for (var i in 1..10)
|
||||||
|
<caret>{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun some() {
|
||||||
|
for (var i in 1..10)<caret> {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
for
|
||||||
|
<caret>(var i in 1..10) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
for <caret>(var i in 1..10) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun some() {
|
||||||
|
for
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun some() {
|
||||||
|
for <caret>
|
||||||
|
}
|
||||||
@@ -2,5 +2,3 @@ fun some() {
|
|||||||
if (3 > 5)
|
if (3 > 5)
|
||||||
<caret>
|
<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
fun some() {
|
fun some() {
|
||||||
if (3 > 5)<caret>
|
if (3 > 5)<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
if
|
||||||
|
<caret>(3 > 5) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
if <caret>(3 > 5) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun some() {
|
||||||
|
if
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun some() {
|
||||||
|
if <caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun some() {
|
||||||
|
if
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun some() {
|
||||||
|
if<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun some() {
|
||||||
|
if
|
||||||
|
|
||||||
|
<caret>(3 > 5) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
if
|
||||||
|
<caret>(3 > 5) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
if (3 > 5) {
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun some() {
|
||||||
|
if (3 > 5) {<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
if (3 > 5)
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
if (3 > 5) <caret>{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,5 +7,3 @@ fun a() {
|
|||||||
a
|
a
|
||||||
}"
|
}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// IGNORE_FORMATTER
|
|
||||||
@@ -6,5 +6,3 @@ fun a() {
|
|||||||
a
|
a
|
||||||
}"
|
}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// IGNORE_FORMATTER
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fun a() = try
|
||||||
|
<caret>
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
fun a() = try<caret>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun a() = try
|
||||||
|
<caret>/* smth */ {
|
||||||
|
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun a() = try<caret> /* smth */ {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun a() {
|
||||||
|
when (true)
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun a() {
|
||||||
|
when (true)<caret> {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun a() {
|
||||||
|
when
|
||||||
|
<caret>(true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun a() {
|
||||||
|
when <caret>(true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun a() {
|
||||||
|
when
|
||||||
|
<caret>{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun a() {
|
||||||
|
when<caret> {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,5 +2,3 @@ fun some() {
|
|||||||
var t = 12
|
var t = 12
|
||||||
while (t > 0)
|
while (t > 0)
|
||||||
<caret>
|
<caret>
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
fun some() {
|
fun some() {
|
||||||
var t = 12
|
var t = 12
|
||||||
while (t > 0)<caret>
|
while (t > 0)<caret>
|
||||||
|
|
||||||
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while (t > 0)
|
||||||
|
<caret>println(true)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while (t > 0)<caret> println(true)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while (t > 0) {
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while (t > 0) {<caret>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while (t > 0)
|
||||||
|
<caret>{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while (t > 0)<caret> {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while
|
||||||
|
<caret>(true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while <caret>(true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun some() {
|
||||||
|
var t = 12
|
||||||
|
while <caret>
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.actionSystem.IdeActions
|
|||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import com.intellij.psi.codeStyle.lineIndent.LineIndentProvider
|
import com.intellij.psi.codeStyle.lineIndent.LineIndentProvider
|
||||||
import com.intellij.testFramework.EditorTestUtil
|
import com.intellij.testFramework.EditorTestUtil
|
||||||
|
import com.intellij.util.ThrowableRunnable
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.idea.formatter.KotlinLineIndentProvider
|
import org.jetbrains.kotlin.idea.formatter.KotlinLineIndentProvider
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinLightPlatformCodeInsightTestCase
|
import org.jetbrains.kotlin.idea.test.KotlinLightPlatformCodeInsightTestCase
|
||||||
@@ -70,11 +71,9 @@ abstract class AbstractTypingIndentationTestBase : KotlinLightPlatformCodeInsigh
|
|||||||
withoutCustomLineIndentProvider: Boolean,
|
withoutCustomLineIndentProvider: Boolean,
|
||||||
ignoreFormatter: Boolean
|
ignoreFormatter: Boolean
|
||||||
) {
|
) {
|
||||||
if (!ignoreFormatter) {
|
KotlinLineIndentProvider.useFormatter = true
|
||||||
KotlinLineIndentProvider.useFormatter = true
|
typeAndCheck(beforeFilePath, afterFilePath, "with FormatterBasedLineIndentProvider", ignoreFormatter)
|
||||||
typeAndCheck(beforeFilePath, afterFilePath, "with FormatterBasedLineIndentProvider")
|
KotlinLineIndentProvider.useFormatter = false
|
||||||
KotlinLineIndentProvider.useFormatter = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!withoutCustomLineIndentProvider) {
|
if (!withoutCustomLineIndentProvider) {
|
||||||
typeAndCheck(beforeFilePath, afterFilePath, "with ${customLineIndentProvider.javaClass.simpleName}")
|
typeAndCheck(beforeFilePath, afterFilePath, "with ${customLineIndentProvider.javaClass.simpleName}")
|
||||||
@@ -98,7 +97,7 @@ abstract class AbstractTypingIndentationTestBase : KotlinLightPlatformCodeInsigh
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun typeAndCheck(beforeFilePath: String, afterFilePath: String, errorMessage: String) {
|
private fun typeAndCheck(beforeFilePath: String, afterFilePath: String, errorMessage: String, invertResult: Boolean = false) {
|
||||||
configureByFile(beforeFilePath)
|
configureByFile(beforeFilePath)
|
||||||
executeAction(IdeActions.ACTION_EDITOR_ENTER)
|
executeAction(IdeActions.ACTION_EDITOR_ENTER)
|
||||||
val actualTextWithCaret = StringBuilder(editor.document.text).insert(
|
val actualTextWithCaret = StringBuilder(editor.document.text).insert(
|
||||||
@@ -106,7 +105,14 @@ abstract class AbstractTypingIndentationTestBase : KotlinLightPlatformCodeInsigh
|
|||||||
EditorTestUtil.CARET_TAG
|
EditorTestUtil.CARET_TAG
|
||||||
).toString()
|
).toString()
|
||||||
|
|
||||||
KotlinTestUtils.assertEqualsToFile(errorMessage, File(afterFilePath), actualTextWithCaret)
|
val result = kotlin.runCatching {
|
||||||
|
KotlinTestUtils.assertEqualsToFile(errorMessage, File(afterFilePath), actualTextWithCaret)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invertResult)
|
||||||
|
Assert.assertTrue("Remove // IGNORE_FORMATTER", result.isFailure)
|
||||||
|
else
|
||||||
|
result.getOrThrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTestDataPath(): String = ""
|
override fun getTestDataPath(): String = ""
|
||||||
|
|||||||
+180
@@ -80,6 +80,21 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
|||||||
runTest("idea/testData/indentationOnNewline/BinaryWithTypeExpressions.after.kt");
|
runTest("idea/testData/indentationOnNewline/BinaryWithTypeExpressions.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Catch.after.kt")
|
||||||
|
public void testCatch() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Catch.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Catch2.after.kt")
|
||||||
|
public void testCatch2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Catch2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Catch3.after.kt")
|
||||||
|
public void testCatch3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Catch3.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ConsecutiveCallsAfterDot.after.kt")
|
@TestMetadata("ConsecutiveCallsAfterDot.after.kt")
|
||||||
public void testConsecutiveCallsAfterDot() throws Exception {
|
public void testConsecutiveCallsAfterDot() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsAfterDot.after.kt");
|
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsAfterDot.after.kt");
|
||||||
@@ -95,21 +110,106 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
|||||||
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsInSafeCallsEnd.after.kt");
|
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsInSafeCallsEnd.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Do2.after.kt")
|
||||||
|
public void testDo2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Do2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("DoInFun.after.kt")
|
@TestMetadata("DoInFun.after.kt")
|
||||||
public void testDoInFun() throws Exception {
|
public void testDoInFun() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/DoInFun.after.kt");
|
runTest("idea/testData/indentationOnNewline/DoInFun.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DoWithBraces.after.kt")
|
||||||
|
public void testDoWithBraces() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/DoWithBraces.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DoWithBraces2.after.kt")
|
||||||
|
public void testDoWithBraces2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/DoWithBraces2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseIf.after.kt")
|
||||||
|
public void testElseIf() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseIf.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseInWhenWithOption.after.kt")
|
||||||
|
public void testElseInWhenWithOption() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseInWhenWithOption.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseInWhenWithoutOption.after.kt")
|
||||||
|
public void testElseInWhenWithoutOption() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseInWhenWithoutOption.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithBrace.after.kt")
|
||||||
|
public void testElseWithBrace() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithBrace.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithBraceAndComment.after.kt")
|
||||||
|
public void testElseWithBraceAndComment() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithBraceAndComment.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithBraceAndComment2.after.kt")
|
||||||
|
public void testElseWithBraceAndComment2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithBraceAndComment2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithoutBrace.after.kt")
|
||||||
|
public void testElseWithoutBrace() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithoutBrace.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ElseWithoutBrace2.after.kt")
|
||||||
|
public void testElseWithoutBrace2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ElseWithoutBrace2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("EmptyParameters.after.kt")
|
@TestMetadata("EmptyParameters.after.kt")
|
||||||
public void testEmptyParameters() throws Exception {
|
public void testEmptyParameters() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/EmptyParameters.after.kt");
|
runTest("idea/testData/indentationOnNewline/EmptyParameters.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Finally.after.kt")
|
||||||
|
public void testFinally() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Finally.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Finally2.after.kt")
|
||||||
|
public void testFinally2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Finally2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Finally3.after.kt")
|
||||||
|
public void testFinally3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Finally3.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("For.after.kt")
|
@TestMetadata("For.after.kt")
|
||||||
public void testFor() throws Exception {
|
public void testFor() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/For.after.kt");
|
runTest("idea/testData/indentationOnNewline/For.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ForWithBlock.after.kt")
|
||||||
|
public void testForWithBlock() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ForWithBlock.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ForWithCondition.after.kt")
|
||||||
|
public void testForWithCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ForWithCondition.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ForWithoutCondition.after.kt")
|
||||||
|
public void testForWithoutCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/ForWithoutCondition.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("FunctionBlock.after.kt")
|
@TestMetadata("FunctionBlock.after.kt")
|
||||||
public void testFunctionBlock() throws Exception {
|
public void testFunctionBlock() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/FunctionBlock.after.kt");
|
runTest("idea/testData/indentationOnNewline/FunctionBlock.after.kt");
|
||||||
@@ -125,6 +225,36 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
|||||||
runTest("idea/testData/indentationOnNewline/If.after.kt");
|
runTest("idea/testData/indentationOnNewline/If.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition.after.kt")
|
||||||
|
public void testIfBeforeCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition2.after.kt")
|
||||||
|
public void testIfBeforeCondition2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition3.after.kt")
|
||||||
|
public void testIfBeforeCondition3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition3.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfBeforeCondition4.after.kt")
|
||||||
|
public void testIfBeforeCondition4() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfBeforeCondition4.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfWithBraces.after.kt")
|
||||||
|
public void testIfWithBraces() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfWithBraces.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IfWithBraces2.after.kt")
|
||||||
|
public void testIfWithBraces2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/IfWithBraces2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InBinaryExpressionInMiddle.after.kt")
|
@TestMetadata("InBinaryExpressionInMiddle.after.kt")
|
||||||
public void testInBinaryExpressionInMiddle() throws Exception {
|
public void testInBinaryExpressionInMiddle() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/InBinaryExpressionInMiddle.after.kt");
|
runTest("idea/testData/indentationOnNewline/InBinaryExpressionInMiddle.after.kt");
|
||||||
@@ -400,11 +530,61 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
|||||||
runTest("idea/testData/indentationOnNewline/TemplateEntryOpenWithoutContent5.after.kt");
|
runTest("idea/testData/indentationOnNewline/TemplateEntryOpenWithoutContent5.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Try.after.kt")
|
||||||
|
public void testTry() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Try.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Try2.after.kt")
|
||||||
|
public void testTry2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/Try2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithCondition.after.kt")
|
||||||
|
public void testWhenWithCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhenWithCondition.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithCondition2.after.kt")
|
||||||
|
public void testWhenWithCondition2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhenWithCondition2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithoutCondition.after.kt")
|
||||||
|
public void testWhenWithoutCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhenWithoutCondition.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("While.after.kt")
|
@TestMetadata("While.after.kt")
|
||||||
public void testWhile() throws Exception {
|
public void testWhile() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/While.after.kt");
|
runTest("idea/testData/indentationOnNewline/While.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("While2.after.kt")
|
||||||
|
public void testWhile2() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/While2.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("While3.after.kt")
|
||||||
|
public void testWhile3() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/While3.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhileWithBlock.after.kt")
|
||||||
|
public void testWhileWithBlock() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhileWithBlock.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhileWithCondition.after.kt")
|
||||||
|
public void testWhileWithCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhileWithCondition.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhileWithoutCondition.after.kt")
|
||||||
|
public void testWhileWithoutCondition() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/WhileWithoutCondition.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/indentationOnNewline/script")
|
@TestMetadata("idea/testData/indentationOnNewline/script")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user