PsiDiamondType (PsiNewExpression expression) { if (PsiUtil.isLanguageLevel7OrHigher(expression)) { final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference(); if (classReference != null) { final PsiReferenceParameterList parameterList = classReference.getParameterList(); if (parameterList != null) { final PsiTypeElement[] parameterElements = parameterList.getTypeParameterElements(); if (parameterElements.length == 1) { final PsiType type = parameterElements[0].getType(); return type instanceof PsiDiamondType ? (PsiDiamondType)type : null; } } } } return null; }