| 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 Sass.SASSSupport = {}; | 4 Sass.SASSSupport = {}; |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * @param {string} url | 7 * @param {string} url |
| 8 * @param {string} content | 8 * @param {string} content |
| 9 * @return {!Promise<!Sass.SASSSupport.AST>} | 9 * @return {!Promise<!Sass.SASSSupport.AST>} |
| 10 */ | 10 */ |
| 11 Sass.SASSSupport.parseSCSS = function(url, content) { | 11 Sass.SASSSupport.parseSCSS = function(url, content) { |
| 12 var text = new Common.Text(content); | 12 var text = new TextUtils.Text(content); |
| 13 var document = new Sass.SASSSupport.ASTDocument(url, text); | 13 var document = new Sass.SASSSupport.ASTDocument(url, text); |
| 14 | 14 |
| 15 return Common.formatterWorkerPool.parseSCSS(content).then(onParsed); | 15 return Common.formatterWorkerPool.parseSCSS(content).then(onParsed); |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * @param {!Array<!Common.FormatterWorkerPool.SCSSRule>} rulePayloads | 18 * @param {!Array<!Common.FormatterWorkerPool.SCSSRule>} rulePayloads |
| 19 * @return {!Sass.SASSSupport.AST} | 19 * @return {!Sass.SASSSupport.AST} |
| 20 */ | 20 */ |
| 21 function onParsed(rulePayloads) { | 21 function onParsed(rulePayloads) { |
| 22 var rules = []; | 22 var rules = []; |
| 23 for (var i = 0; i < rulePayloads.length; ++i) { | 23 for (var i = 0; i < rulePayloads.length; ++i) { |
| 24 var rulePayload = rulePayloads[i]; | 24 var rulePayload = rulePayloads[i]; |
| 25 var selectors = rulePayload.selectors.map(createTextNode); | 25 var selectors = rulePayload.selectors.map(createTextNode); |
| 26 var properties = rulePayload.properties.map(createProperty); | 26 var properties = rulePayload.properties.map(createProperty); |
| 27 var range = Common.TextRange.fromObject(rulePayload.styleRange); | 27 var range = TextUtils.TextRange.fromObject(rulePayload.styleRange); |
| 28 var rule = new Sass.SASSSupport.Rule(document, selectors, range, propertie
s); | 28 var rule = new Sass.SASSSupport.Rule(document, selectors, range, propertie
s); |
| 29 rules.push(rule); | 29 rules.push(rule); |
| 30 } | 30 } |
| 31 return new Sass.SASSSupport.AST(document, rules); | 31 return new Sass.SASSSupport.AST(document, rules); |
| 32 } | 32 } |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * @param {!Object} payload | 35 * @param {!Object} payload |
| 36 */ | 36 */ |
| 37 function createTextNode(payload) { | 37 function createTextNode(payload) { |
| 38 var range = Common.TextRange.fromObject(payload); | 38 var range = TextUtils.TextRange.fromObject(payload); |
| 39 return new Sass.SASSSupport.TextNode(document, text.extract(range), range); | 39 return new Sass.SASSSupport.TextNode(document, text.extract(range), range); |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @param {!Object} payload | 43 * @param {!Object} payload |
| 44 */ | 44 */ |
| 45 function createProperty(payload) { | 45 function createProperty(payload) { |
| 46 var name = createTextNode(payload.name); | 46 var name = createTextNode(payload.name); |
| 47 var value = createTextNode(payload.value); | 47 var value = createTextNode(payload.value); |
| 48 return new Sass.SASSSupport.Property( | 48 return new Sass.SASSSupport.Property( |
| 49 document, name, value, Common.TextRange.fromObject(payload.range), paylo
ad.disabled); | 49 document, name, value, TextUtils.TextRange.fromObject(payload.range), pa
yload.disabled); |
| 50 } | 50 } |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * @unrestricted | 54 * @unrestricted |
| 55 */ | 55 */ |
| 56 Sass.SASSSupport.ASTDocument = class { | 56 Sass.SASSSupport.ASTDocument = class { |
| 57 /** | 57 /** |
| 58 * @param {string} url | 58 * @param {string} url |
| 59 * @param {!Common.Text} text | 59 * @param {!TextUtils.Text} text |
| 60 */ | 60 */ |
| 61 constructor(url, text) { | 61 constructor(url, text) { |
| 62 this.url = url; | 62 this.url = url; |
| 63 this.text = text; | 63 this.text = text; |
| 64 this.edits = []; | 64 this.edits = []; |
| 65 } | 65 } |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * @return {!Sass.SASSSupport.ASTDocument} | 68 * @return {!Sass.SASSSupport.ASTDocument} |
| 69 */ | 69 */ |
| 70 clone() { | 70 clone() { |
| 71 return new Sass.SASSSupport.ASTDocument(this.url, this.text); | 71 return new Sass.SASSSupport.ASTDocument(this.url, this.text); |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * @return {boolean} | 75 * @return {boolean} |
| 76 */ | 76 */ |
| 77 hasChanged() { | 77 hasChanged() { |
| 78 return !!this.edits.length; | 78 return !!this.edits.length; |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * @return {!Common.Text} | 82 * @return {!TextUtils.Text} |
| 83 */ | 83 */ |
| 84 newText() { | 84 newText() { |
| 85 this.edits.stableSort(sequentialOrder); | 85 this.edits.stableSort(sequentialOrder); |
| 86 var text = this.text; | 86 var text = this.text; |
| 87 for (var i = this.edits.length - 1; i >= 0; --i) { | 87 for (var i = this.edits.length - 1; i >= 0; --i) { |
| 88 var range = this.edits[i].oldRange; | 88 var range = this.edits[i].oldRange; |
| 89 var newText = this.edits[i].newText; | 89 var newText = this.edits[i].newText; |
| 90 text = new Common.Text(text.replaceRange(range, newText)); | 90 text = new TextUtils.Text(text.replaceRange(range, newText)); |
| 91 } | 91 } |
| 92 return text; | 92 return text; |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * @param {!Common.SourceEdit} edit1 | 95 * @param {!TextUtils.SourceEdit} edit1 |
| 96 * @param {!Common.SourceEdit} edit2 | 96 * @param {!TextUtils.SourceEdit} edit2 |
| 97 * @return {number} | 97 * @return {number} |
| 98 */ | 98 */ |
| 99 function sequentialOrder(edit1, edit2) { | 99 function sequentialOrder(edit1, edit2) { |
| 100 var range1 = edit1.oldRange.collapseToStart(); | 100 var range1 = edit1.oldRange.collapseToStart(); |
| 101 var range2 = edit2.oldRange.collapseToStart(); | 101 var range2 = edit2.oldRange.collapseToStart(); |
| 102 if (range1.equal(range2)) | 102 if (range1.equal(range2)) |
| 103 return 0; | 103 return 0; |
| 104 return range1.follows(range2) ? 1 : -1; | 104 return range1.follows(range2) ? 1 : -1; |
| 105 } | 105 } |
| 106 } | 106 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 118 } | 118 } |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * @unrestricted | 122 * @unrestricted |
| 123 */ | 123 */ |
| 124 Sass.SASSSupport.TextNode = class extends Sass.SASSSupport.Node { | 124 Sass.SASSSupport.TextNode = class extends Sass.SASSSupport.Node { |
| 125 /** | 125 /** |
| 126 * @param {!Sass.SASSSupport.ASTDocument} document | 126 * @param {!Sass.SASSSupport.ASTDocument} document |
| 127 * @param {string} text | 127 * @param {string} text |
| 128 * @param {!Common.TextRange} range | 128 * @param {!TextUtils.TextRange} range |
| 129 */ | 129 */ |
| 130 constructor(document, text, range) { | 130 constructor(document, text, range) { |
| 131 super(document); | 131 super(document); |
| 132 this.text = text; | 132 this.text = text; |
| 133 this.range = range; | 133 this.range = range; |
| 134 } | 134 } |
| 135 | 135 |
| 136 /** | 136 /** |
| 137 * @param {string} newText | 137 * @param {string} newText |
| 138 */ | 138 */ |
| 139 setText(newText) { | 139 setText(newText) { |
| 140 if (this.text === newText) | 140 if (this.text === newText) |
| 141 return; | 141 return; |
| 142 this.text = newText; | 142 this.text = newText; |
| 143 this.document.edits.push(new Common.SourceEdit(this.document.url, this.range
, newText)); | 143 this.document.edits.push(new TextUtils.SourceEdit(this.document.url, this.ra
nge, newText)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 /** | 146 /** |
| 147 * @param {!Sass.SASSSupport.ASTDocument} document | 147 * @param {!Sass.SASSSupport.ASTDocument} document |
| 148 * @return {!Sass.SASSSupport.TextNode} | 148 * @return {!Sass.SASSSupport.TextNode} |
| 149 */ | 149 */ |
| 150 clone(document) { | 150 clone(document) { |
| 151 return new Sass.SASSSupport.TextNode(document, this.text, this.range.clone()
); | 151 return new Sass.SASSSupport.TextNode(document, this.text, this.range.clone()
); |
| 152 } | 152 } |
| 153 | 153 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * @unrestricted | 169 * @unrestricted |
| 170 */ | 170 */ |
| 171 Sass.SASSSupport.Property = class extends Sass.SASSSupport.Node { | 171 Sass.SASSSupport.Property = class extends Sass.SASSSupport.Node { |
| 172 /** | 172 /** |
| 173 * @param {!Sass.SASSSupport.ASTDocument} document | 173 * @param {!Sass.SASSSupport.ASTDocument} document |
| 174 * @param {!Sass.SASSSupport.TextNode} name | 174 * @param {!Sass.SASSSupport.TextNode} name |
| 175 * @param {!Sass.SASSSupport.TextNode} value | 175 * @param {!Sass.SASSSupport.TextNode} value |
| 176 * @param {!Common.TextRange} range | 176 * @param {!TextUtils.TextRange} range |
| 177 * @param {boolean} disabled | 177 * @param {boolean} disabled |
| 178 */ | 178 */ |
| 179 constructor(document, name, value, range, disabled) { | 179 constructor(document, name, value, range, disabled) { |
| 180 super(document); | 180 super(document); |
| 181 this.name = name; | 181 this.name = name; |
| 182 this.value = value; | 182 this.value = value; |
| 183 this.range = range; | 183 this.range = range; |
| 184 this.name.parent = this; | 184 this.name.parent = this; |
| 185 this.value.parent = this; | 185 this.value.parent = this; |
| 186 this.disabled = disabled; | 186 this.disabled = disabled; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 | 219 |
| 220 /** | 220 /** |
| 221 * @param {boolean} disabled | 221 * @param {boolean} disabled |
| 222 */ | 222 */ |
| 223 setDisabled(disabled) { | 223 setDisabled(disabled) { |
| 224 if (this.disabled === disabled) | 224 if (this.disabled === disabled) |
| 225 return; | 225 return; |
| 226 this.disabled = disabled; | 226 this.disabled = disabled; |
| 227 if (disabled) { | 227 if (disabled) { |
| 228 var oldRange1 = Common.TextRange.createFromLocation(this.range.startLine,
this.range.startColumn); | 228 var oldRange1 = TextUtils.TextRange.createFromLocation(this.range.startLin
e, this.range.startColumn); |
| 229 var edit1 = new Common.SourceEdit(this.document.url, oldRange1, '/* '); | 229 var edit1 = new TextUtils.SourceEdit(this.document.url, oldRange1, '/* '); |
| 230 var oldRange2 = Common.TextRange.createFromLocation(this.range.endLine, th
is.range.endColumn); | 230 var oldRange2 = TextUtils.TextRange.createFromLocation(this.range.endLine,
this.range.endColumn); |
| 231 var edit2 = new Common.SourceEdit(this.document.url, oldRange2, ' */'); | 231 var edit2 = new TextUtils.SourceEdit(this.document.url, oldRange2, ' */'); |
| 232 this.document.edits.push(edit1, edit2); | 232 this.document.edits.push(edit1, edit2); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 var oldRange1 = new Common.TextRange( | 235 var oldRange1 = new TextUtils.TextRange( |
| 236 this.range.startLine, this.range.startColumn, this.range.startLine, this
.name.range.startColumn); | 236 this.range.startLine, this.range.startColumn, this.range.startLine, this
.name.range.startColumn); |
| 237 var edit1 = new Common.SourceEdit(this.document.url, oldRange1, ''); | 237 var edit1 = new TextUtils.SourceEdit(this.document.url, oldRange1, ''); |
| 238 | 238 |
| 239 var propertyText = this.document.text.extract(this.range); | 239 var propertyText = this.document.text.extract(this.range); |
| 240 var endsWithSemicolon = propertyText.slice(0, -2).trim().endsWith(';'); | 240 var endsWithSemicolon = propertyText.slice(0, -2).trim().endsWith(';'); |
| 241 var oldRange2 = new Common.TextRange( | 241 var oldRange2 = new TextUtils.TextRange( |
| 242 this.range.endLine, this.value.range.endColumn + (endsWithSemicolon ? 1
: 0), this.range.endLine, | 242 this.range.endLine, this.value.range.endColumn + (endsWithSemicolon ? 1
: 0), this.range.endLine, |
| 243 this.range.endColumn); | 243 this.range.endColumn); |
| 244 var edit2 = new Common.SourceEdit(this.document.url, oldRange2, ''); | 244 var edit2 = new TextUtils.SourceEdit(this.document.url, oldRange2, ''); |
| 245 this.document.edits.push(edit1, edit2); | 245 this.document.edits.push(edit1, edit2); |
| 246 } | 246 } |
| 247 | 247 |
| 248 remove() { | 248 remove() { |
| 249 console.assert(this.parent); | 249 console.assert(this.parent); |
| 250 var rule = this.parent; | 250 var rule = this.parent; |
| 251 var index = rule.properties.indexOf(this); | 251 var index = rule.properties.indexOf(this); |
| 252 rule.properties.splice(index, 1); | 252 rule.properties.splice(index, 1); |
| 253 this.parent = null; | 253 this.parent = null; |
| 254 | 254 |
| 255 var lineRange = new Common.TextRange(this.range.startLine, 0, this.range.end
Line + 1, 0); | 255 var lineRange = new TextUtils.TextRange(this.range.startLine, 0, this.range.
endLine + 1, 0); |
| 256 var oldRange; | 256 var oldRange; |
| 257 if (this.document.text.extract(lineRange).trim() === this.document.text.extr
act(this.range).trim()) | 257 if (this.document.text.extract(lineRange).trim() === this.document.text.extr
act(this.range).trim()) |
| 258 oldRange = lineRange; | 258 oldRange = lineRange; |
| 259 else | 259 else |
| 260 oldRange = this.range; | 260 oldRange = this.range; |
| 261 this.document.edits.push(new Common.SourceEdit(this.document.url, oldRange,
'')); | 261 this.document.edits.push(new TextUtils.SourceEdit(this.document.url, oldRang
e, '')); |
| 262 } | 262 } |
| 263 }; | 263 }; |
| 264 | 264 |
| 265 /** | 265 /** |
| 266 * @unrestricted | 266 * @unrestricted |
| 267 */ | 267 */ |
| 268 Sass.SASSSupport.Rule = class extends Sass.SASSSupport.Node { | 268 Sass.SASSSupport.Rule = class extends Sass.SASSSupport.Node { |
| 269 /** | 269 /** |
| 270 * @param {!Sass.SASSSupport.ASTDocument} document | 270 * @param {!Sass.SASSSupport.ASTDocument} document |
| 271 * @param {!Array<!Sass.SASSSupport.TextNode>} selectors | 271 * @param {!Array<!Sass.SASSSupport.TextNode>} selectors |
| 272 * @param {!Common.TextRange} styleRange | 272 * @param {!TextUtils.TextRange} styleRange |
| 273 * @param {!Array<!Sass.SASSSupport.Property>} properties | 273 * @param {!Array<!Sass.SASSSupport.Property>} properties |
| 274 */ | 274 */ |
| 275 constructor(document, selectors, styleRange, properties) { | 275 constructor(document, selectors, styleRange, properties) { |
| 276 super(document); | 276 super(document); |
| 277 this.selectors = selectors; | 277 this.selectors = selectors; |
| 278 this.properties = properties; | 278 this.properties = properties; |
| 279 this.styleRange = styleRange; | 279 this.styleRange = styleRange; |
| 280 | 280 |
| 281 var blockStartRange = styleRange.collapseToStart(); | 281 var blockStartRange = styleRange.collapseToStart(); |
| 282 blockStartRange.startColumn -= 1; | 282 blockStartRange.startColumn -= 1; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 for (var i = 0; result && i < this.properties.length; ++i) | 335 for (var i = 0; result && i < this.properties.length; ++i) |
| 336 result = result && this.properties[i].match(other.properties[i], outNodeMa
pping); | 336 result = result && this.properties[i].match(other.properties[i], outNodeMa
pping); |
| 337 return result; | 337 return result; |
| 338 } | 338 } |
| 339 | 339 |
| 340 _addTrailingSemicolon() { | 340 _addTrailingSemicolon() { |
| 341 if (this._hasTrailingSemicolon || !this.properties) | 341 if (this._hasTrailingSemicolon || !this.properties) |
| 342 return; | 342 return; |
| 343 this._hasTrailingSemicolon = true; | 343 this._hasTrailingSemicolon = true; |
| 344 this.document.edits.push( | 344 this.document.edits.push( |
| 345 new Common.SourceEdit(this.document.url, this.properties.peekLast().rang
e.collapseToEnd(), ';')); | 345 new TextUtils.SourceEdit(this.document.url, this.properties.peekLast().r
ange.collapseToEnd(), ';')); |
| 346 } | 346 } |
| 347 | 347 |
| 348 /** | 348 /** |
| 349 * @param {?Sass.SASSSupport.Property} anchorProperty | 349 * @param {?Sass.SASSSupport.Property} anchorProperty |
| 350 * @param {!Array<string>} nameTexts | 350 * @param {!Array<string>} nameTexts |
| 351 * @param {!Array<string>} valueTexts | 351 * @param {!Array<string>} valueTexts |
| 352 * @param {!Array<boolean>} disabledStates | 352 * @param {!Array<boolean>} disabledStates |
| 353 * @return {!Array<!Sass.SASSSupport.Property>} | 353 * @return {!Array<!Sass.SASSSupport.Property>} |
| 354 */ | 354 */ |
| 355 insertProperties(anchorProperty, nameTexts, valueTexts, disabledStates) { | 355 insertProperties(anchorProperty, nameTexts, valueTexts, disabledStates) { |
| 356 console.assert( | 356 console.assert( |
| 357 nameTexts.length === valueTexts.length && valueTexts.length === disabled
States.length, | 357 nameTexts.length === valueTexts.length && valueTexts.length === disabled
States.length, |
| 358 'Input array should be of the same size.'); | 358 'Input array should be of the same size.'); |
| 359 | 359 |
| 360 this._addTrailingSemicolon(); | 360 this._addTrailingSemicolon(); |
| 361 var newProperties = []; | 361 var newProperties = []; |
| 362 var index = anchorProperty ? this.properties.indexOf(anchorProperty) : -1; | 362 var index = anchorProperty ? this.properties.indexOf(anchorProperty) : -1; |
| 363 for (var i = 0; i < nameTexts.length; ++i) { | 363 for (var i = 0; i < nameTexts.length; ++i) { |
| 364 var nameText = nameTexts[i]; | 364 var nameText = nameTexts[i]; |
| 365 var valueText = valueTexts[i]; | 365 var valueText = valueTexts[i]; |
| 366 var disabled = disabledStates[i]; | 366 var disabled = disabledStates[i]; |
| 367 this.document.edits.push(this._insertPropertyEdit(anchorProperty, nameText
, valueText, disabled)); | 367 this.document.edits.push(this._insertPropertyEdit(anchorProperty, nameText
, valueText, disabled)); |
| 368 | 368 |
| 369 var name = new Sass.SASSSupport.TextNode(this.document, nameText, Common.T
extRange.createFromLocation(0, 0)); | 369 var name = new Sass.SASSSupport.TextNode(this.document, nameText, TextUtil
s.TextRange.createFromLocation(0, 0)); |
| 370 var value = new Sass.SASSSupport.TextNode(this.document, valueText, Common
.TextRange.createFromLocation(0, 0)); | 370 var value = new Sass.SASSSupport.TextNode(this.document, valueText, TextUt
ils.TextRange.createFromLocation(0, 0)); |
| 371 var newProperty = new Sass.SASSSupport.Property( | 371 var newProperty = new Sass.SASSSupport.Property( |
| 372 this.document, name, value, Common.TextRange.createFromLocation(0, 0),
disabled); | 372 this.document, name, value, TextUtils.TextRange.createFromLocation(0,
0), disabled); |
| 373 | 373 |
| 374 this.properties.splice(index + i + 1, 0, newProperty); | 374 this.properties.splice(index + i + 1, 0, newProperty); |
| 375 newProperty.parent = this; | 375 newProperty.parent = this; |
| 376 newProperties.push(newProperty); | 376 newProperties.push(newProperty); |
| 377 } | 377 } |
| 378 return newProperties; | 378 return newProperties; |
| 379 } | 379 } |
| 380 | 380 |
| 381 /** | 381 /** |
| 382 * @param {?Sass.SASSSupport.Property} anchorProperty | 382 * @param {?Sass.SASSSupport.Property} anchorProperty |
| 383 * @param {string} nameText | 383 * @param {string} nameText |
| 384 * @param {string} valueText | 384 * @param {string} valueText |
| 385 * @param {boolean} disabled | 385 * @param {boolean} disabled |
| 386 * @return {!Common.SourceEdit} | 386 * @return {!TextUtils.SourceEdit} |
| 387 */ | 387 */ |
| 388 _insertPropertyEdit(anchorProperty, nameText, valueText, disabled) { | 388 _insertPropertyEdit(anchorProperty, nameText, valueText, disabled) { |
| 389 var anchorRange = anchorProperty ? anchorProperty.range : this.blockStart.ra
nge; | 389 var anchorRange = anchorProperty ? anchorProperty.range : this.blockStart.ra
nge; |
| 390 var indent = this._computePropertyIndent(); | 390 var indent = this._computePropertyIndent(); |
| 391 var leftComment = disabled ? '/* ' : ''; | 391 var leftComment = disabled ? '/* ' : ''; |
| 392 var rightComment = disabled ? ' */' : ''; | 392 var rightComment = disabled ? ' */' : ''; |
| 393 var newText = String.sprintf('\n%s%s%s: %s;%s', indent, leftComment, nameTex
t, valueText, rightComment); | 393 var newText = String.sprintf('\n%s%s%s: %s;%s', indent, leftComment, nameTex
t, valueText, rightComment); |
| 394 return new Common.SourceEdit(this.document.url, anchorRange.collapseToEnd(),
newText); | 394 return new TextUtils.SourceEdit(this.document.url, anchorRange.collapseToEnd
(), newText); |
| 395 } | 395 } |
| 396 | 396 |
| 397 /** | 397 /** |
| 398 * @return {string} | 398 * @return {string} |
| 399 */ | 399 */ |
| 400 _computePropertyIndent() { | 400 _computePropertyIndent() { |
| 401 var indentProperty = this.properties.find(property => !property.range.isEmpt
y()); | 401 var indentProperty = this.properties.find(property => !property.range.isEmpt
y()); |
| 402 var result = ''; | 402 var result = ''; |
| 403 if (indentProperty) { | 403 if (indentProperty) { |
| 404 result = this.document.text.extract(new Common.TextRange( | 404 result = this.document.text.extract(new TextUtils.TextRange( |
| 405 indentProperty.range.startLine, 0, indentProperty.range.startLine, ind
entProperty.range.startColumn)); | 405 indentProperty.range.startLine, 0, indentProperty.range.startLine, ind
entProperty.range.startColumn)); |
| 406 } else { | 406 } else { |
| 407 var lineNumber = this.blockStart.range.startLine; | 407 var lineNumber = this.blockStart.range.startLine; |
| 408 var columnNumber = this.blockStart.range.startColumn; | 408 var columnNumber = this.blockStart.range.startColumn; |
| 409 var baseLine = this.document.text.extract(new Common.TextRange(lineNumber,
0, lineNumber, columnNumber)); | 409 var baseLine = this.document.text.extract(new TextUtils.TextRange(lineNumb
er, 0, lineNumber, columnNumber)); |
| 410 result = Common.TextUtils.lineIndent(baseLine) + Common.moduleSetting('tex
tEditorIndent').get(); | 410 result = TextUtils.TextUtils.lineIndent(baseLine) + Common.moduleSetting('
textEditorIndent').get(); |
| 411 } | 411 } |
| 412 return result.isWhitespace() ? result : ''; | 412 return result.isWhitespace() ? result : ''; |
| 413 } | 413 } |
| 414 }; | 414 }; |
| 415 | 415 |
| 416 /** | 416 /** |
| 417 * @unrestricted | 417 * @unrestricted |
| 418 */ | 418 */ |
| 419 Sass.SASSSupport.AST = class extends Sass.SASSSupport.Node { | 419 Sass.SASSSupport.AST = class extends Sass.SASSSupport.Node { |
| 420 /** | 420 /** |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return; | 505 return; |
| 506 this._sortedTextNodes.push(node); | 506 this._sortedTextNodes.push(node); |
| 507 } | 507 } |
| 508 | 508 |
| 509 /** | 509 /** |
| 510 * @param {!Sass.SASSSupport.TextNode} text1 | 510 * @param {!Sass.SASSSupport.TextNode} text1 |
| 511 * @param {!Sass.SASSSupport.TextNode} text2 | 511 * @param {!Sass.SASSSupport.TextNode} text2 |
| 512 * @return {number} | 512 * @return {number} |
| 513 */ | 513 */ |
| 514 function nodeComparator(text1, text2) { | 514 function nodeComparator(text1, text2) { |
| 515 return Common.TextRange.comparator(text1.range, text2.range); | 515 return TextUtils.TextRange.comparator(text1.range, text2.range); |
| 516 } | 516 } |
| 517 } | 517 } |
| 518 }; | 518 }; |
| 519 | 519 |
| 520 /** @enum {string} */ | 520 /** @enum {string} */ |
| 521 Sass.SASSSupport.PropertyChangeType = { | 521 Sass.SASSSupport.PropertyChangeType = { |
| 522 PropertyAdded: 'PropertyAdded', | 522 PropertyAdded: 'PropertyAdded', |
| 523 PropertyRemoved: 'PropertyRemoved', | 523 PropertyRemoved: 'PropertyRemoved', |
| 524 PropertyToggled: 'PropertyToggled', | 524 PropertyToggled: 'PropertyToggled', |
| 525 ValueChanged: 'ValueChanged', | 525 ValueChanged: 'ValueChanged', |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 mapping.set(oldProperty.name, newProperty.name); | 654 mapping.set(oldProperty.name, newProperty.name); |
| 655 mapping.set(oldProperty.value, newProperty.value); | 655 mapping.set(oldProperty.value, newProperty.value); |
| 656 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) | 656 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) |
| 657 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newPropertyIn
dex); | 657 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newPropertyIn
dex); |
| 658 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) | 658 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) |
| 659 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPropertyI
ndex); | 659 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPropertyI
ndex); |
| 660 if (oldProperty.disabled !== newProperty.disabled) | 660 if (oldProperty.disabled !== newProperty.disabled) |
| 661 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, newProper
tyIndex); | 661 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, newProper
tyIndex); |
| 662 } | 662 } |
| 663 }; | 663 }; |
| OLD | NEW |