FIR IDE: fix duplicating diagnostics collection

This commit is contained in:
Ilya Kirillov
2020-12-31 17:24:19 +01:00
parent 008260451c
commit 601d5cbff8
@@ -54,16 +54,10 @@ internal class FileStructure(
fun getAllDiagnosticsForFile(): Collection<Diagnostic> { fun getAllDiagnosticsForFile(): Collection<Diagnostic> {
val containersForStructureElement = buildList { val containersForStructureElement = buildList {
add(ktFile) add(ktFile)
ktFile.forEachDescendantOfType<KtDeclaration>( addAll(ktFile.declarations)
canGoInside = { psi -> psi !is KtFunction && psi !is KtValVarKeywordOwner }
) { declaration ->
if (FileStructureUtil.isStructureElementContainer(declaration)) {
add(declaration)
}
}
} }
val structureElements = containersForStructureElement.map(::getStructureElementFor) val structureElements = containersForStructureElement.map(::getStructureElementFor)
return buildList { return buildSet {
structureElements.forEach { it.diagnostics.forEach { diagnostics -> addAll(diagnostics) } } structureElements.forEach { it.diagnostics.forEach { diagnostics -> addAll(diagnostics) } }
} }
} }