Skip to content

Commit

Permalink
Added semicolon after the last property name
Browse files Browse the repository at this point in the history
Signed-off-by: Subhajit Ghosh <[email protected]>
  • Loading branch information
subhajit20 committed Apr 3, 2024
1 parent 7c14d70 commit 18522a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/codegen/fromcto/java/javavisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ class JavaVisitor {
this.plugin.addEnumAnnotations(enumDeclaration, parameters);
parameters.fileWriter.writeLine(0, 'public enum ' + enumDeclaration.getName() + ' {' );

if(!parameters.property_len){
parameters.property_len = enumDeclaration.getOwnProperties().length - 1;
}

enumDeclaration.getOwnProperties().forEach((property) => {
property.accept(this, parameters);
parameters.property_len--;
});

parameters.fileWriter.writeLine(1, '@Override');
Expand Down Expand Up @@ -313,7 +318,7 @@ class JavaVisitor {
* @private
*/
visitEnumValueDeclaration(enumValueDeclaration, parameters) {
parameters.fileWriter.writeLine(1, enumValueDeclaration.getName() + ',' );
parameters.fileWriter.writeLine(1, enumValueDeclaration.getName() + `${parameters.property_len === 0 ? ';' : ','}` );
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions test/codegen/__snapshots__/codegen.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ public enum State {
CO,
WA,
IL,
CA,
CA;
@Override
public String toString() {
return name();
Expand Down Expand Up @@ -7106,7 +7106,7 @@ public enum State {
CO,
WA,
IL,
CA,
CA;
@Override
public String toString() {
return name();
Expand Down
2 changes: 1 addition & 1 deletion test/codegen/fromcto/java/javavisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('JavaVisitor', function () {
let acceptSpy = sinon.spy();

let param = {
fileWriter: mockFileWriter
fileWriter: mockFileWriter,
};

let mockEnumDeclaration = sinon.createStubInstance(EnumDeclaration);
Expand Down

0 comments on commit 18522a9

Please sign in to comment.