OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {!WebInspector.ASTService} astService | 7 * @param {!WebInspector.ASTService} astService |
8 * @param {!WebInspector.ASTSourceMap} map | 8 * @param {!WebInspector.ASTSourceMap} map |
9 * @param {!Array<!WebInspector.SASSProcessor.EditOperation>} editOperations | 9 * @param {!Array<!WebInspector.SASSProcessor.EditOperation>} editOperations |
10 */ | 10 */ |
11 WebInspector.SASSProcessor = function(astService, map, editOperations) | 11 WebInspector.SASSProcessor = function(astService, map, editOperations) |
12 { | 12 { |
13 this._astService = astService; | 13 this._astService = astService; |
14 this._map = map; | 14 this._map = map; |
15 this._editOperations = editOperations; | 15 this._editOperations = editOperations; |
16 } | 16 }; |
17 | 17 |
18 WebInspector.SASSProcessor.prototype = { | 18 WebInspector.SASSProcessor.prototype = { |
19 /** | 19 /** |
20 * @return {!Promise<?WebInspector.SourceMap.EditResult>} | 20 * @return {!Promise<?WebInspector.SourceMap.EditResult>} |
21 */ | 21 */ |
22 _mutate: function() | 22 _mutate: function() |
23 { | 23 { |
24 /** @type {!Set<!WebInspector.SASSSupport.Rule>} */ | 24 /** @type {!Set<!WebInspector.SASSSupport.Rule>} */ |
25 var changedCSSRules = new Set(); | 25 var changedCSSRules = new Set(); |
26 for (var editOperation of this._editOperations) { | 26 for (var editOperation of this._editOperations) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 /** @type {!Map<string, string>} */ | 68 /** @type {!Map<string, string>} */ |
69 var newSASSSources = new Map(); | 69 var newSASSSources = new Map(); |
70 for (var model of changedModels) { | 70 for (var model of changedModels) { |
71 if (model.document.url === map.compiledURL()) | 71 if (model.document.url === map.compiledURL()) |
72 continue; | 72 continue; |
73 newSASSSources.set(model.document.url, model.document.text.value()); | 73 newSASSSources.set(model.document.url, model.document.text.value()); |
74 } | 74 } |
75 return new WebInspector.SourceMap.EditResult(map, cssEdits, newSASSSourc
es); | 75 return new WebInspector.SourceMap.EditResult(map, cssEdits, newSASSSourc
es); |
76 } | 76 } |
77 } | 77 }; |
78 | 78 |
79 /** | 79 /** |
80 * @param {!WebInspector.ASTSourceMap} map | 80 * @param {!WebInspector.ASTSourceMap} map |
81 * @param {!WebInspector.SASSSupport.Property} cssProperty | 81 * @param {!WebInspector.SASSSupport.Property} cssProperty |
82 * @return {?WebInspector.SASSSupport.Property} | 82 * @return {?WebInspector.SASSSupport.Property} |
83 */ | 83 */ |
84 WebInspector.SASSProcessor._toSASSProperty = function(map, cssProperty) | 84 WebInspector.SASSProcessor._toSASSProperty = function(map, cssProperty) |
85 { | 85 { |
86 var sassName = map.toSourceNode(cssProperty.name); | 86 var sassName = map.toSourceNode(cssProperty.name); |
87 return sassName ? sassName.parent : null; | 87 return sassName ? sassName.parent : null; |
88 } | 88 }; |
89 | 89 |
90 /** | 90 /** |
91 * @param {!WebInspector.ASTSourceMap} map | 91 * @param {!WebInspector.ASTSourceMap} map |
92 * @param {!WebInspector.SASSSupport.Property} sassProperty | 92 * @param {!WebInspector.SASSSupport.Property} sassProperty |
93 * @return {!Array<!WebInspector.SASSSupport.Property>} | 93 * @return {!Array<!WebInspector.SASSSupport.Property>} |
94 */ | 94 */ |
95 WebInspector.SASSProcessor._toCSSProperties = function(map, sassProperty) | 95 WebInspector.SASSProcessor._toCSSProperties = function(map, sassProperty) |
96 { | 96 { |
97 return map.toCompiledNodes(sassProperty.name).map(name => name.parent); | 97 return map.toCompiledNodes(sassProperty.name).map(name => name.parent); |
98 } | 98 }; |
99 | 99 |
100 /** | 100 /** |
101 * @param {!WebInspector.ASTService} astService | 101 * @param {!WebInspector.ASTService} astService |
102 * @param {!WebInspector.ASTSourceMap} map | 102 * @param {!WebInspector.ASTSourceMap} map |
103 * @param {!Array<!WebInspector.TextRange>} ranges | 103 * @param {!Array<!WebInspector.TextRange>} ranges |
104 * @param {!Array<string>} newTexts | 104 * @param {!Array<string>} newTexts |
105 * @return {!Promise<?WebInspector.SourceMap.EditResult>} | 105 * @return {!Promise<?WebInspector.SourceMap.EditResult>} |
106 */ | 106 */ |
107 WebInspector.SASSProcessor.processCSSEdits = function(astService, map, ranges, n
ewTexts) | 107 WebInspector.SASSProcessor.processCSSEdits = function(astService, map, ranges, n
ewTexts) |
108 { | 108 { |
(...skipping 25 matching lines...) Expand all Loading... |
134 clonedModels.push(map.modelForURL(url).clone()); | 134 clonedModels.push(map.modelForURL(url).clone()); |
135 | 135 |
136 // Rebase map and edits onto a cloned AST trees. | 136 // Rebase map and edits onto a cloned AST trees. |
137 var nodeMapping = new Map(); | 137 var nodeMapping = new Map(); |
138 var rebasedMap = /** @type {!WebInspector.ASTSourceMap} */(map.rebase(cl
onedModels, nodeMapping)); | 138 var rebasedMap = /** @type {!WebInspector.ASTSourceMap} */(map.rebase(cl
onedModels, nodeMapping)); |
139 console.assert(rebasedMap); | 139 console.assert(rebasedMap); |
140 var rebasedEdits = edits.map(edit => edit.rebase(rebasedMap, nodeMapping
)); | 140 var rebasedEdits = edits.map(edit => edit.rebase(rebasedMap, nodeMapping
)); |
141 | 141 |
142 return new WebInspector.SASSProcessor(astService, rebasedMap, rebasedEdi
ts)._mutate(); | 142 return new WebInspector.SASSProcessor(astService, rebasedMap, rebasedEdi
ts)._mutate(); |
143 } | 143 } |
144 } | 144 }; |
145 | 145 |
146 /** | 146 /** |
147 * @param {!WebInspector.SASSSupport.ASTDiff} cssDiff | 147 * @param {!WebInspector.SASSSupport.ASTDiff} cssDiff |
148 * @param {!WebInspector.ASTSourceMap} map | 148 * @param {!WebInspector.ASTSourceMap} map |
149 * @return {!Array<!WebInspector.SASSProcessor.EditOperation>} | 149 * @return {!Array<!WebInspector.SASSProcessor.EditOperation>} |
150 */ | 150 */ |
151 WebInspector.SASSProcessor._editsFromCSSDiff = function(cssDiff, map) | 151 WebInspector.SASSProcessor._editsFromCSSDiff = function(cssDiff, map) |
152 { | 152 { |
153 var T = WebInspector.SASSSupport.PropertyChangeType; | 153 var T = WebInspector.SASSSupport.PropertyChangeType; |
154 var operations = []; | 154 var operations = []; |
(...skipping 13 matching lines...) Expand all Loading... |
168 continue; | 168 continue; |
169 } | 169 } |
170 | 170 |
171 var merged = false; | 171 var merged = false; |
172 for (var j = 0; !merged && j < operations.length; ++j) | 172 for (var j = 0; !merged && j < operations.length; ++j) |
173 merged = operations[j].merge(operation); | 173 merged = operations[j].merge(operation); |
174 if (!merged) | 174 if (!merged) |
175 operations.push(operation); | 175 operations.push(operation); |
176 } | 176 } |
177 return operations; | 177 return operations; |
178 } | 178 }; |
179 | 179 |
180 /** | 180 /** |
181 * @constructor | 181 * @constructor |
182 * @param {!WebInspector.ASTSourceMap} map | 182 * @param {!WebInspector.ASTSourceMap} map |
183 * @param {string} sassURL | 183 * @param {string} sassURL |
184 */ | 184 */ |
185 WebInspector.SASSProcessor.EditOperation = function(map, sassURL) | 185 WebInspector.SASSProcessor.EditOperation = function(map, sassURL) |
186 { | 186 { |
187 this.map = map; | 187 this.map = map; |
188 this.sassURL = sassURL; | 188 this.sassURL = sassURL; |
189 } | 189 }; |
190 | 190 |
191 WebInspector.SASSProcessor.EditOperation.prototype = { | 191 WebInspector.SASSProcessor.EditOperation.prototype = { |
192 /** | 192 /** |
193 * @param {!WebInspector.SASSProcessor.EditOperation} other | 193 * @param {!WebInspector.SASSProcessor.EditOperation} other |
194 * @return {boolean} | 194 * @return {boolean} |
195 */ | 195 */ |
196 merge: function(other) | 196 merge: function(other) |
197 { | 197 { |
198 return false; | 198 return false; |
199 }, | 199 }, |
200 | 200 |
201 /** | 201 /** |
202 * @return {!Array<!WebInspector.SASSSupport.Rule>} | 202 * @return {!Array<!WebInspector.SASSSupport.Rule>} |
203 */ | 203 */ |
204 perform: function() | 204 perform: function() |
205 { | 205 { |
206 return []; | 206 return []; |
207 }, | 207 }, |
208 | 208 |
209 /** | 209 /** |
210 * @param {!WebInspector.ASTSourceMap} newMap | 210 * @param {!WebInspector.ASTSourceMap} newMap |
211 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping | 211 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping |
212 * @return {!WebInspector.SASSProcessor.EditOperation} | 212 * @return {!WebInspector.SASSProcessor.EditOperation} |
213 */ | 213 */ |
214 rebase: function(newMap, nodeMapping) | 214 rebase: function(newMap, nodeMapping) |
215 { | 215 { |
216 return this; | 216 return this; |
217 }, | 217 }, |
218 } | 218 }; |
219 | 219 |
220 /** | 220 /** |
221 * @constructor | 221 * @constructor |
222 * @extends {WebInspector.SASSProcessor.EditOperation} | 222 * @extends {WebInspector.SASSProcessor.EditOperation} |
223 * @param {!WebInspector.ASTSourceMap} map | 223 * @param {!WebInspector.ASTSourceMap} map |
224 * @param {!WebInspector.SASSSupport.TextNode} sassNode | 224 * @param {!WebInspector.SASSSupport.TextNode} sassNode |
225 * @param {string} newText | 225 * @param {string} newText |
226 */ | 226 */ |
227 WebInspector.SASSProcessor.SetTextOperation = function(map, sassNode, newText) | 227 WebInspector.SASSProcessor.SetTextOperation = function(map, sassNode, newText) |
228 { | 228 { |
229 WebInspector.SASSProcessor.EditOperation.call(this, map, sassNode.document.u
rl); | 229 WebInspector.SASSProcessor.EditOperation.call(this, map, sassNode.document.u
rl); |
230 this._sassNode = sassNode; | 230 this._sassNode = sassNode; |
231 this._newText = newText; | 231 this._newText = newText; |
232 } | 232 }; |
233 | 233 |
234 /** | 234 /** |
235 * @param {!WebInspector.SASSSupport.PropertyChange} change | 235 * @param {!WebInspector.SASSSupport.PropertyChange} change |
236 * @param {!WebInspector.ASTSourceMap} map | 236 * @param {!WebInspector.ASTSourceMap} map |
237 * @return {?WebInspector.SASSProcessor.SetTextOperation} | 237 * @return {?WebInspector.SASSProcessor.SetTextOperation} |
238 */ | 238 */ |
239 WebInspector.SASSProcessor.SetTextOperation.fromCSSChange = function(change, map
) | 239 WebInspector.SASSProcessor.SetTextOperation.fromCSSChange = function(change, map
) |
240 { | 240 { |
241 var oldProperty = /** @type {!WebInspector.SASSSupport.Property} */(change.o
ldProperty()); | 241 var oldProperty = /** @type {!WebInspector.SASSSupport.Property} */(change.o
ldProperty()); |
242 var newProperty = /** @type {!WebInspector.SASSSupport.Property} */(change.n
ewProperty()); | 242 var newProperty = /** @type {!WebInspector.SASSSupport.Property} */(change.n
ewProperty()); |
243 console.assert(oldProperty && newProperty, "SetTextOperation must have both
oldProperty and newProperty"); | 243 console.assert(oldProperty && newProperty, "SetTextOperation must have both
oldProperty and newProperty"); |
244 var newValue = null; | 244 var newValue = null; |
245 var sassNode = null; | 245 var sassNode = null; |
246 if (change.type === WebInspector.SASSSupport.PropertyChangeType.NameChanged)
{ | 246 if (change.type === WebInspector.SASSSupport.PropertyChangeType.NameChanged)
{ |
247 newValue = newProperty.name.text; | 247 newValue = newProperty.name.text; |
248 sassNode = map.toSourceNode(oldProperty.name); | 248 sassNode = map.toSourceNode(oldProperty.name); |
249 } else { | 249 } else { |
250 newValue = newProperty.value.text; | 250 newValue = newProperty.value.text; |
251 sassNode = map.toSourceNode(oldProperty.value); | 251 sassNode = map.toSourceNode(oldProperty.value); |
252 } | 252 } |
253 if (!sassNode) | 253 if (!sassNode) |
254 return null; | 254 return null; |
255 return new WebInspector.SASSProcessor.SetTextOperation(map, sassNode, newVal
ue); | 255 return new WebInspector.SASSProcessor.SetTextOperation(map, sassNode, newVal
ue); |
256 } | 256 }; |
257 | 257 |
258 WebInspector.SASSProcessor.SetTextOperation.prototype = { | 258 WebInspector.SASSProcessor.SetTextOperation.prototype = { |
259 /** | 259 /** |
260 * @override | 260 * @override |
261 * @param {!WebInspector.SASSProcessor.EditOperation} other | 261 * @param {!WebInspector.SASSProcessor.EditOperation} other |
262 * @return {boolean} | 262 * @return {boolean} |
263 */ | 263 */ |
264 merge: function(other) | 264 merge: function(other) |
265 { | 265 { |
266 if (!(other instanceof WebInspector.SASSProcessor.SetTextOperation)) | 266 if (!(other instanceof WebInspector.SASSProcessor.SetTextOperation)) |
(...skipping 22 matching lines...) Expand all Loading... |
289 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping | 289 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping |
290 * @return {!WebInspector.SASSProcessor.SetTextOperation} | 290 * @return {!WebInspector.SASSProcessor.SetTextOperation} |
291 */ | 291 */ |
292 rebase: function(newMap, nodeMapping) | 292 rebase: function(newMap, nodeMapping) |
293 { | 293 { |
294 var sassNode = /** @type {?WebInspector.SASSSupport.TextNode} */(nodeMap
ping.get(this._sassNode)) || this._sassNode; | 294 var sassNode = /** @type {?WebInspector.SASSSupport.TextNode} */(nodeMap
ping.get(this._sassNode)) || this._sassNode; |
295 return new WebInspector.SASSProcessor.SetTextOperation(newMap, sassNode,
this._newText); | 295 return new WebInspector.SASSProcessor.SetTextOperation(newMap, sassNode,
this._newText); |
296 }, | 296 }, |
297 | 297 |
298 __proto__: WebInspector.SASSProcessor.EditOperation.prototype | 298 __proto__: WebInspector.SASSProcessor.EditOperation.prototype |
299 } | 299 }; |
300 | 300 |
301 /** | 301 /** |
302 * @constructor | 302 * @constructor |
303 * @extends {WebInspector.SASSProcessor.EditOperation} | 303 * @extends {WebInspector.SASSProcessor.EditOperation} |
304 * @param {!WebInspector.ASTSourceMap} map | 304 * @param {!WebInspector.ASTSourceMap} map |
305 * @param {!WebInspector.SASSSupport.Property} sassProperty | 305 * @param {!WebInspector.SASSSupport.Property} sassProperty |
306 * @param {boolean} newDisabled | 306 * @param {boolean} newDisabled |
307 */ | 307 */ |
308 WebInspector.SASSProcessor.TogglePropertyOperation = function(map, sassProperty,
newDisabled) | 308 WebInspector.SASSProcessor.TogglePropertyOperation = function(map, sassProperty,
newDisabled) |
309 { | 309 { |
310 WebInspector.SASSProcessor.EditOperation.call(this, map, sassProperty.docume
nt.url); | 310 WebInspector.SASSProcessor.EditOperation.call(this, map, sassProperty.docume
nt.url); |
311 this._sassProperty = sassProperty; | 311 this._sassProperty = sassProperty; |
312 this._newDisabled = newDisabled; | 312 this._newDisabled = newDisabled; |
313 } | 313 }; |
314 | 314 |
315 /** | 315 /** |
316 * @param {!WebInspector.SASSSupport.PropertyChange} change | 316 * @param {!WebInspector.SASSSupport.PropertyChange} change |
317 * @param {!WebInspector.ASTSourceMap} map | 317 * @param {!WebInspector.ASTSourceMap} map |
318 * @return {?WebInspector.SASSProcessor.TogglePropertyOperation} | 318 * @return {?WebInspector.SASSProcessor.TogglePropertyOperation} |
319 */ | 319 */ |
320 WebInspector.SASSProcessor.TogglePropertyOperation.fromCSSChange = function(chan
ge, map) | 320 WebInspector.SASSProcessor.TogglePropertyOperation.fromCSSChange = function(chan
ge, map) |
321 { | 321 { |
322 var oldCSSProperty = /** @type {!WebInspector.SASSSupport.Property} */(chang
e.oldProperty()); | 322 var oldCSSProperty = /** @type {!WebInspector.SASSSupport.Property} */(chang
e.oldProperty()); |
323 console.assert(oldCSSProperty, "TogglePropertyOperation must have old CSS pr
operty"); | 323 console.assert(oldCSSProperty, "TogglePropertyOperation must have old CSS pr
operty"); |
324 var sassProperty = WebInspector.SASSProcessor._toSASSProperty(map, oldCSSPro
perty); | 324 var sassProperty = WebInspector.SASSProcessor._toSASSProperty(map, oldCSSPro
perty); |
325 if (!sassProperty) | 325 if (!sassProperty) |
326 return null; | 326 return null; |
327 var newDisabled = change.newProperty().disabled; | 327 var newDisabled = change.newProperty().disabled; |
328 return new WebInspector.SASSProcessor.TogglePropertyOperation(map, sassPrope
rty, newDisabled); | 328 return new WebInspector.SASSProcessor.TogglePropertyOperation(map, sassPrope
rty, newDisabled); |
329 } | 329 }; |
330 | 330 |
331 WebInspector.SASSProcessor.TogglePropertyOperation.prototype = { | 331 WebInspector.SASSProcessor.TogglePropertyOperation.prototype = { |
332 /** | 332 /** |
333 * @override | 333 * @override |
334 * @param {!WebInspector.SASSProcessor.EditOperation} other | 334 * @param {!WebInspector.SASSProcessor.EditOperation} other |
335 * @return {boolean} | 335 * @return {boolean} |
336 */ | 336 */ |
337 merge: function(other) | 337 merge: function(other) |
338 { | 338 { |
339 if (!(other instanceof WebInspector.SASSProcessor.TogglePropertyOperatio
n)) | 339 if (!(other instanceof WebInspector.SASSProcessor.TogglePropertyOperatio
n)) |
(...skipping 22 matching lines...) Expand all Loading... |
362 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping | 362 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping |
363 * @return {!WebInspector.SASSProcessor.TogglePropertyOperation} | 363 * @return {!WebInspector.SASSProcessor.TogglePropertyOperation} |
364 */ | 364 */ |
365 rebase: function(newMap, nodeMapping) | 365 rebase: function(newMap, nodeMapping) |
366 { | 366 { |
367 var sassProperty = /** @type {?WebInspector.SASSSupport.Property} */(nod
eMapping.get(this._sassProperty)) || this._sassProperty; | 367 var sassProperty = /** @type {?WebInspector.SASSSupport.Property} */(nod
eMapping.get(this._sassProperty)) || this._sassProperty; |
368 return new WebInspector.SASSProcessor.TogglePropertyOperation(newMap, sa
ssProperty, this._newDisabled); | 368 return new WebInspector.SASSProcessor.TogglePropertyOperation(newMap, sa
ssProperty, this._newDisabled); |
369 }, | 369 }, |
370 | 370 |
371 __proto__: WebInspector.SASSProcessor.EditOperation.prototype | 371 __proto__: WebInspector.SASSProcessor.EditOperation.prototype |
372 } | 372 }; |
373 | 373 |
374 /** | 374 /** |
375 * @constructor | 375 * @constructor |
376 * @extends {WebInspector.SASSProcessor.EditOperation} | 376 * @extends {WebInspector.SASSProcessor.EditOperation} |
377 * @param {!WebInspector.ASTSourceMap} map | 377 * @param {!WebInspector.ASTSourceMap} map |
378 * @param {!WebInspector.SASSSupport.Property} sassProperty | 378 * @param {!WebInspector.SASSSupport.Property} sassProperty |
379 */ | 379 */ |
380 WebInspector.SASSProcessor.RemovePropertyOperation = function(map, sassProperty) | 380 WebInspector.SASSProcessor.RemovePropertyOperation = function(map, sassProperty) |
381 { | 381 { |
382 WebInspector.SASSProcessor.EditOperation.call(this, map, sassProperty.docume
nt.url); | 382 WebInspector.SASSProcessor.EditOperation.call(this, map, sassProperty.docume
nt.url); |
383 this._sassProperty = sassProperty; | 383 this._sassProperty = sassProperty; |
384 } | 384 }; |
385 | 385 |
386 /** | 386 /** |
387 * @param {!WebInspector.SASSSupport.PropertyChange} change | 387 * @param {!WebInspector.SASSSupport.PropertyChange} change |
388 * @param {!WebInspector.ASTSourceMap} map | 388 * @param {!WebInspector.ASTSourceMap} map |
389 * @return {?WebInspector.SASSProcessor.RemovePropertyOperation} | 389 * @return {?WebInspector.SASSProcessor.RemovePropertyOperation} |
390 */ | 390 */ |
391 WebInspector.SASSProcessor.RemovePropertyOperation.fromCSSChange = function(chan
ge, map) | 391 WebInspector.SASSProcessor.RemovePropertyOperation.fromCSSChange = function(chan
ge, map) |
392 { | 392 { |
393 var removedProperty = /** @type {!WebInspector.SASSSupport.Property} */(chan
ge.oldProperty()); | 393 var removedProperty = /** @type {!WebInspector.SASSSupport.Property} */(chan
ge.oldProperty()); |
394 console.assert(removedProperty, "RemovePropertyOperation must have removed C
SS property"); | 394 console.assert(removedProperty, "RemovePropertyOperation must have removed C
SS property"); |
395 var sassProperty = WebInspector.SASSProcessor._toSASSProperty(map, removedPr
operty); | 395 var sassProperty = WebInspector.SASSProcessor._toSASSProperty(map, removedPr
operty); |
396 if (!sassProperty) | 396 if (!sassProperty) |
397 return null; | 397 return null; |
398 return new WebInspector.SASSProcessor.RemovePropertyOperation(map, sassPrope
rty); | 398 return new WebInspector.SASSProcessor.RemovePropertyOperation(map, sassPrope
rty); |
399 } | 399 }; |
400 | 400 |
401 WebInspector.SASSProcessor.RemovePropertyOperation.prototype = { | 401 WebInspector.SASSProcessor.RemovePropertyOperation.prototype = { |
402 /** | 402 /** |
403 * @override | 403 * @override |
404 * @param {!WebInspector.SASSProcessor.EditOperation} other | 404 * @param {!WebInspector.SASSProcessor.EditOperation} other |
405 * @return {boolean} | 405 * @return {boolean} |
406 */ | 406 */ |
407 merge: function(other) | 407 merge: function(other) |
408 { | 408 { |
409 if (!(other instanceof WebInspector.SASSProcessor.RemovePropertyOperatio
n)) | 409 if (!(other instanceof WebInspector.SASSProcessor.RemovePropertyOperatio
n)) |
(...skipping 25 matching lines...) Expand all Loading... |
435 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping | 435 * @param {!Map<!WebInspector.SASSSupport.Node, !WebInspector.SASSSupport.No
de>} nodeMapping |
436 * @return {!WebInspector.SASSProcessor.RemovePropertyOperation} | 436 * @return {!WebInspector.SASSProcessor.RemovePropertyOperation} |
437 */ | 437 */ |
438 rebase: function(newMap, nodeMapping) | 438 rebase: function(newMap, nodeMapping) |
439 { | 439 { |
440 var sassProperty = /** @type {?WebInspector.SASSSupport.Property} */(nod
eMapping.get(this._sassProperty)) || this._sassProperty; | 440 var sassProperty = /** @type {?WebInspector.SASSSupport.Property} */(nod
eMapping.get(this._sassProperty)) || this._sassProperty; |
441 return new WebInspector.SASSProcessor.RemovePropertyOperation(newMap, sa
ssProperty); | 441 return new WebInspector.SASSProcessor.RemovePropertyOperation(newMap, sa
ssProperty); |
442 }, | 442 }, |
443 | 443 |
444 __proto__: WebInspector.SASSProcessor.EditOperation.prototype | 444 __proto__: WebInspector.SASSProcessor.EditOperation.prototype |
445 } | 445 }; |
446 | 446 |
447 /** | 447 /** |
448 * @constructor | 448 * @constructor |
449 * @extends {WebInspector.SASSProcessor.EditOperation} | 449 * @extends {WebInspector.SASSProcessor.EditOperation} |
450 * @param {!WebInspector.ASTSourceMap} map | 450 * @param {!WebInspector.ASTSourceMap} map |
451 * @param {!WebInspector.SASSSupport.Rule} sassRule | 451 * @param {!WebInspector.SASSSupport.Rule} sassRule |
452 * @param {?WebInspector.SASSSupport.Property} afterSASSProperty | 452 * @param {?WebInspector.SASSSupport.Property} afterSASSProperty |
453 * @param {!Array<string>} propertyNames | 453 * @param {!Array<string>} propertyNames |
454 * @param {!Array<string>} propertyValues | 454 * @param {!Array<string>} propertyValues |
455 * @param {!Array<boolean>} disabledStates | 455 * @param {!Array<boolean>} disabledStates |
456 */ | 456 */ |
457 WebInspector.SASSProcessor.InsertPropertiesOperation = function(map, sassRule, a
fterSASSProperty, propertyNames, propertyValues, disabledStates) | 457 WebInspector.SASSProcessor.InsertPropertiesOperation = function(map, sassRule, a
fterSASSProperty, propertyNames, propertyValues, disabledStates) |
458 { | 458 { |
459 console.assert(propertyNames.length === propertyValues.length && propertyVal
ues.length === disabledStates.length); | 459 console.assert(propertyNames.length === propertyValues.length && propertyVal
ues.length === disabledStates.length); |
460 WebInspector.SASSProcessor.EditOperation.call(this, map, sassRule.document.u
rl); | 460 WebInspector.SASSProcessor.EditOperation.call(this, map, sassRule.document.u
rl); |
461 this._sassRule = sassRule; | 461 this._sassRule = sassRule; |
462 this._afterSASSProperty = afterSASSProperty | 462 this._afterSASSProperty = afterSASSProperty; |
463 this._nameTexts = propertyNames; | 463 this._nameTexts = propertyNames; |
464 this._valueTexts = propertyValues; | 464 this._valueTexts = propertyValues; |
465 this._disabledStates = disabledStates; | 465 this._disabledStates = disabledStates; |
466 } | 466 }; |
467 | 467 |
468 /** | 468 /** |
469 * @param {!WebInspector.SASSSupport.PropertyChange} change | 469 * @param {!WebInspector.SASSSupport.PropertyChange} change |
470 * @param {!WebInspector.ASTSourceMap} map | 470 * @param {!WebInspector.ASTSourceMap} map |
471 * @return {?WebInspector.SASSProcessor.InsertPropertiesOperation} | 471 * @return {?WebInspector.SASSProcessor.InsertPropertiesOperation} |
472 */ | 472 */ |
473 WebInspector.SASSProcessor.InsertPropertiesOperation.fromCSSChange = function(ch
ange, map) | 473 WebInspector.SASSProcessor.InsertPropertiesOperation.fromCSSChange = function(ch
ange, map) |
474 { | 474 { |
475 var sassRule = null; | 475 var sassRule = null; |
476 var afterSASSProperty = null; | 476 var afterSASSProperty = null; |
477 if (change.oldPropertyIndex) { | 477 if (change.oldPropertyIndex) { |
478 var cssAnchor = change.oldRule.properties[change.oldPropertyIndex - 1].n
ame; | 478 var cssAnchor = change.oldRule.properties[change.oldPropertyIndex - 1].n
ame; |
479 var sassAnchor = map.toSourceNode(cssAnchor); | 479 var sassAnchor = map.toSourceNode(cssAnchor); |
480 afterSASSProperty = sassAnchor ? sassAnchor.parent : null; | 480 afterSASSProperty = sassAnchor ? sassAnchor.parent : null; |
481 sassRule = afterSASSProperty ? afterSASSProperty.parent : null; | 481 sassRule = afterSASSProperty ? afterSASSProperty.parent : null; |
482 } else { | 482 } else { |
483 var cssAnchor = change.oldRule.blockStart; | 483 var cssAnchor = change.oldRule.blockStart; |
484 var sassAnchor = map.toSourceNode(cssAnchor); | 484 var sassAnchor = map.toSourceNode(cssAnchor); |
485 sassRule = sassAnchor ? sassAnchor.parent : null; | 485 sassRule = sassAnchor ? sassAnchor.parent : null; |
486 } | 486 } |
487 if (!sassRule) | 487 if (!sassRule) |
488 return null; | 488 return null; |
489 var insertedProperty = /** @type {!WebInspector.SASSSupport.Property} */(cha
nge.newProperty()); | 489 var insertedProperty = /** @type {!WebInspector.SASSSupport.Property} */(cha
nge.newProperty()); |
490 console.assert(insertedProperty, "InsertPropertiesOperation must have insert
ed CSS property"); | 490 console.assert(insertedProperty, "InsertPropertiesOperation must have insert
ed CSS property"); |
491 var names = [insertedProperty.name.text]; | 491 var names = [insertedProperty.name.text]; |
492 var values = [insertedProperty.value.text]; | 492 var values = [insertedProperty.value.text]; |
493 var disabledStates = [insertedProperty.disabled]; | 493 var disabledStates = [insertedProperty.disabled]; |
494 return new WebInspector.SASSProcessor.InsertPropertiesOperation(map, sassRul
e, afterSASSProperty, names, values, disabledStates); | 494 return new WebInspector.SASSProcessor.InsertPropertiesOperation(map, sassRul
e, afterSASSProperty, names, values, disabledStates); |
495 } | 495 }; |
496 | 496 |
497 WebInspector.SASSProcessor.InsertPropertiesOperation.prototype = { | 497 WebInspector.SASSProcessor.InsertPropertiesOperation.prototype = { |
498 /** | 498 /** |
499 * @override | 499 * @override |
500 * @param {!WebInspector.SASSProcessor.EditOperation} other | 500 * @param {!WebInspector.SASSProcessor.EditOperation} other |
501 * @return {boolean} | 501 * @return {boolean} |
502 */ | 502 */ |
503 merge: function(other) | 503 merge: function(other) |
504 { | 504 { |
505 if (!(other instanceof WebInspector.SASSProcessor.InsertPropertiesOperat
ion)) | 505 if (!(other instanceof WebInspector.SASSProcessor.InsertPropertiesOperat
ion)) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 * @return {!WebInspector.SASSProcessor.InsertPropertiesOperation} | 552 * @return {!WebInspector.SASSProcessor.InsertPropertiesOperation} |
553 */ | 553 */ |
554 rebase: function(newMap, nodeMapping) | 554 rebase: function(newMap, nodeMapping) |
555 { | 555 { |
556 var sassRule = /** @type {?WebInspector.SASSSupport.Rule} */(nodeMapping
.get(this._sassRule)) || this._sassRule; | 556 var sassRule = /** @type {?WebInspector.SASSSupport.Rule} */(nodeMapping
.get(this._sassRule)) || this._sassRule; |
557 var afterSASSProperty = this._afterSASSProperty ? /** @type {?WebInspect
or.SASSSupport.Property} */(nodeMapping.get(this._afterSASSProperty)) || this._a
fterSASSProperty : null; | 557 var afterSASSProperty = this._afterSASSProperty ? /** @type {?WebInspect
or.SASSSupport.Property} */(nodeMapping.get(this._afterSASSProperty)) || this._a
fterSASSProperty : null; |
558 return new WebInspector.SASSProcessor.InsertPropertiesOperation(newMap,
sassRule, afterSASSProperty, this._nameTexts, this._valueTexts, this._disabledSt
ates); | 558 return new WebInspector.SASSProcessor.InsertPropertiesOperation(newMap,
sassRule, afterSASSProperty, this._nameTexts, this._valueTexts, this._disabledSt
ates); |
559 }, | 559 }, |
560 | 560 |
561 __proto__: WebInspector.SASSProcessor.EditOperation.prototype | 561 __proto__: WebInspector.SASSProcessor.EditOperation.prototype |
562 } | 562 }; |
OLD | NEW |