priority of array index expression (IDEA-147503)

This commit is contained in:
Anna Kozlova
2015-11-06 20:36:47 +01:00
parent 6348011d80
commit 8405c19832
4 changed files with 16 additions and 1 deletions
@@ -75,7 +75,7 @@ public class ReplaceExpressionUtil {
}
else if (i == JavaElementType.ARRAY_ACCESS_EXPRESSION) {
int role = ((CompositeElement)oldParent).getChildRole(oldExpr);
return role != ChildRole.ARRAY_DIMENSION && priority < parentPriority;
return role != ChildRole.ARRAY_DIMENSION && role != ChildRole.INDEX && priority < parentPriority;
}
else if (i == JavaElementType.ARRAY_INITIALIZER_EXPRESSION) {
return false;
@@ -0,0 +1,6 @@
class C {
void f(int[] a, int i) {
int i1 = i + 1;
int temp = a[i<caret>1];
}
}
@@ -0,0 +1,5 @@
class C {
void f(int[] a, int i) {
int temp = a[i + 1];
}
}
@@ -244,6 +244,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
doTest(true);
}
public void testArrayAccessPriority() throws Exception {
doTest(true);
}
public void testLocalVarInsideLambdaBodyWriteUsage() throws Exception {
doTest(true, "Cannot perform refactoring.\n" +
"Variable 'hello' is accessed for writing");