mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
SplitFilterAction: allow parentheses around lambda
GitOrigin-RevId: e83bfe28747e7e41e96ec430ba754507a0cb5b77
This commit is contained in:
committed by
intellij-monorepo-bot
parent
503821f46c
commit
6cfec9484e
+4
-1
@@ -26,6 +26,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.util.LambdaRefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils;
|
||||
@@ -73,7 +74,9 @@ public class MergeFilterChainAction extends PsiElementBaseIntentionAction {
|
||||
final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
|
||||
final PsiExpression[] expressions = argumentList.getExpressions();
|
||||
if (expressions.length != 1) return false;
|
||||
if (!StreamRefactoringUtil.isRefactoringCandidate(expressions[0], true)) return false;
|
||||
if (!StreamRefactoringUtil.isRefactoringCandidate(PsiUtil.skipParenthesizedExprDown(expressions[0]), true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiMethod method = methodCallExpression.resolveMethod();
|
||||
if (method == null) return false;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SplitFilterAction extends PsiElementBaseIntentionAction {
|
||||
PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
|
||||
if (!(parent instanceof PsiLambdaExpression)) return false;
|
||||
if (((PsiLambdaExpression)parent).getParameterList().getParametersCount() != 1) return false;
|
||||
parent = parent.getParent();
|
||||
parent = PsiUtil.skipParenthesizedExprUp(parent.getParent());
|
||||
|
||||
if (!(parent instanceof PsiExpressionList)) return false;
|
||||
final PsiElement gParent = parent.getParent();
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ import java.util.stream.Stream;
|
||||
class Test {
|
||||
void foo(Stream<String> stringStream ) {
|
||||
stringStream.filter(name -> name.startsWith("A")//starts with A
|
||||
).filter(name -> /*comment*/name.length() > 1).findAny();
|
||||
).filter((name -> /*comment*/name.length() > 1)).findAny();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
import java.util.stream.Stream;
|
||||
class Test {
|
||||
void foo(Stream<String> stringStream ) {
|
||||
stringStream.filter(name -> name.startsWith("A") //starts with A
|
||||
&<caret>& /*comment*/name.length() > 1).findAny();
|
||||
stringStream.filter((name -> name.startsWith("A") //starts with A
|
||||
&<caret>& /*comment*/name.length() > 1)).findAny();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user