ClosureFolding (@NotNull PsiAnonymousClass anonymousClass, boolean quick, @NotNull JavaFoldingBuilderBase builder) { PsiElement parent = anonymousClass.getParent(); if (parent instanceof PsiNewExpression && hasNoArguments((PsiNewExpression)parent)) { PsiClass baseClass = quick ? null : anonymousClass.getBaseClassType().resolve(); if (hasOnlyOneLambdaMethod(anonymousClass, !quick) && (quick || seemsLikeLambda(baseClass, anonymousClass))) { PsiMethod method = anonymousClass.getMethods()[0]; PsiCodeBlock body = method.getBody(); if (body != null) { return new ClosureFolding(anonymousClass, (PsiNewExpression)parent, quick, baseClass, builder, method, body); } } } return null; }