Commit aab2a58e authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[devtools] Roll acorn and acorn-loose 7.1.0.

Remove the `ACORN_ECMA_VERSION` constant, and instead rely on the
official `ecmaVersion` default in acorn, which is now 10 (corresponding
to ES2019).

Bug: chromium:995036, chromium:1009927
Change-Id: Ie6b4c5e2839012f498c2c561c33d811b37749eee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829713
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701461}
parent 1e64afb4
......@@ -11,8 +11,7 @@ FormatterWorker.AcornTokenizer = class {
constructor(content) {
this._content = content;
this._comments = [];
this._tokenizer =
acorn.tokenizer(this._content, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION, onComment: this._comments});
this._tokenizer = acorn.tokenizer(this._content, {onComment: this._comments});
this._textCursor = new TextUtils.TextCursor(this._content.computeLineEndings());
this._tokenLineStart = 0;
this._tokenLineEnd = 0;
......
......@@ -28,8 +28,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
FormatterWorker.ACORN_ECMA_VERSION = 2018;
/**
* @param {string} mimeType
* @return {function(string, function(string, ?string, number, number):(!Object|undefined))}
......@@ -114,7 +112,7 @@ FormatterWorker.parseJSONRelaxed = function(content) {
* @param {string} content
*/
FormatterWorker.evaluatableJavaScriptSubstring = function(content) {
const tokenizer = acorn.tokenizer(content, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
const tokenizer = acorn.tokenizer(content, {});
let result = '';
try {
let token = tokenizer.getToken();
......@@ -163,7 +161,7 @@ FormatterWorker.preprocessTopLevelAwaitExpressions = function(content) {
let root;
let body;
try {
root = acorn.parse(wrapped, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
root = acorn.parse(wrapped, {});
body = root.body[0].expression.callee.body;
} catch (e) {
postMessage('');
......@@ -265,7 +263,7 @@ FormatterWorker.preprocessTopLevelAwaitExpressions = function(content) {
FormatterWorker.javaScriptIdentifiers = function(content) {
let root = null;
try {
root = acorn.parse(content, {ranges: false, ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
root = acorn.parse(content, {ranges: false});
} catch (e) {
}
......@@ -370,7 +368,7 @@ FormatterWorker.findLastFunctionCall = function(content) {
return null;
}
try {
const tokenizer = acorn.tokenizer(content, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
const tokenizer = acorn.tokenizer(content, {});
while (tokenizer.getToken().type !== acorn.tokTypes.eof) {
}
} catch (e) {
......@@ -418,13 +416,13 @@ FormatterWorker.argumentsList = function(content) {
let parsed = null;
try {
// Try to parse as a function, anonymous function, or arrow function.
parsed = acorn.parse(`(${content})`, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
parsed = acorn.parse(`(${content})`, {});
} catch (e) {
}
if (!parsed) {
try {
// Try to parse as a method.
parsed = acorn.parse(`({${content}})`, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
parsed = acorn.parse(`({${content}})`, {});
} catch (e) {
}
}
......@@ -485,7 +483,7 @@ FormatterWorker.findLastExpression = function(content) {
return null;
}
try {
const tokenizer = acorn.tokenizer(content, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
const tokenizer = acorn.tokenizer(content, {});
while (tokenizer.getToken().type !== acorn.tokTypes.eof) {
}
} catch (e) {
......@@ -494,7 +492,7 @@ FormatterWorker.findLastExpression = function(content) {
const suffix = '.DEVTOOLS';
try {
acorn.parse(content + suffix, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
acorn.parse(content + suffix, {});
} catch (parseError) {
// If this is an invalid location for a '.', don't attempt to give autocomplete
if (parseError.message.startsWith('Unexpected token') && parseError.pos === content.length) {
......@@ -524,7 +522,7 @@ FormatterWorker._lastCompleteExpression = function(content, suffix, types) {
try {
// Wrap content in paren to successfully parse object literals
parsedContent = content[i] === '{' ? `(${content.substring(i)})${suffix}` : `${content.substring(i)}${suffix}`;
ast = acorn.parse(parsedContent, {ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
ast = acorn.parse(parsedContent, {});
break;
} catch (e) {
}
......
......@@ -51,8 +51,7 @@ FormatterWorker.JavaScriptFormatter = class {
this._content = text.substring(this._fromOffset, this._toOffset);
this._lastLineNumber = 0;
this._tokenizer = new FormatterWorker.AcornTokenizer(this._content);
const ast = acorn.parse(
this._content, {ranges: false, ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION, preserveParens: true});
const ast = acorn.parse(this._content, {ranges: false, preserveParens: true});
const walker = new FormatterWorker.ESTreeWalker(this._beforeVisit.bind(this), this._afterVisit.bind(this));
walker.walk(ast);
}
......
......@@ -11,9 +11,9 @@ FormatterWorker.javaScriptOutline = function(content) {
let ast;
try {
ast = acorn.parse(content, {ranges: false, ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
ast = acorn.parse(content, {ranges: false});
} catch (e) {
ast = acorn.loose.parse(content, {ranges: false, ecmaVersion: FormatterWorker.ACORN_ECMA_VERSION});
ast = acorn.loose.parse(content, {ranges: false});
}
const textCursor = new TextUtils.TextCursor(content.computeLineEndings());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment