mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-162696 Intention "Merge filter chain" does not add parentheses if necessary
This commit is contained in:
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ig.psiutils.ParenthesesUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -139,7 +140,9 @@ public class MergeFilterChainAction extends PsiElementBaseIntentionAction {
|
||||
|
||||
|
||||
final PsiExpression compoundExpression = JavaPsiFacade.getElementFactory(project)
|
||||
.createExpressionFromText(targetBody.getText() + " && " + sourceLambdaBody.getText(), sourceLambda);
|
||||
.createExpressionFromText(
|
||||
ParenthesesUtils.getText((PsiExpression)targetBody, ParenthesesUtils.OR_PRECEDENCE) + " && " +
|
||||
ParenthesesUtils.getText((PsiExpression)sourceLambdaBody, ParenthesesUtils.OR_PRECEDENCE), sourceLambda);
|
||||
targetBody = targetBody.replace(compoundExpression);
|
||||
CodeStyleManager.getInstance(project).reformat(targetBody);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user