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

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

Issue 2772343006: DevTools: Roll CodeMirror to 5.25.1 (Closed)
Patch Set: stray space Created 3 years, 8 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);
11 })(function(CodeMirror) { 11 })(function(CodeMirror) {
12 "use strict"; 12 "use strict";
13 13
14 function Context(indented, column, type, info, align, prev) { 14 function Context(indented, column, type, info, align, prev) {
15 this.indented = indented; 15 this.indented = indented;
16 this.column = column; 16 this.column = column;
17 this.type = type; 17 this.type = type;
18 this.info = info; 18 this.info = info;
19 this.align = align; 19 this.align = align;
20 this.prev = prev; 20 this.prev = prev;
21 } 21 }
22 function pushContext(state, col, type, info) { 22 function pushContext(state, col, type, info) {
23 var indent = state.indented; 23 var indent = state.indented;
24 if (state.context && state.context.type != "statement" && type != "statement") 24 if (state.context && state.context.type == "statement" && type != "statement")
25 indent = state.context.indented; 25 indent = state.context.indented;
26 return state.context = new Context(indent, col, type, info, null, state.contex t); 26 return state.context = new Context(indent, col, type, info, null, state.contex t);
27 } 27 }
28 function popContext(state) { 28 function popContext(state) {
29 var t = state.context.type; 29 var t = state.context.type;
30 if (t == ")" || t == "]" || t == "}") 30 if (t == ")" || t == "]" || t == "}")
31 state.indented = state.context.indented; 31 state.indented = state.context.indented;
32 return state.context = state.context.prev; 32 return state.context = state.context.prev;
33 } 33 }
34 34
(...skipping 22 matching lines...) Expand all
57 defKeywords = parserConfig.defKeywords || {}, 57 defKeywords = parserConfig.defKeywords || {},
58 atoms = parserConfig.atoms || {}, 58 atoms = parserConfig.atoms || {},
59 hooks = parserConfig.hooks || {}, 59 hooks = parserConfig.hooks || {},
60 multiLineStrings = parserConfig.multiLineStrings, 60 multiLineStrings = parserConfig.multiLineStrings,
61 indentStatements = parserConfig.indentStatements !== false, 61 indentStatements = parserConfig.indentStatements !== false,
62 indentSwitch = parserConfig.indentSwitch !== false, 62 indentSwitch = parserConfig.indentSwitch !== false,
63 namespaceSeparator = parserConfig.namespaceSeparator, 63 namespaceSeparator = parserConfig.namespaceSeparator,
64 isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/ , 64 isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/ ,
65 numberStart = parserConfig.numberStart || /[\d\.]/, 65 numberStart = parserConfig.numberStart || /[\d\.]/,
66 number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+ )(?:e[-+]?\d+)?)(u|ll?|l|f)?/i, 66 number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+ )(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
67 isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/, 67 isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/;
68 endStatement = parserConfig.endStatement || /^[;:,]$/;
69 68
70 var curPunc, isDefKeyword; 69 var curPunc, isDefKeyword;
71 70
72 function tokenBase(stream, state) { 71 function tokenBase(stream, state) {
73 var ch = stream.next(); 72 var ch = stream.next();
74 if (hooks[ch]) { 73 if (hooks[ch]) {
75 var result = hooks[ch](stream, state); 74 var result = hooks[ch](stream, state);
76 if (result !== false) return result; 75 if (result !== false) return result;
77 } 76 }
78 if (ch == '"' || ch == "'") { 77 if (ch == '"' || ch == "'") {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (ctx.align == null) ctx.align = false; 169 if (ctx.align == null) ctx.align = false;
171 state.indented = stream.indentation(); 170 state.indented = stream.indentation();
172 state.startOfLine = true; 171 state.startOfLine = true;
173 } 172 }
174 if (stream.eatSpace()) { maybeEOL(stream, state); return null; } 173 if (stream.eatSpace()) { maybeEOL(stream, state); return null; }
175 curPunc = isDefKeyword = null; 174 curPunc = isDefKeyword = null;
176 var style = (state.tokenize || tokenBase)(stream, state); 175 var style = (state.tokenize || tokenBase)(stream, state);
177 if (style == "comment" || style == "meta") return style; 176 if (style == "comment" || style == "meta") return style;
178 if (ctx.align == null) ctx.align = true; 177 if (ctx.align == null) ctx.align = true;
179 178
180 if (endStatement.test(curPunc)) while (state.context.type == "statement") popContext(state); 179 if (curPunc == ";" || curPunc == ":" || (curPunc == "," && stream.match(/^ \s*(?:\/\/.*)?$/, false)))
180 while (state.context.type == "statement") popContext(state);
181 else if (curPunc == "{") pushContext(state, stream.column(), "}"); 181 else if (curPunc == "{") pushContext(state, stream.column(), "}");
182 else if (curPunc == "[") pushContext(state, stream.column(), "]"); 182 else if (curPunc == "[") pushContext(state, stream.column(), "]");
183 else if (curPunc == "(") pushContext(state, stream.column(), ")"); 183 else if (curPunc == "(") pushContext(state, stream.column(), ")");
184 else if (curPunc == "}") { 184 else if (curPunc == "}") {
185 while (ctx.type == "statement") ctx = popContext(state); 185 while (ctx.type == "statement") ctx = popContext(state);
186 if (ctx.type == "}") ctx = popContext(state); 186 if (ctx.type == "}") ctx = popContext(state);
187 while (ctx.type == "statement") ctx = popContext(state); 187 while (ctx.type == "statement") ctx = popContext(state);
188 } 188 }
189 else if (curPunc == ctx.type) popContext(state); 189 else if (curPunc == ctx.type) popContext(state);
190 else if (indentStatements && 190 else if (indentStatements &&
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 namespaceSeparator: "::", 418 namespaceSeparator: "::",
419 modeProps: {fold: ["brace", "include"]} 419 modeProps: {fold: ["brace", "include"]}
420 }); 420 });
421 421
422 def("text/x-java", { 422 def("text/x-java", {
423 name: "clike", 423 name: "clike",
424 keywords: words("abstract assert break case catch class const continue defau lt " + 424 keywords: words("abstract assert break case catch class const continue defau lt " +
425 "do else enum extends final finally float for goto if implem ents import " + 425 "do else enum extends final finally float for goto if implem ents import " +
426 "instanceof interface native new package private protected p ublic " + 426 "instanceof interface native new package private protected p ublic " +
427 "return static strictfp super switch synchronized this throw throws transient " + 427 "return static strictfp super switch synchronized this throw throws transient " +
428 "try volatile while"), 428 "try volatile while @interface"),
429 types: words("byte short int long float double boolean char void Boolean Byt e Character Double Float " + 429 types: words("byte short int long float double boolean char void Boolean Byt e Character Double Float " +
430 "Integer Long Number Object Short String StringBuffer StringBui lder Void"), 430 "Integer Long Number Object Short String StringBuffer StringBui lder Void"),
431 blockKeywords: words("catch class do else finally for if switch try while"), 431 blockKeywords: words("catch class do else finally for if switch try while"),
432 defKeywords: words("class interface package enum"), 432 defKeywords: words("class interface package enum @interface"),
433 typeFirstDefinitions: true, 433 typeFirstDefinitions: true,
434 atoms: words("true false null"), 434 atoms: words("true false null"),
435 endStatement: /^[;:]$/,
436 number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u |ll?|l|f)?/i, 435 number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u |ll?|l|f)?/i,
437 hooks: { 436 hooks: {
438 "@": function(stream) { 437 "@": function(stream) {
438 // Don't match the @interface keyword.
439 if (stream.match('interface', false)) return false;
440
439 stream.eatWhile(/[\w\$_]/); 441 stream.eatWhile(/[\w\$_]/);
440 return "meta"; 442 return "meta";
441 } 443 }
442 }, 444 },
443 modeProps: {fold: ["brace", "import"]} 445 modeProps: {fold: ["brace", "import"]}
444 }); 446 });
445 447
446 def("text/x-csharp", { 448 def("text/x-csharp", {
447 name: "clike", 449 name: "clike",
448 keywords: words("abstract as async await base break case catch checked class const continue" + 450 keywords: words("abstract as async await base break case catch checked class const continue" +
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return "string"; 486 return "string";
485 } 487 }
486 488
487 def("text/x-scala", { 489 def("text/x-scala", {
488 name: "clike", 490 name: "clike",
489 keywords: words( 491 keywords: words(
490 492
491 /* scala */ 493 /* scala */
492 "abstract case catch class def do else extends final finally for forSome i f " + 494 "abstract case catch class def do else extends final finally for forSome i f " +
493 "implicit import lazy match new null object override package private prote cted return " + 495 "implicit import lazy match new null object override package private prote cted return " +
494 "sealed super this throw trait try type val var while with yield _ : = => <- <: " + 496 "sealed super this throw trait try type val var while with yield _ " +
495 "<% >: # @ " +
496 497
497 /* package scala */ 498 /* package scala */
498 "assert assume require print println printf readLine readBoolean readByte readShort " + 499 "assert assume require print println printf readLine readBoolean readByte readShort " +
499 "readChar readInt readLong readFloat readDouble " + 500 "readChar readInt readLong readFloat readDouble"
500
501 ":: #:: "
502 ), 501 ),
503 types: words( 502 types: words(
504 "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Cons ole Either " + 503 "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Cons ole Either " +
505 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Inte gral Iterable " + 504 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Inte gral Iterable " +
506 "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunc tion PartialOrdering " + 505 "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunc tion PartialOrdering " +
507 "Product Proxy Range Responder Seq Serializable Set Specializable Stream S tringBuilder " + 506 "Product Proxy Range Responder Seq Serializable Set Specializable Stream S tringBuilder " +
508 "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vec tor " + 507 "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vec tor " +
509 508
510 /* package java.lang */ 509 /* package java.lang */
511 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparabl e " + 510 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparabl e " +
512 "Compiler Double Exception Float Integer Long Math Number Object Package P air Process " + 511 "Compiler Double Exception Float Integer Long Math Number Object Package P air Process " +
513 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath Strin g " + 512 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath Strin g " +
514 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" 513 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
515 ), 514 ),
516 multiLineStrings: true, 515 multiLineStrings: true,
517 blockKeywords: words("catch class do else finally for forSome if match switc h try while"), 516 blockKeywords: words("catch class do else finally for forSome if match switc h try while"),
518 defKeywords: words("class def object package trait type val var"), 517 defKeywords: words("class def object package trait type val var"),
519 atoms: words("true false null"), 518 atoms: words("true false null"),
520 indentStatements: false, 519 indentStatements: false,
521 indentSwitch: false, 520 indentSwitch: false,
521 isOperatorChar: /[+\-*&%=<>!?|\/#:@]/,
522 hooks: { 522 hooks: {
523 "@": function(stream) { 523 "@": function(stream) {
524 stream.eatWhile(/[\w\$_]/); 524 stream.eatWhile(/[\w\$_]/);
525 return "meta"; 525 return "meta";
526 }, 526 },
527 '"': function(stream, state) { 527 '"': function(stream, state) {
528 if (!stream.match('""')) return false; 528 if (!stream.match('""')) return false;
529 state.tokenize = tokenTripleString; 529 state.tokenize = tokenTripleString;
530 return state.tokenize(stream, state); 530 return state.tokenize(stream, state);
531 }, 531 },
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 keywords: words( 568 keywords: words(
569 /*keywords*/ 569 /*keywords*/
570 "package as typealias class interface this super val " + 570 "package as typealias class interface this super val " +
571 "var fun for is in This throw return " + 571 "var fun for is in This throw return " +
572 "break continue object if else while do try when !in !is as? " + 572 "break continue object if else while do try when !in !is as? " +
573 573
574 /*soft keywords*/ 574 /*soft keywords*/
575 "file import where by get set abstract enum open inner override private pu blic internal " + 575 "file import where by get set abstract enum open inner override private pu blic internal " +
576 "protected catch finally out final vararg reified dynamic companion constr uctor init " + 576 "protected catch finally out final vararg reified dynamic companion constr uctor init " +
577 "sealed field property receiver param sparam lateinit data inline noinline tailrec " + 577 "sealed field property receiver param sparam lateinit data inline noinline tailrec " +
578 "external annotation crossinline const operator infix" 578 "external annotation crossinline const operator infix suspend"
579 ), 579 ),
580 types: words( 580 types: words(
581 /* package java.lang */ 581 /* package java.lang */
582 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparabl e " + 582 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparabl e " +
583 "Compiler Double Exception Float Integer Long Math Number Object Package P air Process " + 583 "Compiler Double Exception Float Integer Long Math Number Object Package P air Process " +
584 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath Strin g " + 584 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath Strin g " +
585 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" 585 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
586 ), 586 ),
587 intendSwitch: false, 587 intendSwitch: false,
588 indentStatements: false, 588 indentStatements: false,
589 multiLineStrings: true, 589 multiLineStrings: true,
590 number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u |ll?|l|f)?/i,
590 blockKeywords: words("catch class do else finally for if where try while enu m"), 591 blockKeywords: words("catch class do else finally for if where try while enu m"),
591 defKeywords: words("class val var object package interface fun"), 592 defKeywords: words("class val var object package interface fun"),
592 atoms: words("true false null this"), 593 atoms: words("true false null this"),
593 hooks: { 594 hooks: {
594 '"': function(stream, state) { 595 '"': function(stream, state) {
595 state.tokenize = tokenKotlinString(stream.match('""')); 596 state.tokenize = tokenKotlinString(stream.match('""'));
596 return state.tokenize(stream, state); 597 return state.tokenize(stream, state);
597 } 598 }
598 }, 599 },
599 modeProps: {closeBrackets: {triples: '"'}} 600 modeProps: {closeBrackets: {triples: '"'}}
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 778 }
778 } 779 }
779 }, 780 },
780 modeProps: { 781 modeProps: {
781 fold: ["brace", "import"], 782 fold: ["brace", "import"],
782 closeBrackets: {triples: '"'} 783 closeBrackets: {triples: '"'}
783 } 784 }
784 }); 785 });
785 786
786 }); 787 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698