Don't detect isDeprecated twice
This commit is contained in:
@@ -110,11 +110,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
|||||||
private object DeprecatedWeigher : LookupElementWeigher("kotlin.deprecated") {
|
private object DeprecatedWeigher : LookupElementWeigher("kotlin.deprecated") {
|
||||||
override fun weigh(element: LookupElement): Int {
|
override fun weigh(element: LookupElement): Int {
|
||||||
val o = element.getObject() as? DeclarationLookupObject ?: return 0
|
val o = element.getObject() as? DeclarationLookupObject ?: return 0
|
||||||
val isDeprecated = if (o.descriptor != null)
|
return if (o.isDeprecated) 1 else 0
|
||||||
KotlinBuiltIns.isDeprecated(o.descriptor!!)
|
|
||||||
else
|
|
||||||
(o.psiElement as PsiDocCommentOwner).isDeprecated()
|
|
||||||
return if (isDeprecated) 1 else 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
@@ -17,7 +17,9 @@
|
|||||||
package org.jetbrains.kotlin.idea.completion
|
package org.jetbrains.kotlin.idea.completion
|
||||||
|
|
||||||
import com.intellij.openapi.diagnostic.Logger
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
|
import com.intellij.psi.PsiDocCommentOwner
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
|
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
|
||||||
@@ -55,6 +57,8 @@ public class DeclarationLookupObjectImpl(
|
|||||||
return descriptorsEqualWithSubstitution(descriptor, lookupObject.descriptor) && psiElement == lookupObject.psiElement
|
return descriptorsEqualWithSubstitution(descriptor, lookupObject.descriptor) && psiElement == lookupObject.psiElement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val isDeprecated = if (descriptor != null) KotlinBuiltIns.isDeprecated(descriptor) else (psiElement as PsiDocCommentOwner).isDeprecated()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOG = Logger.getInstance("#" + javaClass<DeclarationLookupObject>().getName())
|
private val LOG = Logger.getInstance("#" + javaClass<DeclarationLookupObject>().getName())
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -111,7 +111,7 @@ public class LookupElementFactory(
|
|||||||
val packageName = qualifiedName.substringBeforeLast('.', "<root>")
|
val packageName = qualifiedName.substringBeforeLast('.', "<root>")
|
||||||
element = element.appendTailText(" ($packageName)", true)
|
element = element.appendTailText(" ($packageName)", true)
|
||||||
|
|
||||||
if (psiClass.isDeprecated()) {
|
if (lookupObject.isDeprecated) {
|
||||||
element = element.setStrikeout(true)
|
element = element.setStrikeout(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,8 @@ public class LookupElementFactory(
|
|||||||
val name = nameAndIconDescriptor.getName().asString()
|
val name = nameAndIconDescriptor.getName().asString()
|
||||||
val icon = JetDescriptorIconProvider.getIcon(nameAndIconDescriptor, iconDeclaration, Iconable.ICON_FLAG_VISIBILITY)
|
val icon = JetDescriptorIconProvider.getIcon(nameAndIconDescriptor, iconDeclaration, Iconable.ICON_FLAG_VISIBILITY)
|
||||||
|
|
||||||
var element = LookupElementBuilder.create(DeclarationLookupObjectImpl(descriptor, declaration, resolutionFacade), name)
|
val lookupObject = DeclarationLookupObjectImpl(descriptor, declaration, resolutionFacade)
|
||||||
|
var element = LookupElementBuilder.create(lookupObject, name)
|
||||||
.withIcon(icon)
|
.withIcon(icon)
|
||||||
|
|
||||||
when (descriptor) {
|
when (descriptor) {
|
||||||
@@ -201,7 +202,7 @@ public class LookupElementFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KotlinBuiltIns.isDeprecated(descriptor)) {
|
if (lookupObject.isDeprecated) {
|
||||||
element = element.withStrikeoutness(true)
|
element = element.withStrikeoutness(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -22,4 +22,5 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|||||||
public interface DeclarationLookupObject {
|
public interface DeclarationLookupObject {
|
||||||
public val psiElement: PsiElement?
|
public val psiElement: PsiElement?
|
||||||
public val descriptor: DeclarationDescriptor?
|
public val descriptor: DeclarationDescriptor?
|
||||||
|
public val isDeprecated: Boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user