Boolean (@NotNull PsiElement element) { if (!(element instanceof PsiJavaCodeReferenceElement javaCodeReferenceElement)) { return Boolean.TRUE; } final PsiReferenceParameterList parameterList = javaCodeReferenceElement.getParameterList(); if (parameterList == null) { return Boolean.TRUE; } final PsiTypeElement[] elements = parameterList.getTypeParameterElements(); if (elements.length != 1) { return Boolean.TRUE; } final PsiTypeElement typeElement = elements[0]; final MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(typeElement); if (handler instanceof SubstitutionHandler substitutionHandler && substitutionHandler.getMinOccurs() > 0) { return null; } return Boolean.valueOf(!(typeElement.getType() instanceof PsiDiamondType)); }