Introduce variable does something really strange for expression in square brackets
#KT-2490 Fixed
This commit is contained in:
+3
@@ -526,6 +526,9 @@ public class JetIntroduceVariableHandler extends JetIntroduceHandlerBase {
|
|||||||
((JetLoopExpression)parent.getParent()).getBody() != place) {
|
((JetLoopExpression)parent.getParent()).getBody() != place) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (parent.getParent() instanceof JetArrayAccessExpression) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
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]
|
||||||
|
}
|
||||||
|
*/
|
||||||
+4
@@ -137,6 +137,10 @@ public class JetIntroduceVariableTest extends LightCodeInsightFixtureTestCase {
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testArrayAccessExpr() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|||||||
Reference in New Issue
Block a user