| 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 /** |
| 282 * @param {string} text |
| 283 * @return {string} |
| 284 */ |
| 285 extract: function(text) |
| 286 { |
| 287 var sourceRange = this.toSourceRange(text); |
| 288 return text.substr(sourceRange.offset, sourceRange.length); |
| 289 }, |
| 290 |
| 291 /** |
| 292 * @param {number} lineNumber |
| 293 * @param {number} columnNumber |
| 294 * @return {boolean} |
| 295 */ |
| 296 containsLocation: function(lineNumber, columnNumber) |
| 297 { |
| 298 if (this.startLine === this.endLine) |
| 299 return this.startLine === lineNumber && this.startColumn <= columnNu
mber && columnNumber <= this.endColumn; |
| 300 if (this.startLine === lineNumber) |
| 301 return this.startColumn <= columnNumber; |
| 302 if (this.endLine === lineNumber) |
| 303 return columnNumber <= this.endColumn; |
| 304 return this.startLine < lineNumber && lineNumber < this.endLine; |
| 279 } | 305 } |
| 280 } | 306 } |
| 281 | 307 |
| 282 /** | 308 /** |
| 283 * @constructor | 309 * @constructor |
| 284 * @param {number} offset | 310 * @param {number} offset |
| 285 * @param {number} length | 311 * @param {number} length |
| 286 */ | 312 */ |
| 287 WebInspector.SourceRange = function(offset, length) | 313 WebInspector.SourceRange = function(offset, length) |
| 288 { | 314 { |
| 289 this.offset = offset; | 315 this.offset = offset; |
| 290 this.length = length; | 316 this.length = length; |
| 291 } | 317 } |
| OLD | NEW |