PsiDirectory (@Nullable PsiElement element) { if (element == null) return null; // handle injection and fragment editor PsiFile file = FileContextUtil.getContextFile(element); return file == null ? null : file.getContainingDirectory(); }