PsiElement (@Nullable PsiElement e) { if (e == null || !e.isValid()) return null; PsiFile containingFile = e.getContainingFile(); if (containingFile != null && containingFile.getVirtualFile() == null) return null; PsiElement orig = e.getOriginalElement(); return !(e instanceof PsiCompiledElement) && orig instanceof PsiCompiledElement ? e : orig; }