PsiNewExpression () { PsiElement typeElementWithDiamondTypeArgument = myTypeElement.getParent(); PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(typeElementWithDiamondTypeArgument, PsiNewExpression.class, true, PsiTypeElement.class, PsiStatement.class); if (newExpression != null) { PsiJavaCodeReferenceElement classReference = newExpression.getClassOrAnonymousClassReference(); if (classReference != null && classReference.getParameterList() == typeElementWithDiamondTypeArgument) { return newExpression; } } return null; }