TextWithImports (PsiElement elementAtCaret) { String result = ""; PsiElement element = findExpressionInner(elementAtCaret, true); if (element != null) { if (element instanceof GrReferenceExpression reference) { if (reference.getQualifier() == null) { final PsiElement resolved = reference.resolve(); if (resolved instanceof PsiEnumConstant enumConstant) { final PsiClass enumClass = enumConstant.getContainingClass(); if (enumClass != null) { result = enumClass.getName() + "." + enumConstant.getName(); } } } } if (result.isEmpty()) { result = element.getText(); } } return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, result); }