mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
extract method: fold parameters after array acces was detected (IDEA-155094)
This commit is contained in:
+4
-7
@@ -118,15 +118,12 @@ public class ParametersFolder {
|
||||
PsiExpression mostRanked = null;
|
||||
for (int i = mentionedInExpressions.size() - 1; i >= 0; i--) {
|
||||
PsiExpression expression = mentionedInExpressions.get(i);
|
||||
if (expression instanceof PsiArrayAccessExpression) {
|
||||
mostRanked = expression;
|
||||
if (!isConditional(expression, scope)) {
|
||||
myFoldingSelectedByDefault = true;
|
||||
break;
|
||||
}
|
||||
boolean arrayAccess = expression instanceof PsiArrayAccessExpression && !isConditional(expression, scope);
|
||||
if (arrayAccess) {
|
||||
myFoldingSelectedByDefault = true;
|
||||
}
|
||||
final int r = findUsedVariables(data, inputVariables, expression).size();
|
||||
if (currentRank < r) {
|
||||
if (currentRank < r || arrayAccess && currentRank == r) {
|
||||
currentRank = r;
|
||||
mostRanked = expression;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
{
|
||||
int i = 0;
|
||||
double[] doubles = null;
|
||||
|
||||
<selection>double progressResult = doubles[0] / i;</selection>
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
{
|
||||
int i = 0;
|
||||
double[] doubles = null;
|
||||
|
||||
newMethod(doubles[0] / i);
|
||||
}
|
||||
|
||||
private void newMethod(double v) {
|
||||
double progressResult = v;
|
||||
}
|
||||
}
|
||||
@@ -500,6 +500,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testArrayAccessWithTopExpression() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testArrayAccessWithDuplicates() throws Exception {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user