diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index 60e90e61f6c..fd5ac40e79a 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.completion +import com.intellij.codeInsight.CodeInsightSettings import com.intellij.codeInsight.completion.* import com.intellij.codeInsight.completion.impl.BetterPrefixMatcher import com.intellij.codeInsight.lookup.LookupElement @@ -202,18 +203,24 @@ class BasicCompletionSession( val contextVariableTypesForSmartCompletion = withCollectRequiredContextVariableTypes(::completeWithSmartCompletion) val contextVariableTypesForReferenceVariants = withCollectRequiredContextVariableTypes { lookupElementFactory -> - if (prefix.isEmpty() || callTypeAndReceiver.receiver != null) { - addReferenceVariantElements(lookupElementFactory, descriptorKindFilter) - } - else if (prefix[0].isLowerCase()) { - addReferenceVariantElements(lookupElementFactory, USUALLY_START_LOWER_CASE.intersect(descriptorKindFilter)) - flushToResultSet() - addReferenceVariantElements(lookupElementFactory, USUALLY_START_UPPER_CASE.intersect(descriptorKindFilter)) - } - else { - addReferenceVariantElements(lookupElementFactory, USUALLY_START_UPPER_CASE.intersect(descriptorKindFilter)) - flushToResultSet() - addReferenceVariantElements(lookupElementFactory, USUALLY_START_LOWER_CASE.intersect(descriptorKindFilter)) + when { + prefix.isEmpty() + || callTypeAndReceiver.receiver != null + || CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE == CodeInsightSettings.NONE -> { + addReferenceVariantElements(lookupElementFactory, descriptorKindFilter) + } + + prefix[0].isLowerCase() -> { + addReferenceVariantElements(lookupElementFactory, USUALLY_START_LOWER_CASE.intersect(descriptorKindFilter)) + flushToResultSet() + addReferenceVariantElements(lookupElementFactory, USUALLY_START_UPPER_CASE.intersect(descriptorKindFilter)) + } + + else -> { + addReferenceVariantElements(lookupElementFactory, USUALLY_START_UPPER_CASE.intersect(descriptorKindFilter)) + flushToResultSet() + addReferenceVariantElements(lookupElementFactory, USUALLY_START_LOWER_CASE.intersect(descriptorKindFilter)) + } } referenceVariantsCollector!!.collectingFinished() } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt index 88ae7b3b58d..eb7f76fc292 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt @@ -119,6 +119,7 @@ class BasicLookupElementFactory( ): LookupElement { val declarationLazy by lazy { DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor) } + //TODO: try JavaClassDescriptor? if (descriptor is ClassifierDescriptor && declarationLazy is PsiClass && declarationLazy !is KtLightClass) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ReferenceVariantsCollector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ReferenceVariantsCollector.kt index 08f6c1acc24..cae5181df4e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ReferenceVariantsCollector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ReferenceVariantsCollector.kt @@ -74,6 +74,8 @@ class ReferenceVariantsCollector( return variants } + private val GET_SET_PREFIXES = listOf("get", "set", "ge", "se", "g", "s") + private fun doCollectReferenceVariants(descriptorKindFilter: DescriptorKindFilter): ReferenceVariants { val completeExtensionsFromIndices = descriptorKindFilter.kindMask.and(DescriptorKindFilter.CALLABLES_MASK) != 0 && DescriptorKindExclude.Extensions !in descriptorKindFilter.excludes @@ -97,10 +99,9 @@ class ReferenceVariantsCollector( var variants = getReferenceVariants(descriptorKindFilter, descriptorNameFilter.toNameFilter()) - val getOrSetPrefix = listOf("get", "set", "ge", "se", "g", "s").firstOrNull { prefix.startsWith(it) } - val additionalPropertyNameFilter: ((String) -> Boolean)? = run { - getOrSetPrefix?.let { prefixMatcher.cloneWithPrefix(prefix.removePrefix(getOrSetPrefix).decapitalizeSmart()).asStringNameFilter() } - } + val getOrSetPrefix = GET_SET_PREFIXES.firstOrNull { prefix.startsWith(it) } + val additionalPropertyNameFilter: ((String) -> Boolean)? = getOrSetPrefix + ?.let { prefixMatcher.cloneWithPrefix(prefix.removePrefix(getOrSetPrefix).decapitalizeSmart()).asStringNameFilter() } if (additionalPropertyNameFilter != null) { variants += getReferenceVariants(descriptorKindFilter.intersect(DescriptorKindFilter.VARIABLES), additionalPropertyNameFilter.toNameFilter())