Refactoring
This commit is contained in:
-4
@@ -165,10 +165,6 @@ class BasicCompletionSession(
|
|||||||
filter = filter.exclude(DescriptorKindExclude.TopLevelPackages)
|
filter = filter.exclude(DescriptorKindExclude.TopLevelPackages)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callTypeAndReceiver.shouldCompleteCallableExtensions()) {
|
|
||||||
filter = filter.exclude(TopLevelExtensionsExclude) // completed via indices
|
|
||||||
}
|
|
||||||
|
|
||||||
filter
|
filter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ abstract class CompletionSession(
|
|||||||
parameters.position.containingFile,
|
parameters.position.containingFile,
|
||||||
parameters.offset,
|
parameters.offset,
|
||||||
kotlinIdentifierPartPattern or singleCharPattern('@'),
|
kotlinIdentifierPartPattern or singleCharPattern('@'),
|
||||||
kotlinIdentifierStartPattern)
|
kotlinIdentifierStartPattern)!!
|
||||||
|
|
||||||
protected val prefixMatcher = CamelHumpMatcher(prefix)
|
protected val prefixMatcher = CamelHumpMatcher(prefix)
|
||||||
|
|
||||||
@@ -303,6 +303,14 @@ abstract class CompletionSession(
|
|||||||
nameExpression: KtSimpleNameExpression,
|
nameExpression: KtSimpleNameExpression,
|
||||||
runtimeReceiver: ExpressionReceiver? = null
|
runtimeReceiver: ExpressionReceiver? = null
|
||||||
): ReferenceVariants {
|
): ReferenceVariants {
|
||||||
|
val completeExtensionsFromIndices = descriptorKindFilter.kindMask.and(DescriptorKindFilter.CALLABLES_MASK) != 0
|
||||||
|
&& callTypeAndReceiver !is CallTypeAndReceiver.IMPORT_DIRECTIVE
|
||||||
|
@Suppress("NAME_SHADOWING")
|
||||||
|
val descriptorKindFilter = if (completeExtensionsFromIndices)
|
||||||
|
descriptorKindFilter exclude TopLevelExtensionsExclude // handled via indices
|
||||||
|
else
|
||||||
|
descriptorKindFilter
|
||||||
|
|
||||||
fun getReferenceVariants(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
fun getReferenceVariants(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||||
return referenceVariantsHelper.getReferenceVariants(
|
return referenceVariantsHelper.getReferenceVariants(
|
||||||
nameExpression,
|
nameExpression,
|
||||||
@@ -327,7 +335,7 @@ abstract class CompletionSession(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var notImportedExtensions: Collection<CallableDescriptor> = emptyList()
|
var notImportedExtensions: Collection<CallableDescriptor> = emptyList()
|
||||||
if (callTypeAndReceiver.shouldCompleteCallableExtensions()) {
|
if (completeExtensionsFromIndices) {
|
||||||
val indicesHelper = indicesHelper(true)
|
val indicesHelper = indicesHelper(true)
|
||||||
val nameFilter = if (additionalPropertyNameFilter != null)
|
val nameFilter = if (additionalPropertyNameFilter != null)
|
||||||
descriptorNameFilter or additionalPropertyNameFilter
|
descriptorNameFilter or additionalPropertyNameFilter
|
||||||
@@ -434,11 +442,6 @@ abstract class CompletionSession(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun CallTypeAndReceiver<*, *>.shouldCompleteCallableExtensions(): Boolean {
|
|
||||||
return callType.descriptorKindFilter.kindMask.and(DescriptorKindFilter.CALLABLES_MASK) != 0
|
|
||||||
&& this !is CallTypeAndReceiver.IMPORT_DIRECTIVE
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun withCollectRequiredContextVariableTypes(action: (LookupElementFactory) -> Unit): Collection<FuzzyType> {
|
protected fun withCollectRequiredContextVariableTypes(action: (LookupElementFactory) -> Unit): Collection<FuzzyType> {
|
||||||
val provider = CollectRequiredTypesContextVariablesProvider()
|
val provider = CollectRequiredTypesContextVariablesProvider()
|
||||||
val lookupElementFactory = createLookupElementFactory(provider)
|
val lookupElementFactory = createLookupElementFactory(provider)
|
||||||
|
|||||||
-2
@@ -47,8 +47,6 @@ class SmartCompletionSession(
|
|||||||
// 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
|
||||||
var filter = DescriptorKindFilter.VALUES exclude SamConstructorDescriptorKindExclude
|
var filter = DescriptorKindFilter.VALUES exclude SamConstructorDescriptorKindExclude
|
||||||
|
|
||||||
filter = filter exclude TopLevelExtensionsExclude // handled via indices
|
|
||||||
|
|
||||||
if (smartCompletion?.expectedInfos?.filterFunctionExpected()?.isNotEmpty() ?: false) {
|
if (smartCompletion?.expectedInfos?.filterFunctionExpected()?.isNotEmpty() ?: false) {
|
||||||
// if function type is expected we need classes to obtain their constructors
|
// if function type is expected we need classes to obtain their constructors
|
||||||
filter = filter.withKinds(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS_MASK)
|
filter = filter.withKinds(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS_MASK)
|
||||||
|
|||||||
Reference in New Issue
Block a user