[LL FIR] FileStructure: avoid redundant bodies visiting

We shouldn't try to find structure elements inside non-local declarations
Only classes and scripts can have an inner structure

^KT-60611
This commit is contained in:
Dmitrii Gridin
2023-08-31 23:16:30 +02:00
committed by Space Team
parent 8832865e9a
commit 420b6d48c3
@@ -136,7 +136,12 @@ internal class FileStructure private constructor(
override fun visitDeclaration(dcl: KtDeclaration) {
val structureElement = getStructureElementFor(dcl)
structureElements += structureElement
dcl.acceptChildren(this)
// Go down only in the case of container declaration
val canHaveInnerStructure = dcl is KtClassOrObject || dcl is KtScript
if (canHaveInnerStructure) {
dcl.acceptChildren(this)
}
}
override fun visitModifierList(list: KtModifierList) {