aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/python
diff options
context:
space:
mode:
authorAnanya Sen2012-07-17 14:25:53 -0700
committerAnanya Sen2012-07-17 14:25:53 -0700
commit09457e39532e9b35afb9c635266755bfcb9b488a (patch)
tree665dcbd41377b98dcab15ff995e9434d9db1a462 /imports/codemirror/mode/python
parentf2dbca782bbaca3bed96dff808693693ba083ea9 (diff)
parent4f737b24c19ddc02d20f9783b8b080fc6ef11142 (diff)
downloadninja-09457e39532e9b35afb9c635266755bfcb9b488a.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into copy-paste-bugfix
Diffstat (limited to 'imports/codemirror/mode/python')
-rw-r--r--imports/codemirror/mode/python/python.js30
1 files changed, 14 insertions, 16 deletions
diff --git a/imports/codemirror/mode/python/python.js b/imports/codemirror/mode/python/python.js
index cfe8a774..d6888e8e 100644
--- a/imports/codemirror/mode/python/python.js
+++ b/imports/codemirror/mode/python/python.js
@@ -249,32 +249,30 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
249 249
250 // Handle '.' connected identifiers 250 // Handle '.' connected identifiers
251 if (current === '.') { 251 if (current === '.') {
252 style = state.tokenize(stream, state); 252 style = stream.match(identifiers, false) ? null : ERRORCLASS;
253 current = stream.current(); 253 if (style === null && state.lastToken === 'meta') {
254 if (style === 'variable' || style === 'builtin') { 254 // Apply 'meta' style to '.' connected identifiers when
255 return 'variable'; 255 // appropriate.
256 } else { 256 style = 'meta';
257 return ERRORCLASS;
258 } 257 }
258 return style;
259 } 259 }
260 260
261 // Handle decorators 261 // Handle decorators
262 if (current === '@') { 262 if (current === '@') {
263 style = state.tokenize(stream, state); 263 return stream.match(identifiers, false) ? 'meta' : ERRORCLASS;
264 current = stream.current(); 264 }
265 if (style === 'variable' 265
266 || current === '@staticmethod' 266 if ((style === 'variable' || style === 'builtin')
267 || current === '@classmethod') { 267 && state.lastToken === 'meta') {
268 return 'meta'; 268 style = 'meta';
269 } else {
270 return ERRORCLASS;
271 }
272 } 269 }
273 270
274 // Handle scope changes. 271 // Handle scope changes.
275 if (current === 'pass' || current === 'return') { 272 if (current === 'pass' || current === 'return') {
276 state.dedent += 1; 273 state.dedent += 1;
277 } 274 }
275 if (current === 'lambda') state.lambda = true;
278 if ((current === ':' && !state.lambda && state.scopes[0].type == 'py') 276 if ((current === ':' && !state.lambda && state.scopes[0].type == 'py')
279 || indentInfo === 'indent') { 277 || indentInfo === 'indent') {
280 indent(stream, state); 278 indent(stream, state);
@@ -316,7 +314,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
316 token: function(stream, state) { 314 token: function(stream, state) {
317 var style = tokenLexer(stream, state); 315 var style = tokenLexer(stream, state);
318 316
319 state.lastToken = {style:style, content: stream.current()}; 317 state.lastToken = style;
320 318
321 if (stream.eol() && stream.lambda) { 319 if (stream.eol() && stream.lambda) {
322 state.lambda = false; 320 state.lambda = false;