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 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 /** | 270 /** |
271 * @param {string} text | 271 * @param {string} text |
272 * @param {string} replacement | 272 * @param {string} replacement |
273 * @return {string} | 273 * @return {string} |
274 */ | 274 */ |
275 replaceInText: function(text, replacement) | 275 replaceInText: function(text, replacement) |
276 { | 276 { |
277 var sourceRange = this.toSourceRange(text); | 277 var sourceRange = this.toSourceRange(text); |
278 return text.substring(0, sourceRange.offset) + replacement + text.substr
ing(sourceRange.offset + sourceRange.length); | 278 return text.substring(0, sourceRange.offset) + replacement + text.substr
ing(sourceRange.offset + sourceRange.length); |
| 279 }, |
| 280 |
| 281 extract: function(text) |
| 282 { |
| 283 var sourceRange = this.toSourceRange(text); |
| 284 return text.substr(sourceRange.offset, sourceRange.length); |
| 285 }, |
| 286 |
| 287 /** |
| 288 * @param {number} lineNumber |
| 289 * @param {number} columnNumber |
| 290 * @return {boolean} |
| 291 */ |
| 292 containsLocation: function(lineNumber, columnNumber) |
| 293 { |
| 294 if (this.startLine === this.endLine) |
| 295 return this.startLine === lineNumber && this.startColumn <= columnNu
mber && columnNumber <= this.endColumn; |
| 296 if (this.startLine === lineNumber) |
| 297 return this.startColumn <= columnNumber; |
| 298 if (this.endLine === lineNumber) |
| 299 return columnNumber <= this.endColumn; |
| 300 return this.startLine < lineNumber && lineNumber < this.endLine; |
279 } | 301 } |
280 } | 302 } |
281 | 303 |
282 /** | 304 /** |
283 * @constructor | 305 * @constructor |
284 * @param {number} offset | 306 * @param {number} offset |
285 * @param {number} length | 307 * @param {number} length |
286 */ | 308 */ |
287 WebInspector.SourceRange = function(offset, length) | 309 WebInspector.SourceRange = function(offset, length) |
288 { | 310 { |
289 this.offset = offset; | 311 this.offset = offset; |
290 this.length = length; | 312 this.length = length; |
291 } | 313 } |
OLD | NEW |