LineIndentProvider: support empty brackets
Part of #KT-22211 Part of #KT-39353
This commit is contained in:
+3
@@ -47,6 +47,9 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
|
|||||||
before.isAt(BlockOpeningBrace) && after.isAt(BlockClosingBrace) && !currentPosition.hasLineBreaksAfter(offset) ->
|
before.isAt(BlockOpeningBrace) && after.isAt(BlockClosingBrace) && !currentPosition.hasLineBreaksAfter(offset) ->
|
||||||
return factory.createIndentCalculator(Indent.getNoneIndent(), before.startOffset)
|
return factory.createIndentCalculator(Indent.getNoneIndent(), before.startOffset)
|
||||||
|
|
||||||
|
before.isAt(ArrayOpeningBracket) && after.isAt(ArrayClosingBracket) && !currentPosition.hasLineBreaksAfter(offset) ->
|
||||||
|
return factory.createIndentCalculator(Indent.getNoneIndent(), before.startOffset)
|
||||||
|
|
||||||
before.isAt(BlockOpeningBrace) && before.beforeIgnoringWhiteSpaceOrComment().isFunctionDeclaration() ->
|
before.isAt(BlockOpeningBrace) && before.beforeIgnoringWhiteSpaceOrComment().isFunctionDeclaration() ->
|
||||||
return factory.createIndentCalculator(Indent.getNormalIndent(), before.startOffset)
|
return factory.createIndentCalculator(Indent.getNormalIndent(), before.startOffset)
|
||||||
|
|
||||||
|
|||||||
+18
@@ -203,6 +203,24 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
|
|||||||
runTest("idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.kt");
|
runTest("idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/indentationOnNewline/arrayAccess")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ArrayAccess extends AbstractPerformanceTypingIndentationTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doPerfTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInArrayAccess() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/arrayAccess"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("listAccess.kt")
|
||||||
|
public void testListAccess() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/arrayAccess/listAccess.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/indentationOnNewline/controlFlowConstructions")
|
@TestMetadata("idea/testData/indentationOnNewline/controlFlowConstructions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun a() {
|
||||||
|
val a = listOf(1, 2)
|
||||||
|
println(
|
||||||
|
a[
|
||||||
|
<caret>
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun a() {
|
||||||
|
val a = listOf(1, 2)
|
||||||
|
println(
|
||||||
|
a[<caret>]
|
||||||
|
)
|
||||||
|
}
|
||||||
+31
@@ -205,6 +205,24 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
|||||||
runTest("idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.kt");
|
runTest("idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/indentationOnNewline/arrayAccess")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ArrayAccess extends AbstractTypingIndentationTestBase {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doNewlineTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInArrayAccess() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/arrayAccess"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("listAccess.after.kt")
|
||||||
|
public void testListAccess() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/arrayAccess/listAccess.after.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/indentationOnNewline/controlFlowConstructions")
|
@TestMetadata("idea/testData/indentationOnNewline/controlFlowConstructions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
@@ -1174,6 +1192,19 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
|||||||
runTest("idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.inv.kt");
|
runTest("idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.inv.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/indentationOnNewline/arrayAccess")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ArrayAccess extends AbstractTypingIndentationTestBase {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doNewlineTestWithInvert, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInArrayAccess() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/arrayAccess"), Pattern.compile("^([^\\.]+)\\.after\\.inv\\.kt.*$"), null, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/indentationOnNewline/controlFlowConstructions")
|
@TestMetadata("idea/testData/indentationOnNewline/controlFlowConstructions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user