mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-refactoring] CodeBlockSurrounder: do not fail when parentheses are removed by nested surrounder
Found by property tests GitOrigin-RevId: 244eea39dbb352bb1486a99d2aab9c5e636693b1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b03f6c2569
commit
9276b73b49
+10
@@ -0,0 +1,10 @@
|
||||
class X{
|
||||
|
||||
boolean test(String s1, String s2) {
|
||||
if (s1 == null) return true;
|
||||
if (!s2.equals(s1.trim())) return false;
|
||||
boolean foo = s1.isEmpty();
|
||||
return foo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class X{
|
||||
|
||||
boolean test(String s1, String s2) {
|
||||
return s1 == null || (s2.equals(s1.trim()) && <selection>s1.isEmpty()</selection>);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -347,6 +347,7 @@ public class IntroduceVariableTest extends LightJavaCodeInsightTestCase {
|
||||
public void testCapturedWildcardUpperBoundSuggestedAsType() { doTest("m", false, false, false, "I"); }
|
||||
public void testArrayOfCapturedWildcardUpperBoundSuggestedAsType() { doTest("m", false, false, false, "I[]"); }
|
||||
public void testFieldFromLambda() { doTest("foo", false, false, true, "int"); }
|
||||
public void testNestedAndOrParentheses() { doTest("foo", false, false, false, "boolean"); }
|
||||
|
||||
public void testReturnNonExportedArray() {
|
||||
doTest(new MockIntroduceVariableHandler("i", false, false, false, "java.io.File[]") {
|
||||
|
||||
+6
-2
@@ -132,8 +132,12 @@ public abstract class CodeBlockSurrounder {
|
||||
* @return the expression that replaced the original expression
|
||||
*/
|
||||
public @NotNull CodeBlockSurrounder.SurroundResult surround() {
|
||||
Object marker = new Object();
|
||||
PsiTreeUtil.mark(myExpression, marker);
|
||||
Object marker = ObjectUtils.sentinel("CodeBlockSurrounder.MARKER");
|
||||
PsiExpression expr = PsiUtil.skipParenthesizedExprDown(myExpression);
|
||||
if (expr == null) {
|
||||
expr = myExpression;
|
||||
}
|
||||
PsiTreeUtil.mark(expr, marker);
|
||||
Project project = myExpression.getProject();
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
|
||||
boolean physical = myExpression.isPhysical();
|
||||
|
||||
Reference in New Issue
Block a user