mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
upgrade Espree, and update code to reflect breaking changes in Espree (#977)
This commit is contained in:
parent
4167b2408c
commit
05a08ad6a0
@ -128,6 +128,9 @@ var nodeToValue = exports.nodeToValue = function(node) {
|
||||
break;
|
||||
|
||||
case Syntax.AssignmentExpression:
|
||||
// falls through
|
||||
|
||||
case Syntax.AssignmentPattern:
|
||||
str = nodeToValue(node.left);
|
||||
break;
|
||||
|
||||
@ -218,6 +221,10 @@ var nodeToValue = exports.nodeToValue = function(node) {
|
||||
str = JSON.stringify(tempObject);
|
||||
break;
|
||||
|
||||
case Syntax.RestElement:
|
||||
str = nodeToValue(node.argument);
|
||||
break;
|
||||
|
||||
case Syntax.ThisExpression:
|
||||
str = 'this';
|
||||
break;
|
||||
@ -255,14 +262,11 @@ exports.nodeToString = nodeToValue;
|
||||
var getParamNames = exports.getParamNames = function(node) {
|
||||
var params;
|
||||
|
||||
if ( !node || (!node.params && !node.rest) ) {
|
||||
if (!node || !node.params) {
|
||||
return [];
|
||||
}
|
||||
|
||||
params = node.params.slice(0);
|
||||
if (node.rest) {
|
||||
params.push(node.rest);
|
||||
}
|
||||
|
||||
return params.map(function(param) {
|
||||
return nodeToValue(param);
|
||||
|
||||
@ -49,9 +49,11 @@ exports.Syntax = {
|
||||
ObjectPattern: 'ObjectPattern',
|
||||
Program: 'Program',
|
||||
Property: 'Property',
|
||||
RestElement: 'RestElement',
|
||||
ReturnStatement: 'ReturnStatement',
|
||||
SequenceExpression: 'SequenceExpression',
|
||||
SpreadElement: 'SpreadElement',
|
||||
Super: 'Super',
|
||||
SwitchCase: 'SwitchCase',
|
||||
SwitchStatement: 'SwitchStatement',
|
||||
TaggedTemplateExpression: 'TaggedTemplateExpression',
|
||||
|
||||
@ -117,9 +117,30 @@ function makeInlineParamsFinisher(parser) {
|
||||
}
|
||||
|
||||
/**
|
||||
* For rest parameters, 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.
|
||||
* Given an array of nodes that represent function parameters, find the node for the rest parameter,
|
||||
* if any.
|
||||
*
|
||||
* @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
|
||||
* @param {module:jsdoc/src/parser.Parser} parser - The JSDoc parser.
|
||||
@ -137,20 +158,46 @@ function makeRestParamFinisher(parser) {
|
||||
}
|
||||
|
||||
documentedParams = doclet.params = doclet.params || [];
|
||||
restNode = e.code.node.rest;
|
||||
for (var i = documentedParams.length - 1; i >= 0; i--) {
|
||||
if (documentedParams[i].name === restNode.name) {
|
||||
documentedParams[i].variable = true;
|
||||
break;
|
||||
restNode = findRestParam(e.code.node.params);
|
||||
|
||||
if (restNode) {
|
||||
for (var i = documentedParams.length - 1; i >= 0; i--) {
|
||||
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
|
||||
* 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.
|
||||
* Given an array of nodes that represent function parameters, find the nodes for the default
|
||||
* parameters, if any.
|
||||
*
|
||||
* @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`
|
||||
* (string, numeric, and boolean literals). This is because more complex default values may include,
|
||||
@ -167,15 +214,16 @@ function makeDefaultParamFinisher(parser) {
|
||||
var defaultValues;
|
||||
var doclet = e.doclet;
|
||||
var documentedParams;
|
||||
var paramName;
|
||||
var params;
|
||||
|
||||
if (!doclet) {
|
||||
return;
|
||||
}
|
||||
|
||||
defaultValues = e.code.node.defaults;
|
||||
documentedParams = doclet.params = doclet.params || [];
|
||||
params = e.code.node.params;
|
||||
defaultValues = findDefaultParams(e.code.node.params);
|
||||
|
||||
for (var i = 0, j = 0, l = params.length; i < l; i++) {
|
||||
// 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 (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;
|
||||
}
|
||||
|
||||
// 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
|
||||
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' &&
|
||||
defaultValues[i].value !== '') {
|
||||
documentedParams[j].defaultvalue = jsdoc.src.astnode.nodeToValue(defaultValues[i]);
|
||||
defaultValues[i].right.value !== '') {
|
||||
documentedParams[j].defaultvalue =
|
||||
jsdoc.src.astnode.nodeToValue(defaultValues[i].right);
|
||||
}
|
||||
|
||||
// move to the next documented param
|
||||
@ -502,13 +556,10 @@ Visitor.prototype.makeSymbolFoundEvent = function(node, parser, filename) {
|
||||
extras.finishers = [];
|
||||
|
||||
// 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
|
||||
if (node.rest) {
|
||||
extras.finishers.push( makeRestParamFinisher(parser) );
|
||||
}
|
||||
extras.finishers.push( makeRestParamFinisher(parser) );
|
||||
|
||||
e = new SymbolFound(node, filename, extras);
|
||||
|
||||
|
||||
@ -75,17 +75,7 @@ walkers[Syntax.ArrowFunctionExpression] = function(node, parent, state, cb) {
|
||||
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);
|
||||
|
||||
if (node.rest) {
|
||||
cb(node.rest, node, state);
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
walkers[Syntax.RestElement] = function(node, parent, state, cb) {
|
||||
if (node.argument) {
|
||||
cb(node.argument, node, state);
|
||||
}
|
||||
};
|
||||
|
||||
walkers[Syntax.ReturnStatement] = function(node, parent, state, cb) {
|
||||
if (node.argument) {
|
||||
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) {
|
||||
if (node.test) {
|
||||
cb(node.test, node, state);
|
||||
@ -426,20 +424,10 @@ walkers[Syntax.TryStatement] = function(node, parent, state, cb) {
|
||||
|
||||
cb(node.block, node, state);
|
||||
|
||||
// handle Esprima ASTs, which deviate from the spec a bit
|
||||
if ( node.handlers && Array.isArray(node.handlers) && node.handlers[0] ) {
|
||||
cb(node.handlers[0].body, node, state);
|
||||
}
|
||||
else if (node.handler) {
|
||||
if (node.handler) {
|
||||
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) {
|
||||
cb(node.finalizer, node, state);
|
||||
}
|
||||
|
||||
152
node_modules/espree/espree.js
generated
vendored
152
node_modules/espree/espree.js
generated
vendored
@ -2277,9 +2277,7 @@ function parsePropertyFunction(paramInfo, options) {
|
||||
return markerApply(options.marker, astNodeFactory.createFunctionExpression(
|
||||
null,
|
||||
paramInfo.params,
|
||||
paramInfo.defaults,
|
||||
body,
|
||||
paramInfo.rest,
|
||||
generator,
|
||||
body.type !== astNodeTypes.BlockStatement
|
||||
));
|
||||
@ -2388,11 +2386,9 @@ function tryParseMethodDefinition(token, key, computed, marker) {
|
||||
|
||||
value = parsePropertyFunction({
|
||||
params: [],
|
||||
defaults: [],
|
||||
stricted: null,
|
||||
firstRestricted: null,
|
||||
message: null,
|
||||
rest: null
|
||||
message: null
|
||||
}, {
|
||||
marker: methodMarker
|
||||
});
|
||||
@ -2408,19 +2404,14 @@ function tryParseMethodDefinition(token, key, computed, marker) {
|
||||
options = {
|
||||
params: [],
|
||||
defaultCount: 0,
|
||||
defaults: [],
|
||||
stricted: null,
|
||||
firstRestricted: null,
|
||||
paramSet: new StringMap(),
|
||||
rest: null
|
||||
paramSet: new StringMap()
|
||||
};
|
||||
if (match(")")) {
|
||||
throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value);
|
||||
} else {
|
||||
parseParam(options);
|
||||
if (options.defaultCount === 0) {
|
||||
options.defaults = [];
|
||||
}
|
||||
}
|
||||
expect(")");
|
||||
|
||||
@ -2521,20 +2512,15 @@ function parseObjectProperty() {
|
||||
options = {
|
||||
params: [],
|
||||
defaultCount: 0,
|
||||
defaults: [],
|
||||
stricted: null,
|
||||
firstRestricted: null,
|
||||
paramSet: new StringMap(),
|
||||
rest: null
|
||||
paramSet: new StringMap()
|
||||
};
|
||||
|
||||
if (match(")")) {
|
||||
throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value);
|
||||
} else {
|
||||
parseParam(options);
|
||||
if (options.defaultCount === 0) {
|
||||
options.defaults = [];
|
||||
}
|
||||
}
|
||||
|
||||
expect(")");
|
||||
@ -2866,7 +2852,7 @@ function parsePrimaryExpression() {
|
||||
if (allowSuper && matchKeyword("super") && state.inFunctionBody) {
|
||||
marker = markerCreate();
|
||||
lex();
|
||||
return markerApply(marker, astNodeFactory.createIdentifier("super"));
|
||||
return markerApply(marker, astNodeFactory.createSuper());
|
||||
}
|
||||
|
||||
if (matchKeyword("this")) {
|
||||
@ -2910,7 +2896,6 @@ function parseArguments() {
|
||||
var args = [], arg;
|
||||
|
||||
expect("(");
|
||||
|
||||
if (!match(")")) {
|
||||
while (index < length) {
|
||||
arg = parseSpreadOrAssignmentExpression();
|
||||
@ -3276,12 +3261,10 @@ function parseConciseBody() {
|
||||
}
|
||||
|
||||
function reinterpretAsCoverFormalsList(expressions) {
|
||||
var i, len, param, params, defaults, defaultCount, options, rest;
|
||||
var i, len, param, params, options,
|
||||
allowRestParams = extra.ecmaFeatures.restParams;
|
||||
|
||||
params = [];
|
||||
defaults = [];
|
||||
defaultCount = 0;
|
||||
rest = null;
|
||||
options = {
|
||||
paramSet: new StringMap()
|
||||
};
|
||||
@ -3290,23 +3273,34 @@ function reinterpretAsCoverFormalsList(expressions) {
|
||||
param = expressions[i];
|
||||
if (param.type === astNodeTypes.Identifier) {
|
||||
params.push(param);
|
||||
defaults.push(null);
|
||||
validateParam(options, param, param.name);
|
||||
} else if (param.type === astNodeTypes.ObjectExpression || param.type === astNodeTypes.ArrayExpression) {
|
||||
reinterpretAsDestructuredParameter(options, param);
|
||||
params.push(param);
|
||||
defaults.push(null);
|
||||
} else if (param.type === astNodeTypes.SpreadElement) {
|
||||
assert(i === len - 1, "It is guaranteed that SpreadElement is last element by parseExpression");
|
||||
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);
|
||||
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) {
|
||||
params.push(param.left);
|
||||
defaults.push(param.right);
|
||||
++defaultCount;
|
||||
|
||||
// TODO: Find a less hacky way of doing this
|
||||
param.type = astNodeTypes.AssignmentPattern;
|
||||
delete param.operator;
|
||||
|
||||
params.push(param);
|
||||
validateParam(options, param.left, param.left.name);
|
||||
} else {
|
||||
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 {
|
||||
params: params,
|
||||
defaults: defaults,
|
||||
rest: rest,
|
||||
stricted: options.stricted,
|
||||
firstRestricted: options.firstRestricted,
|
||||
message: options.message
|
||||
@ -3353,9 +3340,7 @@ function parseArrowFunctionExpression(options, marker) {
|
||||
strict = previousStrict;
|
||||
return markerApply(marker, astNodeFactory.createArrowFunctionExpression(
|
||||
options.params,
|
||||
options.defaults,
|
||||
body,
|
||||
options.rest,
|
||||
body.type !== astNodeTypes.BlockStatement
|
||||
));
|
||||
}
|
||||
@ -3696,6 +3681,30 @@ function parseConstLetDeclaration(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
|
||||
|
||||
function parseEmptyStatement() {
|
||||
@ -4059,6 +4068,9 @@ function parseSwitchCase() {
|
||||
break;
|
||||
}
|
||||
statement = parseSourceElement();
|
||||
if (typeof statement === "undefined") {
|
||||
break;
|
||||
}
|
||||
consequent.push(statement);
|
||||
}
|
||||
|
||||
@ -4402,19 +4414,21 @@ function validateParam(options, param, name) {
|
||||
}
|
||||
|
||||
function parseParam(options) {
|
||||
var token, rest, param, def,
|
||||
var token, param, def,
|
||||
allowRestParams = extra.ecmaFeatures.restParams,
|
||||
allowDestructuring = extra.ecmaFeatures.destructuring,
|
||||
allowDefaultParams = extra.ecmaFeatures.defaultParams;
|
||||
|
||||
allowDefaultParams = extra.ecmaFeatures.defaultParams,
|
||||
marker = markerCreate();
|
||||
|
||||
token = lookahead;
|
||||
if (token.value === "...") {
|
||||
if (!allowRestParams) {
|
||||
throwUnexpected(lookahead);
|
||||
}
|
||||
token = lex();
|
||||
rest = true;
|
||||
param = parseRestElement();
|
||||
validateParam(options, param.argument, param.argument.name);
|
||||
options.params.push(param);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (match("[")) {
|
||||
@ -4424,9 +4438,6 @@ function parseParam(options) {
|
||||
param = parseArrayInitialiser();
|
||||
reinterpretAsDestructuredParameter(options, param);
|
||||
} else if (match("{")) {
|
||||
if (rest) {
|
||||
throwError({}, Messages.ObjectPatternAsRestParameter);
|
||||
}
|
||||
if (!allowDestructuring) {
|
||||
throwUnexpected(lookahead);
|
||||
}
|
||||
@ -4438,9 +4449,6 @@ function parseParam(options) {
|
||||
}
|
||||
|
||||
if (match("=")) {
|
||||
if (rest) {
|
||||
throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
|
||||
}
|
||||
if (allowDefaultParams || allowDestructuring) {
|
||||
lex();
|
||||
def = parseAssignmentExpression();
|
||||
@ -4450,17 +4458,18 @@ function parseParam(options) {
|
||||
}
|
||||
}
|
||||
|
||||
if (rest) {
|
||||
if (!match(")")) {
|
||||
throwError({}, Messages.ParameterAfterRestParameter);
|
||||
}
|
||||
options.rest = param;
|
||||
return false;
|
||||
if (def) {
|
||||
options.params.push(markerApply(
|
||||
marker,
|
||||
astNodeFactory.createAssignmentPattern(
|
||||
param,
|
||||
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(")");
|
||||
}
|
||||
|
||||
@ -4471,8 +4480,6 @@ function parseParams(firstRestricted) {
|
||||
options = {
|
||||
params: [],
|
||||
defaultCount: 0,
|
||||
defaults: [],
|
||||
rest: null,
|
||||
firstRestricted: firstRestricted
|
||||
};
|
||||
|
||||
@ -4490,14 +4497,8 @@ function parseParams(firstRestricted) {
|
||||
|
||||
expect(")");
|
||||
|
||||
if (options.defaultCount === 0) {
|
||||
options.defaults = [];
|
||||
}
|
||||
|
||||
return {
|
||||
params: options.params,
|
||||
defaults: options.defaults,
|
||||
rest: options.rest,
|
||||
stricted: options.stricted,
|
||||
firstRestricted: options.firstRestricted,
|
||||
message: options.message
|
||||
@ -4564,9 +4565,7 @@ function parseFunctionDeclaration(identifierIsOptional) {
|
||||
astNodeFactory.createFunctionDeclaration(
|
||||
id,
|
||||
tmp.params,
|
||||
tmp.defaults,
|
||||
body,
|
||||
tmp.rest,
|
||||
generator,
|
||||
false
|
||||
)
|
||||
@ -4631,9 +4630,7 @@ function parseFunctionExpression() {
|
||||
astNodeFactory.createFunctionExpression(
|
||||
id,
|
||||
tmp.params,
|
||||
tmp.defaults,
|
||||
body,
|
||||
tmp.rest,
|
||||
generator,
|
||||
false
|
||||
)
|
||||
@ -4656,7 +4653,15 @@ function parseYieldExpression() {
|
||||
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));
|
||||
}
|
||||
@ -5006,7 +5011,8 @@ function parseClassBody() {
|
||||
}
|
||||
|
||||
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) {
|
||||
throwUnexpected(token, Messages.ConstructorSpecialMethod);
|
||||
}
|
||||
|
||||
188
node_modules/espree/lib/ast-node-factory.js
generated
vendored
188
node_modules/espree/lib/ast-node-factory.js
generated
vendored
@ -44,7 +44,7 @@ module.exports = {
|
||||
* @param {ASTNode[]} elements An array of ASTNode elements
|
||||
* @returns {ASTNode} An ASTNode representing the entire array expression
|
||||
*/
|
||||
createArrayExpression: function (elements) {
|
||||
createArrayExpression: function(elements) {
|
||||
return {
|
||||
type: astNodeTypes.ArrayExpression,
|
||||
elements: elements
|
||||
@ -54,22 +54,18 @@ module.exports = {
|
||||
/**
|
||||
* Create an Arrow Function Expression ASTNode
|
||||
* @param {ASTNode} params The function arguments
|
||||
* @param {ASTNode} defaults Any default arguments
|
||||
* @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.
|
||||
* Always false for declarations, but kept here to be in sync with
|
||||
* FunctionExpression objects.
|
||||
* @returns {ASTNode} An ASTNode representing the entire arrow function expression
|
||||
*/
|
||||
createArrowFunctionExpression: function (params, defaults, body, rest, expression) {
|
||||
createArrowFunctionExpression: function (params, body, expression) {
|
||||
return {
|
||||
type: astNodeTypes.ArrowFunctionExpression,
|
||||
id: null,
|
||||
params: params,
|
||||
defaults: defaults,
|
||||
body: body,
|
||||
rest: rest,
|
||||
generator: false,
|
||||
expression: expression
|
||||
};
|
||||
@ -82,7 +78,7 @@ module.exports = {
|
||||
* @param {ASTNode} right The right operand
|
||||
* @returns {ASTNode} An ASTNode representing the entire assignment expression
|
||||
*/
|
||||
createAssignmentExpression: function (operator, left, right) {
|
||||
createAssignmentExpression: function(operator, left, right) {
|
||||
return {
|
||||
type: astNodeTypes.AssignmentExpression,
|
||||
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
|
||||
* @param {ASTNode} operator The assignment operator
|
||||
@ -98,7 +108,7 @@ module.exports = {
|
||||
* @param {ASTNode} right The right operand
|
||||
* @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 :
|
||||
astNodeTypes.BinaryExpression;
|
||||
return {
|
||||
@ -114,7 +124,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The block statement body
|
||||
* @returns {ASTNode} An ASTNode representing the entire block statement
|
||||
*/
|
||||
createBlockStatement: function (body) {
|
||||
createBlockStatement: function(body) {
|
||||
return {
|
||||
type: astNodeTypes.BlockStatement,
|
||||
body: body
|
||||
@ -126,7 +136,7 @@ module.exports = {
|
||||
* @param {ASTNode} label The break statement label
|
||||
* @returns {ASTNode} An ASTNode representing the break statement
|
||||
*/
|
||||
createBreakStatement: function (label) {
|
||||
createBreakStatement: function(label) {
|
||||
return {
|
||||
type: astNodeTypes.BreakStatement,
|
||||
label: label
|
||||
@ -139,7 +149,7 @@ module.exports = {
|
||||
* @param {ASTNode[]} args An array of ASTNodes representing the function call arguments
|
||||
* @returns {ASTNode} An ASTNode representing the entire call expression
|
||||
*/
|
||||
createCallExpression: function (callee, args) {
|
||||
createCallExpression: function(callee, args) {
|
||||
return {
|
||||
type: astNodeTypes.CallExpression,
|
||||
callee: callee,
|
||||
@ -153,7 +163,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The catch block body
|
||||
* @returns {ASTNode} An ASTNode representing the entire catch clause
|
||||
*/
|
||||
createCatchClause: function (param, body) {
|
||||
createCatchClause: function(param, body) {
|
||||
return {
|
||||
type: astNodeTypes.CatchClause,
|
||||
param: param,
|
||||
@ -166,14 +176,14 @@ module.exports = {
|
||||
* @param {ASTNode} body The node representing the body of the class.
|
||||
* @returns {ASTNode} An ASTNode representing the class body.
|
||||
*/
|
||||
createClassBody: function (body) {
|
||||
createClassBody: function(body) {
|
||||
return {
|
||||
type: astNodeTypes.ClassBody,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
createClassExpression: function (id, superClass, body) {
|
||||
createClassExpression: function(id, superClass, body) {
|
||||
return {
|
||||
type: astNodeTypes.ClassExpression,
|
||||
id: id,
|
||||
@ -182,7 +192,7 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createClassDeclaration: function (id, superClass, body) {
|
||||
createClassDeclaration: function(id, superClass, body) {
|
||||
return {
|
||||
type: astNodeTypes.ClassDeclaration,
|
||||
id: id,
|
||||
@ -191,7 +201,7 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createMethodDefinition: function (propertyType, kind, key, value, computed) {
|
||||
createMethodDefinition: function(propertyType, kind, key, value, computed) {
|
||||
return {
|
||||
type: astNodeTypes.MethodDefinition,
|
||||
key: key,
|
||||
@ -209,7 +219,7 @@ module.exports = {
|
||||
* @param {ASTNode} alternate The code to be run if the test returns false
|
||||
* @returns {ASTNode} An ASTNode representing the entire conditional expression
|
||||
*/
|
||||
createConditionalExpression: function (test, consequent, alternate) {
|
||||
createConditionalExpression: function(test, consequent, alternate) {
|
||||
return {
|
||||
type: astNodeTypes.ConditionalExpression,
|
||||
test: test,
|
||||
@ -223,7 +233,7 @@ module.exports = {
|
||||
* @param {?ASTNode} label The optional continue label (null if not set)
|
||||
* @returns {ASTNode} An ASTNode representing the continue statement
|
||||
*/
|
||||
createContinueStatement: function (label) {
|
||||
createContinueStatement: function(label) {
|
||||
return {
|
||||
type: astNodeTypes.ContinueStatement,
|
||||
label: label
|
||||
@ -234,7 +244,7 @@ module.exports = {
|
||||
* Create an ASTNode representation of a debugger statement
|
||||
* @returns {ASTNode} An ASTNode representing the debugger statement
|
||||
*/
|
||||
createDebuggerStatement: function () {
|
||||
createDebuggerStatement: function() {
|
||||
return {
|
||||
type: astNodeTypes.DebuggerStatement
|
||||
};
|
||||
@ -244,7 +254,7 @@ module.exports = {
|
||||
* Create an ASTNode representation of an empty statement
|
||||
* @returns {ASTNode} An ASTNode representing an empty statement
|
||||
*/
|
||||
createEmptyStatement: function () {
|
||||
createEmptyStatement: function() {
|
||||
return {
|
||||
type: astNodeTypes.EmptyStatement
|
||||
};
|
||||
@ -255,7 +265,7 @@ module.exports = {
|
||||
* @param {ASTNode} expression The expression
|
||||
* @returns {ASTNode} An ASTNode representing an expression statement
|
||||
*/
|
||||
createExpressionStatement: function (expression) {
|
||||
createExpressionStatement: function(expression) {
|
||||
return {
|
||||
type: astNodeTypes.ExpressionStatement,
|
||||
expression: expression
|
||||
@ -268,7 +278,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The while loop body
|
||||
* @returns {ASTNode} An ASTNode representing a while statement
|
||||
*/
|
||||
createWhileStatement: function (test, body) {
|
||||
createWhileStatement: function(test, body) {
|
||||
return {
|
||||
type: astNodeTypes.WhileStatement,
|
||||
test: test,
|
||||
@ -282,7 +292,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The do..while loop body
|
||||
* @returns {ASTNode} An ASTNode representing a do..while statement
|
||||
*/
|
||||
createDoWhileStatement: function (test, body) {
|
||||
createDoWhileStatement: function(test, body) {
|
||||
return {
|
||||
type: astNodeTypes.DoWhileStatement,
|
||||
body: body,
|
||||
@ -298,7 +308,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The statement body
|
||||
* @returns {ASTNode} An ASTNode representing a for statement
|
||||
*/
|
||||
createForStatement: function (init, test, update, body) {
|
||||
createForStatement: function(init, test, update, body) {
|
||||
return {
|
||||
type: astNodeTypes.ForStatement,
|
||||
init: init,
|
||||
@ -315,7 +325,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The statement body
|
||||
* @returns {ASTNode} An ASTNode representing a for..in statement
|
||||
*/
|
||||
createForInStatement: function (left, right, body) {
|
||||
createForInStatement: function(left, right, body) {
|
||||
return {
|
||||
type: astNodeTypes.ForInStatement,
|
||||
left: left,
|
||||
@ -332,7 +342,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The statement body
|
||||
* @returns {ASTNode} An ASTNode representing a for..of statement
|
||||
*/
|
||||
createForOfStatement: function (left, right, body) {
|
||||
createForOfStatement: function(left, right, body) {
|
||||
return {
|
||||
type: astNodeTypes.ForOfStatement,
|
||||
left: left,
|
||||
@ -345,23 +355,19 @@ module.exports = {
|
||||
* Create an ASTNode representation of a function declaration
|
||||
* @param {ASTNode} id The function name
|
||||
* @param {ASTNode} params The function arguments
|
||||
* @param {ASTNode} defaults Any default arguments (ES6-only feature)
|
||||
* @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} expression True if the function is created via an expression.
|
||||
* Always false for declarations, but kept here to be in sync with
|
||||
* FunctionExpression objects.
|
||||
* @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 {
|
||||
type: astNodeTypes.FunctionDeclaration,
|
||||
id: id,
|
||||
params: params || [],
|
||||
defaults: defaults || [],
|
||||
body: body,
|
||||
rest: rest || null,
|
||||
generator: !!generator,
|
||||
expression: !!expression
|
||||
};
|
||||
@ -371,21 +377,17 @@ module.exports = {
|
||||
* Create an ASTNode representation of a function expression
|
||||
* @param {ASTNode} id The function name
|
||||
* @param {ASTNode} params The function arguments
|
||||
* @param {ASTNode} defaults Any default arguments (ES6-only feature)
|
||||
* @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} expression True if the function is created via an expression.
|
||||
* @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 {
|
||||
type: astNodeTypes.FunctionExpression,
|
||||
id: id,
|
||||
params: params || [],
|
||||
defaults: defaults || [],
|
||||
body: body,
|
||||
rest: rest || null,
|
||||
generator: !!generator,
|
||||
expression: !!expression
|
||||
};
|
||||
@ -396,7 +398,7 @@ module.exports = {
|
||||
* @param {ASTNode} name The identifier name
|
||||
* @returns {ASTNode} An ASTNode representing an identifier
|
||||
*/
|
||||
createIdentifier: function (name) {
|
||||
createIdentifier: function(name) {
|
||||
return {
|
||||
type: astNodeTypes.Identifier,
|
||||
name: name
|
||||
@ -410,7 +412,7 @@ module.exports = {
|
||||
* @param {ASTNode} alternate the "else" alternate statement
|
||||
* @returns {ASTNode} An ASTNode representing an if statement
|
||||
*/
|
||||
createIfStatement: function (test, consequent, alternate) {
|
||||
createIfStatement: function(test, consequent, alternate) {
|
||||
return {
|
||||
type: astNodeTypes.IfStatement,
|
||||
test: test,
|
||||
@ -425,7 +427,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The labeled statement body
|
||||
* @returns {ASTNode} An ASTNode representing a labeled statement
|
||||
*/
|
||||
createLabeledStatement: function (label, body) {
|
||||
createLabeledStatement: function(label, body) {
|
||||
return {
|
||||
type: astNodeTypes.LabeledStatement,
|
||||
label: label,
|
||||
@ -439,7 +441,7 @@ module.exports = {
|
||||
* @param {string} source The source code to get the literal from
|
||||
* @returns {ASTNode} An ASTNode representing the new literal
|
||||
*/
|
||||
createLiteralFromSource: function (token, source) {
|
||||
createLiteralFromSource: function(token, source) {
|
||||
var node = {
|
||||
type: astNodeTypes.Literal,
|
||||
value: token.value,
|
||||
@ -462,7 +464,7 @@ module.exports = {
|
||||
* @param {boolean} tail True if this is the final element in a template string
|
||||
* @returns {ASTNode} An ASTNode representing the template string element
|
||||
*/
|
||||
createTemplateElement: function (value, tail) {
|
||||
createTemplateElement: function(value, tail) {
|
||||
return {
|
||||
type: astNodeTypes.TemplateElement,
|
||||
value: value,
|
||||
@ -476,7 +478,7 @@ module.exports = {
|
||||
* @param {ASTNode[]} expressions An array of the template string expressions
|
||||
* @returns {ASTNode} An ASTNode representing the template string
|
||||
*/
|
||||
createTemplateLiteral: function (quasis, expressions) {
|
||||
createTemplateLiteral: function(quasis, expressions) {
|
||||
return {
|
||||
type: astNodeTypes.TemplateLiteral,
|
||||
quasis: quasis,
|
||||
@ -489,7 +491,7 @@ module.exports = {
|
||||
* @param {ASTNode} argument The array being spread
|
||||
* @returns {ASTNode} An ASTNode representing a spread element
|
||||
*/
|
||||
createSpreadElement: function (argument) {
|
||||
createSpreadElement: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.SpreadElement,
|
||||
argument: argument
|
||||
@ -503,7 +505,7 @@ module.exports = {
|
||||
* the template string itself.
|
||||
* @returns {ASTNode} An ASTNode representing the tagged template
|
||||
*/
|
||||
createTaggedTemplateExpression: function (tag, quasi) {
|
||||
createTaggedTemplateExpression: function(tag, quasi) {
|
||||
return {
|
||||
type: astNodeTypes.TaggedTemplateExpression,
|
||||
tag: tag,
|
||||
@ -518,7 +520,7 @@ module.exports = {
|
||||
* @param {ASTNode} property The object-property being referenced
|
||||
* @returns {ASTNode} An ASTNode representing a member expression
|
||||
*/
|
||||
createMemberExpression: function (accessor, object, property) {
|
||||
createMemberExpression: function(accessor, object, property) {
|
||||
return {
|
||||
type: astNodeTypes.MemberExpression,
|
||||
computed: accessor === "[",
|
||||
@ -533,7 +535,7 @@ module.exports = {
|
||||
* @param {ASTNode} args The arguments passed to the constructor
|
||||
* @returns {ASTNode} An ASTNode representing a new expression
|
||||
*/
|
||||
createNewExpression: function (callee, args) {
|
||||
createNewExpression: function(callee, args) {
|
||||
return {
|
||||
type: astNodeTypes.NewExpression,
|
||||
callee: callee,
|
||||
@ -547,7 +549,7 @@ module.exports = {
|
||||
* properties and associated values
|
||||
* @returns {ASTNode} An ASTNode representing a new object expression
|
||||
*/
|
||||
createObjectExpression: function (properties) {
|
||||
createObjectExpression: function(properties) {
|
||||
return {
|
||||
type: astNodeTypes.ObjectExpression,
|
||||
properties: properties
|
||||
@ -560,7 +562,7 @@ module.exports = {
|
||||
* @param {ASTNode} argument The operator argument
|
||||
* @returns {ASTNode} An ASTNode representing a postfix expression
|
||||
*/
|
||||
createPostfixExpression: function (operator, argument) {
|
||||
createPostfixExpression: function(operator, argument) {
|
||||
return {
|
||||
type: astNodeTypes.UpdateExpression,
|
||||
operator: operator,
|
||||
@ -575,7 +577,7 @@ module.exports = {
|
||||
* @param {string} sourceType Either "module" or "script".
|
||||
* @returns {ASTNode} An ASTNode representing an entire program
|
||||
*/
|
||||
createProgram: function (body, sourceType) {
|
||||
createProgram: function(body, sourceType) {
|
||||
return {
|
||||
type: astNodeTypes.Program,
|
||||
body: body,
|
||||
@ -593,7 +595,7 @@ module.exports = {
|
||||
* @param {boolean} computed True if the property value has been computed
|
||||
* @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 {
|
||||
type: astNodeTypes.Property,
|
||||
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
|
||||
* @param {?ASTNode} argument The return argument, null if no argument is provided
|
||||
* @returns {ASTNode} An ASTNode representing a return statement
|
||||
*/
|
||||
createReturnStatement: function (argument) {
|
||||
createReturnStatement: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.ReturnStatement,
|
||||
argument: argument
|
||||
@ -622,20 +636,30 @@ module.exports = {
|
||||
* @param {ASTNode[]} expressions An array containing each expression, in order
|
||||
* @returns {ASTNode} An ASTNode representing a sequence of expressions
|
||||
*/
|
||||
createSequenceExpression: function (expressions) {
|
||||
createSequenceExpression: function(expressions) {
|
||||
return {
|
||||
type: astNodeTypes.SequenceExpression,
|
||||
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
|
||||
* @param {ASTNode} test The case value to test against the switch value
|
||||
* @param {ASTNode} consequent The consequent case statement
|
||||
* @returns {ASTNode} An ASTNode representing a switch case
|
||||
*/
|
||||
createSwitchCase: function (test, consequent) {
|
||||
createSwitchCase: function(test, consequent) {
|
||||
return {
|
||||
type: astNodeTypes.SwitchCase,
|
||||
test: test,
|
||||
@ -649,7 +673,7 @@ module.exports = {
|
||||
* @param {ASTNode[]} cases An array of switch case statements
|
||||
* @returns {ASTNode} An ASTNode representing a switch statement
|
||||
*/
|
||||
createSwitchStatement: function (discriminant, cases) {
|
||||
createSwitchStatement: function(discriminant, cases) {
|
||||
return {
|
||||
type: astNodeTypes.SwitchStatement,
|
||||
discriminant: discriminant,
|
||||
@ -661,7 +685,7 @@ module.exports = {
|
||||
* Create an ASTNode representation of a this statement
|
||||
* @returns {ASTNode} An ASTNode representing a this statement
|
||||
*/
|
||||
createThisExpression: function () {
|
||||
createThisExpression: function() {
|
||||
return {
|
||||
type: astNodeTypes.ThisExpression
|
||||
};
|
||||
@ -672,7 +696,7 @@ module.exports = {
|
||||
* @param {ASTNode} argument The argument to throw
|
||||
* @returns {ASTNode} An ASTNode representing a throw statement
|
||||
*/
|
||||
createThrowStatement: function (argument) {
|
||||
createThrowStatement: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.ThrowStatement,
|
||||
argument: argument
|
||||
@ -686,12 +710,10 @@ module.exports = {
|
||||
* @param {?ASTNode} finalizer The final code block to run after the try/catch has run
|
||||
* @returns {ASTNode} An ASTNode representing a try statement
|
||||
*/
|
||||
createTryStatement: function (block, handler, finalizer) {
|
||||
createTryStatement: function(block, handler, finalizer) {
|
||||
return {
|
||||
type: astNodeTypes.TryStatement,
|
||||
block: block,
|
||||
guardedHandlers: [],
|
||||
handlers: handler ? [ handler ] : [],
|
||||
handler: handler,
|
||||
finalizer: finalizer
|
||||
};
|
||||
@ -703,7 +725,7 @@ module.exports = {
|
||||
* @param {ASTNode} argument The unary operand
|
||||
* @returns {ASTNode} An ASTNode representing a unary expression
|
||||
*/
|
||||
createUnaryExpression: function (operator, argument) {
|
||||
createUnaryExpression: function(operator, argument) {
|
||||
if (operator === "++" || operator === "--") {
|
||||
return {
|
||||
type: astNodeTypes.UpdateExpression,
|
||||
@ -726,7 +748,7 @@ module.exports = {
|
||||
* @param {string} kind The kind of variable created ("var", "let", etc.)
|
||||
* @returns {ASTNode} An ASTNode representing a variable declaration
|
||||
*/
|
||||
createVariableDeclaration: function (declarations, kind) {
|
||||
createVariableDeclaration: function(declarations, kind) {
|
||||
return {
|
||||
type: astNodeTypes.VariableDeclaration,
|
||||
declarations: declarations,
|
||||
@ -740,7 +762,7 @@ module.exports = {
|
||||
* @param {ASTNode} init The variable's initial value
|
||||
* @returns {ASTNode} An ASTNode representing a variable declarator
|
||||
*/
|
||||
createVariableDeclarator: function (id, init) {
|
||||
createVariableDeclarator: function(id, init) {
|
||||
return {
|
||||
type: astNodeTypes.VariableDeclarator,
|
||||
id: id,
|
||||
@ -754,7 +776,7 @@ module.exports = {
|
||||
* @param {ASTNode} body The with statement body
|
||||
* @returns {ASTNode} An ASTNode representing a with statement
|
||||
*/
|
||||
createWithStatement: function (object, body) {
|
||||
createWithStatement: function(object, body) {
|
||||
return {
|
||||
type: astNodeTypes.WithStatement,
|
||||
object: object,
|
||||
@ -762,15 +784,15 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createYieldExpression: function (argument, delegate) {
|
||||
createYieldExpression: function(argument, delegate) {
|
||||
return {
|
||||
type: astNodeTypes.YieldExpression,
|
||||
argument: argument,
|
||||
argument: argument || null,
|
||||
delegate: delegate
|
||||
};
|
||||
},
|
||||
|
||||
createJSXAttribute: function (name, value) {
|
||||
createJSXAttribute: function(name, value) {
|
||||
return {
|
||||
type: astNodeTypes.JSXAttribute,
|
||||
name: name,
|
||||
@ -778,21 +800,21 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createJSXSpreadAttribute: function (argument) {
|
||||
createJSXSpreadAttribute: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.JSXSpreadAttribute,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
createJSXIdentifier: function (name) {
|
||||
createJSXIdentifier: function(name) {
|
||||
return {
|
||||
type: astNodeTypes.JSXIdentifier,
|
||||
name: name
|
||||
};
|
||||
},
|
||||
|
||||
createJSXNamespacedName: function (namespace, name) {
|
||||
createJSXNamespacedName: function(namespace, name) {
|
||||
return {
|
||||
type: astNodeTypes.JSXNamespacedName,
|
||||
namespace: namespace,
|
||||
@ -800,7 +822,7 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createJSXMemberExpression: function (object, property) {
|
||||
createJSXMemberExpression: function(object, property) {
|
||||
return {
|
||||
type: astNodeTypes.JSXMemberExpression,
|
||||
object: object,
|
||||
@ -808,7 +830,7 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createJSXElement: function (openingElement, closingElement, children) {
|
||||
createJSXElement: function(openingElement, closingElement, children) {
|
||||
return {
|
||||
type: astNodeTypes.JSXElement,
|
||||
openingElement: openingElement,
|
||||
@ -817,20 +839,20 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createJSXEmptyExpression: function () {
|
||||
createJSXEmptyExpression: function() {
|
||||
return {
|
||||
type: astNodeTypes.JSXEmptyExpression
|
||||
};
|
||||
},
|
||||
|
||||
createJSXExpressionContainer: function (expression) {
|
||||
createJSXExpressionContainer: function(expression) {
|
||||
return {
|
||||
type: astNodeTypes.JSXExpressionContainer,
|
||||
expression: expression
|
||||
};
|
||||
},
|
||||
|
||||
createJSXOpeningElement: function (name, attributes, selfClosing) {
|
||||
createJSXOpeningElement: function(name, attributes, selfClosing) {
|
||||
return {
|
||||
type: astNodeTypes.JSXOpeningElement,
|
||||
name: name,
|
||||
@ -839,14 +861,14 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createJSXClosingElement: function (name) {
|
||||
createJSXClosingElement: function(name) {
|
||||
return {
|
||||
type: astNodeTypes.JSXClosingElement,
|
||||
name: name
|
||||
};
|
||||
},
|
||||
|
||||
createExportSpecifier: function (local, exported) {
|
||||
createExportSpecifier: function(local, exported) {
|
||||
return {
|
||||
type: astNodeTypes.ExportSpecifier,
|
||||
exported: exported || local,
|
||||
@ -854,21 +876,21 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createImportDefaultSpecifier: function (local) {
|
||||
createImportDefaultSpecifier: function(local) {
|
||||
return {
|
||||
type: astNodeTypes.ImportDefaultSpecifier,
|
||||
local: local
|
||||
};
|
||||
},
|
||||
|
||||
createImportNamespaceSpecifier: function (local) {
|
||||
createImportNamespaceSpecifier: function(local) {
|
||||
return {
|
||||
type: astNodeTypes.ImportNamespaceSpecifier,
|
||||
local: local
|
||||
};
|
||||
},
|
||||
|
||||
createExportNamedDeclaration: function (declaration, specifiers, source) {
|
||||
createExportNamedDeclaration: function(declaration, specifiers, source) {
|
||||
return {
|
||||
type: astNodeTypes.ExportNamedDeclaration,
|
||||
declaration: declaration,
|
||||
@ -877,21 +899,21 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createExportDefaultDeclaration: function (declaration) {
|
||||
createExportDefaultDeclaration: function(declaration) {
|
||||
return {
|
||||
type: astNodeTypes.ExportDefaultDeclaration,
|
||||
declaration: declaration
|
||||
};
|
||||
},
|
||||
|
||||
createExportAllDeclaration: function (source) {
|
||||
createExportAllDeclaration: function(source) {
|
||||
return {
|
||||
type: astNodeTypes.ExportAllDeclaration,
|
||||
source: source
|
||||
};
|
||||
},
|
||||
|
||||
createImportSpecifier: function (local, imported) {
|
||||
createImportSpecifier: function(local, imported) {
|
||||
return {
|
||||
type: astNodeTypes.ImportSpecifier,
|
||||
local: local || imported,
|
||||
@ -899,7 +921,7 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
createImportDeclaration: function (specifiers, source) {
|
||||
createImportDeclaration: function(specifiers, source) {
|
||||
return {
|
||||
type: astNodeTypes.ImportDeclaration,
|
||||
specifiers: specifiers,
|
||||
|
||||
2
node_modules/espree/lib/ast-node-types.js
generated
vendored
2
node_modules/espree/lib/ast-node-types.js
generated
vendored
@ -74,9 +74,11 @@ module.exports = {
|
||||
ObjectPattern: "ObjectPattern",
|
||||
Program: "Program",
|
||||
Property: "Property",
|
||||
RestElement: "RestElement",
|
||||
ReturnStatement: "ReturnStatement",
|
||||
SequenceExpression: "SequenceExpression",
|
||||
SpreadElement: "SpreadElement",
|
||||
Super: "Super",
|
||||
SwitchCase: "SwitchCase",
|
||||
SwitchStatement: "SwitchStatement",
|
||||
TaggedTemplateExpression: "TaggedTemplateExpression",
|
||||
|
||||
2
node_modules/espree/lib/messages.js
generated
vendored
2
node_modules/espree/lib/messages.js
generated
vendored
@ -69,7 +69,7 @@ module.exports = {
|
||||
StrictParamName: "Parameter name eval or arguments is not allowed in strict mode",
|
||||
StrictParamDupe: "Strict mode function may not have duplicate parameter names",
|
||||
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",
|
||||
ElementAfterSpreadElement: "Spread must be the final element of an element list",
|
||||
ObjectPatternAsRestParameter: "Invalid rest parameter",
|
||||
|
||||
34
node_modules/espree/package.json
generated
vendored
34
node_modules/espree/package.json
generated
vendored
File diff suppressed because one or more lines are too long
@ -17,7 +17,7 @@
|
||||
"bluebird": "~2.9.14",
|
||||
"catharsis": "~0.8.7",
|
||||
"escape-string-regexp": "~1.0.2",
|
||||
"espree": "~1.12.3",
|
||||
"espree": "~2.0.3",
|
||||
"js2xmlparser": "~0.1.7",
|
||||
"marked": "~0.3.2",
|
||||
"requizzle": "~0.2.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user