do not generate protected constructors for enums (IDEA-53086)

This commit is contained in:
anna
2010-11-15 12:59:20 +03:00
parent cd7ee51187
commit e102ffa653
4 changed files with 24 additions and 1 deletions

View File

@@ -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)) {

View File

@@ -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() {
}
}

View File

@@ -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>
}

View File

@@ -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();