PsiFile (PsiElement element) { PsiJavaCodeReferenceElement referenceElement = getReferenceElement((PsiNewExpression)element); PsiElement q = referenceElement.getQualifier(); if (q instanceof PsiJavaCodeReferenceElement qualifier && qualifier.resolve() instanceof PsiClass psiClass) { return psiClass.getContainingFile(); } return null; }