Skip to content

Commit

Permalink
DevTools: [SASS] start parsing CSS with SCSS parser
Browse files Browse the repository at this point in the history
As CSS is a subset of SCSS, we can just parse CSS with the SCSS parser.

BUG=608097
R=pfeldman

Review-Url: https://codereview.chromium.org/1941283002
Cr-Commit-Position: refs/heads/master@{#391414}
  • Loading branch information
aslushnikov authored and Commit bot committed May 4, 2016
1 parent 51b0ebb commit 4150aff
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
2 changes: 1 addition & 1 deletion front_end/sass/ASTService.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ WebInspector.ASTService.prototype = {
*/
parseCSS: function(url, text)
{
return WebInspector.SASSSupport.parseCSS(url, text);
return WebInspector.SASSSupport.parseSCSS(url, text);
},

/**
Expand Down
37 changes: 0 additions & 37 deletions front_end/sass/SASSSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,6 @@

WebInspector.SASSSupport = {}

/**
* @param {string} url
* @param {string} text
* @return {!Promise<!WebInspector.SASSSupport.AST>}
*/
WebInspector.SASSSupport.parseCSS = function(url, text)
{
var cssParser = new WebInspector.CSSParser();
return cssParser.parsePromise(text)
.then(onParsed);

/**
* @param {!Array.<!WebInspector.CSSParser.Rule>} parsedCSS
* @return {!WebInspector.SASSSupport.AST}
*/
function onParsed(parsedCSS)
{
var document = new WebInspector.SASSSupport.ASTDocument(url, new WebInspector.Text(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, WebInspector.TextRange.fromObject(rule.styleRange), properties));
}
return new WebInspector.SASSSupport.AST(document, rules);
}
}

/**
* @param {string} url
* @param {string} content
Expand Down

0 comments on commit 4150aff

Please sign in to comment.