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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/cm_modes/shell.js

Issue 2862603003: Revert of DevTools: Roll CodeMirror to 5.25.1
Patch Set: Created 3 years, 7 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
OLDNEW
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE 2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3 3
4 (function(mod) { 4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS 5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror")); 6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD 7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod); 8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env 9 else // Plain browser env
10 mod(CodeMirror); 10 mod(CodeMirror);
(...skipping 28 matching lines...) Expand all
39 if (stream.eatSpace()) return null; 39 if (stream.eatSpace()) return null;
40 40
41 var sol = stream.sol(); 41 var sol = stream.sol();
42 var ch = stream.next(); 42 var ch = stream.next();
43 43
44 if (ch === '\\') { 44 if (ch === '\\') {
45 stream.next(); 45 stream.next();
46 return null; 46 return null;
47 } 47 }
48 if (ch === '\'' || ch === '"' || ch === '`') { 48 if (ch === '\'' || ch === '"' || ch === '`') {
49 state.tokens.unshift(tokenString(ch, ch === "`" ? "quote" : "string")); 49 state.tokens.unshift(tokenString(ch));
50 return tokenize(stream, state); 50 return tokenize(stream, state);
51 } 51 }
52 if (ch === '#') { 52 if (ch === '#') {
53 if (sol && stream.eat('!')) { 53 if (sol && stream.eat('!')) {
54 stream.skipToEnd(); 54 stream.skipToEnd();
55 return 'meta'; // 'comment'? 55 return 'meta'; // 'comment'?
56 } 56 }
57 stream.skipToEnd(); 57 stream.skipToEnd();
58 return 'comment'; 58 return 'comment';
59 } 59 }
(...skipping 14 matching lines...) Expand all
74 if(stream.eol() || !/\w/.test(stream.peek())) { 74 if(stream.eol() || !/\w/.test(stream.peek())) {
75 return 'number'; 75 return 'number';
76 } 76 }
77 } 77 }
78 stream.eatWhile(/[\w-]/); 78 stream.eatWhile(/[\w-]/);
79 var cur = stream.current(); 79 var cur = stream.current();
80 if (stream.peek() === '=' && /\w+/.test(cur)) return 'def'; 80 if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
81 return words.hasOwnProperty(cur) ? words[cur] : null; 81 return words.hasOwnProperty(cur) ? words[cur] : null;
82 } 82 }
83 83
84 function tokenString(quote, style) { 84 function tokenString(quote) {
85 var close = quote == "(" ? ")" : quote
86 return function(stream, state) { 85 return function(stream, state) {
87 var next, end = false, escaped = false; 86 var next, end = false, escaped = false;
88 while ((next = stream.next()) != null) { 87 while ((next = stream.next()) != null) {
89 if (next === close && !escaped) { 88 if (next === quote && !escaped) {
90 end = true; 89 end = true;
91 break; 90 break;
92 } 91 }
93 if (next === '$' && !escaped && quote !== "'") { 92 if (next === '$' && !escaped && quote !== '\'') {
94 escaped = true; 93 escaped = true;
95 stream.backUp(1); 94 stream.backUp(1);
96 state.tokens.unshift(tokenDollar); 95 state.tokens.unshift(tokenDollar);
97 break; 96 break;
98 } 97 }
99 if (!escaped && next === "(" && quote === "(") {
100 state.tokens.unshift(tokenString(quote, style))
101 return tokenize(stream, state)
102 }
103 escaped = !escaped && next === '\\'; 98 escaped = !escaped && next === '\\';
104 } 99 }
105 if (end || !escaped) state.tokens.shift(); 100 if (end || !escaped) {
106 return style; 101 state.tokens.shift();
102 }
103 return (quote === '`' || quote === ')' ? 'quote' : 'string');
107 }; 104 };
108 }; 105 };
109 106
110 var tokenDollar = function(stream, state) { 107 var tokenDollar = function(stream, state) {
111 if (state.tokens.length > 1) stream.eat('$'); 108 if (state.tokens.length > 1) stream.eat('$');
112 var ch = stream.next(), hungry = /\w/; 109 var ch = stream.next(), hungry = /\w/;
113 if (ch === '{') hungry = /[^}]/; 110 if (ch === '{') hungry = /[^}]/;
114 if (/['"(]/.test(ch)) { 111 if (ch === '(') {
115 state.tokens[0] = tokenString(ch, ch == "(" ? "quote" : "string"); 112 state.tokens[0] = tokenString(')');
116 return tokenize(stream, state); 113 return tokenize(stream, state);
117 } 114 }
118 if (!/\d/.test(ch)) { 115 if (!/\d/.test(ch)) {
119 stream.eatWhile(hungry); 116 stream.eatWhile(hungry);
120 stream.eat('}'); 117 stream.eat('}');
121 } 118 }
122 state.tokens.shift(); 119 state.tokens.shift();
123 return 'def'; 120 return 'def';
124 }; 121 };
125 122
126 function tokenize(stream, state) { 123 function tokenize(stream, state) {
127 return (state.tokens[0] || tokenBase) (stream, state); 124 return (state.tokens[0] || tokenBase) (stream, state);
128 }; 125 };
129 126
130 return { 127 return {
131 startState: function() {return {tokens:[]};}, 128 startState: function() {return {tokens:[]};},
132 token: function(stream, state) { 129 token: function(stream, state) {
133 return tokenize(stream, state); 130 return tokenize(stream, state);
134 }, 131 },
135 closeBrackets: "()[]{}''\"\"``",
136 lineComment: '#', 132 lineComment: '#',
137 fold: "brace" 133 fold: "brace"
138 }; 134 };
139 }); 135 });
140 136
141 CodeMirror.defineMIME('text/x-sh', 'shell'); 137 CodeMirror.defineMIME('text/x-sh', 'shell');
142 138
143 }); 139 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698