Refactored sorting in completion

Also changed semantics of DeclarationDescriptor.importableFqName - it now returns null when descriptor cannot be referenced by import + dropped DeclarationDescriptor.importableFqNameSafe
This commit is contained in:
Valentin Kipyatkov
2015-08-21 16:15:05 +03:00
parent 68c0c83879
commit 0f332bd8b9
19 changed files with 289 additions and 255 deletions
@@ -22,23 +22,22 @@ import org.jetbrains.kotlin.psi.JetReferenceExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor
import org.jetbrains.kotlin.types.JetType
public val DeclarationDescriptor.importableFqName: FqName?
get() {
val mayBeUnsafe = DescriptorUtils.getFqName(getImportableDescriptor())
return if (mayBeUnsafe.isSafe()) mayBeUnsafe.toSafe() else null
val importableDescriptor = getImportableDescriptor()
if (!importableDescriptor.canBeReferencedViaImport()) return null
return importableDescriptor.fqNameSafe
}
public val DeclarationDescriptor.importableFqNameSafe: FqName
get() = DescriptorUtils.getFqNameSafe(getImportableDescriptor())
public fun DeclarationDescriptor.canBeReferencedViaImport(): Boolean {
if (this is PackageViewDescriptor ||
DescriptorUtils.isTopLevelDeclaration(this) ||
(this is CallableDescriptor && DescriptorUtils.isStaticDeclaration(this))) {
return !getName().isSpecial()
this is CallableDescriptor && DescriptorUtils.isStaticDeclaration(this)) {
return !name.isSpecial
}
val parentClass = getContainingDeclaration() as? ClassDescriptor ?: return false