show local functions in structure view
#KT-13473 Fixed
This commit is contained in:
+17
@@ -89,6 +89,23 @@ class KotlinStructureViewElement(val element: NavigatablePsiElement,
|
||||
is KtFile -> element.declarations
|
||||
is KtClass -> element.getPrimaryConstructorParameters().filter { it.hasValOrVar() } + element.declarations
|
||||
is KtClassOrObject -> element.declarations
|
||||
is KtFunction -> element.collectLocalDeclarations()
|
||||
else -> emptyList()
|
||||
}
|
||||
|
||||
private fun KtFunction.collectLocalDeclarations(): List<KtDeclaration> {
|
||||
val result = mutableListOf<KtDeclaration>()
|
||||
|
||||
acceptChildren(object : KtTreeVisitorVoid() {
|
||||
override fun visitClassOrObject(classOrObject: KtClassOrObject) {
|
||||
result.add(classOrObject)
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(function: KtNamedFunction) {
|
||||
result.add(function)
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-LocalElements.kt
|
||||
-foo(): Unit
|
||||
bar(): Unit
|
||||
-X
|
||||
xyzzy(): Unit
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo() {
|
||||
fun bar() { }
|
||||
|
||||
class X {
|
||||
fun xyzzy() {
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -113,6 +113,12 @@ public class KotlinFileStructureTestGenerated extends AbstractKotlinFileStructur
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("LocalElements.kt")
|
||||
public void testLocalElements() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/structureView/fileStructure/LocalElements.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Render.kt")
|
||||
public void testRender() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/structureView/fileStructure/Render.kt");
|
||||
|
||||
Reference in New Issue
Block a user