Imports on paste: fixed overloaded extensions import
This commit is contained in:
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import java.awt.datatransfer.Transferable
|
||||
import java.awt.datatransfer.UnsupportedFlavorException
|
||||
import java.io.IOException
|
||||
@@ -194,7 +195,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
||||
val refData: KotlinReferenceData
|
||||
)
|
||||
|
||||
override fun processTransferableData (
|
||||
override fun processTransferableData(
|
||||
project: Project,
|
||||
editor: Editor,
|
||||
bounds: RangeMarker,
|
||||
@@ -328,11 +329,10 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
||||
val importDirective = JetPsiFactory(file.getProject()).createImportDirective(ImportPath(fqName, false))
|
||||
val moduleDescriptor = file.getResolutionFacade().findModuleDescriptor(file)
|
||||
val scope = JetModuleUtil.getSubpackagesOfRootScope(moduleDescriptor)
|
||||
val descriptors = QualifiedExpressionResolver()
|
||||
return QualifiedExpressionResolver()
|
||||
.processImportReference(importDirective, scope, scope, BindingTraceContext(), LookupMode.EVERYTHING)
|
||||
.getAllDescriptors()
|
||||
.filterIsInstance<CallableDescriptor>()
|
||||
return descriptors.singleOrNull() //TODO: not correct
|
||||
.firstIsInstanceOrNull<CallableDescriptor>()
|
||||
}
|
||||
|
||||
private fun showRestoreReferencesDialog(project: Project, referencesToRestore: List<ReferenceToRestoreData>): Collection<ReferenceToRestoreData> {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package dependency
|
||||
|
||||
fun String.extensionFun(){}
|
||||
fun Char.extensionFun(){}
|
||||
@@ -0,0 +1,3 @@
|
||||
import dependency.extensionFun
|
||||
|
||||
val v = "".extensionFun()
|
||||
@@ -0,0 +1 @@
|
||||
dependency.extensionFun
|
||||
@@ -0,0 +1,6 @@
|
||||
// RUNTIME
|
||||
import dependency.*
|
||||
|
||||
fun foo() {
|
||||
<selection>"".extensionFun()</selection>
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
val v = <caret>
|
||||
+12
@@ -306,6 +306,12 @@ public class InsertImportOnPasteTestGenerated extends AbstractInsertImportOnPast
|
||||
doTestCopy(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("OverloadedExtensionFunction.kt")
|
||||
public void testOverloadedExtensionFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/OverloadedExtensionFunction.kt");
|
||||
doTestCopy(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PackageView.kt")
|
||||
public void testPackageView() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/PackageView.kt");
|
||||
@@ -633,6 +639,12 @@ public class InsertImportOnPasteTestGenerated extends AbstractInsertImportOnPast
|
||||
doTestCut(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("OverloadedExtensionFunction.kt")
|
||||
public void testOverloadedExtensionFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/OverloadedExtensionFunction.kt");
|
||||
doTestCut(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PackageView.kt")
|
||||
public void testPackageView() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/PackageView.kt");
|
||||
|
||||
Reference in New Issue
Block a user