Support formatting of 'where' clauses

#KT-14083 Fixed
This commit is contained in:
Dmitry Jemerov
2017-07-18 18:49:36 +02:00
parent 325e950bfe
commit 7555bb6c3c
4 changed files with 39 additions and 1 deletions
@@ -263,6 +263,9 @@ abstract class KotlinCommonBlock(
}
}
parentType == KtNodeTypes.TYPE_CONSTRAINT_LIST ->
createAlignmentStrategy(true, getAlignment())
else ->
getNullAlignmentStrategy()
}
@@ -505,7 +508,12 @@ private val INDENT_RULES = arrayOf<NodeIndentStrategy>(
Indent.getContinuationIndent()
else
Indent.getNormalIndent()
})
},
strategy("Where clause")
.within(KtNodeTypes.CLASS, KtNodeTypes.FUN, KtNodeTypes.PROPERTY)
.forType(KtTokens.WHERE_KEYWORD)
.set(Indent.getContinuationIndent()))
private fun getOperationType(node: ASTNode): IElementType? = node.findChildByType(KtNodeTypes.OPERATION_REFERENCE)?.firstChildNode?.elementType
+12
View File
@@ -0,0 +1,12 @@
abstract class RustNavigationContributorBase<T> protected constructor(
private val indexKey: StubIndexKey<String, T>,
private val clazz: Class<T>
) : ChooseByNameContributor, GotoClassContributor
where T : NavigationItem,
T : RustNamedElement {
}
fun <T> foo()
where T : NavigationItem,
T : RustNamedElement {
}
+12
View File
@@ -0,0 +1,12 @@
abstract class RustNavigationContributorBase<T> protected constructor(
private val indexKey: StubIndexKey<String, T>,
private val clazz: Class<T>
) : ChooseByNameContributor, GotoClassContributor
where T : NavigationItem,
T : RustNamedElement {
}
fun <T> foo()
where T : NavigationItem,
T : RustNamedElement {
}
@@ -842,6 +842,12 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
doTest(fileName);
}
@TestMetadata("WhereClause.after.kt")
public void testWhereClause() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/WhereClause.after.kt");
doTest(fileName);
}
@TestMetadata("WhileLineBreak.after.kt")
public void testWhileLineBreak() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/WhileLineBreak.after.kt");