JetLookupObject renamed to DeclarationLookupObject
This commit is contained in:
@@ -68,7 +68,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
||||
override fun weigh(element: LookupElement): Weight {
|
||||
val o = element.getObject()
|
||||
return when (o) {
|
||||
is JetLookupObject -> when (o.getDescriptor()) {
|
||||
is DeclarationLookupObject -> when (o.getDescriptor()) {
|
||||
is LocalVariableDescriptor, is ValueParameterDescriptor -> Weight.localOrParameter
|
||||
is PropertyDescriptor -> Weight.property
|
||||
is PackageViewDescriptor -> Weight.packages
|
||||
@@ -85,7 +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 JetLookupObject) {
|
||||
if (o is DeclarationLookupObject) {
|
||||
val descriptor = o.getDescriptor()
|
||||
if (descriptor != null && KotlinBuiltIns.getInstance().isDeprecated(descriptor)) return 1
|
||||
}
|
||||
@@ -114,7 +114,7 @@ private class JetDeclarationRemotenessWeigher(private val file: JetFile) : Looku
|
||||
|
||||
override fun weigh(element: LookupElement): Weight {
|
||||
val o = element.getObject()
|
||||
if (o is JetLookupObject) {
|
||||
if (o is DeclarationLookupObject) {
|
||||
val elementFile = o.getPsiElement()?.getContainingFile()
|
||||
if (elementFile is JetFile && elementFile.getOriginalFile() == file) {
|
||||
return Weight.thisFile
|
||||
|
||||
+8
-4
@@ -27,8 +27,8 @@ import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
||||
* Stores information about resolved descriptor and position of that descriptor.
|
||||
* Position will be used for removing duplicates
|
||||
*/
|
||||
public final class JetLookupObject {
|
||||
private static final Logger LOG = Logger.getInstance("#" + JetLookupObject.class.getName());
|
||||
public final class DeclarationLookupObject {
|
||||
private static final Logger LOG = Logger.getInstance("#" + DeclarationLookupObject.class.getName());
|
||||
|
||||
@Nullable
|
||||
private final DeclarationDescriptor descriptor;
|
||||
@@ -39,7 +39,11 @@ public final class JetLookupObject {
|
||||
@Nullable
|
||||
private final PsiElement psiElement;
|
||||
|
||||
public JetLookupObject(@Nullable DeclarationDescriptor descriptor, @NotNull KotlinCodeAnalyzer analyzer, @Nullable PsiElement psiElement) {
|
||||
public DeclarationLookupObject(
|
||||
@Nullable DeclarationDescriptor descriptor,
|
||||
@NotNull KotlinCodeAnalyzer analyzer,
|
||||
@Nullable PsiElement psiElement
|
||||
) {
|
||||
this.descriptor = descriptor;
|
||||
this.analyzer = analyzer;
|
||||
this.psiElement = psiElement;
|
||||
@@ -70,7 +74,7 @@ public final class JetLookupObject {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
JetLookupObject lookupObject = (JetLookupObject) obj;
|
||||
DeclarationLookupObject lookupObject = (DeclarationLookupObject) obj;
|
||||
|
||||
if (!analyzer.equals(lookupObject.analyzer)) {
|
||||
LOG.warn("Descriptors from different resolve sessions");
|
||||
@@ -46,7 +46,7 @@ public final class DescriptorLookupConverter {
|
||||
public static LookupElement createLookupElement(@NotNull KotlinCodeAnalyzer analyzer,
|
||||
@NotNull DeclarationDescriptor descriptor, @Nullable PsiElement declaration) {
|
||||
LookupElementBuilder element = LookupElementBuilder.create(
|
||||
new JetLookupObject(descriptor, analyzer, declaration), descriptor.getName().asString());
|
||||
new DeclarationLookupObject(descriptor, analyzer, declaration), descriptor.getName().asString());
|
||||
|
||||
String presentableText = descriptor.getName().asString();
|
||||
String typeText = "";
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.openapi.editor.Document
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||
import org.jetbrains.jet.plugin.completion.JetLookupObject
|
||||
import org.jetbrains.jet.plugin.completion.DeclarationLookupObject
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor
|
||||
@@ -33,7 +33,7 @@ public object JetClassInsertHandler : InsertHandler<LookupElement> {
|
||||
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
||||
val file = context.getFile()
|
||||
if (file is JetFile) {
|
||||
val descriptor = (item.getObject() as? JetLookupObject)?.getDescriptor() as? ClassDescriptor
|
||||
val descriptor = (item.getObject() as? org.jetbrains.jet.plugin.completion.DeclarationLookupObject)?.getDescriptor() as? ClassDescriptor
|
||||
if (descriptor != null) {
|
||||
val startOffset = context.getStartOffset()
|
||||
val document = context.getDocument()
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.jet.plugin.formatter.JetCodeStyleSettings
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.plugin.completion.JetLookupObject
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
@@ -156,8 +155,8 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val lam
|
||||
if (element == null) return@runReadAction
|
||||
|
||||
val file = context.getFile()
|
||||
if (file is JetFile && item.getObject() is JetLookupObject) {
|
||||
val descriptor = (item.getObject() as JetLookupObject).getDescriptor()
|
||||
if (file is JetFile && item.getObject() is org.jetbrains.jet.plugin.completion.DeclarationLookupObject) {
|
||||
val descriptor = (item.getObject() as org.jetbrains.jet.plugin.completion.DeclarationLookupObject).getDescriptor()
|
||||
|
||||
if (descriptor is SimpleFunctionDescriptor) {
|
||||
val functionDescriptor = descriptor as SimpleFunctionDescriptor
|
||||
|
||||
Reference in New Issue
Block a user