introduce vararg variable from the selected enumeration (IDEA-82508)

This commit is contained in:
anna
2012-03-11 19:00:58 +01:00
parent deb7f52be3
commit fd6b282da2
4 changed files with 30 additions and 1 deletions
@@ -408,7 +408,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
args, PsiSubstitutor.EMPTY, parent,
DefaultParameterTypeInferencePolicy.INSTANCE);
if (startOffset < args[parameters.length - 1].getTextOffset()) return null;
if (startOffset < args[parameters.length - 1].getTextRange().getStartOffset()) return null;
final PsiFile containingFile = parent.getContainingFile();
@@ -0,0 +1,13 @@
class Test {
void foo(E... e) {
}
void bar() {
E[] strs = {E.E1, E.E2};
foo(strs);
}
}
static enum E {
E1, E2;
}
@@ -0,0 +1,12 @@
class Test {
void foo(E... e) {
}
void bar() {
foo(<selection>E.E1, E.E2</selection>);
}
}
static enum E {
E1, E2;
}
@@ -202,6 +202,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
public void testArrayFromVarargs1() throws Exception {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String[]"));
}
public void testEnumArrayFromVarargs() throws Exception {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "E[]"));
}
public void testFromFinalFieldOnAssignment() throws Exception {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String"));