Non-imported top-level functions completion does not require second press
This commit is contained in:
+6
-4
@@ -108,9 +108,11 @@ class BasicCompletionSession(
|
||||
return ALL
|
||||
}
|
||||
|
||||
public fun shouldDisableAutoPopup(): Boolean {
|
||||
return completionKind.shouldDisableAutoPopup()
|
||||
}
|
||||
fun shouldDisableAutoPopup(): Boolean
|
||||
= completionKind.shouldDisableAutoPopup()
|
||||
|
||||
override fun shouldCompleteTopLevelCallablesFromIndex()
|
||||
= super.shouldCompleteTopLevelCallablesFromIndex() && prefix.isNotEmpty()
|
||||
|
||||
override fun doComplete() {
|
||||
assert(parameters.completionType == CompletionType.BASIC)
|
||||
@@ -255,7 +257,7 @@ class BasicCompletionSession(
|
||||
else -> classKindFilter = null
|
||||
}
|
||||
if (classKindFilter != null) {
|
||||
if (configuration.completeNonImportedDeclarations) {
|
||||
if (configuration.completeNonImportedClasses) {
|
||||
addClassesFromIndex(classKindFilter)
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||
import java.util.*
|
||||
|
||||
class CompletionSessionConfiguration(
|
||||
val completeNonImportedDeclarations: Boolean,
|
||||
val completeNonImportedClasses: Boolean,
|
||||
val completeNonAccessibleDeclarations: Boolean,
|
||||
val filterOutJavaGettersAndSetters: Boolean,
|
||||
val completeJavaClassesNotToBeUsed: Boolean,
|
||||
@@ -62,7 +62,7 @@ class CompletionSessionConfiguration(
|
||||
)
|
||||
|
||||
fun CompletionSessionConfiguration(parameters: CompletionParameters) = CompletionSessionConfiguration(
|
||||
completeNonImportedDeclarations = parameters.invocationCount >= 2,
|
||||
completeNonImportedClasses = parameters.invocationCount >= 2,
|
||||
completeNonAccessibleDeclarations = parameters.invocationCount >= 2,
|
||||
filterOutJavaGettersAndSetters = parameters.invocationCount < 2,
|
||||
completeJavaClassesNotToBeUsed = parameters.invocationCount >= 2,
|
||||
@@ -389,8 +389,8 @@ abstract class CompletionSession(
|
||||
return result
|
||||
}
|
||||
|
||||
protected fun shouldCompleteTopLevelCallablesFromIndex(): Boolean {
|
||||
if (!configuration.completeNonImportedDeclarations) return false
|
||||
protected open fun shouldCompleteTopLevelCallablesFromIndex(): Boolean {
|
||||
if (nameExpression == null) return false
|
||||
if ((descriptorKindFilter?.kindMask ?: 0).and(DescriptorKindFilter.CALLABLES_MASK) == 0) return false
|
||||
if (callTypeAndReceiver is CallTypeAndReceiver.IMPORT_DIRECTIVE) return false
|
||||
return callTypeAndReceiver.receiver == null
|
||||
|
||||
+1
-1
@@ -260,7 +260,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
||||
if (!somethingAdded && parameters.invocationCount < 2) {
|
||||
// Rerun completion if nothing was found
|
||||
val newConfiguration = CompletionSessionConfiguration(
|
||||
completeNonImportedDeclarations = true,
|
||||
completeNonImportedClasses = true,
|
||||
completeNonAccessibleDeclarations = false,
|
||||
filterOutJavaGettersAndSetters = false,
|
||||
completeJavaClassesNotToBeUsed = false,
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package dependency
|
||||
|
||||
fun topLevelFun(){}
|
||||
fun xxx_topLevelFun(){}
|
||||
|
||||
val topLevelVal: Int = 1
|
||||
val xxx_topLevelVal: Int = 1
|
||||
|
||||
fun CharSequence.extFun(){}
|
||||
fun CharSequence.xxx_extFun(){}
|
||||
|
||||
+4
-5
@@ -1,8 +1,7 @@
|
||||
fun String.foo() {
|
||||
val v = ::<caret>
|
||||
val v = ::xxx_<caret>
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// EXIST: topLevelFun
|
||||
// EXIST: topLevelVal
|
||||
// ABSENT: extFun
|
||||
// EXIST: xxx_topLevelFun
|
||||
// EXIST: xxx_topLevelVal
|
||||
// ABSENT: xxx_extFun
|
||||
|
||||
-1
@@ -8,5 +8,4 @@ fun firstFun() {
|
||||
a.<caret>
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// EXIST: secondExtension
|
||||
-1
@@ -7,7 +7,6 @@ fun String.foo() {
|
||||
hid<caret>
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// ABSENT: hiddenFun
|
||||
// ABSENT: hiddenProperty
|
||||
// ABSENT: hiddenFunFromSameFile
|
||||
|
||||
idea/idea-completion/testData/basic/multifile/NotImportedInfixExtension/NotImportedInfixExtension.kt
Vendored
-1
@@ -6,7 +6,6 @@ fun f() {
|
||||
C() <caret>
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// ABSENT: "xxx"
|
||||
// EXIST: { lookupString: "yyy", attributes: "bold" }
|
||||
// ABSENT: "zzz"
|
||||
|
||||
-1
@@ -10,7 +10,6 @@ class C {
|
||||
}
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// EXIST: { lookupString: "xxx", itemText: "xxx", tailText: "()", typeText: "Unit" }
|
||||
// EXIST: { lookupString: "xxy", itemText: "xxy", tailText: "()", typeText: "Unit" }
|
||||
// EXIST: { lookupString: "xxz", itemText: "xxz", tailText: "(p: Int)", typeText: "Unit" }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(){
|
||||
val l : java.lang.Thread = <caret>
|
||||
val l: java.lang.Thread = <caret>
|
||||
}
|
||||
|
||||
// ELEMENT: currentThread
|
||||
// ELEMENT_TEXT: Thread.currentThread
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(){
|
||||
val l : java.lang.Thread = Thread.currentThread()<caret>
|
||||
val l: java.lang.Thread = Thread.currentThread()<caret>
|
||||
}
|
||||
|
||||
// ELEMENT: currentThread
|
||||
// ELEMENT_TEXT: Thread.currentThread
|
||||
|
||||
-1
@@ -6,6 +6,5 @@ fun bar(p: () -> Unit) { }
|
||||
fun bar(p: String.() -> Unit) { }
|
||||
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// EXIST: topLevelFun
|
||||
// ABSENT: extFun
|
||||
|
||||
Reference in New Issue
Block a user