Skip to content

Commit

Permalink
avoid reserved keywords like constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Jan 19, 2017
1 parent 53cd23f commit f820f4d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Parser.prototype.parseAnnotation = function () {
this.token = this.lexer.lex(); // eat the tag name

// grammar specific annotation
if (this.grammar[type]) {
if (Array.isArray(this.grammar[type])) {
var backup = this.lexer.state();
result = this.parseGrammar(type);
if (result !== null) {
Expand Down
27 changes: 27 additions & 0 deletions test/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@ describe('Test annotations', function () {
ast.body[0].name.should.be.exactly('foobar');
ast.body[0].options.length.should.be.exactly(0);
});
it('should every block', function () {
var ast = doc.parse([
'/**',
' * @constructor',
' * @param SimpleElement $element',
' * @param BlockFactory $blockFactory',
' * @param Mapper $mapper',
' * @param BrowserInterface $browser',
' * @param SequenceSorterInterface $sequenceSorter',
' * @param ObjectManager $objectManager',
' * @param array $config [optional]',
' */'
].join('\r'));
JSON.stringify(ast.body).should.be.exactly(
'[' +
'{"kind":"block","name":"constructor","options":[]},' +
'{"kind":"param","type":{"kind":"type","fqn":false,"name":"SimpleElement"},"name":"element","description":""},' +
'{"kind":"param","type":{"kind":"type","fqn":false,"name":"BlockFactory"},"name":"blockFactory","description":""},' +
'{"kind":"param","type":{"kind":"type","fqn":false,"name":"Mapper"},"name":"mapper","description":""},' +
'{"kind":"param","type":{"kind":"type","fqn":false,"name":"BrowserInterface"},"name":"browser","description":""},' +
'{"kind":"param","type":{"kind":"type","fqn":false,"name":"SequenceSorterInterface"},"name":"sequenceSorter","description":""},' +
'{"kind":"param","type":{"kind":"type","fqn":false,"name":"ObjectManager"},"name":"objectManager","description":""},' +
'{"kind":"param","type":{"kind":"type","fqn":false,"name":"array"},"name":"config","description":""},{"kind":"array","value":["optional"]}' +
']'
);
});

it('should parse', function () {
var ast = doc.parse([
'/**',
Expand Down

0 comments on commit f820f4d

Please sign in to comment.