| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 WebInspector.SASSSupport = {} | 5 WebInspector.SASSSupport = {} |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @param {!WebInspector.CSSParser} parser |
| 9 * @param {string} url | 9 * @param {string} url |
| 10 * @param {string} text | 10 * @param {string} text |
| 11 * @return {!Promise<!WebInspector.SASSSupport.AST>} |
| 11 */ | 12 */ |
| 12 WebInspector.SASSSupport.ASTDocument = function(url, text) | 13 WebInspector.SASSSupport.parseCSS = function(parser, url, text) |
| 13 { | 14 { |
| 14 this.url = url; | 15 return parser.parsePromise(text) |
| 15 this.text = text; | 16 .then(onParsed); |
| 17 |
| 18 /** |
| 19 * @param {!Array.<!WebInspector.CSSParser.Rule>} parsedCSS |
| 20 * @return {!WebInspector.SASSSupport.AST} |
| 21 */ |
| 22 function onParsed(parsedCSS) |
| 23 { |
| 24 var document = new WebInspector.SASSSupport.ASTDocument(url, text); |
| 25 var rules = []; |
| 26 for (var i = 0; i < parsedCSS.length; ++i) { |
| 27 var rule = parsedCSS[i]; |
| 28 if (!rule.properties) |
| 29 continue; |
| 30 var properties = []; |
| 31 for (var j = 0; j < rule.properties.length; ++j) { |
| 32 var cssProperty = rule.properties[j]; |
| 33 var name = new WebInspector.SASSSupport.TextNode(document, cssPr
operty.name, WebInspector.TextRange.fromObject(cssProperty.nameRange)); |
| 34 var value = new WebInspector.SASSSupport.TextNode(document, cssP
roperty.value, WebInspector.TextRange.fromObject(cssProperty.valueRange)); |
| 35 var property = new WebInspector.SASSSupport.Property(document, n
ame, value, WebInspector.TextRange.fromObject(cssProperty.range), !!cssProperty.
disabled); |
| 36 properties.push(property); |
| 37 } |
| 38 rules.push(new WebInspector.SASSSupport.Rule(document, rule.selector
Text, properties)); |
| 39 } |
| 40 return new WebInspector.SASSSupport.AST(document, rules); |
| 41 } |
| 16 } | 42 } |
| 17 | 43 |
| 18 /** | 44 /** |
| 19 * @param {string} url | 45 * @param {string} url |
| 20 * @param {string} text | 46 * @param {string} text |
| 21 * @param {!WebInspector.TokenizerFactory} tokenizerFactory | 47 * @param {!WebInspector.TokenizerFactory} tokenizerFactory |
| 22 * @return {!WebInspector.SASSSupport.AST} | 48 * @return {!WebInspector.SASSSupport.AST} |
| 23 */ | 49 */ |
| 24 WebInspector.SASSSupport.parseSCSS = function(url, text, tokenizerFactory) | 50 WebInspector.SASSSupport.parseSCSS = function(url, text, tokenizerFactory) |
| 25 { | 51 { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 227 } |
| 202 return { | 228 return { |
| 203 variables: variables, | 229 variables: variables, |
| 204 properties: properties, | 230 properties: properties, |
| 205 mixins: mixins | 231 mixins: mixins |
| 206 }; | 232 }; |
| 207 } | 233 } |
| 208 | 234 |
| 209 /** | 235 /** |
| 210 * @constructor | 236 * @constructor |
| 237 * @param {string} url |
| 238 * @param {string} text |
| 239 */ |
| 240 WebInspector.SASSSupport.ASTDocument = function(url, text) |
| 241 { |
| 242 this.url = url; |
| 243 this.text = text; |
| 244 } |
| 245 |
| 246 /** |
| 247 * @constructor |
| 211 * @param {!WebInspector.SASSSupport.ASTDocument} document | 248 * @param {!WebInspector.SASSSupport.ASTDocument} document |
| 212 */ | 249 */ |
| 213 WebInspector.SASSSupport.Node = function(document) | 250 WebInspector.SASSSupport.Node = function(document) |
| 214 { | 251 { |
| 215 this.document = document; | 252 this.document = document; |
| 216 } | 253 } |
| 217 | 254 |
| 218 /** | 255 /** |
| 219 * @constructor | 256 * @constructor |
| 220 * @extends {WebInspector.SASSSupport.Node} | 257 * @extends {WebInspector.SASSSupport.Node} |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 { | 363 { |
| 327 var rules = []; | 364 var rules = []; |
| 328 for (var i = 0; i < this.rules.length; ++i) | 365 for (var i = 0; i < this.rules.length; ++i) |
| 329 rules.push(this.rules[i].clone()); | 366 rules.push(this.rules[i].clone()); |
| 330 return new WebInspector.SASSSupport.AST(this.document, rules); | 367 return new WebInspector.SASSSupport.AST(this.document, rules); |
| 331 }, | 368 }, |
| 332 | 369 |
| 333 __proto__: WebInspector.SASSSupport.Node.prototype | 370 __proto__: WebInspector.SASSSupport.Node.prototype |
| 334 } | 371 } |
| 335 | 372 |
| OLD | NEW |