mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract method: skip parenthesis as they are skipped by control flow (IDEA-134904)
This commit is contained in:
+3
-2
@@ -142,8 +142,9 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
String helpId) {
|
||||
myProject = project;
|
||||
myEditor = editor;
|
||||
if (elements.length != 1 || elements.length == 1 && !(elements[0] instanceof PsiBlockStatement)) {
|
||||
myElements = elements;
|
||||
if (elements.length != 1 || !(elements[0] instanceof PsiBlockStatement)) {
|
||||
myElements = elements.length == 1 && elements[0] instanceof PsiParenthesizedExpression
|
||||
? new PsiElement[] {PsiUtil.skipParenthesizedExprDown((PsiExpression)elements[0])} : elements;
|
||||
myEnclosingBlockStatement = null;
|
||||
}
|
||||
else {
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
{
|
||||
int i = 2;
|
||||
int n = 5;
|
||||
boolean b = !<selection>(i < n)</selection>;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Test {
|
||||
{
|
||||
int i = 2;
|
||||
int n = 5;
|
||||
boolean b = !newMethod(i, n);
|
||||
}
|
||||
|
||||
private boolean newMethod(int i, int n) {
|
||||
return i < n;
|
||||
}
|
||||
}
|
||||
@@ -657,6 +657,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTheOnlyParenthesisExpressionWhichIsSkippedInControlFlow() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExpression() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user