| 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 | 9 * @param {string} text |
| 10 * @return {!Promise<!WebInspector.SASSSupport.AST>} | 10 * @return {!Promise<!WebInspector.SASSSupport.AST>} |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return WebInspector.formatterWorkerPool.runTask("parseSCSS", {content: conte
nt}).then(onParsed); | 54 return WebInspector.formatterWorkerPool.runTask("parseSCSS", {content: conte
nt}).then(onParsed); |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * @param {?MessageEvent} event | 57 * @param {?MessageEvent} event |
| 58 * @return {!WebInspector.SASSSupport.AST} | 58 * @return {!WebInspector.SASSSupport.AST} |
| 59 */ | 59 */ |
| 60 function onParsed(event) | 60 function onParsed(event) |
| 61 { | 61 { |
| 62 if (!event) | 62 if (!event) |
| 63 return new WebInspector.SASSSupport.AST(document, []); | 63 return new WebInspector.SASSSupport.AST(document, []); |
| 64 var data = /** @type {!{properties: !Array<!Object>, variables: !Array<!
Object>, mixins: !Array<!Object>}} */(event.data); | 64 var data = /** @type {!Array<!Object>} */(event.data); |
| 65 var properties = data.properties.map(createProperty); | 65 var rules = []; |
| 66 var variables = data.variables.map(createProperty); | 66 for (var i = 0; i < data.length; ++i) { |
| 67 var mixins = data.mixins.map(createProperty); | 67 var rulePayload = data[i]; |
| 68 var rules = [ | 68 var selectorText = ""; |
| 69 new WebInspector.SASSSupport.Rule(document, "variables", WebInspecto
r.TextRange.createFromLocation(0, 0), variables), | 69 if (rulePayload.selectors.length) { |
| 70 new WebInspector.SASSSupport.Rule(document, "properties", WebInspect
or.TextRange.createFromLocation(0, 0), properties), | 70 var first = rulePayload.selectors[0]; |
| 71 new WebInspector.SASSSupport.Rule(document, "mixins", WebInspector.T
extRange.createFromLocation(0, 0), mixins) | 71 var last = rulePayload.selectors.peekLast(); |
| 72 ]; | 72 var selectorRange = new WebInspector.TextRange(first.startLine,
first.startColumn, last.endLine, last.endColumn); |
| 73 | 73 selectorText = text.extract(selectorRange); |
| 74 } |
| 75 var properties = rulePayload.properties.map(createProperty); |
| 76 var range = WebInspector.TextRange.fromObject(rulePayload.styleRange
); |
| 77 var rule = new WebInspector.SASSSupport.Rule(document, selectorText,
range, properties); |
| 78 rules.push(rule); |
| 79 } |
| 74 return new WebInspector.SASSSupport.AST(document, rules); | 80 return new WebInspector.SASSSupport.AST(document, rules); |
| 75 } | 81 } |
| 76 | 82 |
| 77 /** | 83 /** |
| 78 * @param {!Object} payload | 84 * @param {!Object} payload |
| 79 */ | 85 */ |
| 80 function createTextNode(payload) | 86 function createTextNode(payload) |
| 81 { | 87 { |
| 82 var range = WebInspector.TextRange.fromObject(payload); | 88 var range = WebInspector.TextRange.fromObject(payload); |
| 83 var value = text.extract(range); | 89 var value = text.extract(range); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 mapping.set(oldProperty.name, newProperty.name); | 704 mapping.set(oldProperty.name, newProperty.name); |
| 699 mapping.set(oldProperty.value, newProperty.value); | 705 mapping.set(oldProperty.value, newProperty.value); |
| 700 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) | 706 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) |
| 701 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp
ertyIndex); | 707 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp
ertyIndex); |
| 702 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) | 708 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) |
| 703 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro
pertyIndex); | 709 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro
pertyIndex); |
| 704 if (oldProperty.disabled !== newProperty.disabled) | 710 if (oldProperty.disabled !== newProperty.disabled) |
| 705 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new
PropertyIndex); | 711 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new
PropertyIndex); |
| 706 } | 712 } |
| 707 } | 713 } |
| OLD | NEW |