PsiElement () { final PsiNewExpression expression = getNewExpression(); if (expression == null || (!expression.getManager().isInProject(expression) && !ScratchUtil.isScratch(PsiUtilCore.getVirtualFile(expression)))) { return null; } PsiJavaCodeReferenceElement referenceElement = getReferenceElement(expression); if (referenceElement == null) return null; if (referenceElement.getReferenceNameElement() instanceof PsiIdentifier) return expression; return null; }