KT-10770 IDEA cannot keep import if a type is only referenced by kdoc.

#KT-10770 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-04-25 20:40:40 +03:00
parent cd2161b37d
commit e1d8c72aa7
6 changed files with 53 additions and 0 deletions
@@ -189,7 +189,11 @@ fun KtExpression.readWriteAccess(useResolveForReadWrite: Boolean): ReferenceAcce
fun KtReference.canBeResolvedViaImport(target: DeclarationDescriptor): Boolean {
if (!target.canBeReferencedViaImport()) return false
if (this is KDocReference) return element.getQualifiedName().size == 1
if (target.isExtension) return true // assume that any type of reference can use imports when resolved to extension
val referenceExpression = this.element as? KtNameReferenceExpression ?: return false
if (CallTypeAndReceiver.detect(referenceExpression).receiver != null) return false
if (element.parent is KtThisExpression || element.parent is KtSuperExpression) return false // TODO: it's a bad design of PSI tree, we should change it