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

Unified Diff: third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.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/text_editor/CodeMirrorTextEditor.js
diff --git a/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js b/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js
index 5dc4134aafaac5b7ab68f6fe0c6d7d5ed68e041d..6b5e1898f570c6eed34acf2f3a7b06e522cdfa75 100644
--- a/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js
+++ b/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js
@@ -438,8 +438,8 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
var position = charNumber;
var nextPosition = charNumber + 1;
return valid(position, text.length) && valid(nextPosition, text.length) &&
- Common.TextUtils.isWordChar(text[position]) && Common.TextUtils.isWordChar(text[nextPosition]) &&
- Common.TextUtils.isUpperCase(text[position]) && Common.TextUtils.isLowerCase(text[nextPosition]);
+ TextUtils.TextUtils.isWordChar(text[position]) && TextUtils.TextUtils.isWordChar(text[nextPosition]) &&
+ TextUtils.TextUtils.isUpperCase(text[position]) && TextUtils.TextUtils.isLowerCase(text[nextPosition]);
}
/**
@@ -451,8 +451,8 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
var position = charNumber;
var prevPosition = charNumber - 1;
return valid(position, text.length) && valid(prevPosition, text.length) &&
- Common.TextUtils.isWordChar(text[position]) && Common.TextUtils.isWordChar(text[prevPosition]) &&
- Common.TextUtils.isUpperCase(text[position]) && Common.TextUtils.isLowerCase(text[prevPosition]);
+ TextUtils.TextUtils.isWordChar(text[position]) && TextUtils.TextUtils.isWordChar(text[prevPosition]) &&
+ TextUtils.TextUtils.isUpperCase(text[position]) && TextUtils.TextUtils.isLowerCase(text[prevPosition]);
}
/**
@@ -474,13 +474,13 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
var charNumber = direction === 1 ? columnNumber : columnNumber - 1;
// Move through initial spaces if any.
- while (valid(charNumber, length) && Common.TextUtils.isSpaceChar(text[charNumber]))
+ while (valid(charNumber, length) && TextUtils.TextUtils.isSpaceChar(text[charNumber]))
charNumber += direction;
if (!valid(charNumber, length))
return constrainPosition(lineNumber, length, charNumber);
- if (Common.TextUtils.isStopChar(text[charNumber])) {
- while (valid(charNumber, length) && Common.TextUtils.isStopChar(text[charNumber]))
+ if (TextUtils.TextUtils.isStopChar(text[charNumber])) {
+ while (valid(charNumber, length) && TextUtils.TextUtils.isStopChar(text[charNumber]))
charNumber += direction;
if (!valid(charNumber, length))
return constrainPosition(lineNumber, length, charNumber);
@@ -489,7 +489,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
charNumber += direction;
while (valid(charNumber, length) && !isWordStart(text, charNumber) && !isWordEnd(text, charNumber) &&
- Common.TextUtils.isWordChar(text[charNumber]))
+ TextUtils.TextUtils.isWordChar(text[charNumber]))
charNumber += direction;
if (!valid(charNumber, length))
@@ -611,7 +611,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
/**
* @param {number} x
* @param {number} y
- * @return {?Common.TextRange}
+ * @return {?TextUtils.TextRange}
*/
coordinatesToCursorPosition(x, y) {
var element = this.element.ownerDocument.elementFromPoint(x, y);
@@ -757,7 +757,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
}
/**
- * @param {!Common.TextRange} range
+ * @param {!TextUtils.TextRange} range
* @param {symbol=} type
* @return {!Array.<!TextEditor.TextEditorBookMark>}
*/
@@ -917,7 +917,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
if (!this._readOnly)
this._clearHighlightTimeout = setTimeout(this.clearPositionHighlight.bind(this), 2000);
}
- this.setSelection(Common.TextRange.createFromLocation(lineNumber, columnNumber));
+ this.setSelection(TextUtils.TextRange.createFromLocation(lineNumber, columnNumber));
}
clearPositionHighlight() {
@@ -996,10 +996,10 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
}
/**
- * @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 pos = TextEditor.CodeMirrorUtils.toPos(range);
@@ -1020,7 +1020,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
* @param {number} lineNumber
* @param {number} column
* @param {function(string):boolean} isWordChar
- * @return {!Common.TextRange}
+ * @return {!TextUtils.TextRange}
*/
wordRangeForCursorPosition(lineNumber, column, isWordChar) {
var line = this.line(lineNumber);
@@ -1033,7 +1033,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
var wordEnd = column;
while (wordEnd < line.length && isWordChar(line.charAt(wordEnd)))
++wordEnd;
- return new Common.TextRange(lineNumber, wordStart, lineNumber, wordEnd);
+ return new TextUtils.TextRange(lineNumber, wordStart, lineNumber, wordEnd);
}
/**
@@ -1101,7 +1101,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
/**
* @override
- * @return {!Common.TextRange}
+ * @return {!TextUtils.TextRange}
*/
selection() {
var start = this._codeMirror.getCursor('anchor');
@@ -1111,7 +1111,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
}
/**
- * @return {!Array.<!Common.TextRange>}
+ * @return {!Array.<!TextUtils.TextRange>}
*/
selections() {
var selectionList = this._codeMirror.listSelections();
@@ -1124,7 +1124,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
}
/**
- * @return {?Common.TextRange}
+ * @return {?TextUtils.TextRange}
*/
lastSelection() {
return this._lastSelection;
@@ -1132,7 +1132,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
/**
* @override
- * @param {!Common.TextRange} textRange
+ * @param {!TextUtils.TextRange} textRange
*/
setSelection(textRange) {
this._lastSelection = textRange;
@@ -1145,7 +1145,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
}
/**
- * @param {!Array.<!Common.TextRange>} ranges
+ * @param {!Array.<!TextUtils.TextRange>} ranges
* @param {number=} primarySelectionIndex
*/
setSelections(ranges, primarySelectionIndex) {
@@ -1189,7 +1189,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
/**
* @override
- * @param {!Common.TextRange=} textRange
+ * @param {!TextUtils.TextRange=} textRange
* @return {string}
*/
text(textRange) {
@@ -1201,7 +1201,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
/**
* @override
- * @return {!Common.TextRange}
+ * @return {!TextUtils.TextRange}
*/
fullRange() {
var lineCount = this.linesCount;
@@ -1330,7 +1330,7 @@ CodeMirror.commands.dismiss = function(codemirror) {
* @return {!Object|undefined}
*/
CodeMirror.commands.goSmartPageUp = function(codemirror) {
- if (codemirror._codeMirrorTextEditor.selection().equal(Common.TextRange.createFromLocation(0, 0)))
+ if (codemirror._codeMirrorTextEditor.selection().equal(TextUtils.TextRange.createFromLocation(0, 0)))
return CodeMirror.Pass;
codemirror.execCommand('goPageUp');
};
@@ -1409,8 +1409,8 @@ TextEditor.CodeMirrorTextEditor.SelectNextOccurrenceController = class {
}
/**
- * @param {!Array.<!Common.TextRange>} selections
- * @param {!Common.TextRange} range
+ * @param {!Array.<!TextUtils.TextRange>} selections
+ * @param {!TextUtils.TextRange} range
* @return {boolean}
*/
_findRange(selections, range) {
@@ -1459,19 +1459,19 @@ TextEditor.CodeMirrorTextEditor.SelectNextOccurrenceController = class {
}
/**
- * @param {!Array.<!Common.TextRange>} selections
+ * @param {!Array.<!TextUtils.TextRange>} selections
*/
_expandSelectionsToWords(selections) {
var newSelections = [];
for (var i = 0; i < selections.length; ++i) {
var selection = selections[i];
var startRangeWord = this._textEditor.wordRangeForCursorPosition(
- selection.startLine, selection.startColumn, Common.TextUtils.isWordChar) ||
- Common.TextRange.createFromLocation(selection.startLine, selection.startColumn);
+ selection.startLine, selection.startColumn, TextUtils.TextUtils.isWordChar) ||
+ TextUtils.TextRange.createFromLocation(selection.startLine, selection.startColumn);
var endRangeWord = this._textEditor.wordRangeForCursorPosition(
- selection.endLine, selection.endColumn, Common.TextUtils.isWordChar) ||
- Common.TextRange.createFromLocation(selection.endLine, selection.endColumn);
- var newSelection = new Common.TextRange(
+ selection.endLine, selection.endColumn, TextUtils.TextUtils.isWordChar) ||
+ TextUtils.TextRange.createFromLocation(selection.endLine, selection.endColumn);
+ var newSelection = new TextUtils.TextRange(
startRangeWord.startLine, startRangeWord.startColumn, endRangeWord.endLine, endRangeWord.endColumn);
newSelections.push(newSelection);
}
@@ -1480,9 +1480,9 @@ TextEditor.CodeMirrorTextEditor.SelectNextOccurrenceController = class {
}
/**
- * @param {!Common.TextRange} range
+ * @param {!TextUtils.TextRange} range
* @param {boolean} fullWord
- * @return {?Common.TextRange}
+ * @return {?TextUtils.TextRange}
*/
_findNextOccurrence(range, fullWord) {
range = range.normalize();
@@ -1522,7 +1522,7 @@ TextEditor.CodeMirrorTextEditor.SelectNextOccurrenceController = class {
if (typeof matchedLineNumber !== 'number')
return null;
- return new Common.TextRange(
+ return new TextUtils.TextRange(
matchedLineNumber, matchedColumnNumber, matchedLineNumber, matchedColumnNumber + textToFind.length);
}
};
@@ -1605,11 +1605,11 @@ TextEditor.TextEditorBookMark = class {
}
/**
- * @return {?Common.TextRange}
+ * @return {?TextUtils.TextRange}
*/
position() {
var pos = this._marker.find();
- return pos ? Common.TextRange.createFromLocation(pos.line, pos.ch) : null;
+ return pos ? TextUtils.TextRange.createFromLocation(pos.line, pos.ch) : null;
}
};

Powered by Google App Engine
This is Rietveld 408576698