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") {
|
private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
||||||
enum class Weight {
|
private enum class Weight {
|
||||||
localOrParameter
|
localOrParameter
|
||||||
property
|
property
|
||||||
keyword
|
keyword
|
||||||
@@ -69,7 +69,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
|||||||
packages
|
packages
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun weigh(element: LookupElement): Comparable<Any> {
|
override fun weigh(element: LookupElement): Weight {
|
||||||
val o = element.getObject()
|
val o = element.getObject()
|
||||||
return when (o) {
|
return when (o) {
|
||||||
is DeclarationDescriptorLookupObject -> when (o.descriptor) {
|
is DeclarationDescriptorLookupObject -> when (o.descriptor) {
|
||||||
@@ -82,7 +82,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
|||||||
is KeywordLookupObject -> Weight.keyword
|
is KeywordLookupObject -> Weight.keyword
|
||||||
|
|
||||||
else -> Weight.default
|
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
|
notImported
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun weigh(element: LookupElement): Comparable<Any> {
|
override fun weigh(element: LookupElement): Weight {
|
||||||
val o = element.getObject()
|
val o = element.getObject()
|
||||||
if (o is DeclarationDescriptorLookupObject) {
|
if (o is DeclarationDescriptorLookupObject) {
|
||||||
val elementFile = o.psiElement?.getContainingFile()
|
val elementFile = o.psiElement?.getContainingFile()
|
||||||
if (elementFile is JetFile && elementFile.getOriginalFile() == file) {
|
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()
|
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().needImport(importPath, file) -> Weight.notImported
|
||||||
ImportInsertHelper.getInstance().isImportedWithDefault(importPath, file) -> Weight.kotlinDefaultImport
|
ImportInsertHelper.getInstance().isImportedWithDefault(importPath, file) -> Weight.kotlinDefaultImport
|
||||||
else -> Weight.imported
|
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