diff --git a/lib/jsdoc/src/astbuilder.js b/lib/jsdoc/src/astbuilder.js index 4c5cae4c..83670e93 100644 --- a/lib/jsdoc/src/astbuilder.js +++ b/lib/jsdoc/src/astbuilder.js @@ -8,6 +8,7 @@ var parserOptions = exports.parserOptions = { ranges: true, sourceType: 'module', plugins: [ + 'decorators2', 'doExpressions', 'estree', 'jsx', diff --git a/lib/jsdoc/src/syntax.js b/lib/jsdoc/src/syntax.js index f8bc1bc3..bbe27629 100644 --- a/lib/jsdoc/src/syntax.js +++ b/lib/jsdoc/src/syntax.js @@ -21,6 +21,7 @@ exports.Syntax = { ConditionalExpression: 'ConditionalExpression', ContinueStatement: 'ContinueStatement', DebuggerStatement: 'DebuggerStatement', + Decorator: 'Decorator', DoExpression: 'DoExpression', DoWhileStatement: 'DoWhileStatement', EmptyStatement: 'EmptyStatement', diff --git a/lib/jsdoc/src/walker.js b/lib/jsdoc/src/walker.js index 63e322e7..12c4abb4 100644 --- a/lib/jsdoc/src/walker.js +++ b/lib/jsdoc/src/walker.js @@ -149,6 +149,12 @@ walkers[Syntax.ClassDeclaration] = function(node, parent, state, cb) { if (node.body) { cb(node.body, node, state); } + + if (node.decorators) { + for (var i = 0, l = node.decorators.length; i < l; i++) { + cb(node.decorators[i], node, state); + } + } }; walkers[Syntax.ClassExpression] = walkers[Syntax.ClassDeclaration]; @@ -179,6 +185,10 @@ walkers[Syntax.ContinueStatement] = leafNode; walkers[Syntax.DebuggerStatement] = leafNode; +walkers[Syntax.Decorator] = function(node, parent, state, cb) { + cb(node.expression, node, state); +}; + walkers[Syntax.DoExpression] = function(node, parent, state, cb) { cb(node.body, node, state); }; @@ -406,6 +416,12 @@ walkers[Syntax.MethodDefinition] = function(node, parent, state, cb) { if (node.value) { cb(node.value, node, state); } + + if (node.decorators) { + for (var i = 0, l = node.decorators.length; i < l; i++) { + cb(node.decorators[i], node, state); + } + } }; walkers[Syntax.ModuleDeclaration] = function(node, parent, state, cb) { @@ -455,6 +471,12 @@ walkers[Syntax.Property] = function(node, parent, state, cb) { moveLeadingComments(node.key, node); cb(node.value, node, state); + + if (node.decorators) { + for (var i = 0, l = node.decorators.length; i < l; i++) { + cb(node.decorators[i], node, state); + } + } }; walkers[Syntax.RestElement] = function(node, parent, state, cb) {