From 6e621ab1149cc97530dc87d950e60b63fe14fb72 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Tue, 20 Jan 2015 21:45:04 +0300 Subject: [PATCH] Lazy usage search (using SearchQuery as Iterable leads to computing all results, which is wasting time). --- .../kotlin/idea/inspections/UnusedSymbolInspection.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index db77f176608..8dad5c64acd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -51,6 +51,7 @@ import org.jetbrains.kotlin.psi.JetParameter import org.jetbrains.kotlin.idea.search.usagesSearch.dataClassComponentFunctionName import org.jetbrains.kotlin.psi.JetTypeParameter import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper +import com.intellij.util.Processor public class UnusedSymbolInspection : AbstractKotlinInspection() { private val javaInspection = UnusedDeclarationInspection() @@ -197,6 +198,6 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { val request = searchHelper.newRequest(UsagesSearchTarget(declaration, useScope)) val query = UsagesSearch.search(request) - return query.any { !declaration.isAncestor(it.getElement()) } + return !query.forEach(Processor { declaration.isAncestor(it.getElement()) }) } } \ No newline at end of file