Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1397)

Unified Diff: Source/devtools/front_end/common/TextUtils.js

Issue 1331083002: DevTools: [STRUCT] edit SASS through SourceMaps (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebaseline atop master Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/common/TextRange.js ('k') | Source/devtools/front_end/sdk/CSSParser.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ },
+}
« no previous file with comments | « Source/devtools/front_end/common/TextRange.js ('k') | Source/devtools/front_end/sdk/CSSParser.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698