More correct shadowed declarations filtering in completion
This commit is contained in:
+1
-1
@@ -172,7 +172,7 @@ class BasicCompletionSession(
|
||||
val contextVariableTypesForSmartCompletion = withCollectRequiredContextVariableTypes(::completeWithSmartCompletion)
|
||||
|
||||
fun completeReferenceVariants(lookupElementFactory: LookupElementFactory) {
|
||||
val (imported, notImported) = referenceVariants!!
|
||||
val (imported, notImported) = referenceVariantsWithNonInitializedVarExcluded!!
|
||||
collector.addDescriptorElements(imported, lookupElementFactory)
|
||||
collector.addDescriptorElements(notImported, lookupElementFactory, notImported = true)
|
||||
}
|
||||
|
||||
@@ -284,6 +284,9 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
if (nameExpression != null && descriptorKindFilter != null) collectReferenceVariants(descriptorKindFilter!!, nameExpression) else null
|
||||
}
|
||||
|
||||
protected val referenceVariantsWithNonInitializedVarExcluded: ReferenceVariants? by lazy {
|
||||
referenceVariants?.let { ReferenceVariants(referenceVariantsHelper.excludeNonInitializedVariable(it.imported, position), it.notImportedExtensions) }
|
||||
}
|
||||
|
||||
private fun collectReferenceVariants(descriptorKindFilter: DescriptorKindFilter, nameExpression: KtSimpleNameExpression, runtimeReceiver: ExpressionReceiver? = null): ReferenceVariants {
|
||||
var variants = referenceVariantsHelper.getReferenceVariants(
|
||||
@@ -292,6 +295,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
descriptorNameFilter,
|
||||
filterOutJavaGettersAndSetters = false,
|
||||
filterOutShadowed = false,
|
||||
excludeNonInitializedVariable = false,
|
||||
useReceiverType = runtimeReceiver?.type)
|
||||
|
||||
val shadowedDeclarationsFilter = if (runtimeReceiver != null)
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para
|
||||
val filter = smartCompletion!!.descriptorFilter
|
||||
var contextVariableTypesForReferenceVariants = filter?.let {
|
||||
withCollectRequiredContextVariableTypes { lookupElementFactory ->
|
||||
val (imported, notImported) = referenceVariants ?: return@withCollectRequiredContextVariableTypes
|
||||
val (imported, notImported) = referenceVariantsWithNonInitializedVarExcluded ?: return@withCollectRequiredContextVariableTypes
|
||||
imported.forEach { collector.addElements(filter(it, lookupElementFactory)) }
|
||||
notImported.forEach { collector.addElements(filter(it, lookupElementFactory), notImported = true) }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
val xxx: String = ""
|
||||
|
||||
class C {
|
||||
val xxx = x<caret>
|
||||
}
|
||||
|
||||
// ABSENT: xxx
|
||||
+6
@@ -1929,6 +1929,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InInitializer7.kt")
|
||||
public void testInInitializer7() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/InInitializer7.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Locals1.kt")
|
||||
public void testLocals1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/Locals1.kt");
|
||||
|
||||
+6
@@ -1929,6 +1929,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InInitializer7.kt")
|
||||
public void testInInitializer7() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/InInitializer7.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Locals1.kt")
|
||||
public void testLocals1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/Locals1.kt");
|
||||
|
||||
Reference in New Issue
Block a user