void (@NotNull List<? super FoldingDescriptor> list, @NotNull PsiNewExpression expression, @NotNull Document document, boolean quick) { final PsiElement parent = expression.getParent(); if (!(parent instanceof PsiVariable)) { return; } final PsiType declType = ((PsiVariable)parent).getType(); if (!(declType instanceof PsiClassReferenceType)) { return; } final PsiType[] parameters = ((PsiClassType)declType).getParameters(); if (parameters.length == 0) { return; } PsiJavaCodeReferenceElement classReference = expression.getClassReference(); if (classReference == null) { final PsiAnonymousClass anonymousClass = expression.getAnonymousClass(); if (anonymousClass != null) { classReference = anonymousClass.getBaseClassReference(); if (quick || ClosureFolding.seemsLikeLambda(anonymousClass.getSuperClass(), anonymousClass)) { return; } } } if (classReference != null) { final PsiReferenceParameterList parameterList = classReference.getParameterList(); if (parameterList != null) { if (quick) { final PsiJavaCodeReferenceElement declReference = ((PsiClassReferenceType)declType).getReference(); final PsiReferenceParameterList declList = declReference.getParameterList(); if (declList == null || !parameterList.getText().equals(declList.getText())) { return; } } else if (!Arrays.equals(parameterList.getTypeArguments(), parameters)) { return; } addTypeParametersFolding(list, document, parameterList, 5, quick); } } }