Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Unified Diff: third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js

Issue 1917863008: DevTools: [SASS] introduce Gonzales-PE for SCSS parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaseline Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b7c5227125f65e68446d940cad7340a2127a8f03..bd7e5d5bbbf7c9928befb802130284708dfc29a4 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
@@ -69,6 +69,9 @@ self.onmessage = function(event) {
case "parseCSS":
WebInspector.parseCSS(params.content);
break;
+ case "parseSCSS":
+ WebInspector.FormatterWorkerContentParser.parse(params.content, "text/x-scss");
+ break;
case "javaScriptOutline":
WebInspector.javaScriptOutline(params.content);
break;
@@ -228,3 +231,35 @@ WebInspector.format = function(mimeType, text, indentString)
}
postMessage(result);
}
+
+/**
+ * @interface
+ */
+WebInspector.FormatterWorkerContentParser = function() { }
+
+WebInspector.FormatterWorkerContentParser.prototype = {
+ /**
+ * @param {string} content
+ * @return {!Object}
+ */
+ parse: function(content) { }
+}
+
+WebInspector.FormatterWorkerContentParser.parse = function(content, mimeType)
+{
+ var extension = self.runtime.extensions(WebInspector.FormatterWorkerContentParser).find(findExtension);
+ console.assert(extension);
+ extension.instancePromise()
+ .then(instance => instance.parse(content))
+ .catchException(null)
+ .then(postMessage);
+
+ /**
+ * @param {!Runtime.Extension} extension
+ * @return {boolean}
+ */
+ function findExtension(extension)
+ {
+ return extension.descriptor()["mimeType"] === mimeType;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698