Completion: non-imported elements are added to the list later
This commit is contained in:
@@ -75,7 +75,8 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
resultSet: CompletionResultSet)
|
resultSet: CompletionResultSet)
|
||||||
: CompletionSessionBase(configuration, parameters, resultSet) {
|
: CompletionSessionBase(configuration, parameters, resultSet) {
|
||||||
|
|
||||||
private val collector: LookupElementsCollector = LookupElementsCollector(prefixMatcher, resolveSession, { isVisibleDescriptor(it) })
|
private val collector = LookupElementsCollector(prefixMatcher, resolveSession, { isVisibleDescriptor(it) })
|
||||||
|
private var anythingAdded = false
|
||||||
|
|
||||||
private val project = position.getProject()
|
private val project = position.getProject()
|
||||||
private val indicesHelper = KotlinIndicesHelper(project)
|
private val indicesHelper = KotlinIndicesHelper(project)
|
||||||
@@ -85,16 +86,10 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
public fun complete(): Boolean {
|
public fun complete(): Boolean {
|
||||||
assert(parameters.getCompletionType() == CompletionType.BASIC)
|
assert(parameters.getCompletionType() == CompletionType.BASIC)
|
||||||
|
|
||||||
collectElements()
|
|
||||||
|
|
||||||
collector.flushToResultSet(resultSet)
|
|
||||||
|
|
||||||
return !collector.isEmpty
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun collectElements() {
|
|
||||||
if (!NamedParametersCompletion.isOnlyNamedParameterExpected(position)) {
|
if (!NamedParametersCompletion.isOnlyNamedParameterExpected(position)) {
|
||||||
if (jetReference != null && !isOnlyKeywordCompletion()) {
|
val completeReference = jetReference != null && !isOnlyKeywordCompletion()
|
||||||
|
|
||||||
|
if (completeReference) {
|
||||||
if (shouldRunOnlyTypeCompletion()) {
|
if (shouldRunOnlyTypeCompletion()) {
|
||||||
if (configuration.completeNonImportedDeclarations) {
|
if (configuration.completeNonImportedDeclarations) {
|
||||||
TypesCompletion(parameters, resolveSession, prefixMatcher).addAllTypes(collector)
|
TypesCompletion(parameters, resolveSession, prefixMatcher).addAllTypes(collector)
|
||||||
@@ -106,15 +101,27 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addReferenceVariants()
|
addReferenceVariants()
|
||||||
|
|
||||||
addNonImported()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeywordCompletion().complete(parameters, collector)
|
KeywordCompletion().complete(parameters, collector)
|
||||||
|
|
||||||
|
if (completeReference && !shouldRunOnlyTypeCompletion()) {
|
||||||
|
addNonImported()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedParametersCompletion.complete(position, collector)
|
NamedParametersCompletion.complete(position, collector)
|
||||||
|
|
||||||
|
flushToResultSet()
|
||||||
|
return anythingAdded
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun flushToResultSet() {
|
||||||
|
if (!collector.isEmpty) {
|
||||||
|
anythingAdded = true
|
||||||
|
}
|
||||||
|
collector.flushToResultSet(resultSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addNonImported() {
|
private fun addNonImported() {
|
||||||
@@ -127,6 +134,8 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
if (PsiTreeUtil.getParentOfType(jetReference!!.expression, javaClass<JetDotQualifiedExpression>()) == null) return
|
if (PsiTreeUtil.getParentOfType(jetReference!!.expression, javaClass<JetDotQualifiedExpression>()) == null) return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flushToResultSet()
|
||||||
|
|
||||||
if (shouldRunTopLevelCompletion()) {
|
if (shouldRunTopLevelCompletion()) {
|
||||||
TypesCompletion(parameters, resolveSession, prefixMatcher).addAllTypes(collector)
|
TypesCompletion(parameters, resolveSession, prefixMatcher).addAllTypes(collector)
|
||||||
addKotlinTopLevelDeclarations()
|
addKotlinTopLevelDeclarations()
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class LookupElementsCollector(private val prefixMatcher: PrefixMatcher,
|
|||||||
|
|
||||||
public fun flushToResultSet(resultSet: CompletionResultSet) {
|
public fun flushToResultSet(resultSet: CompletionResultSet) {
|
||||||
resultSet.addAllElements(elements)
|
resultSet.addAllElements(elements)
|
||||||
|
elements.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
public val isEmpty: Boolean
|
public val isEmpty: Boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user