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

Unified Diff: third_party/WebKit/Source/devtools/front_end/source_frame/SourcesTextEditor.js

Issue 2769843003: DevTools: split text_utils out of common module (Closed)
Patch Set: rebaseline Created 3 years, 9 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
Index: third_party/WebKit/Source/devtools/front_end/source_frame/SourcesTextEditor.js
diff --git a/third_party/WebKit/Source/devtools/front_end/source_frame/SourcesTextEditor.js b/third_party/WebKit/Source/devtools/front_end/source_frame/SourcesTextEditor.js
index af8f11d6aa1d9a2fabaa259efeb4436dcabbf06e..5db383122ce66352e0ea32f69318f477620bd3ca 100644
--- a/third_party/WebKit/Source/devtools/front_end/source_frame/SourcesTextEditor.js
+++ b/third_party/WebKit/Source/devtools/front_end/source_frame/SourcesTextEditor.js
@@ -66,14 +66,14 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
var indents = {};
for (var lineNumber = 0; lineNumber < lines.length; ++lineNumber) {
var text = lines[lineNumber];
- if (text.length === 0 || !Common.TextUtils.isSpaceChar(text[0]))
+ if (text.length === 0 || !TextUtils.TextUtils.isSpaceChar(text[0]))
continue;
if (tabRegex.test(text)) {
++tabLines;
continue;
}
var i = 0;
- while (i < text.length && Common.TextUtils.isSpaceChar(text[i]))
+ while (i < text.length && TextUtils.TextUtils.isSpaceChar(text[i]))
++i;
if (i % 2 !== 0)
continue;
@@ -113,7 +113,7 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
/**
* @param {!RegExp} regex
- * @param {?Common.TextRange} range
+ * @param {?TextUtils.TextRange} range
*/
highlightSearchResults(regex, range) {
/**
@@ -125,7 +125,7 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
if (range.endColumn > TextEditor.CodeMirrorTextEditor.maxHighlightLength)
this.setSelection(range);
else
- this.setSelection(Common.TextRange.createFromLocation(range.startLine, range.startColumn));
+ this.setSelection(TextUtils.TextRange.createFromLocation(range.startLine, range.startColumn));
}
this._tokenHighlighter.highlightSearchResults(regex, range);
}
@@ -153,7 +153,7 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
}
/**
- * @param {!Common.TextRange} range
+ * @param {!TextUtils.TextRange} range
* @param {string} cssClass
* @return {!Object}
*/
@@ -299,10 +299,10 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
/**
* @override
- * @param {!Common.TextRange} range
+ * @param {!TextUtils.TextRange} range
* @param {string} text
* @param {string=} origin
- * @return {!Common.TextRange}
+ * @return {!TextUtils.TextRange}
*/
editRange(range, text, origin) {
var newRange = super.editRange(range, text, origin);
@@ -329,7 +329,7 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
if (Common.moduleSetting('textEditorAutoDetectIndent').get())
indent = SourceFrame.SourcesTextEditor._guessIndentationLevel(lines);
- if (indent === Common.TextUtils.Indent.TabCharacter) {
+ if (indent === TextUtils.TextUtils.Indent.TabCharacter) {
this.codeMirror().setOption('indentWithTabs', true);
this.codeMirror().setOption('indentUnit', 4);
} else {
@@ -362,7 +362,7 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
if (!position)
continue;
var line = this.line(position.lineNumber);
- if (line.length === position.columnNumber && Common.TextUtils.lineIndent(line).length === line.length) {
+ if (line.length === position.columnNumber && TextUtils.TextUtils.lineIndent(line).length === line.length) {
this.codeMirror().replaceRange(
'', new CodeMirror.Pos(position.lineNumber, 0),
new CodeMirror.Pos(position.lineNumber, position.columnNumber));
@@ -413,8 +413,8 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
}
/**
- * @param {?Common.TextRange} from
- * @param {?Common.TextRange} to
+ * @param {?TextUtils.TextRange} from
+ * @param {?TextUtils.TextRange} to
*/
_reportJump(from, to) {
if (from && to && from.equal(to))
@@ -623,7 +623,7 @@ CodeMirror.commands.smartNewlineAndIndent = function(codeMirror) {
var selection = selections[i];
var cur = CodeMirror.cmpPos(selection.head, selection.anchor) < 0 ? selection.head : selection.anchor;
var line = codeMirror.getLine(cur.line);
- var indent = Common.TextUtils.lineIndent(line);
+ var indent = TextUtils.TextUtils.lineIndent(line);
replacements.push('\n' + indent.substring(0, Math.min(cur.ch, indent.length)));
}
codeMirror.replaceSelections(replacements);
@@ -654,7 +654,7 @@ SourceFrame.SourcesTextEditor._BlockIndentController = {
var selection = selections[i];
var start = CodeMirror.cmpPos(selection.head, selection.anchor) < 0 ? selection.head : selection.anchor;
var line = codeMirror.getLine(start.line);
- var indent = Common.TextUtils.lineIndent(line);
+ var indent = TextUtils.TextUtils.lineIndent(line);
var indentToInsert = '\n' + indent + codeMirror._codeMirrorTextEditor.indent();
var isCollapsedBlock = false;
if (selection.head.ch === 0)
@@ -698,7 +698,7 @@ SourceFrame.SourcesTextEditor._BlockIndentController = {
for (var i = 0; i < selections.length; ++i) {
var selection = selections[i];
var line = codeMirror.getLine(selection.head.line);
- if (line !== Common.TextUtils.lineIndent(line))
+ if (line !== TextUtils.TextUtils.lineIndent(line))
return CodeMirror.Pass;
replacements.push('}');
}
@@ -713,7 +713,7 @@ SourceFrame.SourcesTextEditor._BlockIndentController = {
return;
updatedSelections.push({head: selection.head, anchor: new CodeMirror.Pos(selection.head.line, 0)});
var line = codeMirror.getLine(matchingBracket.to.line);
- var indent = Common.TextUtils.lineIndent(line);
+ var indent = TextUtils.TextUtils.lineIndent(line);
replacements.push(indent + '}');
}
codeMirror.setSelections(updatedSelections);
@@ -737,7 +737,7 @@ SourceFrame.SourcesTextEditor.TokenHighlighter = class {
/**
* @param {!RegExp} regex
- * @param {?Common.TextRange} range
+ * @param {?TextUtils.TextRange} range
*/
highlightSearchResults(regex, range) {
var oldRegex = this._highlightRegex;
@@ -806,9 +806,9 @@ SourceFrame.SourcesTextEditor.TokenHighlighter = class {
*/
_isWord(selectedText, lineNumber, startColumn, endColumn) {
var line = this._codeMirror.getLine(lineNumber);
- var leftBound = startColumn === 0 || !Common.TextUtils.isWordChar(line.charAt(startColumn - 1));
- var rightBound = endColumn === line.length || !Common.TextUtils.isWordChar(line.charAt(endColumn));
- return leftBound && rightBound && Common.TextUtils.isWord(selectedText);
+ var leftBound = startColumn === 0 || !TextUtils.TextUtils.isWordChar(line.charAt(startColumn - 1));
+ var rightBound = endColumn === line.length || !TextUtils.TextUtils.isWordChar(line.charAt(endColumn));
+ return leftBound && rightBound && TextUtils.TextUtils.isWord(selectedText);
}
_removeHighlight() {
@@ -857,12 +857,12 @@ SourceFrame.SourcesTextEditor.TokenHighlighter = class {
*/
_tokenHighlighter(token, selectionStart, stream) {
var tokenFirstChar = token.charAt(0);
- if (stream.match(token) && (stream.eol() || !Common.TextUtils.isWordChar(stream.peek())))
+ if (stream.match(token) && (stream.eol() || !TextUtils.TextUtils.isWordChar(stream.peek())))
return stream.column() === selectionStart.ch ? 'token-highlight column-with-selection' : 'token-highlight';
var eatenChar;
do
eatenChar = stream.next();
- while (eatenChar && (Common.TextUtils.isWordChar(eatenChar) || stream.peek() !== tokenFirstChar));
+ while (eatenChar && (TextUtils.TextUtils.isWordChar(eatenChar) || stream.peek() !== tokenFirstChar));
}
/**

Powered by Google App Engine
This is Rietveld 408576698