KT-17928 Support code folding for primary constructors
This commit is contained in:
committed by
Dmitry Jemerov
parent
18cb9593c8
commit
eb25ac44e6
@@ -82,7 +82,7 @@ class KotlinFoldingBuilder : CustomFoldingBuilder(), DumbAware {
|
||||
return type == KtNodeTypes.FUNCTION_LITERAL ||
|
||||
(type == KtNodeTypes.BLOCK && parentType != KtNodeTypes.FUNCTION_LITERAL) ||
|
||||
type == KtNodeTypes.CLASS_BODY || type == KtTokens.BLOCK_COMMENT || type == KDocTokens.KDOC ||
|
||||
type == KtNodeTypes.STRING_TEMPLATE
|
||||
type == KtNodeTypes.STRING_TEMPLATE || type == KtNodeTypes.PRIMARY_CONSTRUCTOR
|
||||
}
|
||||
|
||||
private fun getRangeToFold(node: ASTNode): TextRange {
|
||||
@@ -101,6 +101,7 @@ class KotlinFoldingBuilder : CustomFoldingBuilder(), DumbAware {
|
||||
node.elementType == KtTokens.BLOCK_COMMENT -> "/${getFirstLineOfComment(node)}.../"
|
||||
node.elementType == KDocTokens.KDOC -> "/**${getFirstLineOfComment(node)}...*/"
|
||||
node.elementType == KtNodeTypes.STRING_TEMPLATE -> "\"\"\"${getTrimmedFirstLineOfString(node).addSpaceIfNeeded()}...\"\"\""
|
||||
node.elementType == KtNodeTypes.PRIMARY_CONSTRUCTOR -> "(...)"
|
||||
node.psi is KtImportList -> "..."
|
||||
else -> "{...}"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
data class Test<fold text='(...)' expand='true'>(
|
||||
val foo: Int,
|
||||
val bar: Int,
|
||||
val baz: Int
|
||||
)</fold>
|
||||
@@ -136,5 +136,11 @@ public class KotlinFoldingTestGenerated extends AbstractKotlinFoldingTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/folding/checkCollapse/multilineStrings.kt");
|
||||
doSettingsFoldingTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primaryConstructor.kt")
|
||||
public void testPrimaryConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/folding/checkCollapse/primaryConstructor.kt");
|
||||
doSettingsFoldingTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user