KT-15286: Provide object member extensions in the completion
- Add extensions only when completion of static members is enabled (double ctrl + space and nonempty prefix) - Add full import for callables with receiver in `LookupElement.decorateAsStaticMember`
This commit is contained in:
committed by
Roman Golyshev
parent
15613afa20
commit
6560ecc82b
+13
-2
@@ -339,8 +339,19 @@ class BasicCompletionSession(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configuration.staticMembers && callTypeAndReceiver is CallTypeAndReceiver.DEFAULT && prefix.isNotEmpty()) {
|
if (configuration.staticMembers && prefix.isNotEmpty()) {
|
||||||
staticMembersCompletion.completeFromIndices(indicesHelper(false), collector)
|
if (!receiverTypes.isNullOrEmpty()) {
|
||||||
|
staticMembersCompletion.completeObjectMemberExtensionsFromIndices(
|
||||||
|
indicesHelper(false),
|
||||||
|
receiverTypes.map { it.type },
|
||||||
|
callTypeAndReceiver.callType,
|
||||||
|
collector
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callTypeAndReceiver is CallTypeAndReceiver.DEFAULT) {
|
||||||
|
staticMembersCompletion.completeFromIndices(indicesHelper(false), collector)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ fun LookupElement.decorateAsStaticMember(
|
|||||||
val qualifierPresentation = classDescriptor.name.asString()
|
val qualifierPresentation = classDescriptor.name.asString()
|
||||||
|
|
||||||
return object : LookupElementDecorator<LookupElement>(this) {
|
return object : LookupElementDecorator<LookupElement>(this) {
|
||||||
|
private val descriptorIsCallableExtension = (memberDescriptor as? CallableDescriptor)?.extensionReceiverParameter != null
|
||||||
override fun getAllLookupStrings(): Set<String> {
|
override fun getAllLookupStrings(): Set<String> {
|
||||||
return if (classNameAsLookupString) setOf(delegate.lookupString, qualifierPresentation) else super.getAllLookupStrings()
|
return if (classNameAsLookupString) setOf(delegate.lookupString, qualifierPresentation) else super.getAllLookupStrings()
|
||||||
}
|
}
|
||||||
@@ -381,7 +382,9 @@ fun LookupElement.decorateAsStaticMember(
|
|||||||
override fun renderElement(presentation: LookupElementPresentation) {
|
override fun renderElement(presentation: LookupElementPresentation) {
|
||||||
delegate.renderElement(presentation)
|
delegate.renderElement(presentation)
|
||||||
|
|
||||||
presentation.itemText = qualifierPresentation + "." + presentation.itemText
|
if (!descriptorIsCallableExtension) {
|
||||||
|
presentation.itemText = qualifierPresentation + "." + presentation.itemText
|
||||||
|
}
|
||||||
|
|
||||||
val tailText = " (" + DescriptorUtils.getFqName(classDescriptor.containingDeclaration) + ")"
|
val tailText = " (" + DescriptorUtils.getFqName(classDescriptor.containingDeclaration) + ")"
|
||||||
if (memberDescriptor is FunctionDescriptor) {
|
if (memberDescriptor is FunctionDescriptor) {
|
||||||
@@ -399,7 +402,11 @@ fun LookupElement.decorateAsStaticMember(
|
|||||||
val psiDocumentManager = PsiDocumentManager.getInstance(context.project)
|
val psiDocumentManager = PsiDocumentManager.getInstance(context.project)
|
||||||
val file = context.file as KtFile
|
val file = context.file as KtFile
|
||||||
|
|
||||||
val addMemberImport = file.importDirectives.any { !it.isAllUnder && it.importPath?.fqName?.parent() == containerFqName }
|
fun importFromSameParentIsPresent() = file.importDirectives.any {
|
||||||
|
!it.isAllUnder && it.importPath?.fqName?.parent() == containerFqName
|
||||||
|
}
|
||||||
|
|
||||||
|
val addMemberImport = descriptorIsCallableExtension || importFromSameParentIsPresent()
|
||||||
|
|
||||||
if (addMemberImport) {
|
if (addMemberImport) {
|
||||||
psiDocumentManager.commitAllDocuments()
|
psiDocumentManager.commitAllDocuments()
|
||||||
|
|||||||
+46
@@ -26,6 +26,8 @@ import org.jetbrains.kotlin.idea.codeInsight.collectSyntheticStaticMembersAndCon
|
|||||||
import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper
|
import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper
|
||||||
import org.jetbrains.kotlin.idea.core.targetDescriptors
|
import org.jetbrains.kotlin.idea.core.targetDescriptors
|
||||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||||
|
import org.jetbrains.kotlin.idea.util.CallType
|
||||||
|
import org.jetbrains.kotlin.idea.util.substituteExtensionIfCallable
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.KtClass
|
import org.jetbrains.kotlin.psi.KtClass
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
@@ -35,6 +37,7 @@ import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
|
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class StaticMembersCompletion(
|
class StaticMembersCompletion(
|
||||||
@@ -117,6 +120,19 @@ class StaticMembersCompletion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun processObjectMemberExtensions(indicesHelper: KotlinIndicesHelper, processor: (CallableDescriptor) -> Unit) {
|
||||||
|
val descriptorKindFilter = DescriptorKindFilter.CALLABLES exclude DescriptorKindExclude.NonExtensions
|
||||||
|
val nameFilter: (String) -> Boolean = { prefixMatcher.prefixMatches(it) }
|
||||||
|
|
||||||
|
val filter = { _: KtNamedDeclaration, _: KtObjectDeclaration -> true }
|
||||||
|
|
||||||
|
indicesHelper.processObjectMembers(descriptorKindFilter, nameFilter, filter) {
|
||||||
|
if (it !in alreadyAdded && it is CallableDescriptor) {
|
||||||
|
processor(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun KtObjectDeclaration.isTopLevelOrCompanion(): Boolean {
|
private fun KtObjectDeclaration.isTopLevelOrCompanion(): Boolean {
|
||||||
if (isCompanion()) {
|
if (isCompanion()) {
|
||||||
val owner = parent.parent as? KtClass ?: return false
|
val owner = parent.parent as? KtClass ?: return false
|
||||||
@@ -134,6 +150,36 @@ class StaticMembersCompletion(
|
|||||||
.forEach { collector.addElement(it) }
|
.forEach { collector.addElement(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects extensions declared as members in objects into [collector], for example:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* object Obj {
|
||||||
|
* fun String.foo() {}
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* `foo` here is object member extension.
|
||||||
|
*/
|
||||||
|
fun completeObjectMemberExtensionsFromIndices(
|
||||||
|
indicesHelper: KotlinIndicesHelper,
|
||||||
|
receiverTypes: Collection<KotlinType>,
|
||||||
|
callType: CallType<*>,
|
||||||
|
collector: LookupElementsCollector
|
||||||
|
) {
|
||||||
|
val factory = decoratedLookupElementFactory(ItemPriority.STATIC_MEMBER)
|
||||||
|
processObjectMemberExtensions(indicesHelper) { objectMemberDescriptor ->
|
||||||
|
val substitutedExtensions = objectMemberDescriptor.substituteExtensionIfCallable(receiverTypes, callType)
|
||||||
|
|
||||||
|
for (substituted in substitutedExtensions) {
|
||||||
|
val lookups = factory.createStandardLookupElementsForDescriptor(substituted, useReceiverTypes = true)
|
||||||
|
lookups.forEach { collector.addElement(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
collector.flushToResultSet()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun completeFromIndices(indicesHelper: KotlinIndicesHelper, collector: LookupElementsCollector) {
|
fun completeFromIndices(indicesHelper: KotlinIndicesHelper, collector: LookupElementsCollector) {
|
||||||
val factory = decoratedLookupElementFactory(ItemPriority.STATIC_MEMBER)
|
val factory = decoratedLookupElementFactory(ItemPriority.STATIC_MEMBER)
|
||||||
processMembersFromIndices(indicesHelper) {
|
processMembersFromIndices(indicesHelper) {
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
class A {
|
||||||
|
companion object {
|
||||||
|
fun T.fooExtension() {}
|
||||||
|
val T.fooProperty get() = 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooExtension", itemText: "fooExtension" }
|
||||||
|
// EXIST: { lookupString: "fooProperty", itemText: "fooProperty" }
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
class A {
|
||||||
|
companion object {
|
||||||
|
fun T.fooExtension() {}
|
||||||
|
val T.fooProperty get() = 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooExtension", itemText: "fooExtension" }
|
||||||
|
// EXIST: { lookupString: "fooProperty", itemText: "fooProperty" }
|
||||||
Vendored
+35
@@ -0,0 +1,35 @@
|
|||||||
|
interface T
|
||||||
|
interface B: T
|
||||||
|
interface C: T
|
||||||
|
|
||||||
|
object A {
|
||||||
|
fun Any.fooForAny() {}
|
||||||
|
|
||||||
|
fun T.fooForT() {}
|
||||||
|
fun B.fooForB() {}
|
||||||
|
fun C.fooForC() {}
|
||||||
|
|
||||||
|
fun <TT> TT.fooForAnyGeneric() {}
|
||||||
|
fun <TT: T> TT.fooForTGeneric() {}
|
||||||
|
fun <TT: B> TT.fooForBGeneric() {}
|
||||||
|
fun <TT: C> TT.fooForCGeneric() {}
|
||||||
|
|
||||||
|
fun fooNoReceiver() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(b: B) {
|
||||||
|
b.foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooForAny", itemText: "fooForAny" }
|
||||||
|
|
||||||
|
// EXIST: { lookupString: "fooForT", itemText: "fooForT" }
|
||||||
|
// EXIST: { lookupString: "fooForB", itemText: "fooForB" }
|
||||||
|
|
||||||
|
// EXIST: { lookupString: "fooForTGeneric", itemText: "fooForTGeneric" }
|
||||||
|
// EXIST: { lookupString: "fooForBGeneric", itemText: "fooForBGeneric" }
|
||||||
|
|
||||||
|
// ABSENT: fooForC
|
||||||
|
// ABSENT: fooForCGeneric
|
||||||
|
// ABSENT: fooNoReceiver
|
||||||
Vendored
+36
@@ -0,0 +1,36 @@
|
|||||||
|
interface T
|
||||||
|
interface B: T
|
||||||
|
interface C: T
|
||||||
|
|
||||||
|
object A {
|
||||||
|
fun Any.fooForAny() {}
|
||||||
|
|
||||||
|
fun T.fooForT() {}
|
||||||
|
fun B.fooForB() {}
|
||||||
|
fun C.fooForC() {}
|
||||||
|
|
||||||
|
fun <TT> TT.fooForAnyGeneric() {}
|
||||||
|
fun <TT: T> TT.fooForTGeneric() {}
|
||||||
|
fun <TT: B> TT.fooForBGeneric() {}
|
||||||
|
fun <TT: C> TT.fooForCGeneric() {}
|
||||||
|
|
||||||
|
fun fooNoReceiver() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun B.usage() {
|
||||||
|
foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooForAny", itemText: "fooForAny" }
|
||||||
|
|
||||||
|
// EXIST: { lookupString: "fooForT", itemText: "fooForT" }
|
||||||
|
// EXIST: { lookupString: "fooForB", itemText: "fooForB" }
|
||||||
|
|
||||||
|
// EXIST: { lookupString: "fooForTGeneric", itemText: "fooForTGeneric" }
|
||||||
|
// EXIST: { lookupString: "fooForBGeneric", itemText: "fooForBGeneric" }
|
||||||
|
|
||||||
|
// EXIST: fooNoReceiver
|
||||||
|
|
||||||
|
// ABSENT: fooForC
|
||||||
|
// ABSENT: fooForCGeneric
|
||||||
Vendored
+24
@@ -0,0 +1,24 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
object O {
|
||||||
|
fun A.fooForA() {}
|
||||||
|
fun A.B.fooForB() {}
|
||||||
|
fun A.B.C.fooForC() {}
|
||||||
|
fun T.fooForT() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
inner class B {
|
||||||
|
fun T.usage() {
|
||||||
|
foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class C {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooForA", itemText: "fooForA" }
|
||||||
|
// EXIST: { lookupString: "fooForB", itemText: "fooForB" }
|
||||||
|
// EXIST: { lookupString: "fooForT", itemText: "fooForT" }
|
||||||
|
// ABSENT: fooForC
|
||||||
Vendored
+14
@@ -0,0 +1,14 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
object A {
|
||||||
|
fun T.fooExtension() {}
|
||||||
|
val T.fooProperty get() = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooExtension", itemText: "fooExtension" }
|
||||||
|
// EXIST: { lookupString: "fooProperty", itemText: "fooProperty" }
|
||||||
Vendored
+14
@@ -0,0 +1,14 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
object A {
|
||||||
|
fun T.fooExtension() {}
|
||||||
|
val T.fooProperty get() = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooExtension", itemText: "fooExtension" }
|
||||||
|
// EXIST: { lookupString: "fooProperty", itemText: "fooProperty" }
|
||||||
Vendored
+19
@@ -0,0 +1,19 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
interface Foo {
|
||||||
|
fun T.fooExtension()
|
||||||
|
val T.fooProperty: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
object A : Foo {
|
||||||
|
override fun T.fooExtension() {}
|
||||||
|
override val T.fooProperty get() = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
foo<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: { lookupString: "fooExtension", itemText: "fooExtension" }
|
||||||
|
// EXIST: { lookupString: "fooProperty", itemText: "fooProperty" }
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
class T {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import T.Companion.foo
|
||||||
|
|
||||||
|
class T {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
class T {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import T.Companion.foo
|
||||||
|
|
||||||
|
class T {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
class A {
|
||||||
|
class B {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import A.B.Companion.foo
|
||||||
|
|
||||||
|
class T
|
||||||
|
|
||||||
|
class A {
|
||||||
|
class B {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
class A {
|
||||||
|
class B {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import A.B.Companion.foo
|
||||||
|
|
||||||
|
class T
|
||||||
|
|
||||||
|
class A {
|
||||||
|
class B {
|
||||||
|
companion object {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
object TopLevel {
|
||||||
|
object Nested {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
import TopLevel.Nested.foo
|
||||||
|
|
||||||
|
class T
|
||||||
|
|
||||||
|
object TopLevel {
|
||||||
|
object Nested {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
object TopLevel {
|
||||||
|
object Nested {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
import TopLevel.Nested.foo
|
||||||
|
|
||||||
|
class T
|
||||||
|
|
||||||
|
object TopLevel {
|
||||||
|
object Nested {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
object Extensions {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import Extensions.foo
|
||||||
|
|
||||||
|
class T
|
||||||
|
|
||||||
|
object Extensions {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage(t: T) {
|
||||||
|
t.foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
class T
|
||||||
|
|
||||||
|
object Extensions {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
f<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import Extensions.foo
|
||||||
|
|
||||||
|
class T
|
||||||
|
|
||||||
|
object Extensions {
|
||||||
|
fun T.foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun T.usage() {
|
||||||
|
foo()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// ELEMENT: foo
|
||||||
+53
@@ -1229,6 +1229,59 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/idea-completion/testData/basic/common/extensionMethodInObject")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ExtensionMethodInObject extends AbstractJSBasicCompletionTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInExtensionMethodInObject() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/extensionMethodInObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectExplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CompanionObjectExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectImplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CompanionObjectImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CorrectTypeExplicitReceiver.kt")
|
||||||
|
public void testCorrectTypeExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CorrectTypeExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CorrectTypeImplicitReceiver.kt")
|
||||||
|
public void testCorrectTypeImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CorrectTypeImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("MultipleImplicitReceivers.kt")
|
||||||
|
public void testMultipleImplicitReceivers() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/MultipleImplicitReceivers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectExplicitReceiver.kt")
|
||||||
|
public void testObjectExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/ObjectExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectImplicitReceiver.kt")
|
||||||
|
public void testObjectImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/ObjectImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("OverridenExtensionsInObject.kt")
|
||||||
|
public void testOverridenExtensionsInObject() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/OverridenExtensionsInObject.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/idea-completion/testData/basic/common/extensions")
|
@TestMetadata("idea/idea-completion/testData/basic/common/extensions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+53
@@ -1229,6 +1229,59 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/idea-completion/testData/basic/common/extensionMethodInObject")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ExtensionMethodInObject extends AbstractJvmBasicCompletionTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInExtensionMethodInObject() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/extensionMethodInObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectExplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CompanionObjectExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectImplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CompanionObjectImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CorrectTypeExplicitReceiver.kt")
|
||||||
|
public void testCorrectTypeExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CorrectTypeExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CorrectTypeImplicitReceiver.kt")
|
||||||
|
public void testCorrectTypeImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/CorrectTypeImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("MultipleImplicitReceivers.kt")
|
||||||
|
public void testMultipleImplicitReceivers() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/MultipleImplicitReceivers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectExplicitReceiver.kt")
|
||||||
|
public void testObjectExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/ObjectExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectImplicitReceiver.kt")
|
||||||
|
public void testObjectImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/ObjectImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("OverridenExtensionsInObject.kt")
|
||||||
|
public void testOverridenExtensionsInObject() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/basic/common/extensionMethodInObject/OverridenExtensionsInObject.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/idea-completion/testData/basic/common/extensions")
|
@TestMetadata("idea/idea-completion/testData/basic/common/extensions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+53
@@ -343,6 +343,59 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/idea-completion/testData/handlers/basic/extensionMethodInObject")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ExtensionMethodInObject extends AbstractBasicCompletionHandlerTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInExtensionMethodInObject() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/handlers/basic/extensionMethodInObject"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/CompanionObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/CompanionObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedCompanionObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testNestedCompanionObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedCompanionObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedCompanionObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testNestedCompanionObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedCompanionObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testNestedObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testNestedObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/ObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/ObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions")
|
@TestMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+53
@@ -343,6 +343,59 @@ public class PerformanceBasicCompletionHandlerTestGenerated extends AbstractPerf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/idea-completion/testData/handlers/basic/extensionMethodInObject")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ExtensionMethodInObject extends AbstractPerformanceBasicCompletionHandlerTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doPerfTest, TargetBackend.ANY, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInExtensionMethodInObject() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/handlers/basic/extensionMethodInObject"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/CompanionObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("CompanionObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testCompanionObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/CompanionObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedCompanionObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testNestedCompanionObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedCompanionObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedCompanionObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testNestedCompanionObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedCompanionObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testNestedObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NestedObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testNestedObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/NestedObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectInSameFileExplicitReceiver.kt")
|
||||||
|
public void testObjectInSameFileExplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/ObjectInSameFileExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectInSameFileImplicitReceiver.kt")
|
||||||
|
public void testObjectInSameFileImplicitReceiver() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/extensionMethodInObject/ObjectInSameFileImplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions")
|
@TestMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user