Fixed KT-5046 No autocompletion for not imported extension properties
#KT-5046 Fixed
This commit is contained in:
@@ -201,7 +201,6 @@ public class JetShortNamesCache(private val project: Project) : PsiShortNamesCac
|
||||
public fun getJetTopLevelCallables(nameFilter: (String) -> Boolean, context: JetExpression /*TODO: to be dropped*/, resolveSession: ResolveSessionForBodies, scope: GlobalSearchScope): Collection<DeclarationDescriptor> {
|
||||
val result = ArrayList<DeclarationDescriptor>()
|
||||
|
||||
|
||||
val sourceNames = JetTopLevelFunctionsFqnNameIndex.getInstance().getAllKeys(project).stream() + JetTopLevelPropertiesFqnNameIndex.getInstance().getAllKeys(project).stream()
|
||||
val allFqNames = sourceNames.map { FqName(it) } + JetFromJavaDescriptorHelper.getTopLevelCallableFqNames(project, scope, false).stream()
|
||||
|
||||
@@ -213,7 +212,6 @@ public class JetShortNamesCache(private val project: Project) : PsiShortNamesCac
|
||||
return result
|
||||
}
|
||||
|
||||
// TODO: Make it work for properties
|
||||
public fun getJetCallableExtensions(nameFilter: (String) -> Boolean,
|
||||
expression: JetSimpleNameExpression,
|
||||
resolveSession: ResolveSessionForBodies,
|
||||
@@ -227,39 +225,14 @@ public class JetShortNamesCache(private val project: Project) : PsiShortNamesCac
|
||||
return listOf()
|
||||
}
|
||||
|
||||
val functionFQNs = extensionFunctionsFromSourceFqNames(nameFilter, scope)
|
||||
|
||||
JetFromJavaDescriptorHelper.getTopLevelCallableFqNames(project, scope, true)
|
||||
.filterTo(functionFQNs) { nameFilter(it.shortName().asString()) }
|
||||
val sourceNames = JetTopLevelFunctionsFqnNameIndex.getInstance().getAllKeys(project).stream() + JetTopLevelPropertiesFqnNameIndex.getInstance().getAllKeys(project).stream()
|
||||
val allFqNames = sourceNames.map { FqName(it) } + JetFromJavaDescriptorHelper.getTopLevelCallableFqNames(project, scope, true).stream()
|
||||
|
||||
// Iterate through the function with attempt to resolve found functions
|
||||
return functionFQNs.flatMap { ExpressionTypingUtils.canFindSuitableCall(it, receiverExpression, expressionType, jetScope, resolveSession.getModuleDescriptor()) }
|
||||
}
|
||||
|
||||
private fun extensionFunctionsFromSourceFqNames(nameFilter: (String) -> Boolean, scope: GlobalSearchScope): HashSet<FqName> {
|
||||
val extensionFunctionNames = HashSet(JetTopLevelExtensionFunctionShortNameIndex.getInstance().getAllKeys(project))
|
||||
|
||||
val functionFQNs = HashSet<FqName>()
|
||||
|
||||
// Collect all possible extension function qualified names
|
||||
for (name in extensionFunctionNames) {
|
||||
if (nameFilter(name)) {
|
||||
val extensionFunctions = getJetExtensionFunctionsByName(name, scope)
|
||||
|
||||
for (extensionFunction in extensionFunctions) {
|
||||
if (extensionFunction is JetNamedFunction) {
|
||||
functionFQNs.add(extensionFunction.getFqName()!!)
|
||||
}
|
||||
else if (extensionFunction is PsiMethod) {
|
||||
val functionFQN = JetFromJavaDescriptorHelper.getJetTopLevelDeclarationFQN(extensionFunction)
|
||||
if (functionFQN != null) {
|
||||
functionFQNs.add(functionFQN)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return functionFQNs
|
||||
return allFqNames
|
||||
.filter { nameFilter(it.shortName().asString()) }
|
||||
.toList()
|
||||
.flatMap { ExpressionTypingUtils.canFindSuitableCall(it, receiverExpression, expressionType, jetScope, resolveSession.getModuleDescriptor()) }
|
||||
}
|
||||
|
||||
public fun getJetClassesDescriptors(acceptedShortNameCondition: (String) -> Boolean, analyzer: KotlinCodeAnalyzer, scope: GlobalSearchScope): Collection<ClassDescriptor> {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package testing
|
||||
|
||||
fun someFun() {
|
||||
"".hello<caret>
|
||||
}
|
||||
|
||||
// EXIST: helloProp1, helloProp2
|
||||
// ABSENT: helloProp3, helloProp4
|
||||
@@ -0,0 +1,6 @@
|
||||
package abc
|
||||
|
||||
public val String.helloProp1: Int get() = 1
|
||||
public val String.helloProp2: Int get() = 2
|
||||
public val Int.helloProp3: Int get() = 3
|
||||
public val helloProp4: Int = 4
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package abc
|
||||
|
||||
val String.helloProp1: Int get() = 1
|
||||
val String.helloProp2: Int get() = 2
|
||||
val Int.helloProp3: Int get() = 3
|
||||
val helloProp4: Int = 4
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package first
|
||||
|
||||
fun firstFun() {
|
||||
val a = ""
|
||||
a.hello<caret>
|
||||
}
|
||||
|
||||
// EXIST: helloProp1
|
||||
// EXIST: helloProp2
|
||||
// ABSENT: helloProp3
|
||||
// ABSENT: helloProp4
|
||||
// NUMBER: 2
|
||||
Reference in New Issue
Block a user