Result (Expression @NotNull [] params, final ExpressionContext context) { int templateStartOffset = context.getTemplateStartOffset(); int offset = templateStartOffset > 0 ? context.getTemplateStartOffset() - 1 : context.getTemplateStartOffset(); PsiElement place = context.getPsiElementAtStartOffset(); PsiClass aClass = null; while(place != null){ if (place instanceof PsiClass && !(place instanceof PsiAnonymousClass) && !(place instanceof PsiTypeParameter)){ aClass = (PsiClass)place; // if className() is evaluated outside of the body of inner class, return name of its outer class instead (IDEADEV-19865) final PsiElement lBrace = aClass.getLBrace(); if (lBrace != null && offset < lBrace.getTextOffset() && aClass.getContainingClass() != null) { aClass = aClass.getContainingClass(); } break; } if (place instanceof PsiJavaFile){ PsiClass[] classes = ((PsiJavaFile)place).getClasses(); aClass = classes.length != 0 ? classes[0] : null; break; } place = place.getParent(); } if (aClass == null) return null; String qname = aClass.getName(); return qname == null ? null : new TextResult(qname); }