Fixed extension properties not completed after "get"
This commit is contained in:
@@ -118,17 +118,16 @@ abstract class CompletionSession(
|
|||||||
|
|
||||||
protected val prefixMatcher = CamelHumpMatcher(prefix)
|
protected val prefixMatcher = CamelHumpMatcher(prefix)
|
||||||
|
|
||||||
protected val descriptorNameFilter: (Name) -> Boolean = run {
|
private val descriptorStringNameFilter: (String) -> Boolean = run {
|
||||||
val nameFilter = prefixMatcher.asNameFilter()
|
val nameFilter = prefixMatcher.asStringNameFilter()
|
||||||
val getOrSetPrefix = listOf("get", "set", "ge", "se", "g", "s").firstOrNull { prefix.startsWith(it) }
|
val getOrSetPrefix = listOf("get", "set", "ge", "se", "g", "s").firstOrNull { prefix.startsWith(it) }
|
||||||
if (getOrSetPrefix != null)
|
if (getOrSetPrefix != null)
|
||||||
nameFilter or prefixMatcher.cloneWithPrefix(prefix.removePrefix(getOrSetPrefix).decapitalizeSmart()).asNameFilter()
|
prefixMatcher.cloneWithPrefix(prefix.removePrefix(getOrSetPrefix).decapitalizeSmart()).asStringNameFilter() or nameFilter
|
||||||
else
|
else
|
||||||
nameFilter
|
nameFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
private infix fun ((Name) -> Boolean).or(otherFilter: (Name) -> Boolean): (Name) -> Boolean
|
protected val descriptorNameFilter: (Name) -> Boolean = descriptorStringNameFilter.toNameFilter()
|
||||||
= { this(it) || otherFilter(it) }
|
|
||||||
|
|
||||||
protected val isVisibleFilter: (DeclarationDescriptor) -> Boolean = { isVisibleDescriptor(it, completeNonAccessible = configuration.completeNonAccessibleDeclarations) }
|
protected val isVisibleFilter: (DeclarationDescriptor) -> Boolean = { isVisibleDescriptor(it, completeNonAccessible = configuration.completeNonAccessibleDeclarations) }
|
||||||
protected val isVisibleFilterCheckAlways: (DeclarationDescriptor) -> Boolean = { isVisibleDescriptor(it, completeNonAccessible = false) }
|
protected val isVisibleFilterCheckAlways: (DeclarationDescriptor) -> Boolean = { isVisibleDescriptor(it, completeNonAccessible = false) }
|
||||||
@@ -318,12 +317,11 @@ abstract class CompletionSession(
|
|||||||
|
|
||||||
var notImportedExtensions: Collection<CallableDescriptor> = emptyList()
|
var notImportedExtensions: Collection<CallableDescriptor> = emptyList()
|
||||||
if (callTypeAndReceiver.shouldCompleteCallableExtensions()) {
|
if (callTypeAndReceiver.shouldCompleteCallableExtensions()) {
|
||||||
val nameFilter: (String) -> Boolean = { prefixMatcher.prefixMatches(it) }
|
|
||||||
val indicesHelper = indicesHelper(true)
|
val indicesHelper = indicesHelper(true)
|
||||||
val extensions = if (runtimeReceiver != null)
|
val extensions = if (runtimeReceiver != null)
|
||||||
indicesHelper.getCallableTopLevelExtensions(callTypeAndReceiver, listOf(runtimeReceiver.type), nameFilter)
|
indicesHelper.getCallableTopLevelExtensions(callTypeAndReceiver, listOf(runtimeReceiver.type), descriptorStringNameFilter)
|
||||||
else
|
else
|
||||||
indicesHelper.getCallableTopLevelExtensions(callTypeAndReceiver, expression!!, bindingContext, nameFilter)
|
indicesHelper.getCallableTopLevelExtensions(callTypeAndReceiver, expression!!, bindingContext, descriptorStringNameFilter)
|
||||||
|
|
||||||
val pair = extensions.partition { isImportableDescriptorImported(it) }
|
val pair = extensions.partition { isImportableDescriptorImported(it) }
|
||||||
variants += pair.first
|
variants += pair.first
|
||||||
|
|||||||
@@ -118,21 +118,19 @@ fun rethrowWithCancelIndicator(exception: ProcessCanceledException): ProcessCanc
|
|||||||
return exception
|
return exception
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PrefixMatcher.asNameFilter() = { name: Name ->
|
fun PrefixMatcher.asNameFilter(): (Name) -> Boolean {
|
||||||
if (name.isSpecial) {
|
return { name -> !name.isSpecial && prefixMatches(name.identifier) }
|
||||||
false
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
val identifier = name.identifier
|
|
||||||
if (prefix.startsWith("$")) { // we need properties from scope for backing field completion
|
|
||||||
prefixMatches("$" + identifier)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prefixMatches(identifier)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun PrefixMatcher.asStringNameFilter() = { name: String -> prefixMatches(name) }
|
||||||
|
|
||||||
|
fun ((String) -> Boolean).toNameFilter(): (Name) -> Boolean {
|
||||||
|
return { name -> !name.isSpecial && this(name.identifier) }
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun <T> ((T) -> Boolean).or(otherFilter: (T) -> Boolean): (T) -> Boolean
|
||||||
|
= { this(it) || otherFilter(it) }
|
||||||
|
|
||||||
fun LookupElementPresentation.prependTailText(text: String, grayed: Boolean) {
|
fun LookupElementPresentation.prependTailText(text: String, grayed: Boolean) {
|
||||||
val tails = tailFragments
|
val tails = tailFragments
|
||||||
clearTail()
|
clearTail()
|
||||||
|
|||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package dependency
|
||||||
|
|
||||||
|
val String.notImportedExtension: Int
|
||||||
|
get() = 0
|
||||||
Vendored
+9
@@ -0,0 +1,9 @@
|
|||||||
|
val String.thisFileExtension: Int
|
||||||
|
get() = 0
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
"".get<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: thisFileExtension
|
||||||
|
// EXIST: notImportedExtension
|
||||||
+6
@@ -119,6 +119,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ExtensionsAndGetPrefix")
|
||||||
|
public void testExtensionsAndGetPrefix() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExtensionsAndGetPrefix/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ExtensionsForSmartCast")
|
@TestMetadata("ExtensionsForSmartCast")
|
||||||
public void testExtensionsForSmartCast() throws Exception {
|
public void testExtensionsForSmartCast() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExtensionsForSmartCast/");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExtensionsForSmartCast/");
|
||||||
|
|||||||
Reference in New Issue
Block a user