3 lines
2.6 KiB
JavaScript
3 lines
2.6 KiB
JavaScript
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../clike/clike")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../clike/clike"],e):e(CodeMirror)})(function(e){function d(b){for(var a={},c=0;c<b.length;++c)a[b[c]]=!0;return a}function f(b,a,c,e){function d(a,c){for(var d=!1;!a.eol();){if(!e&&!d&&"$"==a.peek()){a=c;(a.interpolationStack||(a.interpolationStack=[])).push(a.tokenize);c.tokenize=n;break}var h=a.next();if(h==b&&!d&&(!f||a.match(b+b))){c.tokenize=null;break}d=!e&&!d&&"\\"==h}return"string"}var f=!1;if(a.eat(b))if(a.eat(b))f=!0;else return"string";c.tokenize=d;return d(a,c)}function n(b,a){b.eat("$");b.eat("{")?a.tokenize=null:a.tokenize=p;return null}function p(b,a){b.eatWhile(/[\w_]/);a.tokenize=(a.interpolationStack||(a.interpolationStack=[])).pop();return"variable"}function g(b){return function(a,c){for(var d;d=a.next();)if("*"==d&&a.eat("/"))if(1==b){c.tokenize=null;break}else return c.tokenize=g(b-1),c.tokenize(a,c);else if("/"==d&&a.eat("*"))return c.tokenize=g(b+1),c.tokenize(a,c);return"comment"}}var k="this super static final const abstract class extends external factory implements mixin get native set typedef with enum throw rethrow assert break case continue default in return new deferred async await covariant try catch finally do else for if switch while import library export part of show hide is as extension on yield late required sealed base interface when".split(" "),l=["true","false","null"],m="void bool num int double dynamic var String Null Never".split(" ");e.defineMIME("application/dart",{name:"clike",keywords:d(k),blockKeywords:d("try catch finally do else for if switch while".split(" ")),builtin:d(m),atoms:d(l),number:/^(?:0x[a-f\d_]+|(?:[\d_]+\.?[\d_]*|\.[\d_]+)(?:e[-+]?[\d_]+)?)/i,hooks:{"@":function(b){b.eatWhile(/[\w\$_\.]/);return"meta"},"'":function(b,a){return f("'",b,a,!1)},'"':function(b,a){return f('"',b,a,!1)},r:function(b,a){var c=b.peek();return"'"==c||'"'==c?f(b.next(),b,a,!0):!1},"}":function(b,a){return 0<(a.interpolationStack?a.interpolationStack.length:0)?(a.tokenize=(a.interpolationStack||(a.interpolationStack=[])).pop(),null):!1},"/":function(b,a){if(!b.eat("*"))return!1;a.tokenize=g(1);return a.tokenize(b,a)},token:function(b,a,c){if("variable"==c&&/^[_$]*[A-Z][a-zA-Z0-9_$]*$/g.test(b.current()))return"variable-2"}}});e.registerHelper("hintWords","application/dart",k.concat(l).concat(m));e.defineMode("dart",function(b){return e.getMode(b,"application/dart")},"clike")}); |