Support formatting of 'where' clauses
#KT-14083 Fixed
This commit is contained in:
@@ -263,6 +263,9 @@ abstract class KotlinCommonBlock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parentType == KtNodeTypes.TYPE_CONSTRAINT_LIST ->
|
||||||
|
createAlignmentStrategy(true, getAlignment())
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
getNullAlignmentStrategy()
|
getNullAlignmentStrategy()
|
||||||
}
|
}
|
||||||
@@ -505,7 +508,12 @@ private val INDENT_RULES = arrayOf<NodeIndentStrategy>(
|
|||||||
Indent.getContinuationIndent()
|
Indent.getContinuationIndent()
|
||||||
else
|
else
|
||||||
Indent.getNormalIndent()
|
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
|
private fun getOperationType(node: ASTNode): IElementType? = node.findChildByType(KtNodeTypes.OPERATION_REFERENCE)?.firstChildNode?.elementType
|
||||||
|
|||||||
+12
@@ -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
@@ -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);
|
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")
|
@TestMetadata("WhileLineBreak.after.kt")
|
||||||
public void testWhileLineBreak() throws Exception {
|
public void testWhileLineBreak() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/WhileLineBreak.after.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/WhileLineBreak.after.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user