Fix effective search scope for find references
Relates to #KT-18619
This commit is contained in:
+5
-5
@@ -70,15 +70,15 @@ data class KotlinReferencesSearchOptions(
|
|||||||
val Empty = KotlinReferencesSearchOptions()
|
val Empty = KotlinReferencesSearchOptions()
|
||||||
|
|
||||||
internal fun calculateEffectiveScope(
|
internal fun calculateEffectiveScope(
|
||||||
unwrappedElement: PsiNamedElement,
|
elementToSearch: PsiNamedElement,
|
||||||
parameters: ReferencesSearch.SearchParameters
|
parameters: ReferencesSearch.SearchParameters
|
||||||
): SearchScope {
|
): SearchScope {
|
||||||
val kotlinOptions = (parameters as? KotlinReferencesSearchParameters)?.kotlinOptions ?: Empty
|
val kotlinOptions = (parameters as? KotlinReferencesSearchParameters)?.kotlinOptions ?: Empty
|
||||||
val elements = if (unwrappedElement is KtDeclaration && !isOnlyKotlinSearch(parameters.scopeDeterminedByUser)) {
|
val elements = if (elementToSearch is KtDeclaration && !isOnlyKotlinSearch(parameters.scopeDeterminedByUser)) {
|
||||||
unwrappedElement.toLightElements().filterDataClassComponentsIfDisabled(kotlinOptions).nullize()
|
elementToSearch.toLightElements().filterDataClassComponentsIfDisabled(kotlinOptions).nullize()
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
} ?: listOf(unwrappedElement)
|
} ?: listOf(elementToSearch)
|
||||||
|
|
||||||
return elements.fold(parameters.effectiveSearchScope) { scope, e ->
|
return elements.fold(parameters.effectiveSearchScope) { scope, e ->
|
||||||
scope.unionSafe(parameters.effectiveSearchScope(e))
|
scope.unionSafe(parameters.effectiveSearchScope(e))
|
||||||
@@ -163,7 +163,7 @@ class KotlinReferencesSearcher : QueryExecutorBase<PsiReference, ReferencesSearc
|
|||||||
null
|
null
|
||||||
} ?: unwrappedElement
|
} ?: unwrappedElement
|
||||||
|
|
||||||
val effectiveSearchScope = calculateEffectiveScope(unwrappedElement, queryParameters)
|
val effectiveSearchScope = calculateEffectiveScope(elementToSearch, queryParameters)
|
||||||
|
|
||||||
val refFilter: (PsiReference) -> Boolean = when (elementToSearch) {
|
val refFilter: (PsiReference) -> Boolean = when (elementToSearch) {
|
||||||
is KtParameter -> ({ ref: PsiReference -> !ref.isNamedArgumentReference()/* they are processed later*/ })
|
is KtParameter -> ({ ref: PsiReference -> !ref.isNamedArgumentReference()/* they are processed later*/ })
|
||||||
|
|||||||
Reference in New Issue
Block a user