From 0a40b375a119ef45cfc9bb59521e80c5a0cee6a6 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 28 Jul 2015 20:03:03 +0300 Subject: [PATCH] Minor: get SmartCastManager as a service in CompletionSession and KotlinIndicesHelper --- .../org/jetbrains/kotlin/idea/completion/CompletionSession.kt | 4 +++- .../src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 6316338c1c5..6eaeec8e9a9 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -29,6 +29,7 @@ import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade +import org.jetbrains.kotlin.idea.caches.resolve.getService import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper @@ -146,7 +147,8 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC var receiverTypes = receiversData.receivers.flatMap { receiverValue -> val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiverValue, bindingContext, moduleDescriptor) if (dataFlowValue.isPredictable) { // we don't include smart cast receiver types for "unpredictable" receiver value to mark members grayed - SmartCastManager().getSmartCastVariantsWithLessSpecificExcluded(receiverValue, bindingContext, moduleDescriptor, dataFlowInfo) + resolutionFacade.getService(file) + .getSmartCastVariantsWithLessSpecificExcluded(receiverValue, bindingContext, moduleDescriptor, dataFlowInfo) } else { listOf(receiverValue.type) diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt index efbdd89f37a..631717e9ca9 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt @@ -24,6 +24,7 @@ import com.intellij.psi.stubs.StringStubIndexExtension import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade +import org.jetbrains.kotlin.idea.caches.resolve.getService import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper import org.jetbrains.kotlin.idea.imports.importableFqName import org.jetbrains.kotlin.idea.stubindex.* @@ -114,7 +115,8 @@ public class KotlinIndicesHelper( private fun possibleReceiverTypeNames(receiverValues: Collection, dataFlowInfo: DataFlowInfo, bindingContext: BindingContext): Set { val result = HashSet() for (receiverValue in receiverValues) { - for (type in SmartCastManager().getSmartCastVariants(receiverValue, bindingContext, moduleDescriptor, dataFlowInfo)) { + val smartCastManager = resolutionFacade.getService(moduleDescriptor) + for (type in smartCastManager.getSmartCastVariants(receiverValue, bindingContext, moduleDescriptor, dataFlowInfo)) { result.addTypeNames(type) } }