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

Side by Side Diff: Source/devtools/front_end/cm/coffeescript.js

Issue 354833004: DevTools: [CodeMirror] roll CodeMirror to version @e20d175 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/cm/codemirror.js ('k') | Source/devtools/front_end/cm/comment.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3
1 /** 4 /**
2 * Link to the project's GitHub page: 5 * Link to the project's GitHub page:
3 * https://github.com/pickhardt/coffeescript-codemirror-mode 6 * https://github.com/pickhardt/coffeescript-codemirror-mode
4 */ 7 */
8 (function(mod) {
9 if (typeof exports == "object" && typeof module == "object") // CommonJS
10 mod(require("../../lib/codemirror"));
11 else if (typeof define == "function" && define.amd) // AMD
12 define(["../../lib/codemirror"], mod);
13 else // Plain browser env
14 mod(CodeMirror);
15 })(function(CodeMirror) {
16 "use strict";
17
5 CodeMirror.defineMode("coffeescript", function(conf) { 18 CodeMirror.defineMode("coffeescript", function(conf) {
6 var ERRORCLASS = "error"; 19 var ERRORCLASS = "error";
7 20
8 function wordRegexp(words) { 21 function wordRegexp(words) {
9 return new RegExp("^((" + words.join(")|(") + "))\\b"); 22 return new RegExp("^((" + words.join(")|(") + "))\\b");
10 } 23 }
11 24
12 var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>> ?=?|%=?|&=?|\|=?|\^=?|\~|!|\?)/; 25 var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>> ?=?|%=?|&=?|\|=?|\^=?|\~|!|\?)/;
13 var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/; 26 var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
14 var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/; 27 var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (stream.match(/^-?0(?![\dx])/i)) { 125 if (stream.match(/^-?0(?![\dx])/i)) {
113 intLiteral = true; 126 intLiteral = true;
114 } 127 }
115 if (intLiteral) { 128 if (intLiteral) {
116 return "number"; 129 return "number";
117 } 130 }
118 } 131 }
119 132
120 // Handle strings 133 // Handle strings
121 if (stream.match(stringPrefixes)) { 134 if (stream.match(stringPrefixes)) {
122 state.tokenize = tokenFactory(stream.current(), "string"); 135 state.tokenize = tokenFactory(stream.current(), false, "string");
123 return state.tokenize(stream, state); 136 return state.tokenize(stream, state);
124 } 137 }
125 // Handle regex literals 138 // Handle regex literals
126 if (stream.match(regexPrefixes)) { 139 if (stream.match(regexPrefixes)) {
127 if (stream.current() != "/" || stream.match(/^.*\//, false)) { // prevent highlight of division 140 if (stream.current() != "/" || stream.match(/^.*\//, false)) { // prevent highlight of division
128 state.tokenize = tokenFactory(stream.current(), "string-2"); 141 state.tokenize = tokenFactory(stream.current(), true, "string-2");
129 return state.tokenize(stream, state); 142 return state.tokenize(stream, state);
130 } else { 143 } else {
131 stream.backUp(1); 144 stream.backUp(1);
132 } 145 }
133 } 146 }
134 147
135 // Handle operators and delimiters 148 // Handle operators and delimiters
136 if (stream.match(operators) || stream.match(wordOperators)) { 149 if (stream.match(operators) || stream.match(wordOperators)) {
137 return "operator"; 150 return "operator";
138 } 151 }
(...skipping 15 matching lines...) Expand all
154 167
155 if (stream.match(properties)) { 168 if (stream.match(properties)) {
156 return "property"; 169 return "property";
157 } 170 }
158 171
159 // Handle non-detected items 172 // Handle non-detected items
160 stream.next(); 173 stream.next();
161 return ERRORCLASS; 174 return ERRORCLASS;
162 } 175 }
163 176
164 function tokenFactory(delimiter, outclass) { 177 function tokenFactory(delimiter, singleline, outclass) {
165 var singleline = delimiter.length == 1;
166 return function(stream, state) { 178 return function(stream, state) {
167 while (!stream.eol()) { 179 while (!stream.eol()) {
168 stream.eatWhile(/[^'"\/\\]/); 180 stream.eatWhile(/[^'"\/\\]/);
169 if (stream.eat("\\")) { 181 if (stream.eat("\\")) {
170 stream.next(); 182 stream.next();
171 if (singleline && stream.eol()) { 183 if (singleline && stream.eol()) {
172 return outclass; 184 return outclass;
173 } 185 }
174 } else if (stream.match(delimiter)) { 186 } else if (stream.match(delimiter)) {
175 state.tokenize = tokenBase; 187 state.tokenize = tokenBase;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 return (closes ? scope.prev : scope).offset; 357 return (closes ? scope.prev : scope).offset;
346 }, 358 },
347 359
348 lineComment: "#", 360 lineComment: "#",
349 fold: "indent" 361 fold: "indent"
350 }; 362 };
351 return external; 363 return external;
352 }); 364 });
353 365
354 CodeMirror.defineMIME("text/x-coffeescript", "coffeescript"); 366 CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
367
368 });
OLDNEW
« no previous file with comments | « Source/devtools/front_end/cm/codemirror.js ('k') | Source/devtools/front_end/cm/comment.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698