private static boolean isPartOfLargerExpression(PsiPolyadicExpression expression) { if (expression.getOperands().length > 2) { return true; } final PsiElement containingElement = expression.getParent(); if (containingElement instanceof PsiExpression) { final PsiExpression containingExpression = (PsiExpression) containingElement; if (!PsiUtil.isConstantExpression(containingExpression)) { return false; } } else { return false; } return true; }
@Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { final PsiPolyadicExpression expression = SplitConditionUtil.findCondition(element, true, false); if (expression == null || expression.getOperands().length < 2) return false; PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent()); if (!(parent instanceof PsiLambdaExpression)) return false; if (((PsiLambdaExpression) parent).getParameterList().getParametersCount() != 1) return false; parent = parent.getParent(); if (!(parent instanceof PsiExpressionList)) return false; final PsiElement gParent = parent.getParent(); if (!(gParent instanceof PsiMethodCallExpression)) return false; if (MergeFilterChainAction.isFilterCall((PsiMethodCallExpression) gParent)) { return true; } return false; }