Skip to content

Commit

Permalink
Merge pull request #8 from Mouradif/master
Browse files Browse the repository at this point in the history
Added support for empty arrays in blocks annotations
  • Loading branch information
ichiriac authored Feb 16, 2019
2 parents 6c97351 + 1b2be8e commit dacf670
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ Parser.prototype.parseStatement = function () {
Parser.prototype.readArray = function (endChar) {
var result = [];
this.token = this.lexer.lex(); // consume start char
if (this.token === endChar) {
this.token = this.lexer.lex();
return result;
}
do {
var item = this.parseTopStatement();
if (item !== null) { // ignore
Expand Down
14 changes: 14 additions & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,18 @@ describe('Test parser', function () {
ast.body[0].kind.should.be.exactly('annotation');
ast.body[0].arguments.length.should.be.exactly(0);
});

it('test empty array annotation', function () {
var ast = doc.parse([
'/**',
' * @SomeArray[]',
' * @SomeOtherAnnotation',
' */'
].join('\n'));
ast.body.length.should.be.exactly(2);
ast.body[0].kind.should.be.exactly('block');
ast.body[0].options.length.should.be.exactly(1);
ast.body[0].options[0].kind.should.be.exactly('array');
ast.body[0].options[0].value.length.should.be.exactly(0);
});
});

0 comments on commit dacf670

Please sign in to comment.