DeclarationLookupObject.descriptor is never null
This commit is contained in:
@@ -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.<no name provided>.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.<no name provided>.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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<JetQualifiedExpression>()) != null &&
|
||||
descriptor.getReceiverParameter() == null) {
|
||||
return@runReadAction
|
||||
|
||||
Reference in New Issue
Block a user