Make formatter put no indent after a line break inside/after a modifier list

This commit is contained in:
Andrey Breslav
2013-09-20 15:22:46 +04:00
parent 8952365ae3
commit 2d01e93fa4
35 changed files with 245 additions and 3 deletions
@@ -36,7 +36,7 @@ public abstract class ASTAlignmentStrategy {
}
@Nullable
public abstract Alignment getAlignment(ASTNode node);
public abstract Alignment getAlignment(@NotNull ASTNode node);
public static class AlignmentStrategyWrapper extends ASTAlignmentStrategy {
private final AlignmentStrategy internalStrategy;
@@ -264,7 +264,7 @@ public class JetBlock extends AbstractBlock {
return new ASTAlignmentStrategy() {
@Override
public Alignment getAlignment(ASTNode node) {
public Alignment getAlignment(@NotNull ASTNode node) {
IElementType childNodeType = node.getElementType();
ASTNode prev = getPrevWithoutWhitespace(node);
@@ -327,7 +327,7 @@ public class JetBlock extends AbstractBlock {
ASTIndentStrategy.forNode("Indent for parts")
.in(PROPERTY, FUN)
.notForType(BLOCK)
.notForType(BLOCK, FUN_KEYWORD, VAL_KEYWORD, VAR_KEYWORD)
.set(Indent.getContinuationWithoutFirstIndent()),
ASTIndentStrategy.forNode("KDoc comment indent")
@@ -0,0 +1,4 @@
[annot]
[foo] fun foo() {
}
@@ -0,0 +1,4 @@
[annot]
[foo] fun foo() {
}
@@ -0,0 +1,4 @@
[annot]
foo() fun foo() {
}
@@ -0,0 +1,4 @@
[annot]
foo() fun foo() {
}
@@ -0,0 +1,4 @@
[annot]
final fun foo() {
}
@@ -0,0 +1,4 @@
[annot]
final fun foo() {
}
@@ -0,0 +1,4 @@
annot()
[foo] fun foo() {
}
@@ -0,0 +1,4 @@
annot()
[foo] fun foo() {
}
@@ -0,0 +1,4 @@
annot()
foo() fun foo() {
}
@@ -0,0 +1,4 @@
annot()
foo() fun foo() {
}
@@ -0,0 +1,4 @@
annot()
final fun foo() {
}
@@ -0,0 +1,4 @@
annot()
final fun foo() {
}
@@ -0,0 +1,4 @@
public
[foo] fun foo() {
}
@@ -0,0 +1,4 @@
public
[foo] fun foo() {
}
@@ -0,0 +1,4 @@
public
foo() fun foo() {
}
@@ -0,0 +1,4 @@
public
foo() fun foo() {
}
@@ -0,0 +1,4 @@
public
final fun foo() {
}
@@ -0,0 +1,4 @@
public
final fun foo() {
}
@@ -0,0 +1,4 @@
private
fun foo() {
}
@@ -0,0 +1,4 @@
private
fun foo() {
}
@@ -0,0 +1,5 @@
class C {
private
fun foo() {
}
}
@@ -0,0 +1,5 @@
class C {
private
fun foo() {
}
}
@@ -0,0 +1,4 @@
class C {
private
val foo = 1
}
@@ -0,0 +1,4 @@
class C {
private
val foo = 1
}
@@ -0,0 +1,4 @@
class C {
private
var foo = 1
}
@@ -0,0 +1,4 @@
class C {
private
var foo = 1
}
@@ -0,0 +1,8 @@
class C {
fun foo0() {
}
private
fun foo() {
}
}
@@ -0,0 +1,7 @@
class C {
fun foo0() {}
private
fun foo() {
}
}
@@ -0,0 +1,7 @@
class C {
fun foo0() {
}
private
val foo = 1
}
@@ -0,0 +1,6 @@
class C {
fun foo0() {}
private
val foo = 1
}
@@ -0,0 +1,7 @@
class C {
fun foo0() {
}
private
var foo = 1
}
@@ -0,0 +1,6 @@
class C {
fun foo0() {}
private
var foo = 1
}
@@ -31,6 +31,7 @@ import org.jetbrains.jet.formatter.AbstractJetFormatterTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/formatter")
@InnerTestClasses({JetFormatterTestGenerated.ModifierList.class})
public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
public void testAllFilesPresentInFormatter() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/formatter"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
@@ -201,4 +202,98 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTest("idea/testData/formatter/WhenLinesBeforeLbrace.kt");
}
@TestMetadata("idea/testData/formatter/modifierList")
public static class ModifierList extends AbstractJetFormatterTest {
public void testAllFilesPresentInModifierList() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/formatter/modifierList"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
}
@TestMetadata("funAnnotationBeforeAnnotation.kt")
public void testFunAnnotationBeforeAnnotation() throws Exception {
doTest("idea/testData/formatter/modifierList/funAnnotationBeforeAnnotation.kt");
}
@TestMetadata("funAnnotationBeforeAnnotationEntry.kt")
public void testFunAnnotationBeforeAnnotationEntry() throws Exception {
doTest("idea/testData/formatter/modifierList/funAnnotationBeforeAnnotationEntry.kt");
}
@TestMetadata("funAnnotationBeforeModifiers.kt")
public void testFunAnnotationBeforeModifiers() throws Exception {
doTest("idea/testData/formatter/modifierList/funAnnotationBeforeModifiers.kt");
}
@TestMetadata("funAnnotationEntryBeforeAnnotation.kt")
public void testFunAnnotationEntryBeforeAnnotation() throws Exception {
doTest("idea/testData/formatter/modifierList/funAnnotationEntryBeforeAnnotation.kt");
}
@TestMetadata("funAnnotationEntryBeforeAnnotationEntry.kt")
public void testFunAnnotationEntryBeforeAnnotationEntry() throws Exception {
doTest("idea/testData/formatter/modifierList/funAnnotationEntryBeforeAnnotationEntry.kt");
}
@TestMetadata("funAnnotationEntryBeforeModifiers.kt")
public void testFunAnnotationEntryBeforeModifiers() throws Exception {
doTest("idea/testData/formatter/modifierList/funAnnotationEntryBeforeModifiers.kt");
}
@TestMetadata("funModifierBeforeAnnotation.kt")
public void testFunModifierBeforeAnnotation() throws Exception {
doTest("idea/testData/formatter/modifierList/funModifierBeforeAnnotation.kt");
}
@TestMetadata("funModifierBeforeAnnotationEntry.kt")
public void testFunModifierBeforeAnnotationEntry() throws Exception {
doTest("idea/testData/formatter/modifierList/funModifierBeforeAnnotationEntry.kt");
}
@TestMetadata("funModifierBeforeModifiers.kt")
public void testFunModifierBeforeModifiers() throws Exception {
doTest("idea/testData/formatter/modifierList/funModifierBeforeModifiers.kt");
}
@TestMetadata("funTheOnlyModifier.kt")
public void testFunTheOnlyModifier() throws Exception {
doTest("idea/testData/formatter/modifierList/funTheOnlyModifier.kt");
}
@TestMetadata("memberFunTheOnlyModifier.kt")
public void testMemberFunTheOnlyModifier() throws Exception {
doTest("idea/testData/formatter/modifierList/memberFunTheOnlyModifier.kt");
}
@TestMetadata("memberValTheOnlyModifier.kt")
public void testMemberValTheOnlyModifier() throws Exception {
doTest("idea/testData/formatter/modifierList/memberValTheOnlyModifier.kt");
}
@TestMetadata("memberVarTheOnlyModifier.kt")
public void testMemberVarTheOnlyModifier() throws Exception {
doTest("idea/testData/formatter/modifierList/memberVarTheOnlyModifier.kt");
}
@TestMetadata("secondMemberFunTheOnlyModifier.kt")
public void testSecondMemberFunTheOnlyModifier() throws Exception {
doTest("idea/testData/formatter/modifierList/secondMemberFunTheOnlyModifier.kt");
}
@TestMetadata("secondMemberValTheOnlyModifier.kt")
public void testSecondMemberValTheOnlyModifier() throws Exception {
doTest("idea/testData/formatter/modifierList/secondMemberValTheOnlyModifier.kt");
}
@TestMetadata("secondMemberVarTheOnlyModifier.kt")
public void testSecondMemberVarTheOnlyModifier() throws Exception {
doTest("idea/testData/formatter/modifierList/secondMemberVarTheOnlyModifier.kt");
}
}
public static Test suite() {
TestSuite suite = new TestSuite("JetFormatterTestGenerated");
suite.addTestSuite(JetFormatterTestGenerated.class);
suite.addTestSuite(ModifierList.class);
return suite;
}
}