Fixed bug in reference shortening related on on the fly import optimization
This commit is contained in:
@@ -159,6 +159,10 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
|
|||||||
for (descriptor in descriptorsToImport) {
|
for (descriptor in descriptorsToImport) {
|
||||||
assert(descriptor !in failedToImportDescriptors)
|
assert(descriptor !in failedToImportDescriptors)
|
||||||
|
|
||||||
|
if (importInserter.optimizeImports()) {
|
||||||
|
anyChange = true
|
||||||
|
}
|
||||||
|
|
||||||
val result = importInserter.addImport(descriptor)
|
val result = importInserter.addImport(descriptor)
|
||||||
if (result != ImportInsertHelper.ImportDescriptorResult.ALREADY_IMPORTED) {
|
if (result != ImportInsertHelper.ImportDescriptorResult.ALREADY_IMPORTED) {
|
||||||
anyChange = true
|
anyChange = true
|
||||||
@@ -456,7 +460,6 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
|
|||||||
private val helper = ImportInsertHelper.getInstance(file.getProject())
|
private val helper = ImportInsertHelper.getInstance(file.getProject())
|
||||||
|
|
||||||
fun addImport(target: DeclarationDescriptor): ImportInsertHelper.ImportDescriptorResult {
|
fun addImport(target: DeclarationDescriptor): ImportInsertHelper.ImportDescriptorResult {
|
||||||
optimizeImports()
|
|
||||||
return helper.importDescriptor(file, target)
|
return helper.importDescriptor(file, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// OPTIMIZE_IMPORTS: true
|
||||||
|
// NAME_COUNT_TO_USE_STAR_IMPORT: 1
|
||||||
|
import java.util.HashMap
|
||||||
|
|
||||||
|
val v: HashMap<String, <selection>java.util.Date</selection>>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// OPTIMIZE_IMPORTS: true
|
||||||
|
// NAME_COUNT_TO_USE_STAR_IMPORT: 1
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
val v: HashMap<String, Date>
|
||||||
@@ -186,6 +186,12 @@ public class ShortenRefsTestGenerated extends AbstractShortenRefsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ImportsOnTheFlyBug.kt")
|
||||||
|
public void testImportsOnTheFlyBug() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/shortenRefs/imports/ImportsOnTheFlyBug.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("leaveQualifiedConstructor.kt")
|
@TestMetadata("leaveQualifiedConstructor.kt")
|
||||||
public void testLeaveQualifiedConstructor() throws Exception {
|
public void testLeaveQualifiedConstructor() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/shortenRefs/imports/leaveQualifiedConstructor.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/shortenRefs/imports/leaveQualifiedConstructor.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user