From 3d3f64cc7b6b4af669153c252f6f088d9fed9a69 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 11 Sep 2015 15:32:14 +0300 Subject: [PATCH] Use non-blocking lazy values in completion --- .../org/jetbrains/kotlin/idea/completion/CompletionSession.kt | 4 ++-- .../jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt | 2 +- .../jetbrains/kotlin/idea/completion/LookupElementFactory.kt | 2 +- .../jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt | 4 ++-- .../kotlin/idea/completion/smart/SmartCompletionSession.kt | 2 +- 5 files changed, 7 insertions(+), 7 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 d1f88bcd469..61f32b6e398 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 @@ -179,7 +179,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC } // LookupElementsCollector instantiation is deferred because virtual call to createSorter uses data from derived classes - protected val collector: LookupElementsCollector by lazy { + protected val collector: LookupElementsCollector by lazy(LazyThreadSafetyMode.NONE) { LookupElementsCollector(prefixMatcher, parameters, resultSet, lookupElementFactory, createSorter()) } @@ -281,7 +281,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC return context } - protected val referenceVariants: Collection by lazy { + protected val referenceVariants: Collection by lazy(LazyThreadSafetyMode.NONE) { if (descriptorKindFilter != null) { referenceVariantsHelper.getReferenceVariants( nameExpression!!, diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt index 09f86e871b5..a8ad6cd533e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.JetType import java.util.* class InsertHandlerProvider(expectedInfosCalculator: () -> Collection) { - private val expectedInfos by lazy { expectedInfosCalculator() } + private val expectedInfos by lazy(LazyThreadSafetyMode.NONE) { expectedInfosCalculator() } public fun insertHandler(descriptor: DeclarationDescriptor): InsertHandler { return when (descriptor) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 968386b845c..c8f64088b81 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -56,7 +56,7 @@ class LookupElementFactory( ) { private val basicFactory = BasicLookupElementFactory(resolutionFacade.project, insertHandlerProvider) - private val functionTypeContextVariables by lazy { + private val functionTypeContextVariables by lazy(LazyThreadSafetyMode.NONE) { contextVariablesProvider().filter { KotlinBuiltIns.isFunctionOrExtensionFunctionType(it.type) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt index d1c2c5c45b6..bf487705998 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt @@ -64,7 +64,7 @@ class SmartCompletion( public val expectedInfos: Collection = calcExpectedInfos(expressionWithType) - public val smartCastCalculator: SmartCastCalculator by lazy { + public val smartCastCalculator: SmartCastCalculator by lazy(LazyThreadSafetyMode.NONE) { SmartCastCalculator(bindingContext, resolutionFacade.moduleDescriptor, expression) } @@ -86,7 +86,7 @@ class SmartCompletion( return postProcessedItems to postProcessedSearcher } - public val descriptorsToSkip: Set by lazy> { + public val descriptorsToSkip: Set by lazy>(LazyThreadSafetyMode.NONE) { val parent = expressionWithType.getParent() when (parent) { is JetBinaryExpression -> { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt index b594782835c..dcaeadd334c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletionSession.kt @@ -38,7 +38,7 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para // we do not include SAM-constructors because they are handled separately and adding them requires iterating of java classes override val descriptorKindFilter = DescriptorKindFilter.VALUES exclude SamConstructorDescriptorKindExclude - private val smartCompletion by lazy { + private val smartCompletion by lazy(LazyThreadSafetyMode.NONE) { expression?.let { SmartCompletion(it, resolutionFacade, bindingContext, isVisibleFilter, prefixMatcher, originalSearchScope,