Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

Commit

Permalink
Really fixed the commenting in fields with validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu ABOU-AICHI committed Dec 21, 2016
1 parent 223b495 commit 21ac3e4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/dsl/grammar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ entityBody
/ '' { return []; }

fieldDeclList
= SPACE* com:comment? SPACE* f:FIELD_NAME SPACE_WITHOUT_NEWLINE* t:type SPACE_WITHOUT_NEWLINE* vl:validationList? SPACE_WITHOUT_NEWLINE* com2:comment? SPACE* ','? SPACE* fdl:fieldDeclList {
= SPACE* com:comment? SPACE* f:FIELD_NAME SPACE_WITHOUT_NEWLINE* t:type SPACE_WITHOUT_NEWLINE* vl:validationList? SPACE_WITHOUT_NEWLINE* com2:comment? SPACE_WITHOUT_NEWLINE* ','? SPACE* fdl:fieldDeclList {
return addUniqueElements([{ name: f, type: t, validations: vl, javadoc: com || com2 }], fdl );
}
/ '' { return []; }

validationList
= v:validation SPACE* vl:validationList { return addUniqueElements([v], vl); }
= v:validation SPACE_WITHOUT_NEWLINE* vl:validationList { return addUniqueElements([v], vl); }
/ '' { return []; }

//Relationship
Expand Down
8 changes: 4 additions & 4 deletions lib/dsl/pegjs_parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions test/spec/parser/jdl_parser_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,25 @@ describe('JDLParser', function () {
validations: {}
}
});
expect(content.entities.TestEntity2.fields).to.deep.eq({
first: {
name: 'first',
comment: 'first comment',
type: 'String',
validations: {
required: {
name: 'required',
value: ''
}
}
},
second: {
name: 'second',
comment: 'second comment',
type: 'String',
validations: {}
}
});
});
});
});
Expand Down
22 changes: 15 additions & 7 deletions test/test_files/field_comments.jdl
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
entity TestEntity {
/** first comment */
first String
/** second comment */
second String
third Integer
/* another */
fourth String
/** first comment */
first String
/** second comment */
second String
third Integer
/* another */
fourth String
}


entity TestEntity2 {
/** first comment */
first String required
/** second comment */
second String
}

0 comments on commit 21ac3e4

Please sign in to comment.