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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sass/SASSSupport.js

Issue 1515733002: DevTools: [SASS] implement CSS AST-builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sass-module
Patch Set: rebaseline test Created 5 years 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/sass/SASSSupport.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sass/SASSSupport.js b/third_party/WebKit/Source/devtools/front_end/sass/SASSSupport.js
index 4c9a9f691ae1182c23a9385a2e2a36d8fbcc84b1..9e4ea5c974d5200668877e101ad08d19c048d2c9 100644
--- a/third_party/WebKit/Source/devtools/front_end/sass/SASSSupport.js
+++ b/third_party/WebKit/Source/devtools/front_end/sass/SASSSupport.js
@@ -5,14 +5,40 @@
WebInspector.SASSSupport = {}
/**
- * @constructor
+ * @param {!WebInspector.CSSParser} parser
* @param {string} url
* @param {string} text
+ * @return {!Promise<!WebInspector.SASSSupport.AST>}
*/
-WebInspector.SASSSupport.ASTDocument = function(url, text)
+WebInspector.SASSSupport.parseCSS = function(parser, url, text)
{
- this.url = url;
- this.text = text;
+ return parser.parsePromise(text)
+ .then(onParsed);
+
+ /**
+ * @param {!Array.<!WebInspector.CSSParser.Rule>} parsedCSS
+ * @return {!WebInspector.SASSSupport.AST}
+ */
+ function onParsed(parsedCSS)
+ {
+ var document = new WebInspector.SASSSupport.ASTDocument(url, text);
+ var rules = [];
+ for (var i = 0; i < parsedCSS.length; ++i) {
+ var rule = parsedCSS[i];
+ if (!rule.properties)
+ continue;
+ var properties = [];
+ for (var j = 0; j < rule.properties.length; ++j) {
+ var cssProperty = rule.properties[j];
+ var name = new WebInspector.SASSSupport.TextNode(document, cssProperty.name, WebInspector.TextRange.fromObject(cssProperty.nameRange));
+ var value = new WebInspector.SASSSupport.TextNode(document, cssProperty.value, WebInspector.TextRange.fromObject(cssProperty.valueRange));
+ var property = new WebInspector.SASSSupport.Property(document, name, value, WebInspector.TextRange.fromObject(cssProperty.range), !!cssProperty.disabled);
+ properties.push(property);
+ }
+ rules.push(new WebInspector.SASSSupport.Rule(document, rule.selectorText, properties));
+ }
+ return new WebInspector.SASSSupport.AST(document, rules);
+ }
}
/**
@@ -208,6 +234,17 @@ WebInspector.SASSSupport._innerParseSCSS = function(document, tokenizerFactory)
/**
* @constructor
+ * @param {string} url
+ * @param {string} text
+ */
+WebInspector.SASSSupport.ASTDocument = function(url, text)
+{
+ this.url = url;
+ this.text = text;
+}
+
+/**
+ * @constructor
* @param {!WebInspector.SASSSupport.ASTDocument} document
*/
WebInspector.SASSSupport.Node = function(document)

Powered by Google App Engine
This is Rietveld 408576698