| 776 |
lars |
1 |
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
|
2 |
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
|
3 |
|
|
|
4 |
(function(mod) {
|
|
|
5 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
|
6 |
mod(require("../../lib/codemirror"), require("../clike/clike"));
|
|
|
7 |
else if (typeof define == "function" && define.amd) // AMD
|
|
|
8 |
define(["../../lib/codemirror", "../clike/clike"], mod);
|
|
|
9 |
else // Plain browser env
|
|
|
10 |
mod(CodeMirror);
|
|
|
11 |
})(function(CodeMirror) {
|
|
|
12 |
"use strict";
|
|
|
13 |
|
|
|
14 |
var keywords = ("this super static final const abstract class extends external factory " +
|
|
|
15 |
"implements get native operator set typedef with enum throw rethrow " +
|
|
|
16 |
"assert break case continue default in return new deferred async await " +
|
|
|
17 |
"try catch finally do else for if switch while import library export " +
|
|
|
18 |
"part of show hide is").split(" ");
|
|
|
19 |
var blockKeywords = "try catch finally do else for if switch while".split(" ");
|
|
|
20 |
var atoms = "true false null".split(" ");
|
|
|
21 |
var builtins = "void bool num int double dynamic var String".split(" ");
|
|
|
22 |
|
|
|
23 |
function set(words) {
|
|
|
24 |
var obj = {};
|
|
|
25 |
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
|
|
26 |
return obj;
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
CodeMirror.defineMIME("application/dart", {
|
|
|
30 |
name: "clike",
|
|
|
31 |
keywords: set(keywords),
|
|
|
32 |
multiLineStrings: true,
|
|
|
33 |
blockKeywords: set(blockKeywords),
|
|
|
34 |
builtin: set(builtins),
|
|
|
35 |
atoms: set(atoms),
|
|
|
36 |
hooks: {
|
|
|
37 |
"@": function(stream) {
|
|
|
38 |
stream.eatWhile(/[\w\$_]/);
|
|
|
39 |
return "meta";
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
});
|
|
|
43 |
|
|
|
44 |
CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
|
|
|
45 |
|
|
|
46 |
// This is needed to make loading through meta.js work.
|
|
|
47 |
CodeMirror.defineMode("dart", function(conf) {
|
|
|
48 |
return CodeMirror.getMode(conf, "application/dart");
|
|
|
49 |
}, "clike");
|
|
|
50 |
});
|