Minor. Reformat usagesSearch/utils.kt

This commit is contained in:
Denis Zharkov
2018-12-11 11:01:08 +03:00
parent 2b436b493c
commit 9e07b0d31a
@@ -31,9 +31,9 @@ import org.jetbrains.kotlin.asJava.toLightMethods
import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMethodDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.caches.resolve.resolveToParameterDescriptorIfAny import org.jetbrains.kotlin.idea.caches.resolve.resolveToParameterDescriptorIfAny
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMethodDescriptor
import org.jetbrains.kotlin.idea.references.unwrappedTargets import org.jetbrains.kotlin.idea.references.unwrappedTargets
import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest
import org.jetbrains.kotlin.idea.search.declarationsSearch.searchInheritors import org.jetbrains.kotlin.idea.search.declarationsSearch.searchInheritors
@@ -132,7 +132,10 @@ fun PsiElement.buildProcessDelegationCallConstructorUsagesTask(scope: SearchScop
return { task1() && task2() } return { task1() && task2() }
} }
private fun PsiElement.buildProcessDelegationCallKotlinConstructorUsagesTask(scope: SearchScope, process: (KtCallElement) -> Boolean): () -> Boolean { private fun PsiElement.buildProcessDelegationCallKotlinConstructorUsagesTask(
scope: SearchScope,
process: (KtCallElement) -> Boolean
): () -> Boolean {
val element = unwrapped val element = unwrapped
if (element != null && element !in scope) return { true } if (element != null && element !in scope) return { true }
@@ -151,7 +154,10 @@ private fun PsiElement.buildProcessDelegationCallKotlinConstructorUsagesTask(sco
return { processInheritorsDelegatingCallToSpecifiedConstructor(klass, scope, descriptor, process) } return { processInheritorsDelegatingCallToSpecifiedConstructor(klass, scope, descriptor, process) }
} }
private fun PsiElement.buildProcessDelegationCallJavaConstructorUsagesTask(scope: SearchScope, process: (KtCallElement) -> Boolean): () -> Boolean { private fun PsiElement.buildProcessDelegationCallJavaConstructorUsagesTask(
scope: SearchScope,
process: (KtCallElement) -> Boolean
): () -> Boolean {
if (this is KtLightElement<*, *>) return { true } if (this is KtLightElement<*, *>) return { true }
// TODO: Temporary hack to avoid NPE while KotlinNoOriginLightMethod is around // TODO: Temporary hack to avoid NPE while KotlinNoOriginLightMethod is around
if (this is KtLightMethod && this.kotlinOrigin == null) return { true } if (this is KtLightMethod && this.kotlinOrigin == null) return { true }
@@ -237,8 +243,7 @@ fun PsiReference.isCallableOverrideUsage(declaration: KtNamedDeclaration): Boole
if (declaration is KtParameter) { if (declaration is KtParameter) {
// we don't treat parameters in overriding method as "override" here (overriding parameters usages are searched optionally and via searching of overriding methods first) // we don't treat parameters in overriding method as "override" here (overriding parameters usages are searched optionally and via searching of overriding methods first)
if (declaration.hasValOrVar()) declaration.propertyDescriptor else null if (declaration.hasValOrVar()) declaration.propertyDescriptor else null
} } else {
else {
declaration.descriptor as? CallableDescriptor declaration.descriptor as? CallableDescriptor
} }
} }
@@ -263,8 +268,7 @@ fun PsiElement.searchReferencesOrMethodReferences(): Collection<PsiReference> {
val lightMethods = toLightMethods() val lightMethods = toLightMethods()
return if (lightMethods.isNotEmpty()) { return if (lightMethods.isNotEmpty()) {
lightMethods.flatMapTo(LinkedHashSet()) { MethodReferencesSearch.search(it) } lightMethods.flatMapTo(LinkedHashSet()) { MethodReferencesSearch.search(it) }
} } else {
else {
ReferencesSearch.search(this).findAll() ReferencesSearch.search(this).findAll()
} }
} }