TextWithImports (PsiElement elementAtCaret) { String result; PsiElement element = findExpression(elementAtCaret); if (element == null) return null; if (element instanceof PsiVariable) { result = qualifyEnumConstant(element, ((PsiVariable)element).getName()); } else if (element instanceof PsiMethod) { result = ((PsiMethod)element).getName() + "()"; } else if (element instanceof PsiReferenceExpression reference) { result = qualifyEnumConstant(reference.resolve(), element.getText()); } else { result = element.getText(); } return result != null ? new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, result) : null; }