use of org.jetbrains.kotlin.psi.KtObjectDeclaration in project kotlin by JetBrains.
the class ReferenceUtils method renderAsGotoImplementation.
public static String renderAsGotoImplementation(@NotNull PsiElement element) {
PsiElement navigationElement = element.getNavigationElement();
if (navigationElement instanceof KtObjectDeclaration && ((KtObjectDeclaration) navigationElement).isCompanion()) {
//default presenter return null for companion object
KtClass containingClass = PsiTreeUtil.getParentOfType(navigationElement, KtClass.class);
assert containingClass != null;
return "companion object of " + renderAsGotoImplementation(containingClass);
}
if (navigationElement instanceof KtStringTemplateExpression) {
return KtPsiUtilKt.getPlainContent((KtStringTemplateExpression) navigationElement);
}
Assert.assertTrue(navigationElement instanceof NavigationItem);
ItemPresentation presentation = ((NavigationItem) navigationElement).getPresentation();
if (presentation == null) {
String elementText = element.getText();
return elementText != null ? elementText : navigationElement.getText();
}
String presentableText = presentation.getPresentableText();
String locationString = presentation.getLocationString();
if (locationString == null && element.getParent() instanceof PsiAnonymousClass) {
locationString = "<anonymous>";
}
return locationString == null || navigationElement instanceof PsiPackage ? // for PsiPackage, presentableText is FQ name of current package
presentableText : locationString + "." + presentableText;
}
Aggregations