Introduce variable does something really strange for expression in square brackets

#KT-2490 Fixed
This commit is contained in:
Natalia.Ukhorskaya
2013-03-07 14:02:15 +04:00
parent d5b5fe8503
commit 6bea9999d5
3 changed files with 16 additions and 0 deletions
@@ -526,6 +526,9 @@ public class JetIntroduceVariableHandler extends JetIntroduceHandlerBase {
((JetLoopExpression)parent.getParent()).getBody() != place) {
return true;
}
else if (parent.getParent() instanceof JetArrayAccessExpression) {
return true;
}
return false;
}
@@ -0,0 +1,9 @@
fun f(list: List<String>) {
val value = list[<selection>1 + 2</selection>]
}
/*
fun f(list: List<String>) {
val i = 1 + 2
val value = list[i]
}
*/
@@ -137,6 +137,10 @@ public class JetIntroduceVariableTest extends LightCodeInsightFixtureTestCase {
doTest();
}
public void testArrayAccessExpr() {
doTest();
}
@Override
protected void setUp() throws Exception {
super.setUp();