Optimization: don't search named arguments
This commit is contained in:
+4
-3
@@ -52,11 +52,12 @@ data class KotlinReferencesSearchOptions(val acceptCallableOverrides: Boolean =
|
|||||||
val acceptOverloads: Boolean = false,
|
val acceptOverloads: Boolean = false,
|
||||||
val acceptExtensionsOfDeclarationClass: Boolean = false,
|
val acceptExtensionsOfDeclarationClass: Boolean = false,
|
||||||
val acceptCompanionObjectMembers: Boolean = false,
|
val acceptCompanionObjectMembers: Boolean = false,
|
||||||
val searchForComponentConventions: Boolean = true) {
|
val searchForComponentConventions: Boolean = true,
|
||||||
|
val searchNamedArguments: Boolean = true) {
|
||||||
fun anyEnabled(): Boolean = acceptCallableOverrides || acceptOverloads || acceptExtensionsOfDeclarationClass
|
fun anyEnabled(): Boolean = acceptCallableOverrides || acceptOverloads || acceptExtensionsOfDeclarationClass
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val Empty = KotlinReferencesSearchOptions(false, false, false)
|
val Empty = KotlinReferencesSearchOptions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ class KotlinReferencesSearcher : QueryExecutorBase<PsiReference, ReferencesSearc
|
|||||||
resultProcessor)
|
resultProcessor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unwrappedElement is KtParameter) {
|
if (unwrappedElement is KtParameter && kotlinOptions.searchNamedArguments) {
|
||||||
runReadAction { searchNamedArguments(unwrappedElement, queryParameters) }
|
runReadAction { searchNamedArguments(unwrappedElement, queryParameters) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -40,6 +40,8 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
|||||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||||
import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName
|
import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName
|
||||||
import org.jetbrains.kotlin.idea.references.KtDestructuringDeclarationReference
|
import org.jetbrains.kotlin.idea.references.KtDestructuringDeclarationReference
|
||||||
|
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchOptions
|
||||||
|
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchParameters
|
||||||
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinRequestResultProcessor
|
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinRequestResultProcessor
|
||||||
import org.jetbrains.kotlin.idea.search.restrictToKotlinSources
|
import org.jetbrains.kotlin.idea.search.restrictToKotlinSources
|
||||||
import org.jetbrains.kotlin.idea.search.usagesSearch.DestructuringDeclarationUsageSearch.*
|
import org.jetbrains.kotlin.idea.search.usagesSearch.DestructuringDeclarationUsageSearch.*
|
||||||
@@ -260,7 +262,9 @@ private class Processor(
|
|||||||
//TODO: what about Scala and other JVM-languages?
|
//TODO: what about Scala and other JVM-languages?
|
||||||
val scope = GlobalSearchScope.projectScope(project).restrictToKotlinSources()
|
val scope = GlobalSearchScope.projectScope(project).restrictToKotlinSources()
|
||||||
testLog?.add("Searched references to ${declaration.logPresentation()} in Kotlin files")
|
testLog?.add("Searched references to ${declaration.logPresentation()} in Kotlin files")
|
||||||
ReferencesSearch.search(declaration, scope).forEach { reference ->
|
val searchParameters = KotlinReferencesSearchParameters(
|
||||||
|
declaration, scope, kotlinOptions = KotlinReferencesSearchOptions(searchNamedArguments = false))
|
||||||
|
ReferencesSearch.search(searchParameters).forEach { reference ->
|
||||||
when (kind) {
|
when (kind) {
|
||||||
CallableToProcessKind.HAS_DATA_CLASS_TYPE -> {
|
CallableToProcessKind.HAS_DATA_CLASS_TYPE -> {
|
||||||
if (reference is KtDestructuringDeclarationReference) {
|
if (reference is KtDestructuringDeclarationReference) {
|
||||||
|
|||||||
Reference in New Issue
Block a user