inline: support for {} array initializer signature (IDEADEV-40588)

This commit is contained in:
anna
2009-10-06 19:59:55 +04:00
parent ea234d5107
commit 6dd60065a9
6 changed files with 42 additions and 0 deletions
@@ -136,6 +136,14 @@ class InlineConstantFieldProcessor extends BaseRefactoringProcessor {
break;
}
if (initializer1 instanceof PsiArrayInitializerExpression) {
final PsiType type = expr.getType();
if (type != null) {
initializer1 = (PsiExpression)initializer1.replace(
(PsiNewExpression)JavaPsiFacade.getInstance(expr.getProject()).getElementFactory()
.createExpressionFromText("new " + type.getCanonicalText() + initializer1.getText(), initializer1));
}
}
myField.normalizeDeclaration();
ChangeContextUtil.encodeContextInfo(initializer1, true);
PsiElement element = expr.replace(initializer1);
@@ -0,0 +1,7 @@
class Test {
String[] get(){
String[] to<caret>Inline = {""};
return toInline;
}
}
@@ -0,0 +1,6 @@
class Test {
String[] get(){
return new String[]{""};
}
}
@@ -0,0 +1,7 @@
class Test {
String[] get(){
String[] to<caret>Inline = new String[]{""};
return toInline;
}
}
@@ -0,0 +1,6 @@
class Test {
String[] get(){
return new String[]{""};
}
}
@@ -58,6 +58,14 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
doTest(true);
}
public void testArrayInitializer() throws Exception {
doTest(false);
}
public void testNewExpression() throws Exception {
doTest(false);
}
public void testAugmentedAssignment() throws Exception {
String exception = null;
try {