Use non-blocking lazy values in completion

This commit is contained in:
Nikolay Krasko
2015-09-11 15:32:14 +03:00
parent eea8fcdae6
commit 3d3f64cc7b
5 changed files with 7 additions and 7 deletions
@@ -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 // 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()) LookupElementsCollector(prefixMatcher, parameters, resultSet, lookupElementFactory, createSorter())
} }
@@ -281,7 +281,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
return context return context
} }
protected val referenceVariants: Collection<DeclarationDescriptor> by lazy { protected val referenceVariants: Collection<DeclarationDescriptor> by lazy(LazyThreadSafetyMode.NONE) {
if (descriptorKindFilter != null) { if (descriptorKindFilter != null) {
referenceVariantsHelper.getReferenceVariants( referenceVariantsHelper.getReferenceVariants(
nameExpression!!, nameExpression!!,
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.JetType
import java.util.* import java.util.*
class InsertHandlerProvider(expectedInfosCalculator: () -> Collection<ExpectedInfo>) { class InsertHandlerProvider(expectedInfosCalculator: () -> Collection<ExpectedInfo>) {
private val expectedInfos by lazy { expectedInfosCalculator() } private val expectedInfos by lazy(LazyThreadSafetyMode.NONE) { expectedInfosCalculator() }
public fun insertHandler(descriptor: DeclarationDescriptor): InsertHandler<LookupElement> { public fun insertHandler(descriptor: DeclarationDescriptor): InsertHandler<LookupElement> {
return when (descriptor) { return when (descriptor) {
@@ -56,7 +56,7 @@ class LookupElementFactory(
) { ) {
private val basicFactory = BasicLookupElementFactory(resolutionFacade.project, insertHandlerProvider) 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) } contextVariablesProvider().filter { KotlinBuiltIns.isFunctionOrExtensionFunctionType(it.type) }
} }
@@ -64,7 +64,7 @@ class SmartCompletion(
public val expectedInfos: Collection<ExpectedInfo> = calcExpectedInfos(expressionWithType) public val expectedInfos: Collection<ExpectedInfo> = calcExpectedInfos(expressionWithType)
public val smartCastCalculator: SmartCastCalculator by lazy { public val smartCastCalculator: SmartCastCalculator by lazy(LazyThreadSafetyMode.NONE) {
SmartCastCalculator(bindingContext, resolutionFacade.moduleDescriptor, expression) SmartCastCalculator(bindingContext, resolutionFacade.moduleDescriptor, expression)
} }
@@ -86,7 +86,7 @@ class SmartCompletion(
return postProcessedItems to postProcessedSearcher return postProcessedItems to postProcessedSearcher
} }
public val descriptorsToSkip: Set<DeclarationDescriptor> by lazy<Set<DeclarationDescriptor>> { public val descriptorsToSkip: Set<DeclarationDescriptor> by lazy<Set<DeclarationDescriptor>>(LazyThreadSafetyMode.NONE) {
val parent = expressionWithType.getParent() val parent = expressionWithType.getParent()
when (parent) { when (parent) {
is JetBinaryExpression -> { is JetBinaryExpression -> {
@@ -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 // 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 override val descriptorKindFilter = DescriptorKindFilter.VALUES exclude SamConstructorDescriptorKindExclude
private val smartCompletion by lazy { private val smartCompletion by lazy(LazyThreadSafetyMode.NONE) {
expression?.let { expression?.let {
SmartCompletion(it, resolutionFacade, SmartCompletion(it, resolutionFacade,
bindingContext, isVisibleFilter, prefixMatcher, originalSearchScope, bindingContext, isVisibleFilter, prefixMatcher, originalSearchScope,