parse decorators (#1165)

This change allows decorators to be parsed, but it does not add information about decorators to the generated documentation.
This commit is contained in:
Jeff Williams 2017-07-04 16:01:01 -07:00
parent b719e68907
commit fb37938b77
3 changed files with 24 additions and 0 deletions

View File

@ -8,6 +8,7 @@ var parserOptions = exports.parserOptions = {
ranges: true,
sourceType: 'module',
plugins: [
'decorators2',
'doExpressions',
'estree',
'jsx',

View File

@ -21,6 +21,7 @@ exports.Syntax = {
ConditionalExpression: 'ConditionalExpression',
ContinueStatement: 'ContinueStatement',
DebuggerStatement: 'DebuggerStatement',
Decorator: 'Decorator',
DoExpression: 'DoExpression',
DoWhileStatement: 'DoWhileStatement',
EmptyStatement: 'EmptyStatement',

View File

@ -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) {