mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline: support for {} array initializer signature (IDEADEV-40588)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user