| Index: third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js b/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
|
| index 4cdf13a5e0a9f04c9bc87e45acc6429039fda3b7..c3f4c1e128ce91ad8967a9cdd475dd12b8dad3d7 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
|
| @@ -31,7 +31,7 @@
|
| * @param {string} mimeType
|
| * @return {function(string, function(string, ?string, number, number):(!Object|undefined))}
|
| */
|
| -WebInspector.createTokenizer = function(mimeType) {
|
| +FormatterWorker.createTokenizer = function(mimeType) {
|
| var mode = CodeMirror.getMode({indentUnit: 2}, mimeType);
|
| var state = CodeMirror.startState(mode);
|
| /**
|
| @@ -43,7 +43,7 @@ WebInspector.createTokenizer = function(mimeType) {
|
| while (!stream.eol()) {
|
| var style = mode.token(stream, state);
|
| var value = stream.current();
|
| - if (callback(value, style, stream.start, stream.start + value.length) === WebInspector.AbortTokenization)
|
| + if (callback(value, style, stream.start, stream.start + value.length) === FormatterWorker.AbortTokenization)
|
| return;
|
| stream.start = stream.pos;
|
| }
|
| @@ -51,7 +51,7 @@ WebInspector.createTokenizer = function(mimeType) {
|
| return tokenize;
|
| };
|
|
|
| -WebInspector.AbortTokenization = {};
|
| +FormatterWorker.AbortTokenization = {};
|
|
|
| self.onmessage = function(event) {
|
| var method = /** @type {string} */ (event.data.method);
|
| @@ -61,25 +61,25 @@ self.onmessage = function(event) {
|
|
|
| switch (method) {
|
| case 'format':
|
| - WebInspector.format(params.mimeType, params.content, params.indentString);
|
| + FormatterWorker.format(params.mimeType, params.content, params.indentString);
|
| break;
|
| case 'parseCSS':
|
| - WebInspector.parseCSS(params.content);
|
| + FormatterWorker.parseCSS(params.content);
|
| break;
|
| case 'parseSCSS':
|
| - WebInspector.FormatterWorkerContentParser.parse(params.content, 'text/x-scss');
|
| + FormatterWorker.FormatterWorkerContentParser.parse(params.content, 'text/x-scss');
|
| break;
|
| case 'javaScriptOutline':
|
| - WebInspector.javaScriptOutline(params.content);
|
| + FormatterWorker.javaScriptOutline(params.content);
|
| break;
|
| case 'javaScriptIdentifiers':
|
| - WebInspector.javaScriptIdentifiers(params.content);
|
| + FormatterWorker.javaScriptIdentifiers(params.content);
|
| break;
|
| case 'evaluatableJavaScriptSubstring':
|
| - WebInspector.evaluatableJavaScriptSubstring(params.content);
|
| + FormatterWorker.evaluatableJavaScriptSubstring(params.content);
|
| break;
|
| case 'relaxedJSONParser':
|
| - WebInspector.relaxedJSONParser(params.content);
|
| + FormatterWorker.relaxedJSONParser(params.content);
|
| break;
|
| default:
|
| console.error('Unsupport method name: ' + method);
|
| @@ -89,38 +89,38 @@ self.onmessage = function(event) {
|
| /**
|
| * @param {string} content
|
| */
|
| -WebInspector.relaxedJSONParser = function(content) {
|
| - postMessage(WebInspector.RelaxedJSONParser.parse(content));
|
| +FormatterWorker.relaxedJSONParser = function(content) {
|
| + postMessage(FormatterWorker.RelaxedJSONParser.parse(content));
|
| };
|
|
|
| /**
|
| * @param {string} content
|
| */
|
| -WebInspector.evaluatableJavaScriptSubstring = function(content) {
|
| +FormatterWorker.evaluatableJavaScriptSubstring = function(content) {
|
| var tokenizer = acorn.tokenizer(content, {ecmaVersion: 6});
|
| var result = '';
|
| try {
|
| var token = tokenizer.getToken();
|
| - while (token.type !== acorn.tokTypes.eof && WebInspector.AcornTokenizer.punctuator(token))
|
| + while (token.type !== acorn.tokTypes.eof && FormatterWorker.AcornTokenizer.punctuator(token))
|
| token = tokenizer.getToken();
|
|
|
| var startIndex = token.start;
|
| var endIndex = token.end;
|
| var openBracketsCounter = 0;
|
| while (token.type !== acorn.tokTypes.eof) {
|
| - var isIdentifier = WebInspector.AcornTokenizer.identifier(token);
|
| - var isThis = WebInspector.AcornTokenizer.keyword(token, 'this');
|
| + var isIdentifier = FormatterWorker.AcornTokenizer.identifier(token);
|
| + var isThis = FormatterWorker.AcornTokenizer.keyword(token, 'this');
|
| var isString = token.type === acorn.tokTypes.string;
|
| if (!isThis && !isIdentifier && !isString)
|
| break;
|
|
|
| endIndex = token.end;
|
| token = tokenizer.getToken();
|
| - while (WebInspector.AcornTokenizer.punctuator(token, '.[]')) {
|
| - if (WebInspector.AcornTokenizer.punctuator(token, '['))
|
| + while (FormatterWorker.AcornTokenizer.punctuator(token, '.[]')) {
|
| + if (FormatterWorker.AcornTokenizer.punctuator(token, '['))
|
| openBracketsCounter++;
|
|
|
| - if (WebInspector.AcornTokenizer.punctuator(token, ']')) {
|
| + if (FormatterWorker.AcornTokenizer.punctuator(token, ']')) {
|
| endIndex = openBracketsCounter > 0 ? token.end : endIndex;
|
| openBracketsCounter--;
|
| }
|
| @@ -138,12 +138,12 @@ WebInspector.evaluatableJavaScriptSubstring = function(content) {
|
| /**
|
| * @param {string} content
|
| */
|
| -WebInspector.javaScriptIdentifiers = function(content) {
|
| +FormatterWorker.javaScriptIdentifiers = function(content) {
|
| var root = acorn.parse(content, {ranges: false, ecmaVersion: 6});
|
|
|
| /** @type {!Array<!ESTree.Node>} */
|
| var identifiers = [];
|
| - var walker = new WebInspector.ESTreeWalker(beforeVisit);
|
| + var walker = new FormatterWorker.ESTreeWalker(beforeVisit);
|
|
|
| /**
|
| * @param {!ESTree.Node} node
|
| @@ -161,7 +161,7 @@ WebInspector.javaScriptIdentifiers = function(content) {
|
| if (isFunction(node)) {
|
| if (node.id)
|
| identifiers.push(node.id);
|
| - return WebInspector.ESTreeWalker.SkipSubtree;
|
| + return FormatterWorker.ESTreeWalker.SkipSubtree;
|
| }
|
|
|
| if (node.type !== 'Identifier')
|
| @@ -191,28 +191,28 @@ WebInspector.javaScriptIdentifiers = function(content) {
|
| * @param {string} text
|
| * @param {string=} indentString
|
| */
|
| -WebInspector.format = function(mimeType, text, indentString) {
|
| +FormatterWorker.format = function(mimeType, text, indentString) {
|
| // Default to a 4-space indent.
|
| indentString = indentString || ' ';
|
| var result = {};
|
| - var builder = new WebInspector.FormattedContentBuilder(indentString);
|
| + var builder = new FormatterWorker.FormattedContentBuilder(indentString);
|
| var lineEndings = text.computeLineEndings();
|
| try {
|
| switch (mimeType) {
|
| case 'text/html':
|
| - var formatter = new WebInspector.HTMLFormatter(builder);
|
| + var formatter = new FormatterWorker.HTMLFormatter(builder);
|
| formatter.format(text, lineEndings);
|
| break;
|
| case 'text/css':
|
| - var formatter = new WebInspector.CSSFormatter(builder);
|
| + var formatter = new FormatterWorker.CSSFormatter(builder);
|
| formatter.format(text, lineEndings, 0, text.length);
|
| break;
|
| case 'text/javascript':
|
| - var formatter = new WebInspector.JavaScriptFormatter(builder);
|
| + var formatter = new FormatterWorker.JavaScriptFormatter(builder);
|
| formatter.format(text, lineEndings, 0, text.length);
|
| break;
|
| default:
|
| - var formatter = new WebInspector.IdentityFormatter(builder);
|
| + var formatter = new FormatterWorker.IdentityFormatter(builder);
|
| formatter.format(text, lineEndings, 0, text.length);
|
| }
|
| result.mapping = builder.mapping();
|
| @@ -228,9 +228,9 @@ WebInspector.format = function(mimeType, text, indentString) {
|
| /**
|
| * @interface
|
| */
|
| -WebInspector.FormatterWorkerContentParser = function() {};
|
| +FormatterWorker.FormatterWorkerContentParser = function() {};
|
|
|
| -WebInspector.FormatterWorkerContentParser.prototype = {
|
| +FormatterWorker.FormatterWorkerContentParser.prototype = {
|
| /**
|
| * @param {string} content
|
| * @return {!Object}
|
| @@ -242,8 +242,8 @@ WebInspector.FormatterWorkerContentParser.prototype = {
|
| * @param {string} content
|
| * @param {string} mimeType
|
| */
|
| -WebInspector.FormatterWorkerContentParser.parse = function(content, mimeType) {
|
| - var extension = self.runtime.extensions(WebInspector.FormatterWorkerContentParser).find(findExtension);
|
| +FormatterWorker.FormatterWorkerContentParser.parse = function(content, mimeType) {
|
| + var extension = self.runtime.extensions(FormatterWorker.FormatterWorkerContentParser).find(findExtension);
|
| console.assert(extension);
|
| extension.instance().then(instance => instance.parse(content)).catchException(null).then(postMessage);
|
|
|
|
|