diff --git a/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt b/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt index c93fe5e8edc..703cef62fb8 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt @@ -85,12 +85,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") { private object DeprecatedWeigher : LookupElementWeigher("kotlin.deprecated") { override fun weigh(element: LookupElement): Int { val o = element.getObject() - if (o is DeclarationLookupObject) { - val descriptor = o.descriptor - if (descriptor != null && KotlinBuiltIns.getInstance().isDeprecated(descriptor)) return 1 - } - - return 0 + return if (o is DeclarationLookupObject && KotlinBuiltIns.getInstance().isDeprecated(o.descriptor)) 1 else 0 } } @@ -120,17 +115,14 @@ private class JetDeclarationRemotenessWeigher(private val file: JetFile) : Looku return Weight.thisFile } - val descriptor = o.descriptor - if (descriptor != null) { - val fqName = DescriptorUtils.getFqName(descriptor).toString() - // Invalid name can be met for class object descriptor: Test.MyTest.A..testOther - if (isValidJavaFqName(fqName)) { - val importPath = ImportPath(fqName) - return when { - ImportInsertHelper.needImport(importPath, file) -> Weight.notImported - ImportInsertHelper.isImportedWithDefault(importPath, file) -> Weight.kotlinDefaultImport - else -> Weight.imported - } + val fqName = DescriptorUtils.getFqName(o.descriptor).toString() + // Invalid name can be met for class object descriptor: Test.MyTest.A..testOther + if (isValidJavaFqName(fqName)) { + val importPath = ImportPath(fqName) + return when { + ImportInsertHelper.needImport(importPath, file) -> Weight.notImported + ImportInsertHelper.isImportedWithDefault(importPath, file) -> Weight.kotlinDefaultImport + else -> Weight.imported } } } diff --git a/idea/src/org/jetbrains/jet/plugin/completion/DeclarationLookupObject.kt b/idea/src/org/jetbrains/jet/plugin/completion/DeclarationLookupObject.kt index 7c959c9dc56..30b00df3b58 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/DeclarationLookupObject.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/DeclarationLookupObject.kt @@ -25,13 +25,13 @@ import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer * Stores information about resolved descriptor and position of that descriptor. * Position will be used for sorting */ -public class DeclarationLookupObject(public val descriptor: DeclarationDescriptor?, private val analyzer: KotlinCodeAnalyzer, public val psiElement: PsiElement?) { +public class DeclarationLookupObject(public val descriptor: DeclarationDescriptor, private val analyzer: KotlinCodeAnalyzer, public val psiElement: PsiElement?) { override fun toString(): String { return super.toString() + " " + descriptor } override fun hashCode(): Int { - return if (descriptor != null) descriptor!!.hashCode() else 0 + return descriptor.hashCode() } override fun equals(other: Any?): Boolean { diff --git a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt index 0379167d116..410c9a8fc43 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt @@ -160,7 +160,6 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val lam if (file is JetFile && o is DeclarationLookupObject) { val descriptor = o.descriptor as? SimpleFunctionDescriptor if (descriptor != null) { - if (PsiTreeUtil.getParentOfType(element, javaClass()) != null && descriptor.getReceiverParameter() == null) { return@runReadAction