mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
do not generate protected constructors for enums (IDEA-53086)
This commit is contained in:
@@ -259,7 +259,7 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
private static String getConstructorModifier(final PsiClass aClass) {
|
||||
@Modifier String modifier = PsiModifier.PUBLIC;
|
||||
|
||||
if (aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
if (aClass.hasModifierProperty(PsiModifier.ABSTRACT) && !aClass.isEnum()) {
|
||||
modifier = PsiModifier.PROTECTED;
|
||||
}
|
||||
else if (aClass.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
public enum Operation {
|
||||
PLUS {
|
||||
int eval(int x, int y) {
|
||||
return x + y;
|
||||
}
|
||||
};
|
||||
|
||||
abstract int eval(int x, int y);
|
||||
|
||||
Operation() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public enum Operation {
|
||||
PLUS {
|
||||
int eval(int x, int y) {
|
||||
return x + y;
|
||||
}
|
||||
};
|
||||
|
||||
abstract int eval(int x, int y);
|
||||
<caret>
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class GenerateConstructorTest extends LightCodeInsightTestCase {
|
||||
public void testPrivateClass() throws Exception { doTest(); }
|
||||
public void testBoundComments() throws Exception { doTest(); }
|
||||
public void testSameNamedFields() throws Exception { doTest(); }
|
||||
public void testEnumWithAbstractMethod() throws Exception { doTest(); }
|
||||
|
||||
public void testImmediatelyAfterRBrace() throws Exception { // IDEADEV-28811
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
|
||||
|
||||
Reference in New Issue
Block a user