Drop temporary hack, enums are comparable now
This commit is contained in:
@@ -61,7 +61,7 @@ private object PriorityWeigher : LookupElementWeigher("kotlin.priority") {
|
||||
}
|
||||
|
||||
private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
||||
enum class Weight {
|
||||
private enum class Weight {
|
||||
localOrParameter
|
||||
property
|
||||
keyword
|
||||
@@ -69,7 +69,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
||||
packages
|
||||
}
|
||||
|
||||
override fun weigh(element: LookupElement): Comparable<Any> {
|
||||
override fun weigh(element: LookupElement): Weight {
|
||||
val o = element.getObject()
|
||||
return when (o) {
|
||||
is DeclarationDescriptorLookupObject -> when (o.descriptor) {
|
||||
@@ -82,7 +82,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
||||
is KeywordLookupObject -> Weight.keyword
|
||||
|
||||
else -> Weight.default
|
||||
} as Comparable<Any> // TODO: a temporary hack until kotlin.Enum : kotlin.Comparable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,12 +109,12 @@ private class JetDeclarationRemotenessWeigher(private val file: JetFile) : Looku
|
||||
notImported
|
||||
}
|
||||
|
||||
override fun weigh(element: LookupElement): Comparable<Any> {
|
||||
override fun weigh(element: LookupElement): Weight {
|
||||
val o = element.getObject()
|
||||
if (o is DeclarationDescriptorLookupObject) {
|
||||
val elementFile = o.psiElement?.getContainingFile()
|
||||
if (elementFile is JetFile && elementFile.getOriginalFile() == file) {
|
||||
return Weight.thisFile as Comparable<Any> // TODO: a temporary hack until kotlin.Enum : kotlin.Comparable
|
||||
return Weight.thisFile
|
||||
}
|
||||
|
||||
val fqName = DescriptorUtils.getFqName(o.descriptor).toString()
|
||||
@@ -125,10 +125,10 @@ private class JetDeclarationRemotenessWeigher(private val file: JetFile) : Looku
|
||||
ImportInsertHelper.getInstance().needImport(importPath, file) -> Weight.notImported
|
||||
ImportInsertHelper.getInstance().isImportedWithDefault(importPath, file) -> Weight.kotlinDefaultImport
|
||||
else -> Weight.imported
|
||||
} as Comparable<Any> // TODO: a temporary hack until kotlin.Enum : kotlin.Comparable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Weight.normal as Comparable<Any> // TODO: a temporary hack until kotlin.Enum : kotlin.Comparable
|
||||
return Weight.normal
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user