Checked that auto-import works for extension properties
This commit is contained in:
@@ -115,7 +115,7 @@ public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction<Jet
|
|||||||
result.addAll(getTopLevelFunctions(referenceName, element, searchScope, resolveSession, file.getProject()))
|
result.addAll(getTopLevelFunctions(referenceName, element, searchScope, resolveSession, file.getProject()))
|
||||||
}
|
}
|
||||||
|
|
||||||
result.addAll(getExtensionFunctions(referenceName, element, searchScope, resolveSession, file.getProject()))
|
result.addAll(getExtensions(referenceName, element, searchScope, resolveSession, file.getProject()))
|
||||||
|
|
||||||
return result.filter { ImportInsertHelper.needImport(ImportPath(it, false), file) }
|
return result.filter { ImportInsertHelper.needImport(ImportPath(it, false), file) }
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction<Jet
|
|||||||
.map { DescriptorUtils.getFqNameSafe(it) }
|
.map { DescriptorUtils.getFqNameSafe(it) }
|
||||||
.toSet()
|
.toSet()
|
||||||
|
|
||||||
private fun getExtensionFunctions(name: String, expression: JetSimpleNameExpression, searchScope: GlobalSearchScope, resolveSession: ResolveSessionForBodies, project: Project): Collection<FqName>
|
private fun getExtensions(name: String, expression: JetSimpleNameExpression, searchScope: GlobalSearchScope, resolveSession: ResolveSessionForBodies, project: Project): Collection<FqName>
|
||||||
= KotlinIndicesHelper(project).getCallableExtensions({ it == name }, expression, resolveSession, searchScope)
|
= KotlinIndicesHelper(project).getCallableExtensions({ it == name }, expression, resolveSession, searchScope)
|
||||||
.map { DescriptorUtils.getFqNameSafe(it) }
|
.map { DescriptorUtils.getFqNameSafe(it) }
|
||||||
.toSet()
|
.toSet()
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// "Import" "true"
|
||||||
|
// ERROR: Unresolved reference: someVal
|
||||||
|
package test
|
||||||
|
|
||||||
|
import test.data.someVal
|
||||||
|
|
||||||
|
fun some() {
|
||||||
|
"".someVal
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// "Import" "true"
|
||||||
|
// ERROR: Unresolved reference: someVal
|
||||||
|
package test
|
||||||
|
|
||||||
|
fun some() {
|
||||||
|
"".<caret>someVal
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test.data
|
||||||
|
|
||||||
|
val String.someVal: Int get() = 1
|
||||||
@@ -69,6 +69,11 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
|
|||||||
doTestWithExtraFile("idea/testData/quickfix/autoImports/extensionFunctionImport.before.Main.kt");
|
doTestWithExtraFile("idea/testData/quickfix/autoImports/extensionFunctionImport.before.Main.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("extensionPropertyImport.before.Main.kt")
|
||||||
|
public void testExtensionPropertyImport() throws Exception {
|
||||||
|
doTestWithExtraFile("idea/testData/quickfix/autoImports/extensionPropertyImport.before.Main.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("functionImport.before.Main.kt")
|
@TestMetadata("functionImport.before.Main.kt")
|
||||||
public void testFunctionImport() throws Exception {
|
public void testFunctionImport() throws Exception {
|
||||||
doTestWithExtraFile("idea/testData/quickfix/autoImports/functionImport.before.Main.kt");
|
doTestWithExtraFile("idea/testData/quickfix/autoImports/functionImport.before.Main.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user