Rename: Do not search for component convention usages

#KT-9381 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-17 14:12:30 +03:00
parent f507eed42d
commit f6de6eac09
4 changed files with 21 additions and 8 deletions
@@ -49,7 +49,8 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
data class KotlinReferencesSearchOptions(val acceptCallableOverrides: Boolean = false,
val acceptOverloads: Boolean = false,
val acceptExtensionsOfDeclarationClass: Boolean = false,
val acceptCompanionObjectMembers: Boolean = false) {
val acceptCompanionObjectMembers: Boolean = false,
val searchForComponentConventions: Boolean = true) {
fun anyEnabled(): Boolean = acceptCallableOverrides || acceptOverloads || acceptExtensionsOfDeclarationClass
companion object {
@@ -72,7 +73,10 @@ class KotlinReferencesSearcher : QueryExecutorBase<PsiReference, ReferencesSearc
val unwrappedElement = element.namedUnwrappedElement ?: return
val specialSymbols = runReadAction { unwrappedElement.getSpecialNamesToSearch() }
val kotlinOptions = (queryParameters as? KotlinReferencesSearchParameters)?.kotlinOptions
?: KotlinReferencesSearchOptions.Empty
val specialSymbols = runReadAction { unwrappedElement.getSpecialNamesToSearch(kotlinOptions) }
val words = runReadAction {
val classNameForCompanionObject = unwrappedElement.getClassNameForCompanionObject()
specialSymbols.first +
@@ -90,9 +94,6 @@ class KotlinReferencesSearcher : QueryExecutorBase<PsiReference, ReferencesSearc
else -> ({true})
}
val kotlinOptions = (queryParameters as? KotlinReferencesSearchParameters)?.kotlinOptions
?: KotlinReferencesSearchOptions.Empty
val resultProcessor = KotlinRequestResultProcessor(unwrappedElement, filter = refFilter, options = kotlinOptions)
if (kotlinOptions.anyEnabled()) {
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.references.KtDestructuringDeclarationReference
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchOptions
import org.jetbrains.kotlin.lexer.KtSingleValueToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.Name
@@ -64,11 +65,13 @@ fun PsiNamedElement.getClassNameForCompanionObject(): String? {
}
}
fun PsiNamedElement.getSpecialNamesToSearch(): Pair<List<String>, Class<*>?> {
fun PsiNamedElement.getSpecialNamesToSearch(options: KotlinReferencesSearchOptions): Pair<List<String>, Class<*>?> {
val name = name
return when {
name == null || !Name.isValidIdentifier(name) -> Collections.emptyList<String>() to null
this is KtParameter -> {
if (!options.searchForComponentConventions) return Collections.emptyList<String>() to null
val componentFunctionName = this.dataClassComponentFunction()?.name
if (componentFunctionName == null) return Collections.emptyList<String>() to null