| 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 * @param {string} url | 8 * @param {string} url |
| 9 * @param {string} text | |
| 10 * @return {!Promise<!WebInspector.SASSSupport.AST>} | |
| 11 */ | |
| 12 WebInspector.SASSSupport.parseCSS = function(url, text) | |
| 13 { | |
| 14 var cssParser = new WebInspector.CSSParser(); | |
| 15 return cssParser.parsePromise(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, new WebInsp
ector.Text(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, WebInspector.TextRange.fromObject(rule.styleRange), properties)); | |
| 39 } | |
| 40 return new WebInspector.SASSSupport.AST(document, rules); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 /** | |
| 45 * @param {string} url | |
| 46 * @param {string} content | 9 * @param {string} content |
| 47 * @return {!Promise<!WebInspector.SASSSupport.AST>} | 10 * @return {!Promise<!WebInspector.SASSSupport.AST>} |
| 48 */ | 11 */ |
| 49 WebInspector.SASSSupport.parseSCSS = function(url, content) | 12 WebInspector.SASSSupport.parseSCSS = function(url, content) |
| 50 { | 13 { |
| 51 var text = new WebInspector.Text(content); | 14 var text = new WebInspector.Text(content); |
| 52 var document = new WebInspector.SASSSupport.ASTDocument(url, text); | 15 var document = new WebInspector.SASSSupport.ASTDocument(url, text); |
| 53 | 16 |
| 54 return WebInspector.formatterWorkerPool.runTask("parseSCSS", {content: conte
nt}).then(onParsed); | 17 return WebInspector.formatterWorkerPool.runTask("parseSCSS", {content: conte
nt}).then(onParsed); |
| 55 | 18 |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 mapping.set(oldProperty.name, newProperty.name); | 667 mapping.set(oldProperty.name, newProperty.name); |
| 705 mapping.set(oldProperty.value, newProperty.value); | 668 mapping.set(oldProperty.value, newProperty.value); |
| 706 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) | 669 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) |
| 707 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp
ertyIndex); | 670 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp
ertyIndex); |
| 708 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) | 671 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) |
| 709 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro
pertyIndex); | 672 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro
pertyIndex); |
| 710 if (oldProperty.disabled !== newProperty.disabled) | 673 if (oldProperty.disabled !== newProperty.disabled) |
| 711 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new
PropertyIndex); | 674 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new
PropertyIndex); |
| 712 } | 675 } |
| 713 } | 676 } |
| OLD | NEW |