String (JavaSliceUsage usage) { if (usage.indexNesting == 0) return ""; Deque<String> result = new ArrayDeque<>(); JavaSliceUsage prev = usage; String name = ""; while (usage != null) { if (usage.indexNesting != prev.indexNesting) { result.addFirst(name); if (usage.indexNesting == 0) break; } PsiElement element = usage.getElement(); if (element instanceof PsiNamedElement) { name = ((PsiNamedElement)element).getName(); } else if (element instanceof PsiReference) { name = ((PsiReference)element).getCanonicalText(); } else if (element instanceof PsiExpression) { PsiType type = ((PsiExpression)element).getType(); if (type != null) { name = type.getPresentableText(); } } prev = usage; usage = (JavaSliceUsage)usage.getParent(); } return String.join(".", result); }