dart.js 1.8 KB

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