mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-intentions] IDEA-376351 Fix false positive of 'Replace constructor with factory method'
GitOrigin-RevId: dc8c6eb072906fe89bbed5d64e7e1b108c77f3b5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a07259351d
commit
888c7be55e
+1
@@ -231,6 +231,7 @@ public final class ReplaceConstructorWithFactoryAction implements ModCommandActi
|
||||
if (element == null) return null;
|
||||
PsiMethod method = MethodUtils.getJavaMethodFromHeader(element);
|
||||
if (method != null) {
|
||||
if (method.getBody() == null) return null;
|
||||
if (!method.isConstructor()) return null;
|
||||
var containingClass = method.getContainingClass();
|
||||
if (!isSuitableClass(containingClass)) return null;
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.intellij.openapi.graph.services;
|
||||
|
||||
public final class GraphExportService {
|
||||
|
||||
private vola<caret>tile boo(lean myPrintMode = false;
|
||||
private volatile boolean myExportMode = false;
|
||||
|
||||
private static final GraphExportService INSTANCE = new GraphExportService();
|
||||
|
||||
public static GraphExportService getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private GraphExportService() {
|
||||
}
|
||||
|
||||
public boolean isPrintMode() {
|
||||
return myPrintMode;
|
||||
}
|
||||
|
||||
public void setPrintMode(boolean printMode) {
|
||||
myPrintMode = printMode;
|
||||
}
|
||||
|
||||
public boolean isExportMode() {
|
||||
return myExportMode;
|
||||
}
|
||||
|
||||
public void setExportMode(boolean exportMode) {
|
||||
myExportMode = exportMode;
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -83,9 +83,9 @@ public class ReplaceConstructorWithFactoryTest extends LightRefactoringTestCase
|
||||
public void testConstructorTypeParameters() { runTest("08", null); }
|
||||
|
||||
public void testInnerClass2() { runTest("InnerClass2", "SimpleClass"); }
|
||||
|
||||
public void testIncompleteClass() {
|
||||
assertNotAvailable("IncompleteClass");
|
||||
|
||||
public void testIncompleteClass() {
|
||||
assertNotAvailable("IncompleteClass");
|
||||
}
|
||||
|
||||
public void testInjection() {
|
||||
@@ -123,6 +123,10 @@ public class ReplaceConstructorWithFactoryTest extends LightRefactoringTestCase
|
||||
assertNotAvailable("RedCode");
|
||||
}
|
||||
|
||||
public void testRedCodeFromIDEA376351() {
|
||||
assertNotAvailable("RedCodeFromIDEA376351");
|
||||
}
|
||||
|
||||
private void assertNotAvailable(String name) {
|
||||
configureByFile("/refactoring/replaceConstructorWithFactory/before" + name + ".java");
|
||||
ReplaceConstructorWithFactoryAction action = new ReplaceConstructorWithFactoryAction();
|
||||
|
||||
Reference in New Issue
Block a user