mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-refactoring] InlineToAnonymousClass: better support of arrays
GitOrigin-RevId: ddb42b302f70a8b44aca06fc9c643f009ea1c3da
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2c0d7c5469
commit
ae09e7920c
+1
-1
@@ -322,7 +322,7 @@ public class InlineToAnonymousClassHandler extends JavaInlineActionHandler {
|
||||
if (parentElement instanceof PsiThisExpression) {
|
||||
return JavaBundle.message("class.cannot.be.inlined.because.it.is.used.as.a.this.qualifier");
|
||||
}
|
||||
if (parentElement instanceof PsiNewExpression newExpression) {
|
||||
if (parentElement instanceof PsiNewExpression newExpression && !newExpression.isArrayCreation()) {
|
||||
final PsiMethod[] constructors = aClass.getConstructors();
|
||||
if (constructors.length == 0) {
|
||||
PsiExpressionList newArgumentList = newExpression.getArgumentList();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
void test() {
|
||||
Inner[] data = new Inner[]{new Inner(5)};
|
||||
}
|
||||
|
||||
static class Inner<caret> {
|
||||
Inner(int x) {}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
void test() {
|
||||
Object[] data = new Object[]{new Object()};
|
||||
}
|
||||
|
||||
}
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.refactoring.inline;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -170,6 +170,10 @@ public class InlineToAnonymousClassTest extends LightRefactoringTestCase {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testArrayInitializer2() {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testVarargs() {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user