PsiClass (@Nullable SourcePosition position) { if (position == null) { return null; } final PsiElement element = position.getElementAt(); return element != null && element.isValid() ? PsiTreeUtil.getParentOfType(element, PsiClass.class, false) : null; }