use of org.jetbrains.kotlin.descriptors.CallableMemberDescriptor in project kotlin by JetBrains.
the class KotlinOverridingDialog method formatElement.
private static String formatElement(PsiElement element) {
element = KtPsiUtil.ascendIfPropertyAccessor(element);
if (element instanceof KtNamedFunction || element instanceof KtProperty) {
BindingContext bindingContext = ResolutionUtils.analyze((KtElement) element, BodyResolveMode.FULL);
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
if (declarationDescriptor instanceof CallableMemberDescriptor) {
DeclarationDescriptor containingDescriptor = declarationDescriptor.getContainingDeclaration();
if (containingDescriptor instanceof ClassDescriptor) {
return KotlinBundle.message("x.in.y", DescriptorRenderer.COMPACT.render(declarationDescriptor), IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(containingDescriptor));
}
}
}
assert element instanceof PsiMethod : "Method accepts only kotlin functions/properties and java methods, but '" + element.getText() + "' was found";
return RenderingUtilsKt.formatPsiMethod((PsiMethod) element, true, false);
}
Aggregations