Index: Source/devtools/front_end/common/TextUtils.js |
diff --git a/Source/devtools/front_end/common/TextUtils.js b/Source/devtools/front_end/common/TextUtils.js |
index 2310478a50c4635b92e7d5122205c2b76a7f31ac..da8e953c471fb8671ec0b5f96c6cdcea99f134eb 100644 |
--- a/Source/devtools/front_end/common/TextUtils.js |
+++ b/Source/devtools/front_end/common/TextUtils.js |
@@ -239,3 +239,45 @@ WebInspector.TokenizerFactory.prototype = { |
*/ |
createTokenizer: function(mimeType) { } |
} |
+ |
+/** |
+ * @constructor |
+ * @param {string} sourceURL |
+ * @param {!WebInspector.TextRange} oldRange |
+ * @param {string} oldText |
+ * @param {string} newText |
+ */ |
+WebInspector.SourceEdit = function(sourceURL, oldRange, oldText, newText) |
+{ |
+ this.sourceURL = sourceURL; |
+ this.oldRange = oldRange; |
+ this.oldText = oldText; |
+ this.newText = newText; |
+} |
+ |
+WebInspector.SourceEdit.prototype = { |
+ /** |
+ * @return {!WebInspector.TextRange} |
+ */ |
+ newRange: function() |
+ { |
+ var endLine = this.oldRange.startLine; |
+ var endColumn = this.oldRange.startColumn + this.newText.length; |
+ var lineEndings = this.newText.lineEndings(); |
+ if (lineEndings.length > 1) { |
+ endLine = this.oldRange.startLine + lineEndings.length - 1; |
+ var len = lineEndings.length; |
+ endColumn = lineEndings[len - 1] - lineEndings[len - 2] - 1; |
+ } |
+ return new WebInspector.TextRange( |
+ this.oldRange.startLine, |
+ this.oldRange.startColumn, |
+ endLine, |
+ endColumn); |
+ }, |
+ |
+ applyToText: function(text) |
+ { |
+ return this.oldRange.replaceInText(text, this.newText); |
+ }, |
+} |