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

Unified Diff: Source/devtools/front_end/CodeMirrorTextEditor.js

Issue 22638008: DevTools: Use CodeMirror modes instead of highlight tokenizers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 7 years, 4 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/devtools.gyp ('k') | Source/devtools/front_end/CodeMirrorUtils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/CodeMirrorTextEditor.js
diff --git a/Source/devtools/front_end/CodeMirrorTextEditor.js b/Source/devtools/front_end/CodeMirrorTextEditor.js
index 029f07fe4a4ff56d68ffe7bc35feebda5eb86d73..2dacbdbed567f8b1324035ac869ab14d1aeadc35 100644
--- a/Source/devtools/front_end/CodeMirrorTextEditor.js
+++ b/Source/devtools/front_end/CodeMirrorTextEditor.js
@@ -46,6 +46,7 @@ importScript("cm/coffeescript.js");
importScript("cm/php.js");
importScript("cm/python.js");
importScript("cm/shell.js");
+importScript("CodeMirrorUtils.js");
/**
* @constructor
@@ -163,10 +164,6 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate)
this.element.addEventListener("keydown", this._handleKeyDown.bind(this), true);
this.element.tabIndex = 0;
- this._overrideModeWithPrefixedTokens("css-base", "css-");
- this._overrideModeWithPrefixedTokens("javascript", "js-");
- this._overrideModeWithPrefixedTokens("xml", "xml-");
-
this._setupSelectionColor();
this._setupWhitespaceHighlight();
}
@@ -453,17 +450,6 @@ WebInspector.CodeMirrorTextEditor.prototype = {
return this._toRange(coords, coords);
},
- _convertTokenType: function(tokenType)
- {
- if (tokenType.startsWith("js-variable") || tokenType.startsWith("js-property") || tokenType === "js-def")
- return "javascript-ident";
- if (tokenType === "js-string-2")
- return "javascript-regexp";
- if (tokenType === "js-number" || tokenType === "js-comment" || tokenType === "js-string" || tokenType === "js-keyword")
- return "javascript-" + tokenType.substring("js-".length);
- return null;
- },
-
/**
* @param {number} lineNumber
* @param {number} column
@@ -476,7 +462,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
var token = this._codeMirror.getTokenAt(new CodeMirror.Pos(lineNumber, (column || 0) + 1));
if (!token || !token.type)
return null;
- var convertedType = this._convertTokenType(token.type);
+ var convertedType = WebInspector.CodeMirrorUtils.convertTokenType(token.type);
if (!convertedType)
return null;
return {
@@ -557,38 +543,6 @@ WebInspector.CodeMirrorTextEditor.prototype = {
return modeName;
},
- /**
- * @param {string} modeName
- * @param {string} tokenPrefix
- */
- _overrideModeWithPrefixedTokens: function(modeName, tokenPrefix)
- {
- var oldModeName = modeName + "-old";
- if (CodeMirror.modes[oldModeName])
- return;
-
- CodeMirror.defineMode(oldModeName, CodeMirror.modes[modeName]);
- CodeMirror.defineMode(modeName, modeConstructor);
-
- function modeConstructor(config, parserConfig)
- {
- var innerConfig = {};
- for (var i in parserConfig)
- innerConfig[i] = parserConfig[i];
- innerConfig.name = oldModeName;
- var codeMirrorMode = CodeMirror.getMode(config, innerConfig);
- codeMirrorMode.name = modeName;
- codeMirrorMode.token = tokenOverride.bind(this, codeMirrorMode.token);
- return codeMirrorMode;
- }
-
- function tokenOverride(superToken, stream, state)
- {
- var token = superToken(stream, state);
- return token ? tokenPrefix + token : token;
- }
- },
-
_enableLongLinesMode: function()
{
this._codeMirror.setOption("styleSelectedText", false);
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Source/devtools/front_end/CodeMirrorUtils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698