| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | |
| 31 /** | 30 /** |
| 32 * @constructor | 31 * @unrestricted |
| 33 * @param {number} startLine | |
| 34 * @param {number} startColumn | |
| 35 * @param {number} endLine | |
| 36 * @param {number} endColumn | |
| 37 */ | 32 */ |
| 38 WebInspector.TextRange = function(startLine, startColumn, endLine, endColumn) | 33 WebInspector.TextRange = class { |
| 39 { | 34 /** |
| 35 * @param {number} startLine |
| 36 * @param {number} startColumn |
| 37 * @param {number} endLine |
| 38 * @param {number} endColumn |
| 39 */ |
| 40 constructor(startLine, startColumn, endLine, endColumn) { |
| 40 this.startLine = startLine; | 41 this.startLine = startLine; |
| 41 this.startColumn = startColumn; | 42 this.startColumn = startColumn; |
| 42 this.endLine = endLine; | 43 this.endLine = endLine; |
| 43 this.endColumn = endColumn; | 44 this.endColumn = endColumn; |
| 44 }; | 45 } |
| 45 | 46 |
| 46 /** | 47 /** |
| 47 * @param {number} line | 48 * @param {number} line |
| 48 * @param {number} column | 49 * @param {number} column |
| 49 * @return {!WebInspector.TextRange} | 50 * @return {!WebInspector.TextRange} |
| 50 */ | 51 */ |
| 51 WebInspector.TextRange.createFromLocation = function(line, column) | 52 static createFromLocation(line, column) { |
| 52 { | |
| 53 return new WebInspector.TextRange(line, column, line, column); | 53 return new WebInspector.TextRange(line, column, line, column); |
| 54 }; | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * @param {!Object} serializedTextRange | 57 * @param {!Object} serializedTextRange |
| 58 * @return {!WebInspector.TextRange} | 58 * @return {!WebInspector.TextRange} |
| 59 */ | 59 */ |
| 60 WebInspector.TextRange.fromObject = function(serializedTextRange) | 60 static fromObject(serializedTextRange) { |
| 61 { | 61 return new WebInspector.TextRange( |
| 62 return new WebInspector.TextRange(serializedTextRange.startLine, serializedT
extRange.startColumn, serializedTextRange.endLine, serializedTextRange.endColumn
); | 62 serializedTextRange.startLine, serializedTextRange.startColumn, serializ
edTextRange.endLine, |
| 63 }; | 63 serializedTextRange.endColumn); |
| 64 | 64 } |
| 65 /** | 65 |
| 66 * @param {!WebInspector.TextRange} range1 | 66 /** |
| 67 * @param {!WebInspector.TextRange} range2 | 67 * @param {!WebInspector.TextRange} range1 |
| 68 * @return {number} | 68 * @param {!WebInspector.TextRange} range2 |
| 69 */ | 69 * @return {number} |
| 70 WebInspector.TextRange.comparator = function(range1, range2) | 70 */ |
| 71 { | 71 static comparator(range1, range2) { |
| 72 return range1.compareTo(range2); | 72 return range1.compareTo(range2); |
| 73 }; | 73 } |
| 74 | 74 |
| 75 WebInspector.TextRange.prototype = { | 75 /** |
| 76 /** | 76 * @param {!WebInspector.TextRange} oldRange |
| 77 * @return {boolean} | 77 * @param {string} newText |
| 78 */ | 78 * @return {!WebInspector.TextRange} |
| 79 isEmpty: function() | 79 */ |
| 80 { | 80 static fromEdit(oldRange, newText) { |
| 81 return this.startLine === this.endLine && this.startColumn === this.endC
olumn; | |
| 82 }, | |
| 83 | |
| 84 /** | |
| 85 * @param {!WebInspector.TextRange} range | |
| 86 * @return {boolean} | |
| 87 */ | |
| 88 immediatelyPrecedes: function(range) | |
| 89 { | |
| 90 if (!range) | |
| 91 return false; | |
| 92 return this.endLine === range.startLine && this.endColumn === range.star
tColumn; | |
| 93 }, | |
| 94 | |
| 95 /** | |
| 96 * @param {!WebInspector.TextRange} range | |
| 97 * @return {boolean} | |
| 98 */ | |
| 99 immediatelyFollows: function(range) | |
| 100 { | |
| 101 if (!range) | |
| 102 return false; | |
| 103 return range.immediatelyPrecedes(this); | |
| 104 }, | |
| 105 | |
| 106 /** | |
| 107 * @param {!WebInspector.TextRange} range | |
| 108 * @return {boolean} | |
| 109 */ | |
| 110 follows: function(range) | |
| 111 { | |
| 112 return (range.endLine === this.startLine && range.endColumn <= this.star
tColumn) | |
| 113 || range.endLine < this.startLine; | |
| 114 }, | |
| 115 | |
| 116 /** | |
| 117 * @return {number} | |
| 118 */ | |
| 119 get linesCount() | |
| 120 { | |
| 121 return this.endLine - this.startLine; | |
| 122 }, | |
| 123 | |
| 124 /** | |
| 125 * @return {!WebInspector.TextRange} | |
| 126 */ | |
| 127 collapseToEnd: function() | |
| 128 { | |
| 129 return new WebInspector.TextRange(this.endLine, this.endColumn, this.end
Line, this.endColumn); | |
| 130 }, | |
| 131 | |
| 132 /** | |
| 133 * @return {!WebInspector.TextRange} | |
| 134 */ | |
| 135 collapseToStart: function() | |
| 136 { | |
| 137 return new WebInspector.TextRange(this.startLine, this.startColumn, this
.startLine, this.startColumn); | |
| 138 }, | |
| 139 | |
| 140 /** | |
| 141 * @return {!WebInspector.TextRange} | |
| 142 */ | |
| 143 normalize: function() | |
| 144 { | |
| 145 if (this.startLine > this.endLine || (this.startLine === this.endLine &&
this.startColumn > this.endColumn)) | |
| 146 return new WebInspector.TextRange(this.endLine, this.endColumn, this
.startLine, this.startColumn); | |
| 147 else | |
| 148 return this.clone(); | |
| 149 }, | |
| 150 | |
| 151 /** | |
| 152 * @return {!WebInspector.TextRange} | |
| 153 */ | |
| 154 clone: function() | |
| 155 { | |
| 156 return new WebInspector.TextRange(this.startLine, this.startColumn, this
.endLine, this.endColumn); | |
| 157 }, | |
| 158 | |
| 159 /** | |
| 160 * @return {!{startLine: number, startColumn: number, endLine: number, endCo
lumn: number}} | |
| 161 */ | |
| 162 serializeToObject: function() | |
| 163 { | |
| 164 var serializedTextRange = {}; | |
| 165 serializedTextRange.startLine = this.startLine; | |
| 166 serializedTextRange.startColumn = this.startColumn; | |
| 167 serializedTextRange.endLine = this.endLine; | |
| 168 serializedTextRange.endColumn = this.endColumn; | |
| 169 return serializedTextRange; | |
| 170 }, | |
| 171 | |
| 172 /** | |
| 173 * @param {!WebInspector.TextRange} other | |
| 174 * @return {number} | |
| 175 */ | |
| 176 compareTo: function(other) | |
| 177 { | |
| 178 if (this.startLine > other.startLine) | |
| 179 return 1; | |
| 180 if (this.startLine < other.startLine) | |
| 181 return -1; | |
| 182 if (this.startColumn > other.startColumn) | |
| 183 return 1; | |
| 184 if (this.startColumn < other.startColumn) | |
| 185 return -1; | |
| 186 return 0; | |
| 187 }, | |
| 188 | |
| 189 /** | |
| 190 * @param {number} lineNumber | |
| 191 * @param {number} columnNumber | |
| 192 * @return {number} | |
| 193 */ | |
| 194 compareToPosition: function(lineNumber, columnNumber) | |
| 195 { | |
| 196 if (lineNumber < this.startLine || (lineNumber === this.startLine && col
umnNumber < this.startColumn)) | |
| 197 return -1; | |
| 198 if (lineNumber > this.endLine || (lineNumber === this.endLine && columnN
umber > this.endColumn)) | |
| 199 return 1; | |
| 200 return 0; | |
| 201 }, | |
| 202 | |
| 203 /** | |
| 204 * @param {!WebInspector.TextRange} other | |
| 205 * @return {boolean} | |
| 206 */ | |
| 207 equal: function(other) | |
| 208 { | |
| 209 return this.startLine === other.startLine && this.endLine === other.endL
ine && | |
| 210 this.startColumn === other.startColumn && this.endColumn === other.e
ndColumn; | |
| 211 }, | |
| 212 | |
| 213 /** | |
| 214 * @param {number} line | |
| 215 * @param {number} column | |
| 216 * @return {!WebInspector.TextRange} | |
| 217 */ | |
| 218 relativeTo: function(line, column) | |
| 219 { | |
| 220 var relative = this.clone(); | |
| 221 | |
| 222 if (this.startLine === line) | |
| 223 relative.startColumn -= column; | |
| 224 if (this.endLine === line) | |
| 225 relative.endColumn -= column; | |
| 226 | |
| 227 relative.startLine -= line; | |
| 228 relative.endLine -= line; | |
| 229 return relative; | |
| 230 }, | |
| 231 | |
| 232 /** | |
| 233 * @param {!WebInspector.TextRange} originalRange | |
| 234 * @param {!WebInspector.TextRange} editedRange | |
| 235 * @return {!WebInspector.TextRange} | |
| 236 */ | |
| 237 rebaseAfterTextEdit: function(originalRange, editedRange) | |
| 238 { | |
| 239 console.assert(originalRange.startLine === editedRange.startLine); | |
| 240 console.assert(originalRange.startColumn === editedRange.startColumn); | |
| 241 var rebase = this.clone(); | |
| 242 if (!this.follows(originalRange)) | |
| 243 return rebase; | |
| 244 var lineDelta = editedRange.endLine - originalRange.endLine; | |
| 245 var columnDelta = editedRange.endColumn - originalRange.endColumn; | |
| 246 rebase.startLine += lineDelta; | |
| 247 rebase.endLine += lineDelta; | |
| 248 if (rebase.startLine === editedRange.endLine) | |
| 249 rebase.startColumn += columnDelta; | |
| 250 if (rebase.endLine === editedRange.endLine) | |
| 251 rebase.endColumn += columnDelta; | |
| 252 return rebase; | |
| 253 }, | |
| 254 | |
| 255 /** | |
| 256 * @override | |
| 257 * @return {string} | |
| 258 */ | |
| 259 toString: function() | |
| 260 { | |
| 261 return JSON.stringify(this); | |
| 262 }, | |
| 263 | |
| 264 /** | |
| 265 * @param {number} lineNumber | |
| 266 * @param {number} columnNumber | |
| 267 * @return {boolean} | |
| 268 */ | |
| 269 containsLocation: function(lineNumber, columnNumber) | |
| 270 { | |
| 271 if (this.startLine === this.endLine) | |
| 272 return this.startLine === lineNumber && this.startColumn <= columnNu
mber && columnNumber <= this.endColumn; | |
| 273 if (this.startLine === lineNumber) | |
| 274 return this.startColumn <= columnNumber; | |
| 275 if (this.endLine === lineNumber) | |
| 276 return columnNumber <= this.endColumn; | |
| 277 return this.startLine < lineNumber && lineNumber < this.endLine; | |
| 278 } | |
| 279 }; | |
| 280 | |
| 281 /** | |
| 282 * @param {!WebInspector.TextRange} oldRange | |
| 283 * @param {string} newText | |
| 284 * @return {!WebInspector.TextRange} | |
| 285 */ | |
| 286 WebInspector.TextRange.fromEdit = function(oldRange, newText) | |
| 287 { | |
| 288 var endLine = oldRange.startLine; | 81 var endLine = oldRange.startLine; |
| 289 var endColumn = oldRange.startColumn + newText.length; | 82 var endColumn = oldRange.startColumn + newText.length; |
| 290 var lineEndings = newText.computeLineEndings(); | 83 var lineEndings = newText.computeLineEndings(); |
| 291 if (lineEndings.length > 1) { | 84 if (lineEndings.length > 1) { |
| 292 endLine = oldRange.startLine + lineEndings.length - 1; | 85 endLine = oldRange.startLine + lineEndings.length - 1; |
| 293 var len = lineEndings.length; | 86 var len = lineEndings.length; |
| 294 endColumn = lineEndings[len - 1] - lineEndings[len - 2] - 1; | 87 endColumn = lineEndings[len - 1] - lineEndings[len - 2] - 1; |
| 295 } | 88 } |
| 296 return new WebInspector.TextRange( | 89 return new WebInspector.TextRange(oldRange.startLine, oldRange.startColumn,
endLine, endColumn); |
| 297 oldRange.startLine, | 90 } |
| 298 oldRange.startColumn, | 91 |
| 299 endLine, | 92 /** |
| 300 endColumn); | 93 * @return {boolean} |
| 94 */ |
| 95 isEmpty() { |
| 96 return this.startLine === this.endLine && this.startColumn === this.endColum
n; |
| 97 } |
| 98 |
| 99 /** |
| 100 * @param {!WebInspector.TextRange} range |
| 101 * @return {boolean} |
| 102 */ |
| 103 immediatelyPrecedes(range) { |
| 104 if (!range) |
| 105 return false; |
| 106 return this.endLine === range.startLine && this.endColumn === range.startCol
umn; |
| 107 } |
| 108 |
| 109 /** |
| 110 * @param {!WebInspector.TextRange} range |
| 111 * @return {boolean} |
| 112 */ |
| 113 immediatelyFollows(range) { |
| 114 if (!range) |
| 115 return false; |
| 116 return range.immediatelyPrecedes(this); |
| 117 } |
| 118 |
| 119 /** |
| 120 * @param {!WebInspector.TextRange} range |
| 121 * @return {boolean} |
| 122 */ |
| 123 follows(range) { |
| 124 return (range.endLine === this.startLine && range.endColumn <= this.startCol
umn) || range.endLine < this.startLine; |
| 125 } |
| 126 |
| 127 /** |
| 128 * @return {number} |
| 129 */ |
| 130 get linesCount() { |
| 131 return this.endLine - this.startLine; |
| 132 } |
| 133 |
| 134 /** |
| 135 * @return {!WebInspector.TextRange} |
| 136 */ |
| 137 collapseToEnd() { |
| 138 return new WebInspector.TextRange(this.endLine, this.endColumn, this.endLine
, this.endColumn); |
| 139 } |
| 140 |
| 141 /** |
| 142 * @return {!WebInspector.TextRange} |
| 143 */ |
| 144 collapseToStart() { |
| 145 return new WebInspector.TextRange(this.startLine, this.startColumn, this.sta
rtLine, this.startColumn); |
| 146 } |
| 147 |
| 148 /** |
| 149 * @return {!WebInspector.TextRange} |
| 150 */ |
| 151 normalize() { |
| 152 if (this.startLine > this.endLine || (this.startLine === this.endLine && thi
s.startColumn > this.endColumn)) |
| 153 return new WebInspector.TextRange(this.endLine, this.endColumn, this.start
Line, this.startColumn); |
| 154 else |
| 155 return this.clone(); |
| 156 } |
| 157 |
| 158 /** |
| 159 * @return {!WebInspector.TextRange} |
| 160 */ |
| 161 clone() { |
| 162 return new WebInspector.TextRange(this.startLine, this.startColumn, this.end
Line, this.endColumn); |
| 163 } |
| 164 |
| 165 /** |
| 166 * @return {!{startLine: number, startColumn: number, endLine: number, endColu
mn: number}} |
| 167 */ |
| 168 serializeToObject() { |
| 169 var serializedTextRange = {}; |
| 170 serializedTextRange.startLine = this.startLine; |
| 171 serializedTextRange.startColumn = this.startColumn; |
| 172 serializedTextRange.endLine = this.endLine; |
| 173 serializedTextRange.endColumn = this.endColumn; |
| 174 return serializedTextRange; |
| 175 } |
| 176 |
| 177 /** |
| 178 * @param {!WebInspector.TextRange} other |
| 179 * @return {number} |
| 180 */ |
| 181 compareTo(other) { |
| 182 if (this.startLine > other.startLine) |
| 183 return 1; |
| 184 if (this.startLine < other.startLine) |
| 185 return -1; |
| 186 if (this.startColumn > other.startColumn) |
| 187 return 1; |
| 188 if (this.startColumn < other.startColumn) |
| 189 return -1; |
| 190 return 0; |
| 191 } |
| 192 |
| 193 /** |
| 194 * @param {number} lineNumber |
| 195 * @param {number} columnNumber |
| 196 * @return {number} |
| 197 */ |
| 198 compareToPosition(lineNumber, columnNumber) { |
| 199 if (lineNumber < this.startLine || (lineNumber === this.startLine && columnN
umber < this.startColumn)) |
| 200 return -1; |
| 201 if (lineNumber > this.endLine || (lineNumber === this.endLine && columnNumbe
r > this.endColumn)) |
| 202 return 1; |
| 203 return 0; |
| 204 } |
| 205 |
| 206 /** |
| 207 * @param {!WebInspector.TextRange} other |
| 208 * @return {boolean} |
| 209 */ |
| 210 equal(other) { |
| 211 return this.startLine === other.startLine && this.endLine === other.endLine
&& |
| 212 this.startColumn === other.startColumn && this.endColumn === other.endCo
lumn; |
| 213 } |
| 214 |
| 215 /** |
| 216 * @param {number} line |
| 217 * @param {number} column |
| 218 * @return {!WebInspector.TextRange} |
| 219 */ |
| 220 relativeTo(line, column) { |
| 221 var relative = this.clone(); |
| 222 |
| 223 if (this.startLine === line) |
| 224 relative.startColumn -= column; |
| 225 if (this.endLine === line) |
| 226 relative.endColumn -= column; |
| 227 |
| 228 relative.startLine -= line; |
| 229 relative.endLine -= line; |
| 230 return relative; |
| 231 } |
| 232 |
| 233 /** |
| 234 * @param {!WebInspector.TextRange} originalRange |
| 235 * @param {!WebInspector.TextRange} editedRange |
| 236 * @return {!WebInspector.TextRange} |
| 237 */ |
| 238 rebaseAfterTextEdit(originalRange, editedRange) { |
| 239 console.assert(originalRange.startLine === editedRange.startLine); |
| 240 console.assert(originalRange.startColumn === editedRange.startColumn); |
| 241 var rebase = this.clone(); |
| 242 if (!this.follows(originalRange)) |
| 243 return rebase; |
| 244 var lineDelta = editedRange.endLine - originalRange.endLine; |
| 245 var columnDelta = editedRange.endColumn - originalRange.endColumn; |
| 246 rebase.startLine += lineDelta; |
| 247 rebase.endLine += lineDelta; |
| 248 if (rebase.startLine === editedRange.endLine) |
| 249 rebase.startColumn += columnDelta; |
| 250 if (rebase.endLine === editedRange.endLine) |
| 251 rebase.endColumn += columnDelta; |
| 252 return rebase; |
| 253 } |
| 254 |
| 255 /** |
| 256 * @override |
| 257 * @return {string} |
| 258 */ |
| 259 toString() { |
| 260 return JSON.stringify(this); |
| 261 } |
| 262 |
| 263 /** |
| 264 * @param {number} lineNumber |
| 265 * @param {number} columnNumber |
| 266 * @return {boolean} |
| 267 */ |
| 268 containsLocation(lineNumber, columnNumber) { |
| 269 if (this.startLine === this.endLine) |
| 270 return this.startLine === lineNumber && this.startColumn <= columnNumber &
& columnNumber <= this.endColumn; |
| 271 if (this.startLine === lineNumber) |
| 272 return this.startColumn <= columnNumber; |
| 273 if (this.endLine === lineNumber) |
| 274 return columnNumber <= this.endColumn; |
| 275 return this.startLine < lineNumber && lineNumber < this.endLine; |
| 276 } |
| 301 }; | 277 }; |
| 302 | 278 |
| 279 |
| 303 /** | 280 /** |
| 304 * @constructor | 281 * @unrestricted |
| 305 * @param {number} offset | |
| 306 * @param {number} length | |
| 307 */ | 282 */ |
| 308 WebInspector.SourceRange = function(offset, length) | 283 WebInspector.SourceRange = class { |
| 309 { | 284 /** |
| 285 * @param {number} offset |
| 286 * @param {number} length |
| 287 */ |
| 288 constructor(offset, length) { |
| 310 this.offset = offset; | 289 this.offset = offset; |
| 311 this.length = length; | 290 this.length = length; |
| 291 } |
| 312 }; | 292 }; |
| 313 | 293 |
| 314 /** | 294 /** |
| 315 * @constructor | 295 * @unrestricted |
| 316 * @param {string} sourceURL | |
| 317 * @param {!WebInspector.TextRange} oldRange | |
| 318 * @param {string} newText | |
| 319 */ | 296 */ |
| 320 WebInspector.SourceEdit = function(sourceURL, oldRange, newText) | 297 WebInspector.SourceEdit = class { |
| 321 { | 298 /** |
| 299 * @param {string} sourceURL |
| 300 * @param {!WebInspector.TextRange} oldRange |
| 301 * @param {string} newText |
| 302 */ |
| 303 constructor(sourceURL, oldRange, newText) { |
| 322 this.sourceURL = sourceURL; | 304 this.sourceURL = sourceURL; |
| 323 this.oldRange = oldRange; | 305 this.oldRange = oldRange; |
| 324 this.newText = newText; | 306 this.newText = newText; |
| 307 } |
| 308 |
| 309 /** |
| 310 * @param {!WebInspector.SourceEdit} edit1 |
| 311 * @param {!WebInspector.SourceEdit} edit2 |
| 312 * @return {number} |
| 313 */ |
| 314 static comparator(edit1, edit2) { |
| 315 return WebInspector.TextRange.comparator(edit1.oldRange, edit2.oldRange); |
| 316 } |
| 317 |
| 318 /** |
| 319 * @return {!WebInspector.TextRange} |
| 320 */ |
| 321 newRange() { |
| 322 return WebInspector.TextRange.fromEdit(this.oldRange, this.newText); |
| 323 } |
| 325 }; | 324 }; |
| 326 | 325 |
| 327 WebInspector.SourceEdit.prototype = { | 326 |
| 328 /** | |
| 329 * @return {!WebInspector.TextRange} | |
| 330 */ | |
| 331 newRange: function() | |
| 332 { | |
| 333 return WebInspector.TextRange.fromEdit(this.oldRange, this.newText); | |
| 334 }, | |
| 335 }; | |
| 336 | |
| 337 /** | |
| 338 * @param {!WebInspector.SourceEdit} edit1 | |
| 339 * @param {!WebInspector.SourceEdit} edit2 | |
| 340 * @return {number} | |
| 341 */ | |
| 342 WebInspector.SourceEdit.comparator = function(edit1, edit2) | |
| 343 { | |
| 344 return WebInspector.TextRange.comparator(edit1.oldRange, edit2.oldRange); | |
| 345 }; | |
| OLD | NEW |