mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: don't make enum class explicitly abstract on method pull-up (IDEA-236396)
GitOrigin-RevId: 3f4924e16741deec404747f74c7e7c93999b70aa
This commit is contained in:
committed by
intellij-monorepo-bot
parent
751c572919
commit
8202fb4857
@@ -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.refactoring.util;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
|
||||
@@ -36,6 +36,7 @@ import com.intellij.refactoring.introduceField.ElementToWorkOn;
|
||||
import com.intellij.util.CommonJavaRefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -117,7 +118,7 @@ public final class RefactoringUtil {
|
||||
final PsiImportList importList = ((PsiJavaFile)element.getContainingFile()).getImportList();
|
||||
if (importList != null) {
|
||||
final PsiImportStaticStatement[] importStaticStatements = importList.getImportStaticStatements();
|
||||
return Arrays.stream(importStaticStatements).anyMatch(stmt -> stmt.isOnDemand() && stmt.resolveTargetClass() == aClass);
|
||||
return ContainerUtil.exists(importStaticStatements, stmt -> stmt.isOnDemand() && stmt.resolveTargetClass() == aClass);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -386,7 +387,9 @@ public final class RefactoringUtil {
|
||||
}
|
||||
|
||||
if (!targetClass.isInterface()) {
|
||||
PsiUtil.setModifierProperty(targetClass, PsiModifier.ABSTRACT, true);
|
||||
if (!targetClass.isEnum()) {
|
||||
PsiUtil.setModifierProperty(targetClass, PsiModifier.ABSTRACT, true);
|
||||
}
|
||||
prepareForAbstract(method);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
enum TestEnum {
|
||||
|
||||
A {
|
||||
void <caret>foo() {}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
enum TestEnum {
|
||||
|
||||
A {
|
||||
@Override
|
||||
void foo() {}
|
||||
};
|
||||
|
||||
abstract void foo();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// 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;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -31,6 +31,10 @@ public class PullUpTest extends LightRefactoringTestCase {
|
||||
doTest(new RefactoringTestUtil.MemberDescriptor("Inner", PsiClass.class));
|
||||
}
|
||||
|
||||
public void testPullUpEnumMethodAndMakeAbstract() {
|
||||
doTest(new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class, true));
|
||||
}
|
||||
|
||||
public void testQualifiedReference() { // IDEADEV-25008
|
||||
doTest(new RefactoringTestUtil.MemberDescriptor("x", PsiField.class),
|
||||
new RefactoringTestUtil.MemberDescriptor("getX", PsiMethod.class),
|
||||
|
||||
Reference in New Issue
Block a user