Lines 1110-1118
Link Here
|
1110 |
if (kind == TypeDeclaration.ENUM_DECL) { |
1110 |
if (kind == TypeDeclaration.ENUM_DECL) { |
1111 |
FieldDeclaration[] fieldDeclarations = typeDeclaration.fields; |
1111 |
FieldDeclaration[] fieldDeclarations = typeDeclaration.fields; |
1112 |
boolean hasConstants = false; |
1112 |
boolean hasConstants = false; |
|
|
1113 |
int length = fieldDeclarations != null ? fieldDeclarations.length : 0; |
1114 |
int enumConstantsLength = 0; |
1113 |
if (fieldDeclarations != null) { |
1115 |
if (fieldDeclarations != null) { |
1114 |
int length = fieldDeclarations.length; |
|
|
1115 |
int enumConstantsLength = 0; |
1116 |
for (int i = 0; i < length; i++) { |
1116 |
for (int i = 0; i < length; i++) { |
1117 |
FieldDeclaration fieldDeclaration = fieldDeclarations[i]; |
1117 |
FieldDeclaration fieldDeclaration = fieldDeclarations[i]; |
1118 |
if (fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) { |
1118 |
if (fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) { |
Lines 1155-1161
Link Here
|
1155 |
} |
1155 |
} |
1156 |
} while (!ok); |
1156 |
} while (!ok); |
1157 |
this.scribe.exitAlignment(enumConstantsAlignment, true); |
1157 |
this.scribe.exitAlignment(enumConstantsAlignment, true); |
1158 |
} else { |
1158 |
} else if (hasConstants) { |
|
|
1159 |
// only one enum constant |
1159 |
FieldDeclaration fieldDeclaration = fieldDeclarations[0]; |
1160 |
FieldDeclaration fieldDeclaration = fieldDeclarations[0]; |
1160 |
fieldDeclaration.traverse(this, typeDeclaration.initializerScope); |
1161 |
fieldDeclaration.traverse(this, typeDeclaration.initializerScope); |
1161 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
1162 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
Lines 1173-1180
Link Here
|
1173 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1174 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1174 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1175 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1175 |
this.scribe.printTrailingComment(); |
1176 |
this.scribe.printTrailingComment(); |
1176 |
} |
1177 |
if (hasConstants |
1177 |
if (hasConstants) { |
1178 |
|| ((enumConstantsLength - length) != 0) |
|
|
1179 |
|| typeDeclaration.methods != null |
1180 |
|| typeDeclaration.memberTypes != null) { |
1181 |
// make sure that empty enums don't get a new line |
1182 |
this.scribe.printNewLine(); |
1183 |
} |
1184 |
} else if (hasConstants) { |
1185 |
// only had a new line if there is at least one enum constant |
1178 |
this.scribe.printNewLine(); |
1186 |
this.scribe.printNewLine(); |
1179 |
} |
1187 |
} |
1180 |
} |
1188 |
} |