Use render with short types names in completion lookup elements
This commit is contained in:
@@ -64,39 +64,38 @@ public final class DescriptorLookupConverter {
|
||||
String presentableText = descriptor.getName().asString();
|
||||
String typeText = "";
|
||||
String tailText = "";
|
||||
boolean tailTextGrayed = true;
|
||||
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
JetType returnType = functionDescriptor.getReturnType();
|
||||
typeText = DescriptorRenderer.TEXT.renderType(returnType);
|
||||
presentableText += DescriptorRenderer.TEXT.renderFunctionParameters(functionDescriptor);
|
||||
typeText = returnType != null ? DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(returnType) : "";
|
||||
presentableText += DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderFunctionParameters(functionDescriptor);
|
||||
|
||||
boolean extensionFunction = functionDescriptor.getReceiverParameter() != null;
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
if (containingDeclaration != null && extensionFunction) {
|
||||
tailText += " for " + DescriptorRenderer.TEXT.renderType(functionDescriptor.getReceiverParameter().getType());
|
||||
tailText += " for " + DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(functionDescriptor.getReceiverParameter().getType());
|
||||
tailText += " in " + DescriptorUtils.getFqName(containingDeclaration);
|
||||
}
|
||||
}
|
||||
else if (descriptor instanceof VariableDescriptor) {
|
||||
JetType outType = ((VariableDescriptor) descriptor).getType();
|
||||
typeText = DescriptorRenderer.TEXT.renderType(outType);
|
||||
typeText = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(outType);
|
||||
}
|
||||
else if (descriptor instanceof ClassDescriptor) {
|
||||
DeclarationDescriptor declaredIn = descriptor.getContainingDeclaration();
|
||||
assert declaredIn != null;
|
||||
tailText = " (" + DescriptorUtils.getFqName(declaredIn) + ")";
|
||||
tailTextGrayed = true;
|
||||
}
|
||||
else {
|
||||
typeText = DescriptorRenderer.TEXT.render(descriptor);
|
||||
typeText = DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(descriptor);
|
||||
}
|
||||
|
||||
element = element.withInsertHandler(getInsertHandler(descriptor));
|
||||
element = element.withTailText(tailText, tailTextGrayed).withTypeText(typeText).withPresentableText(presentableText);
|
||||
element = element.withTailText(tailText, true).withTypeText(typeText).withPresentableText(presentableText);
|
||||
element = element.withIcon(JetDescriptorIconProvider.getIcon(descriptor, Iconable.ICON_FLAG_VISIBILITY));
|
||||
element = element.withStrikeoutness(KotlinBuiltIns.getInstance().isDeprecated(descriptor));
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -138,7 +137,9 @@ public final class DescriptorLookupConverter {
|
||||
if (containingClass != null && !JavaResolverPsiUtils.isCompiledKotlinClassOrPackageClass(containingClass)) {
|
||||
if (declaration instanceof PsiMethod) {
|
||||
InsertHandler<LookupElement> handler = getInsertHandler(descriptor);
|
||||
assert handler != null: "Special kotlin handler is expected for function: " + declaration.getText() + " and descriptor" + DescriptorRenderer.TEXT.render(descriptor);
|
||||
assert handler != null:
|
||||
"Special kotlin handler is expected for function: " + declaration.getText() +
|
||||
" and descriptor: " + DescriptorRenderer.TEXT.render(descriptor);
|
||||
|
||||
return new JavaMethodCallElementWithCustomHandler(declaration).setInsertHandler(handler);
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@ fun some() {
|
||||
tes<caret>
|
||||
}
|
||||
|
||||
// EXIST: { lookupString:"test", itemText:"test(a: kotlin.Int)" }
|
||||
// EXIST: { lookupString:"test", itemText:"test(a: Int)" }
|
||||
@@ -8,5 +8,5 @@ fun firstFun() {
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 1
|
||||
// EXIST: { lookupString:"toLinkedList", itemText:"toLinkedList()", tailText:" for kotlin.Iterable<T> in kotlin" }
|
||||
// EXIST: { lookupString:"toLinkedList", itemText:"toLinkedList()", tailText:" for Iterable<T> in kotlin" }
|
||||
// NUMBER: 1
|
||||
|
||||
@@ -14,8 +14,8 @@ fun foo(){
|
||||
val k : K = <caret>
|
||||
}
|
||||
|
||||
// EXIST: { lookupString:"K.foo", itemText:"K.foo", tailText:" (sample)", typeText:"sample.K" }
|
||||
// EXIST: { lookupString:"K.bar", itemText:"K.bar()", tailText:" (sample)", typeText:"sample.K" }
|
||||
// EXIST: { lookupString:"K.foo", itemText:"K.foo", tailText:" (sample)", typeText:"K" }
|
||||
// EXIST: { lookupString:"K.bar", itemText:"K.bar()", tailText:" (sample)", typeText:"K" }
|
||||
// ABSENT: K.x
|
||||
// ABSENT: K.kk
|
||||
// ABSENT: K.privateVal
|
||||
|
||||
@@ -13,7 +13,7 @@ fun foo(){
|
||||
val k : K? = <caret>
|
||||
}
|
||||
|
||||
// EXIST: { lookupString:"K.foo", itemText:"K.foo", tailText:" (sample)", typeText:"sample.K" }
|
||||
// EXIST: { lookupString:"K.bar", itemText:"K.bar()", tailText:" (sample)", typeText:"sample.K" }
|
||||
// EXIST: { lookupString:"K.foo", itemText:"K.foo", tailText:" (sample)", typeText:"K" }
|
||||
// EXIST: { lookupString:"K.bar", itemText:"K.bar()", tailText:" (sample)", typeText:"K" }
|
||||
// ABSENT: K.x
|
||||
// EXIST: { lookupString:"K.kk", itemText:"K.kk", tailText:" (sample)", typeText:"sample.K?" }
|
||||
// EXIST: { lookupString:"K.kk", itemText:"K.kk", tailText:" (sample)", typeText:"K?" }
|
||||
|
||||
Reference in New Issue
Block a user