mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-intentions] Ignore array creations
#IDEA-377378 Fixed GitOrigin-RevId: 5341d608d7deef08a4bfe7bf699091f960790493
This commit is contained in:
committed by
intellij-monorepo-bot
parent
985dcb373a
commit
2c6c9d7c1d
+4
@@ -119,6 +119,10 @@ public final class ReplaceConstructorWithFactoryAction implements ModCommandActi
|
||||
PsiUtil.setModifierProperty(wrConstructor, getMinimalAccessLevel(constructorOrClass, usages.otherUsages), true);
|
||||
|
||||
for (PsiNewExpression newExpression : writableUsages) {
|
||||
if (newExpression.isArrayCreation()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var factoryCall = (PsiMethodCallExpression)factory.createExpressionFromText(factoryName + "()", newExpression);
|
||||
CommentTracker ct = new CommentTracker();
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class List<T> {
|
||||
T t;
|
||||
|
||||
private List() {
|
||||
}
|
||||
|
||||
static <T> List<T> createList() {
|
||||
return new List<T>();
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
void foo (){
|
||||
List x = List.createList();
|
||||
List[] y = new List [10];
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class List<T> {
|
||||
T t;
|
||||
}
|
||||
|
||||
class Test {
|
||||
void foo (){
|
||||
List x = new List<T>();
|
||||
List[] y = new List [10];
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.refactoring;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -131,6 +131,10 @@ public class ReplaceConstructorWithFactoryTest extends LightRefactoringTestCase
|
||||
assertNotAvailable("RedCodeFromIDEA376351");
|
||||
}
|
||||
|
||||
public void testArrayCreation() {
|
||||
runTest("ArrayCreation", null);
|
||||
}
|
||||
|
||||
private void assertNotAvailable(String name) {
|
||||
configureByFile("/refactoring/replaceConstructorWithFactory/before" + name + ".java");
|
||||
ReplaceConstructorWithFactoryAction action = new ReplaceConstructorWithFactoryAction();
|
||||
|
||||
Reference in New Issue
Block a user