upgrade Espree, and update code to reflect breaking changes in Espree (#977)

This commit is contained in:
Jeff Williams 2015-06-13 15:03:59 -07:00
parent 4167b2408c
commit 05a08ad6a0
10 changed files with 305 additions and 214 deletions

View File

@ -128,6 +128,9 @@ var nodeToValue = exports.nodeToValue = function(node) {
break; break;
case Syntax.AssignmentExpression: case Syntax.AssignmentExpression:
// falls through
case Syntax.AssignmentPattern:
str = nodeToValue(node.left); str = nodeToValue(node.left);
break; break;
@ -218,6 +221,10 @@ var nodeToValue = exports.nodeToValue = function(node) {
str = JSON.stringify(tempObject); str = JSON.stringify(tempObject);
break; break;
case Syntax.RestElement:
str = nodeToValue(node.argument);
break;
case Syntax.ThisExpression: case Syntax.ThisExpression:
str = 'this'; str = 'this';
break; break;
@ -255,14 +262,11 @@ exports.nodeToString = nodeToValue;
var getParamNames = exports.getParamNames = function(node) { var getParamNames = exports.getParamNames = function(node) {
var params; var params;
if ( !node || (!node.params && !node.rest) ) { if (!node || !node.params) {
return []; return [];
} }
params = node.params.slice(0); params = node.params.slice(0);
if (node.rest) {
params.push(node.rest);
}
return params.map(function(param) { return params.map(function(param) {
return nodeToValue(param); return nodeToValue(param);

View File

@ -49,9 +49,11 @@ exports.Syntax = {
ObjectPattern: 'ObjectPattern', ObjectPattern: 'ObjectPattern',
Program: 'Program', Program: 'Program',
Property: 'Property', Property: 'Property',
RestElement: 'RestElement',
ReturnStatement: 'ReturnStatement', ReturnStatement: 'ReturnStatement',
SequenceExpression: 'SequenceExpression', SequenceExpression: 'SequenceExpression',
SpreadElement: 'SpreadElement', SpreadElement: 'SpreadElement',
Super: 'Super',
SwitchCase: 'SwitchCase', SwitchCase: 'SwitchCase',
SwitchStatement: 'SwitchStatement', SwitchStatement: 'SwitchStatement',
TaggedTemplateExpression: 'TaggedTemplateExpression', TaggedTemplateExpression: 'TaggedTemplateExpression',

View File

@ -117,9 +117,30 @@ function makeInlineParamsFinisher(parser) {
} }
/** /**
* For rest parameters, create a function that will automatically update the rest parameter's * Given an array of nodes that represent function parameters, find the node for the rest parameter,
* documentation to indicate that the parameter is repeatable. If the parameter is not documented, * if any.
* the function's doclet will remain unchanged. *
* @private
* @param {Array.<Object>} params - An array of nodes that represent function parameters.
* @return {Object?} The node for the rest parameter.
*/
function findRestParam(params) {
var restParam = null;
params.some(function(param) {
if (param.type === Syntax.RestElement) {
restParam = param;
return true;
}
});
return restParam;
}
/**
* For functions that may include a rest parameter, create a function that will automatically update
* the rest parameter's documentation to indicate that the parameter is repeatable. If the parameter
* is not documented, the function's doclet will remain unchanged.
* *
* @private * @private
* @param {module:jsdoc/src/parser.Parser} parser - The JSDoc parser. * @param {module:jsdoc/src/parser.Parser} parser - The JSDoc parser.
@ -137,20 +158,46 @@ function makeRestParamFinisher(parser) {
} }
documentedParams = doclet.params = doclet.params || []; documentedParams = doclet.params = doclet.params || [];
restNode = e.code.node.rest; restNode = findRestParam(e.code.node.params);
for (var i = documentedParams.length - 1; i >= 0; i--) {
if (documentedParams[i].name === restNode.name) { if (restNode) {
documentedParams[i].variable = true; for (var i = documentedParams.length - 1; i >= 0; i--) {
break; if (documentedParams[i].name === restNode.argument.name) {
documentedParams[i].variable = true;
break;
}
} }
} }
}; };
} }
/** /**
* For functions that have at least one parameter with default values, create a function that will * Given an array of nodes that represent function parameters, find the nodes for the default
* automatically add the parameters' default values to the function's documentation. If any default * parameters, if any.
* value is already documented, the function's doclet will remain unchanged. *
* @private
* @param {Array.<Object>} params - An array of nodes that represent function parameters.
* @return {Array.<Object>} The nodes for the default parameters.
*/
function findDefaultParams(params) {
var defaultParams = [];
params.forEach(function(param) {
if (param.type === Syntax.AssignmentPattern) {
defaultParams.push(param);
}
else {
defaultParams.push(null);
}
});
return defaultParams;
}
/**
* For functions that may have at least one parameter with default values, create a function that
* will automatically add the parameters' default values to the function's documentation. If any
* default value is already documented, the function's doclet will remain unchanged.
* *
* This function is only intended to handle default parameters whose node type is `Syntax.Literal` * This function is only intended to handle default parameters whose node type is `Syntax.Literal`
* (string, numeric, and boolean literals). This is because more complex default values may include, * (string, numeric, and boolean literals). This is because more complex default values may include,
@ -167,15 +214,16 @@ function makeDefaultParamFinisher(parser) {
var defaultValues; var defaultValues;
var doclet = e.doclet; var doclet = e.doclet;
var documentedParams; var documentedParams;
var paramName;
var params; var params;
if (!doclet) { if (!doclet) {
return; return;
} }
defaultValues = e.code.node.defaults;
documentedParams = doclet.params = doclet.params || []; documentedParams = doclet.params = doclet.params || [];
params = e.code.node.params; params = e.code.node.params;
defaultValues = findDefaultParams(e.code.node.params);
for (var i = 0, j = 0, l = params.length; i < l; i++) { for (var i = 0, j = 0, l = params.length; i < l; i++) {
// bail out if we ran out of documented params // bail out if we ran out of documented params
@ -184,16 +232,22 @@ function makeDefaultParamFinisher(parser) {
} }
// if the current parameter doesn't appear to be documented, move to the next one // if the current parameter doesn't appear to be documented, move to the next one
if (params[i].name !== documentedParams[j].name) { paramName = params[i].type === Syntax.AssignmentPattern ?
params[i].left.name :
params[i].name;
if (paramName !== documentedParams[j].name) {
continue; continue;
} }
// add the default value iff a) a literal default value is defined in the code, // add the default value iff a) a literal default value is defined in the code,
// b) no default value is documented, and c) the default value is not an empty string // b) no default value is documented, and c) the default value is not an empty string
if (defaultValues[i] && defaultValues[i].type === Syntax.Literal && if (defaultValues[i] &&
defaultValues[i].right &&
defaultValues[i].right.type === Syntax.Literal &&
typeof documentedParams[j].defaultvalue === 'undefined' && typeof documentedParams[j].defaultvalue === 'undefined' &&
defaultValues[i].value !== '') { defaultValues[i].right.value !== '') {
documentedParams[j].defaultvalue = jsdoc.src.astnode.nodeToValue(defaultValues[i]); documentedParams[j].defaultvalue =
jsdoc.src.astnode.nodeToValue(defaultValues[i].right);
} }
// move to the next documented param // move to the next documented param
@ -502,13 +556,10 @@ Visitor.prototype.makeSymbolFoundEvent = function(node, parser, filename) {
extras.finishers = []; extras.finishers = [];
// handle cases where at least one parameter has a default value // handle cases where at least one parameter has a default value
if (node.defaults && node.defaults.length) { extras.finishers.push( makeDefaultParamFinisher(parser) );
extras.finishers.push( makeDefaultParamFinisher(parser) );
}
// handle rest parameters // handle rest parameters
if (node.rest) { extras.finishers.push( makeRestParamFinisher(parser) );
extras.finishers.push( makeRestParamFinisher(parser) );
}
e = new SymbolFound(node, filename, extras); e = new SymbolFound(node, filename, extras);

View File

@ -75,17 +75,7 @@ walkers[Syntax.ArrowFunctionExpression] = function(node, parent, state, cb) {
cb(node.params[i], node, state); cb(node.params[i], node, state);
} }
for (i = 0, l = node.defaults.length; i < l; i++) {
if (node.defaults[i]) {
cb(node.defaults[i], node, state);
}
}
cb(node.body, node, state); cb(node.body, node, state);
if (node.rest) {
cb(node.rest, node, state);
}
}; };
walkers[Syntax.AssignmentExpression] = function(node, parent, state, cb) { walkers[Syntax.AssignmentExpression] = function(node, parent, state, cb) {
@ -350,6 +340,12 @@ walkers[Syntax.Property] = function(node, parent, state, cb) {
cb(node.value, node, state); cb(node.value, node, state);
}; };
walkers[Syntax.RestElement] = function(node, parent, state, cb) {
if (node.argument) {
cb(node.argument, node, state);
}
};
walkers[Syntax.ReturnStatement] = function(node, parent, state, cb) { walkers[Syntax.ReturnStatement] = function(node, parent, state, cb) {
if (node.argument) { if (node.argument) {
cb(node.argument, node, state); cb(node.argument, node, state);
@ -368,6 +364,8 @@ walkers[Syntax.SpreadElement] = function(node, parent, state, cb) {
} }
}; };
walkers[Syntax.Super] = leafNode;
walkers[Syntax.SwitchCase] = function(node, parent, state, cb) { walkers[Syntax.SwitchCase] = function(node, parent, state, cb) {
if (node.test) { if (node.test) {
cb(node.test, node, state); cb(node.test, node, state);
@ -426,20 +424,10 @@ walkers[Syntax.TryStatement] = function(node, parent, state, cb) {
cb(node.block, node, state); cb(node.block, node, state);
// handle Esprima ASTs, which deviate from the spec a bit if (node.handler) {
if ( node.handlers && Array.isArray(node.handlers) && node.handlers[0] ) {
cb(node.handlers[0].body, node, state);
}
else if (node.handler) {
cb(node.handler.body, node, state); cb(node.handler.body, node, state);
} }
if (node.guardedHandlers) {
for (i = 0, l = node.guardedHandlers.length; i < l; i++) {
cb(node.guardedHandlers[i].body, node, state);
}
}
if (node.finalizer) { if (node.finalizer) {
cb(node.finalizer, node, state); cb(node.finalizer, node, state);
} }

152
node_modules/espree/espree.js generated vendored
View File

@ -2277,9 +2277,7 @@ function parsePropertyFunction(paramInfo, options) {
return markerApply(options.marker, astNodeFactory.createFunctionExpression( return markerApply(options.marker, astNodeFactory.createFunctionExpression(
null, null,
paramInfo.params, paramInfo.params,
paramInfo.defaults,
body, body,
paramInfo.rest,
generator, generator,
body.type !== astNodeTypes.BlockStatement body.type !== astNodeTypes.BlockStatement
)); ));
@ -2388,11 +2386,9 @@ function tryParseMethodDefinition(token, key, computed, marker) {
value = parsePropertyFunction({ value = parsePropertyFunction({
params: [], params: [],
defaults: [],
stricted: null, stricted: null,
firstRestricted: null, firstRestricted: null,
message: null, message: null
rest: null
}, { }, {
marker: methodMarker marker: methodMarker
}); });
@ -2408,19 +2404,14 @@ function tryParseMethodDefinition(token, key, computed, marker) {
options = { options = {
params: [], params: [],
defaultCount: 0, defaultCount: 0,
defaults: [],
stricted: null, stricted: null,
firstRestricted: null, firstRestricted: null,
paramSet: new StringMap(), paramSet: new StringMap()
rest: null
}; };
if (match(")")) { if (match(")")) {
throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value); throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value);
} else { } else {
parseParam(options); parseParam(options);
if (options.defaultCount === 0) {
options.defaults = [];
}
} }
expect(")"); expect(")");
@ -2521,20 +2512,15 @@ function parseObjectProperty() {
options = { options = {
params: [], params: [],
defaultCount: 0, defaultCount: 0,
defaults: [],
stricted: null, stricted: null,
firstRestricted: null, firstRestricted: null,
paramSet: new StringMap(), paramSet: new StringMap()
rest: null
}; };
if (match(")")) { if (match(")")) {
throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value); throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value);
} else { } else {
parseParam(options); parseParam(options);
if (options.defaultCount === 0) {
options.defaults = [];
}
} }
expect(")"); expect(")");
@ -2866,7 +2852,7 @@ function parsePrimaryExpression() {
if (allowSuper && matchKeyword("super") && state.inFunctionBody) { if (allowSuper && matchKeyword("super") && state.inFunctionBody) {
marker = markerCreate(); marker = markerCreate();
lex(); lex();
return markerApply(marker, astNodeFactory.createIdentifier("super")); return markerApply(marker, astNodeFactory.createSuper());
} }
if (matchKeyword("this")) { if (matchKeyword("this")) {
@ -2910,7 +2896,6 @@ function parseArguments() {
var args = [], arg; var args = [], arg;
expect("("); expect("(");
if (!match(")")) { if (!match(")")) {
while (index < length) { while (index < length) {
arg = parseSpreadOrAssignmentExpression(); arg = parseSpreadOrAssignmentExpression();
@ -3276,12 +3261,10 @@ function parseConciseBody() {
} }
function reinterpretAsCoverFormalsList(expressions) { function reinterpretAsCoverFormalsList(expressions) {
var i, len, param, params, defaults, defaultCount, options, rest; var i, len, param, params, options,
allowRestParams = extra.ecmaFeatures.restParams;
params = []; params = [];
defaults = [];
defaultCount = 0;
rest = null;
options = { options = {
paramSet: new StringMap() paramSet: new StringMap()
}; };
@ -3290,23 +3273,34 @@ function reinterpretAsCoverFormalsList(expressions) {
param = expressions[i]; param = expressions[i];
if (param.type === astNodeTypes.Identifier) { if (param.type === astNodeTypes.Identifier) {
params.push(param); params.push(param);
defaults.push(null);
validateParam(options, param, param.name); validateParam(options, param, param.name);
} else if (param.type === astNodeTypes.ObjectExpression || param.type === astNodeTypes.ArrayExpression) { } else if (param.type === astNodeTypes.ObjectExpression || param.type === astNodeTypes.ArrayExpression) {
reinterpretAsDestructuredParameter(options, param); reinterpretAsDestructuredParameter(options, param);
params.push(param); params.push(param);
defaults.push(null);
} else if (param.type === astNodeTypes.SpreadElement) { } else if (param.type === astNodeTypes.SpreadElement) {
assert(i === len - 1, "It is guaranteed that SpreadElement is last element by parseExpression"); assert(i === len - 1, "It is guaranteed that SpreadElement is last element by parseExpression");
if (param.argument.type !== astNodeTypes.Identifier) { if (param.argument.type !== astNodeTypes.Identifier) {
throwError({}, Messages.InvalidLHSInFormalsList); throwError({}, Messages.UnexpectedToken, "[");
} }
if (!allowRestParams) {
// can't get correct line/column here :(
throwError({}, Messages.UnexpectedToken, ".");
}
reinterpretAsDestructuredParameter(options, param.argument); reinterpretAsDestructuredParameter(options, param.argument);
rest = param.argument; param.type = astNodeTypes.RestElement;
params.push(param);
} else if (param.type === astNodeTypes.RestElement) {
params.push(param);
validateParam(options, param.argument, param.argument.name);
} else if (param.type === astNodeTypes.AssignmentExpression) { } else if (param.type === astNodeTypes.AssignmentExpression) {
params.push(param.left);
defaults.push(param.right); // TODO: Find a less hacky way of doing this
++defaultCount; param.type = astNodeTypes.AssignmentPattern;
delete param.operator;
params.push(param);
validateParam(options, param.left, param.left.name); validateParam(options, param.left, param.left.name);
} else { } else {
return null; return null;
@ -3320,15 +3314,8 @@ function reinterpretAsCoverFormalsList(expressions) {
); );
} }
// must be here so it's not an array of [null, null]
if (defaultCount === 0) {
defaults = [];
}
return { return {
params: params, params: params,
defaults: defaults,
rest: rest,
stricted: options.stricted, stricted: options.stricted,
firstRestricted: options.firstRestricted, firstRestricted: options.firstRestricted,
message: options.message message: options.message
@ -3353,9 +3340,7 @@ function parseArrowFunctionExpression(options, marker) {
strict = previousStrict; strict = previousStrict;
return markerApply(marker, astNodeFactory.createArrowFunctionExpression( return markerApply(marker, astNodeFactory.createArrowFunctionExpression(
options.params, options.params,
options.defaults,
body, body,
options.rest,
body.type !== astNodeTypes.BlockStatement body.type !== astNodeTypes.BlockStatement
)); ));
} }
@ -3696,6 +3681,30 @@ function parseConstLetDeclaration(kind) {
return markerApply(marker, astNodeFactory.createVariableDeclaration(declarations, kind)); return markerApply(marker, astNodeFactory.createVariableDeclaration(declarations, kind));
} }
function parseRestElement() {
var param,
marker = markerCreate();
lex();
if (match("{")) {
throwError(lookahead, Messages.ObjectPatternAsRestParameter);
}
param = parseVariableIdentifier();
if (match("=")) {
throwError(lookahead, Messages.DefaultRestParameter);
}
if (!match(")")) {
throwError(lookahead, Messages.ParameterAfterRestParameter);
}
return markerApply(marker, astNodeFactory.createRestElement(param));
}
// 12.3 Empty Statement // 12.3 Empty Statement
function parseEmptyStatement() { function parseEmptyStatement() {
@ -4059,6 +4068,9 @@ function parseSwitchCase() {
break; break;
} }
statement = parseSourceElement(); statement = parseSourceElement();
if (typeof statement === "undefined") {
break;
}
consequent.push(statement); consequent.push(statement);
} }
@ -4402,19 +4414,21 @@ function validateParam(options, param, name) {
} }
function parseParam(options) { function parseParam(options) {
var token, rest, param, def, var token, param, def,
allowRestParams = extra.ecmaFeatures.restParams, allowRestParams = extra.ecmaFeatures.restParams,
allowDestructuring = extra.ecmaFeatures.destructuring, allowDestructuring = extra.ecmaFeatures.destructuring,
allowDefaultParams = extra.ecmaFeatures.defaultParams; allowDefaultParams = extra.ecmaFeatures.defaultParams,
marker = markerCreate();
token = lookahead; token = lookahead;
if (token.value === "...") { if (token.value === "...") {
if (!allowRestParams) { if (!allowRestParams) {
throwUnexpected(lookahead); throwUnexpected(lookahead);
} }
token = lex(); param = parseRestElement();
rest = true; validateParam(options, param.argument, param.argument.name);
options.params.push(param);
return false;
} }
if (match("[")) { if (match("[")) {
@ -4424,9 +4438,6 @@ function parseParam(options) {
param = parseArrayInitialiser(); param = parseArrayInitialiser();
reinterpretAsDestructuredParameter(options, param); reinterpretAsDestructuredParameter(options, param);
} else if (match("{")) { } else if (match("{")) {
if (rest) {
throwError({}, Messages.ObjectPatternAsRestParameter);
}
if (!allowDestructuring) { if (!allowDestructuring) {
throwUnexpected(lookahead); throwUnexpected(lookahead);
} }
@ -4438,9 +4449,6 @@ function parseParam(options) {
} }
if (match("=")) { if (match("=")) {
if (rest) {
throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
}
if (allowDefaultParams || allowDestructuring) { if (allowDefaultParams || allowDestructuring) {
lex(); lex();
def = parseAssignmentExpression(); def = parseAssignmentExpression();
@ -4450,17 +4458,18 @@ function parseParam(options) {
} }
} }
if (rest) { if (def) {
if (!match(")")) { options.params.push(markerApply(
throwError({}, Messages.ParameterAfterRestParameter); marker,
} astNodeFactory.createAssignmentPattern(
options.rest = param; param,
return false; def
)
));
} else {
options.params.push(param);
} }
options.params.push(param);
options.defaults.push(def ? def : null); // TODO: determine if null or undefined (see: #55)
return !match(")"); return !match(")");
} }
@ -4471,8 +4480,6 @@ function parseParams(firstRestricted) {
options = { options = {
params: [], params: [],
defaultCount: 0, defaultCount: 0,
defaults: [],
rest: null,
firstRestricted: firstRestricted firstRestricted: firstRestricted
}; };
@ -4490,14 +4497,8 @@ function parseParams(firstRestricted) {
expect(")"); expect(")");
if (options.defaultCount === 0) {
options.defaults = [];
}
return { return {
params: options.params, params: options.params,
defaults: options.defaults,
rest: options.rest,
stricted: options.stricted, stricted: options.stricted,
firstRestricted: options.firstRestricted, firstRestricted: options.firstRestricted,
message: options.message message: options.message
@ -4564,9 +4565,7 @@ function parseFunctionDeclaration(identifierIsOptional) {
astNodeFactory.createFunctionDeclaration( astNodeFactory.createFunctionDeclaration(
id, id,
tmp.params, tmp.params,
tmp.defaults,
body, body,
tmp.rest,
generator, generator,
false false
) )
@ -4631,9 +4630,7 @@ function parseFunctionExpression() {
astNodeFactory.createFunctionExpression( astNodeFactory.createFunctionExpression(
id, id,
tmp.params, tmp.params,
tmp.defaults,
body, body,
tmp.rest,
generator, generator,
false false
) )
@ -4656,7 +4653,15 @@ function parseYieldExpression() {
delegateFlag = true; delegateFlag = true;
} }
expr = parseAssignmentExpression(); if (peekLineTerminator()) {
return markerApply(marker, astNodeFactory.createYieldExpression(null, delegateFlag));
}
if (!match(";") && !match(")")) {
if (!match("}") && lookahead.type !== Token.EOF) {
expr = parseAssignmentExpression();
}
}
return markerApply(marker, astNodeFactory.createYieldExpression(expr, delegateFlag)); return markerApply(marker, astNodeFactory.createYieldExpression(expr, delegateFlag));
} }
@ -5006,7 +5011,8 @@ function parseClassBody() {
} }
if (!isStatic) { if (!isStatic) {
if (!method.computed && (method.key.name || method.key.value.toString()) === "constructor") {
if (!method.computed && (method.key.name || (method.key.value && method.key.value.toString())) === "constructor") {
if (method.kind !== "method" || !method.method || method.value.generator) { if (method.kind !== "method" || !method.method || method.value.generator) {
throwUnexpected(token, Messages.ConstructorSpecialMethod); throwUnexpected(token, Messages.ConstructorSpecialMethod);
} }

View File

@ -44,7 +44,7 @@ module.exports = {
* @param {ASTNode[]} elements An array of ASTNode elements * @param {ASTNode[]} elements An array of ASTNode elements
* @returns {ASTNode} An ASTNode representing the entire array expression * @returns {ASTNode} An ASTNode representing the entire array expression
*/ */
createArrayExpression: function (elements) { createArrayExpression: function(elements) {
return { return {
type: astNodeTypes.ArrayExpression, type: astNodeTypes.ArrayExpression,
elements: elements elements: elements
@ -54,22 +54,18 @@ module.exports = {
/** /**
* Create an Arrow Function Expression ASTNode * Create an Arrow Function Expression ASTNode
* @param {ASTNode} params The function arguments * @param {ASTNode} params The function arguments
* @param {ASTNode} defaults Any default arguments
* @param {ASTNode} body The function body * @param {ASTNode} body The function body
* @param {ASTNode} rest The rest parameter
* @param {boolean} expression True if the arrow function is created via an expression. * @param {boolean} expression True if the arrow function is created via an expression.
* Always false for declarations, but kept here to be in sync with * Always false for declarations, but kept here to be in sync with
* FunctionExpression objects. * FunctionExpression objects.
* @returns {ASTNode} An ASTNode representing the entire arrow function expression * @returns {ASTNode} An ASTNode representing the entire arrow function expression
*/ */
createArrowFunctionExpression: function (params, defaults, body, rest, expression) { createArrowFunctionExpression: function (params, body, expression) {
return { return {
type: astNodeTypes.ArrowFunctionExpression, type: astNodeTypes.ArrowFunctionExpression,
id: null, id: null,
params: params, params: params,
defaults: defaults,
body: body, body: body,
rest: rest,
generator: false, generator: false,
expression: expression expression: expression
}; };
@ -82,7 +78,7 @@ module.exports = {
* @param {ASTNode} right The right operand * @param {ASTNode} right The right operand
* @returns {ASTNode} An ASTNode representing the entire assignment expression * @returns {ASTNode} An ASTNode representing the entire assignment expression
*/ */
createAssignmentExpression: function (operator, left, right) { createAssignmentExpression: function(operator, left, right) {
return { return {
type: astNodeTypes.AssignmentExpression, type: astNodeTypes.AssignmentExpression,
operator: operator, operator: operator,
@ -91,6 +87,20 @@ module.exports = {
}; };
}, },
/**
* Create an ASTNode representation of an assignment pattern (default parameters)
* @param {ASTNode} left The left operand
* @param {ASTNode} right The right operand
* @returns {ASTNode} An ASTNode representing the entire assignment pattern
*/
createAssignmentPattern: function(left, right) {
return {
type: astNodeTypes.AssignmentPattern,
left: left,
right: right
};
},
/** /**
* Create an ASTNode representation of a binary expression * Create an ASTNode representation of a binary expression
* @param {ASTNode} operator The assignment operator * @param {ASTNode} operator The assignment operator
@ -98,7 +108,7 @@ module.exports = {
* @param {ASTNode} right The right operand * @param {ASTNode} right The right operand
* @returns {ASTNode} An ASTNode representing the entire binary expression * @returns {ASTNode} An ASTNode representing the entire binary expression
*/ */
createBinaryExpression: function (operator, left, right) { createBinaryExpression: function(operator, left, right) {
var type = (operator === "||" || operator === "&&") ? astNodeTypes.LogicalExpression : var type = (operator === "||" || operator === "&&") ? astNodeTypes.LogicalExpression :
astNodeTypes.BinaryExpression; astNodeTypes.BinaryExpression;
return { return {
@ -114,7 +124,7 @@ module.exports = {
* @param {ASTNode} body The block statement body * @param {ASTNode} body The block statement body
* @returns {ASTNode} An ASTNode representing the entire block statement * @returns {ASTNode} An ASTNode representing the entire block statement
*/ */
createBlockStatement: function (body) { createBlockStatement: function(body) {
return { return {
type: astNodeTypes.BlockStatement, type: astNodeTypes.BlockStatement,
body: body body: body
@ -126,7 +136,7 @@ module.exports = {
* @param {ASTNode} label The break statement label * @param {ASTNode} label The break statement label
* @returns {ASTNode} An ASTNode representing the break statement * @returns {ASTNode} An ASTNode representing the break statement
*/ */
createBreakStatement: function (label) { createBreakStatement: function(label) {
return { return {
type: astNodeTypes.BreakStatement, type: astNodeTypes.BreakStatement,
label: label label: label
@ -139,7 +149,7 @@ module.exports = {
* @param {ASTNode[]} args An array of ASTNodes representing the function call arguments * @param {ASTNode[]} args An array of ASTNodes representing the function call arguments
* @returns {ASTNode} An ASTNode representing the entire call expression * @returns {ASTNode} An ASTNode representing the entire call expression
*/ */
createCallExpression: function (callee, args) { createCallExpression: function(callee, args) {
return { return {
type: astNodeTypes.CallExpression, type: astNodeTypes.CallExpression,
callee: callee, callee: callee,
@ -153,7 +163,7 @@ module.exports = {
* @param {ASTNode} body The catch block body * @param {ASTNode} body The catch block body
* @returns {ASTNode} An ASTNode representing the entire catch clause * @returns {ASTNode} An ASTNode representing the entire catch clause
*/ */
createCatchClause: function (param, body) { createCatchClause: function(param, body) {
return { return {
type: astNodeTypes.CatchClause, type: astNodeTypes.CatchClause,
param: param, param: param,
@ -166,14 +176,14 @@ module.exports = {
* @param {ASTNode} body The node representing the body of the class. * @param {ASTNode} body The node representing the body of the class.
* @returns {ASTNode} An ASTNode representing the class body. * @returns {ASTNode} An ASTNode representing the class body.
*/ */
createClassBody: function (body) { createClassBody: function(body) {
return { return {
type: astNodeTypes.ClassBody, type: astNodeTypes.ClassBody,
body: body body: body
}; };
}, },
createClassExpression: function (id, superClass, body) { createClassExpression: function(id, superClass, body) {
return { return {
type: astNodeTypes.ClassExpression, type: astNodeTypes.ClassExpression,
id: id, id: id,
@ -182,7 +192,7 @@ module.exports = {
}; };
}, },
createClassDeclaration: function (id, superClass, body) { createClassDeclaration: function(id, superClass, body) {
return { return {
type: astNodeTypes.ClassDeclaration, type: astNodeTypes.ClassDeclaration,
id: id, id: id,
@ -191,7 +201,7 @@ module.exports = {
}; };
}, },
createMethodDefinition: function (propertyType, kind, key, value, computed) { createMethodDefinition: function(propertyType, kind, key, value, computed) {
return { return {
type: astNodeTypes.MethodDefinition, type: astNodeTypes.MethodDefinition,
key: key, key: key,
@ -209,7 +219,7 @@ module.exports = {
* @param {ASTNode} alternate The code to be run if the test returns false * @param {ASTNode} alternate The code to be run if the test returns false
* @returns {ASTNode} An ASTNode representing the entire conditional expression * @returns {ASTNode} An ASTNode representing the entire conditional expression
*/ */
createConditionalExpression: function (test, consequent, alternate) { createConditionalExpression: function(test, consequent, alternate) {
return { return {
type: astNodeTypes.ConditionalExpression, type: astNodeTypes.ConditionalExpression,
test: test, test: test,
@ -223,7 +233,7 @@ module.exports = {
* @param {?ASTNode} label The optional continue label (null if not set) * @param {?ASTNode} label The optional continue label (null if not set)
* @returns {ASTNode} An ASTNode representing the continue statement * @returns {ASTNode} An ASTNode representing the continue statement
*/ */
createContinueStatement: function (label) { createContinueStatement: function(label) {
return { return {
type: astNodeTypes.ContinueStatement, type: astNodeTypes.ContinueStatement,
label: label label: label
@ -234,7 +244,7 @@ module.exports = {
* Create an ASTNode representation of a debugger statement * Create an ASTNode representation of a debugger statement
* @returns {ASTNode} An ASTNode representing the debugger statement * @returns {ASTNode} An ASTNode representing the debugger statement
*/ */
createDebuggerStatement: function () { createDebuggerStatement: function() {
return { return {
type: astNodeTypes.DebuggerStatement type: astNodeTypes.DebuggerStatement
}; };
@ -244,7 +254,7 @@ module.exports = {
* Create an ASTNode representation of an empty statement * Create an ASTNode representation of an empty statement
* @returns {ASTNode} An ASTNode representing an empty statement * @returns {ASTNode} An ASTNode representing an empty statement
*/ */
createEmptyStatement: function () { createEmptyStatement: function() {
return { return {
type: astNodeTypes.EmptyStatement type: astNodeTypes.EmptyStatement
}; };
@ -255,7 +265,7 @@ module.exports = {
* @param {ASTNode} expression The expression * @param {ASTNode} expression The expression
* @returns {ASTNode} An ASTNode representing an expression statement * @returns {ASTNode} An ASTNode representing an expression statement
*/ */
createExpressionStatement: function (expression) { createExpressionStatement: function(expression) {
return { return {
type: astNodeTypes.ExpressionStatement, type: astNodeTypes.ExpressionStatement,
expression: expression expression: expression
@ -268,7 +278,7 @@ module.exports = {
* @param {ASTNode} body The while loop body * @param {ASTNode} body The while loop body
* @returns {ASTNode} An ASTNode representing a while statement * @returns {ASTNode} An ASTNode representing a while statement
*/ */
createWhileStatement: function (test, body) { createWhileStatement: function(test, body) {
return { return {
type: astNodeTypes.WhileStatement, type: astNodeTypes.WhileStatement,
test: test, test: test,
@ -282,7 +292,7 @@ module.exports = {
* @param {ASTNode} body The do..while loop body * @param {ASTNode} body The do..while loop body
* @returns {ASTNode} An ASTNode representing a do..while statement * @returns {ASTNode} An ASTNode representing a do..while statement
*/ */
createDoWhileStatement: function (test, body) { createDoWhileStatement: function(test, body) {
return { return {
type: astNodeTypes.DoWhileStatement, type: astNodeTypes.DoWhileStatement,
body: body, body: body,
@ -298,7 +308,7 @@ module.exports = {
* @param {ASTNode} body The statement body * @param {ASTNode} body The statement body
* @returns {ASTNode} An ASTNode representing a for statement * @returns {ASTNode} An ASTNode representing a for statement
*/ */
createForStatement: function (init, test, update, body) { createForStatement: function(init, test, update, body) {
return { return {
type: astNodeTypes.ForStatement, type: astNodeTypes.ForStatement,
init: init, init: init,
@ -315,7 +325,7 @@ module.exports = {
* @param {ASTNode} body The statement body * @param {ASTNode} body The statement body
* @returns {ASTNode} An ASTNode representing a for..in statement * @returns {ASTNode} An ASTNode representing a for..in statement
*/ */
createForInStatement: function (left, right, body) { createForInStatement: function(left, right, body) {
return { return {
type: astNodeTypes.ForInStatement, type: astNodeTypes.ForInStatement,
left: left, left: left,
@ -332,7 +342,7 @@ module.exports = {
* @param {ASTNode} body The statement body * @param {ASTNode} body The statement body
* @returns {ASTNode} An ASTNode representing a for..of statement * @returns {ASTNode} An ASTNode representing a for..of statement
*/ */
createForOfStatement: function (left, right, body) { createForOfStatement: function(left, right, body) {
return { return {
type: astNodeTypes.ForOfStatement, type: astNodeTypes.ForOfStatement,
left: left, left: left,
@ -345,23 +355,19 @@ module.exports = {
* Create an ASTNode representation of a function declaration * Create an ASTNode representation of a function declaration
* @param {ASTNode} id The function name * @param {ASTNode} id The function name
* @param {ASTNode} params The function arguments * @param {ASTNode} params The function arguments
* @param {ASTNode} defaults Any default arguments (ES6-only feature)
* @param {ASTNode} body The function body * @param {ASTNode} body The function body
* @param {ASTNode} rest The node representing a rest argument.
* @param {boolean} generator True if the function is a generator, false if not. * @param {boolean} generator True if the function is a generator, false if not.
* @param {boolean} expression True if the function is created via an expression. * @param {boolean} expression True if the function is created via an expression.
* Always false for declarations, but kept here to be in sync with * Always false for declarations, but kept here to be in sync with
* FunctionExpression objects. * FunctionExpression objects.
* @returns {ASTNode} An ASTNode representing a function declaration * @returns {ASTNode} An ASTNode representing a function declaration
*/ */
createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression) { createFunctionDeclaration: function (id, params, body, generator, expression) {
return { return {
type: astNodeTypes.FunctionDeclaration, type: astNodeTypes.FunctionDeclaration,
id: id, id: id,
params: params || [], params: params || [],
defaults: defaults || [],
body: body, body: body,
rest: rest || null,
generator: !!generator, generator: !!generator,
expression: !!expression expression: !!expression
}; };
@ -371,21 +377,17 @@ module.exports = {
* Create an ASTNode representation of a function expression * Create an ASTNode representation of a function expression
* @param {ASTNode} id The function name * @param {ASTNode} id The function name
* @param {ASTNode} params The function arguments * @param {ASTNode} params The function arguments
* @param {ASTNode} defaults Any default arguments (ES6-only feature)
* @param {ASTNode} body The function body * @param {ASTNode} body The function body
* @param {ASTNode} rest The node representing a rest argument.
* @param {boolean} generator True if the function is a generator, false if not. * @param {boolean} generator True if the function is a generator, false if not.
* @param {boolean} expression True if the function is created via an expression. * @param {boolean} expression True if the function is created via an expression.
* @returns {ASTNode} An ASTNode representing a function declaration * @returns {ASTNode} An ASTNode representing a function declaration
*/ */
createFunctionExpression: function (id, params, defaults, body, rest, generator, expression) { createFunctionExpression: function (id, params, body, generator, expression) {
return { return {
type: astNodeTypes.FunctionExpression, type: astNodeTypes.FunctionExpression,
id: id, id: id,
params: params || [], params: params || [],
defaults: defaults || [],
body: body, body: body,
rest: rest || null,
generator: !!generator, generator: !!generator,
expression: !!expression expression: !!expression
}; };
@ -396,7 +398,7 @@ module.exports = {
* @param {ASTNode} name The identifier name * @param {ASTNode} name The identifier name
* @returns {ASTNode} An ASTNode representing an identifier * @returns {ASTNode} An ASTNode representing an identifier
*/ */
createIdentifier: function (name) { createIdentifier: function(name) {
return { return {
type: astNodeTypes.Identifier, type: astNodeTypes.Identifier,
name: name name: name
@ -410,7 +412,7 @@ module.exports = {
* @param {ASTNode} alternate the "else" alternate statement * @param {ASTNode} alternate the "else" alternate statement
* @returns {ASTNode} An ASTNode representing an if statement * @returns {ASTNode} An ASTNode representing an if statement
*/ */
createIfStatement: function (test, consequent, alternate) { createIfStatement: function(test, consequent, alternate) {
return { return {
type: astNodeTypes.IfStatement, type: astNodeTypes.IfStatement,
test: test, test: test,
@ -425,7 +427,7 @@ module.exports = {
* @param {ASTNode} body The labeled statement body * @param {ASTNode} body The labeled statement body
* @returns {ASTNode} An ASTNode representing a labeled statement * @returns {ASTNode} An ASTNode representing a labeled statement
*/ */
createLabeledStatement: function (label, body) { createLabeledStatement: function(label, body) {
return { return {
type: astNodeTypes.LabeledStatement, type: astNodeTypes.LabeledStatement,
label: label, label: label,
@ -439,7 +441,7 @@ module.exports = {
* @param {string} source The source code to get the literal from * @param {string} source The source code to get the literal from
* @returns {ASTNode} An ASTNode representing the new literal * @returns {ASTNode} An ASTNode representing the new literal
*/ */
createLiteralFromSource: function (token, source) { createLiteralFromSource: function(token, source) {
var node = { var node = {
type: astNodeTypes.Literal, type: astNodeTypes.Literal,
value: token.value, value: token.value,
@ -462,7 +464,7 @@ module.exports = {
* @param {boolean} tail True if this is the final element in a template string * @param {boolean} tail True if this is the final element in a template string
* @returns {ASTNode} An ASTNode representing the template string element * @returns {ASTNode} An ASTNode representing the template string element
*/ */
createTemplateElement: function (value, tail) { createTemplateElement: function(value, tail) {
return { return {
type: astNodeTypes.TemplateElement, type: astNodeTypes.TemplateElement,
value: value, value: value,
@ -476,7 +478,7 @@ module.exports = {
* @param {ASTNode[]} expressions An array of the template string expressions * @param {ASTNode[]} expressions An array of the template string expressions
* @returns {ASTNode} An ASTNode representing the template string * @returns {ASTNode} An ASTNode representing the template string
*/ */
createTemplateLiteral: function (quasis, expressions) { createTemplateLiteral: function(quasis, expressions) {
return { return {
type: astNodeTypes.TemplateLiteral, type: astNodeTypes.TemplateLiteral,
quasis: quasis, quasis: quasis,
@ -489,7 +491,7 @@ module.exports = {
* @param {ASTNode} argument The array being spread * @param {ASTNode} argument The array being spread
* @returns {ASTNode} An ASTNode representing a spread element * @returns {ASTNode} An ASTNode representing a spread element
*/ */
createSpreadElement: function (argument) { createSpreadElement: function(argument) {
return { return {
type: astNodeTypes.SpreadElement, type: astNodeTypes.SpreadElement,
argument: argument argument: argument
@ -503,7 +505,7 @@ module.exports = {
* the template string itself. * the template string itself.
* @returns {ASTNode} An ASTNode representing the tagged template * @returns {ASTNode} An ASTNode representing the tagged template
*/ */
createTaggedTemplateExpression: function (tag, quasi) { createTaggedTemplateExpression: function(tag, quasi) {
return { return {
type: astNodeTypes.TaggedTemplateExpression, type: astNodeTypes.TaggedTemplateExpression,
tag: tag, tag: tag,
@ -518,7 +520,7 @@ module.exports = {
* @param {ASTNode} property The object-property being referenced * @param {ASTNode} property The object-property being referenced
* @returns {ASTNode} An ASTNode representing a member expression * @returns {ASTNode} An ASTNode representing a member expression
*/ */
createMemberExpression: function (accessor, object, property) { createMemberExpression: function(accessor, object, property) {
return { return {
type: astNodeTypes.MemberExpression, type: astNodeTypes.MemberExpression,
computed: accessor === "[", computed: accessor === "[",
@ -533,7 +535,7 @@ module.exports = {
* @param {ASTNode} args The arguments passed to the constructor * @param {ASTNode} args The arguments passed to the constructor
* @returns {ASTNode} An ASTNode representing a new expression * @returns {ASTNode} An ASTNode representing a new expression
*/ */
createNewExpression: function (callee, args) { createNewExpression: function(callee, args) {
return { return {
type: astNodeTypes.NewExpression, type: astNodeTypes.NewExpression,
callee: callee, callee: callee,
@ -547,7 +549,7 @@ module.exports = {
* properties and associated values * properties and associated values
* @returns {ASTNode} An ASTNode representing a new object expression * @returns {ASTNode} An ASTNode representing a new object expression
*/ */
createObjectExpression: function (properties) { createObjectExpression: function(properties) {
return { return {
type: astNodeTypes.ObjectExpression, type: astNodeTypes.ObjectExpression,
properties: properties properties: properties
@ -560,7 +562,7 @@ module.exports = {
* @param {ASTNode} argument The operator argument * @param {ASTNode} argument The operator argument
* @returns {ASTNode} An ASTNode representing a postfix expression * @returns {ASTNode} An ASTNode representing a postfix expression
*/ */
createPostfixExpression: function (operator, argument) { createPostfixExpression: function(operator, argument) {
return { return {
type: astNodeTypes.UpdateExpression, type: astNodeTypes.UpdateExpression,
operator: operator, operator: operator,
@ -575,7 +577,7 @@ module.exports = {
* @param {string} sourceType Either "module" or "script". * @param {string} sourceType Either "module" or "script".
* @returns {ASTNode} An ASTNode representing an entire program * @returns {ASTNode} An ASTNode representing an entire program
*/ */
createProgram: function (body, sourceType) { createProgram: function(body, sourceType) {
return { return {
type: astNodeTypes.Program, type: astNodeTypes.Program,
body: body, body: body,
@ -593,7 +595,7 @@ module.exports = {
* @param {boolean} computed True if the property value has been computed * @param {boolean} computed True if the property value has been computed
* @returns {ASTNode} An ASTNode representing an object property * @returns {ASTNode} An ASTNode representing an object property
*/ */
createProperty: function (kind, key, value, method, shorthand, computed) { createProperty: function(kind, key, value, method, shorthand, computed) {
return { return {
type: astNodeTypes.Property, type: astNodeTypes.Property,
key: key, key: key,
@ -605,12 +607,24 @@ module.exports = {
}; };
}, },
/**
* Create an ASTNode representation of a rest element
* @param {ASTNode} argument The rest argument
* @returns {ASTNode} An ASTNode representing a rest element
*/
createRestElement: function (argument) {
return {
type: astNodeTypes.RestElement,
argument: argument
};
},
/** /**
* Create an ASTNode representation of a return statement * Create an ASTNode representation of a return statement
* @param {?ASTNode} argument The return argument, null if no argument is provided * @param {?ASTNode} argument The return argument, null if no argument is provided
* @returns {ASTNode} An ASTNode representing a return statement * @returns {ASTNode} An ASTNode representing a return statement
*/ */
createReturnStatement: function (argument) { createReturnStatement: function(argument) {
return { return {
type: astNodeTypes.ReturnStatement, type: astNodeTypes.ReturnStatement,
argument: argument argument: argument
@ -622,20 +636,30 @@ module.exports = {
* @param {ASTNode[]} expressions An array containing each expression, in order * @param {ASTNode[]} expressions An array containing each expression, in order
* @returns {ASTNode} An ASTNode representing a sequence of expressions * @returns {ASTNode} An ASTNode representing a sequence of expressions
*/ */
createSequenceExpression: function (expressions) { createSequenceExpression: function(expressions) {
return { return {
type: astNodeTypes.SequenceExpression, type: astNodeTypes.SequenceExpression,
expressions: expressions expressions: expressions
}; };
}, },
/**
* Create an ASTNode representation of super
* @returns {ASTNode} An ASTNode representing super
*/
createSuper: function() {
return {
type: astNodeTypes.Super
};
},
/** /**
* Create an ASTNode representation of a switch case statement * Create an ASTNode representation of a switch case statement
* @param {ASTNode} test The case value to test against the switch value * @param {ASTNode} test The case value to test against the switch value
* @param {ASTNode} consequent The consequent case statement * @param {ASTNode} consequent The consequent case statement
* @returns {ASTNode} An ASTNode representing a switch case * @returns {ASTNode} An ASTNode representing a switch case
*/ */
createSwitchCase: function (test, consequent) { createSwitchCase: function(test, consequent) {
return { return {
type: astNodeTypes.SwitchCase, type: astNodeTypes.SwitchCase,
test: test, test: test,
@ -649,7 +673,7 @@ module.exports = {
* @param {ASTNode[]} cases An array of switch case statements * @param {ASTNode[]} cases An array of switch case statements
* @returns {ASTNode} An ASTNode representing a switch statement * @returns {ASTNode} An ASTNode representing a switch statement
*/ */
createSwitchStatement: function (discriminant, cases) { createSwitchStatement: function(discriminant, cases) {
return { return {
type: astNodeTypes.SwitchStatement, type: astNodeTypes.SwitchStatement,
discriminant: discriminant, discriminant: discriminant,
@ -661,7 +685,7 @@ module.exports = {
* Create an ASTNode representation of a this statement * Create an ASTNode representation of a this statement
* @returns {ASTNode} An ASTNode representing a this statement * @returns {ASTNode} An ASTNode representing a this statement
*/ */
createThisExpression: function () { createThisExpression: function() {
return { return {
type: astNodeTypes.ThisExpression type: astNodeTypes.ThisExpression
}; };
@ -672,7 +696,7 @@ module.exports = {
* @param {ASTNode} argument The argument to throw * @param {ASTNode} argument The argument to throw
* @returns {ASTNode} An ASTNode representing a throw statement * @returns {ASTNode} An ASTNode representing a throw statement
*/ */
createThrowStatement: function (argument) { createThrowStatement: function(argument) {
return { return {
type: astNodeTypes.ThrowStatement, type: astNodeTypes.ThrowStatement,
argument: argument argument: argument
@ -686,12 +710,10 @@ module.exports = {
* @param {?ASTNode} finalizer The final code block to run after the try/catch has run * @param {?ASTNode} finalizer The final code block to run after the try/catch has run
* @returns {ASTNode} An ASTNode representing a try statement * @returns {ASTNode} An ASTNode representing a try statement
*/ */
createTryStatement: function (block, handler, finalizer) { createTryStatement: function(block, handler, finalizer) {
return { return {
type: astNodeTypes.TryStatement, type: astNodeTypes.TryStatement,
block: block, block: block,
guardedHandlers: [],
handlers: handler ? [ handler ] : [],
handler: handler, handler: handler,
finalizer: finalizer finalizer: finalizer
}; };
@ -703,7 +725,7 @@ module.exports = {
* @param {ASTNode} argument The unary operand * @param {ASTNode} argument The unary operand
* @returns {ASTNode} An ASTNode representing a unary expression * @returns {ASTNode} An ASTNode representing a unary expression
*/ */
createUnaryExpression: function (operator, argument) { createUnaryExpression: function(operator, argument) {
if (operator === "++" || operator === "--") { if (operator === "++" || operator === "--") {
return { return {
type: astNodeTypes.UpdateExpression, type: astNodeTypes.UpdateExpression,
@ -726,7 +748,7 @@ module.exports = {
* @param {string} kind The kind of variable created ("var", "let", etc.) * @param {string} kind The kind of variable created ("var", "let", etc.)
* @returns {ASTNode} An ASTNode representing a variable declaration * @returns {ASTNode} An ASTNode representing a variable declaration
*/ */
createVariableDeclaration: function (declarations, kind) { createVariableDeclaration: function(declarations, kind) {
return { return {
type: astNodeTypes.VariableDeclaration, type: astNodeTypes.VariableDeclaration,
declarations: declarations, declarations: declarations,
@ -740,7 +762,7 @@ module.exports = {
* @param {ASTNode} init The variable's initial value * @param {ASTNode} init The variable's initial value
* @returns {ASTNode} An ASTNode representing a variable declarator * @returns {ASTNode} An ASTNode representing a variable declarator
*/ */
createVariableDeclarator: function (id, init) { createVariableDeclarator: function(id, init) {
return { return {
type: astNodeTypes.VariableDeclarator, type: astNodeTypes.VariableDeclarator,
id: id, id: id,
@ -754,7 +776,7 @@ module.exports = {
* @param {ASTNode} body The with statement body * @param {ASTNode} body The with statement body
* @returns {ASTNode} An ASTNode representing a with statement * @returns {ASTNode} An ASTNode representing a with statement
*/ */
createWithStatement: function (object, body) { createWithStatement: function(object, body) {
return { return {
type: astNodeTypes.WithStatement, type: astNodeTypes.WithStatement,
object: object, object: object,
@ -762,15 +784,15 @@ module.exports = {
}; };
}, },
createYieldExpression: function (argument, delegate) { createYieldExpression: function(argument, delegate) {
return { return {
type: astNodeTypes.YieldExpression, type: astNodeTypes.YieldExpression,
argument: argument, argument: argument || null,
delegate: delegate delegate: delegate
}; };
}, },
createJSXAttribute: function (name, value) { createJSXAttribute: function(name, value) {
return { return {
type: astNodeTypes.JSXAttribute, type: astNodeTypes.JSXAttribute,
name: name, name: name,
@ -778,21 +800,21 @@ module.exports = {
}; };
}, },
createJSXSpreadAttribute: function (argument) { createJSXSpreadAttribute: function(argument) {
return { return {
type: astNodeTypes.JSXSpreadAttribute, type: astNodeTypes.JSXSpreadAttribute,
argument: argument argument: argument
}; };
}, },
createJSXIdentifier: function (name) { createJSXIdentifier: function(name) {
return { return {
type: astNodeTypes.JSXIdentifier, type: astNodeTypes.JSXIdentifier,
name: name name: name
}; };
}, },
createJSXNamespacedName: function (namespace, name) { createJSXNamespacedName: function(namespace, name) {
return { return {
type: astNodeTypes.JSXNamespacedName, type: astNodeTypes.JSXNamespacedName,
namespace: namespace, namespace: namespace,
@ -800,7 +822,7 @@ module.exports = {
}; };
}, },
createJSXMemberExpression: function (object, property) { createJSXMemberExpression: function(object, property) {
return { return {
type: astNodeTypes.JSXMemberExpression, type: astNodeTypes.JSXMemberExpression,
object: object, object: object,
@ -808,7 +830,7 @@ module.exports = {
}; };
}, },
createJSXElement: function (openingElement, closingElement, children) { createJSXElement: function(openingElement, closingElement, children) {
return { return {
type: astNodeTypes.JSXElement, type: astNodeTypes.JSXElement,
openingElement: openingElement, openingElement: openingElement,
@ -817,20 +839,20 @@ module.exports = {
}; };
}, },
createJSXEmptyExpression: function () { createJSXEmptyExpression: function() {
return { return {
type: astNodeTypes.JSXEmptyExpression type: astNodeTypes.JSXEmptyExpression
}; };
}, },
createJSXExpressionContainer: function (expression) { createJSXExpressionContainer: function(expression) {
return { return {
type: astNodeTypes.JSXExpressionContainer, type: astNodeTypes.JSXExpressionContainer,
expression: expression expression: expression
}; };
}, },
createJSXOpeningElement: function (name, attributes, selfClosing) { createJSXOpeningElement: function(name, attributes, selfClosing) {
return { return {
type: astNodeTypes.JSXOpeningElement, type: astNodeTypes.JSXOpeningElement,
name: name, name: name,
@ -839,14 +861,14 @@ module.exports = {
}; };
}, },
createJSXClosingElement: function (name) { createJSXClosingElement: function(name) {
return { return {
type: astNodeTypes.JSXClosingElement, type: astNodeTypes.JSXClosingElement,
name: name name: name
}; };
}, },
createExportSpecifier: function (local, exported) { createExportSpecifier: function(local, exported) {
return { return {
type: astNodeTypes.ExportSpecifier, type: astNodeTypes.ExportSpecifier,
exported: exported || local, exported: exported || local,
@ -854,21 +876,21 @@ module.exports = {
}; };
}, },
createImportDefaultSpecifier: function (local) { createImportDefaultSpecifier: function(local) {
return { return {
type: astNodeTypes.ImportDefaultSpecifier, type: astNodeTypes.ImportDefaultSpecifier,
local: local local: local
}; };
}, },
createImportNamespaceSpecifier: function (local) { createImportNamespaceSpecifier: function(local) {
return { return {
type: astNodeTypes.ImportNamespaceSpecifier, type: astNodeTypes.ImportNamespaceSpecifier,
local: local local: local
}; };
}, },
createExportNamedDeclaration: function (declaration, specifiers, source) { createExportNamedDeclaration: function(declaration, specifiers, source) {
return { return {
type: astNodeTypes.ExportNamedDeclaration, type: astNodeTypes.ExportNamedDeclaration,
declaration: declaration, declaration: declaration,
@ -877,21 +899,21 @@ module.exports = {
}; };
}, },
createExportDefaultDeclaration: function (declaration) { createExportDefaultDeclaration: function(declaration) {
return { return {
type: astNodeTypes.ExportDefaultDeclaration, type: astNodeTypes.ExportDefaultDeclaration,
declaration: declaration declaration: declaration
}; };
}, },
createExportAllDeclaration: function (source) { createExportAllDeclaration: function(source) {
return { return {
type: astNodeTypes.ExportAllDeclaration, type: astNodeTypes.ExportAllDeclaration,
source: source source: source
}; };
}, },
createImportSpecifier: function (local, imported) { createImportSpecifier: function(local, imported) {
return { return {
type: astNodeTypes.ImportSpecifier, type: astNodeTypes.ImportSpecifier,
local: local || imported, local: local || imported,
@ -899,7 +921,7 @@ module.exports = {
}; };
}, },
createImportDeclaration: function (specifiers, source) { createImportDeclaration: function(specifiers, source) {
return { return {
type: astNodeTypes.ImportDeclaration, type: astNodeTypes.ImportDeclaration,
specifiers: specifiers, specifiers: specifiers,

View File

@ -74,9 +74,11 @@ module.exports = {
ObjectPattern: "ObjectPattern", ObjectPattern: "ObjectPattern",
Program: "Program", Program: "Program",
Property: "Property", Property: "Property",
RestElement: "RestElement",
ReturnStatement: "ReturnStatement", ReturnStatement: "ReturnStatement",
SequenceExpression: "SequenceExpression", SequenceExpression: "SequenceExpression",
SpreadElement: "SpreadElement", SpreadElement: "SpreadElement",
Super: "Super",
SwitchCase: "SwitchCase", SwitchCase: "SwitchCase",
SwitchStatement: "SwitchStatement", SwitchStatement: "SwitchStatement",
TaggedTemplateExpression: "TaggedTemplateExpression", TaggedTemplateExpression: "TaggedTemplateExpression",

View File

@ -69,7 +69,7 @@ module.exports = {
StrictParamName: "Parameter name eval or arguments is not allowed in strict mode", StrictParamName: "Parameter name eval or arguments is not allowed in strict mode",
StrictParamDupe: "Strict mode function may not have duplicate parameter names", StrictParamDupe: "Strict mode function may not have duplicate parameter names",
TemplateOctalLiteral: "Octal literals are not allowed in template strings.", TemplateOctalLiteral: "Octal literals are not allowed in template strings.",
ParameterAfterRestParameter: "Rest parameter must be final parameter of an argument list", ParameterAfterRestParameter: "Rest parameter must be last formal parameter",
DefaultRestParameter: "Rest parameter can not have a default value", DefaultRestParameter: "Rest parameter can not have a default value",
ElementAfterSpreadElement: "Spread must be the final element of an element list", ElementAfterSpreadElement: "Spread must be the final element of an element list",
ObjectPatternAsRestParameter: "Invalid rest parameter", ObjectPatternAsRestParameter: "Invalid rest parameter",

34
node_modules/espree/package.json generated vendored

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,7 @@
"bluebird": "~2.9.14", "bluebird": "~2.9.14",
"catharsis": "~0.8.7", "catharsis": "~0.8.7",
"escape-string-regexp": "~1.0.2", "escape-string-regexp": "~1.0.2",
"espree": "~1.12.3", "espree": "~2.0.3",
"js2xmlparser": "~0.1.7", "js2xmlparser": "~0.1.7",
"marked": "~0.3.2", "marked": "~0.3.2",
"requizzle": "~0.2.0", "requizzle": "~0.2.0",