Chromium Code Reviews

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

Issue 1713783003: DevTools: improve SCSS parser to correctly handle variable expansions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sass/test-ast-scss-6-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {!WebInspector.CSSParserService} cssParserService 8 * @param {!WebInspector.CSSParserService} cssParserService
9 * @param {string} url 9 * @param {string} url
10 * @param {string} text 10 * @param {string} text
(...skipping 52 matching lines...)
63 63
64 /** @enum {string} */ 64 /** @enum {string} */
65 WebInspector.SASSSupport.SCSSParserStates = { 65 WebInspector.SASSSupport.SCSSParserStates = {
66 Initial: "Initial", 66 Initial: "Initial",
67 PropertyName: "PropertyName", 67 PropertyName: "PropertyName",
68 PropertyValue: "PropertyValue", 68 PropertyValue: "PropertyValue",
69 VariableName: "VariableName", 69 VariableName: "VariableName",
70 VariableValue: "VariableValue", 70 VariableValue: "VariableValue",
71 MixinName: "MixinName", 71 MixinName: "MixinName",
72 MixinValue: "MixinValue", 72 MixinValue: "MixinValue",
73 Media: "Media", 73 Media: "Media"
74 } 74 }
75 75
76 /** 76 /**
77 * @param {!WebInspector.SASSSupport.ASTDocument} document 77 * @param {!WebInspector.SASSSupport.ASTDocument} document
78 * @param {!WebInspector.TokenizerFactory} tokenizerFactory 78 * @param {!WebInspector.TokenizerFactory} tokenizerFactory
79 * @return {!{variables: !Array<!WebInspector.SASSSupport.Property>, properties: !Array<!WebInspector.SASSSupport.Property>, mixins: !Array<!WebInspector.SASSSu pport.Property>}} 79 * @return {!{variables: !Array<!WebInspector.SASSSupport.Property>, properties: !Array<!WebInspector.SASSSupport.Property>, mixins: !Array<!WebInspector.SASSSu pport.Property>}}
80 */ 80 */
81 WebInspector.SASSSupport._innerParseSCSS = function(document, tokenizerFactory) 81 WebInspector.SASSSupport._innerParseSCSS = function(document, tokenizerFactory)
82 { 82 {
83 var lines = document.text.split("\n"); 83 var lines = document.text.split("\n");
(...skipping 48 matching lines...)
132 var value = new WebInspector.SASSSupport.TextNode(document, disabledProperty.value.text, valueRange); 132 var value = new WebInspector.SASSSupport.TextNode(document, disabledProperty.value.text, valueRange);
133 var range = new WebInspector.TextRange(lineNumber, column, l ineNumber, newColumn); 133 var range = new WebInspector.TextRange(lineNumber, column, l ineNumber, newColumn);
134 var property = new WebInspector.SASSSupport.Property(documen t, name, value, range, true); 134 var property = new WebInspector.SASSSupport.Property(documen t, name, value, range, true);
135 properties.push(property); 135 properties.push(property);
136 } 136 }
137 } else if (tokenType["css-def"] && tokenValue === "@media") { 137 } else if (tokenType["css-def"] && tokenValue === "@media") {
138 state = States.Media; 138 state = States.Media;
139 } 139 }
140 break; 140 break;
141 case States.VariableName: 141 case States.VariableName:
142 if (tokenValue === ")" && tokenType === UndefTokenType) { 142 if (tokenValue === "}" && tokenType === UndefTokenType) {
143 state = States.Initial;
144 } else if (tokenValue === ")" && tokenType === UndefTokenType) {
143 state = States.Initial; 145 state = States.Initial;
144 } else if (tokenValue === ":" && tokenType === UndefTokenType) { 146 } else if (tokenValue === ":" && tokenType === UndefTokenType) {
145 state = States.VariableValue; 147 state = States.VariableValue;
146 variableValue = new WebInspector.SASSSupport.TextNode(document, "", WebInspector.TextRange.createFromLocation(lineNumber, newColumn)); 148 variableValue = new WebInspector.SASSSupport.TextNode(document, "", WebInspector.TextRange.createFromLocation(lineNumber, newColumn));
147 } else if (tokenType !== UndefTokenType) { 149 } else if (tokenType !== UndefTokenType) {
148 state = States.Initial; 150 state = States.Initial;
149 } 151 }
150 break; 152 break;
151 case States.VariableValue: 153 case States.VariableValue:
152 if (tokenValue === ";" && tokenType === UndefTokenType) { 154 if (tokenValue === ";" && tokenType === UndefTokenType) {
(...skipping 533 matching lines...)
686 mapping.set(oldProperty.name, newProperty.name); 688 mapping.set(oldProperty.name, newProperty.name);
687 mapping.set(oldProperty.value, newProperty.value); 689 mapping.set(oldProperty.value, newProperty.value);
688 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) 690 if (oldProperty.name.text.trim() !== newProperty.name.text.trim())
689 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp ertyIndex); 691 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp ertyIndex);
690 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) 692 if (oldProperty.value.text.trim() !== newProperty.value.text.trim())
691 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro pertyIndex); 693 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro pertyIndex);
692 if (oldProperty.disabled !== newProperty.disabled) 694 if (oldProperty.disabled !== newProperty.disabled)
693 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new PropertyIndex); 695 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new PropertyIndex);
694 } 696 }
695 } 697 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sass/test-ast-scss-6-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine