a3364b0ae17abf3b8dc45ac0fc88138f.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. ace.define("ace/mode/clojure_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var ClojureHighlightRules = function () {
  5. var builtinFunctions = ('* *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* ' +
  6. '*command-line-args* *compile-files* *compile-path* *e *err* *file* ' +
  7. '*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' +
  8. '*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' +
  9. '*read-eval* *source-path* *use-context-classloader* ' +
  10. '*warn-on-reflection* + - -> ->> .. / < <= = ' +
  11. '== > &gt; >= &gt;= accessor aclone ' +
  12. 'add-classpath add-watch agent agent-errors aget alength alias all-ns ' +
  13. 'alter alter-meta! alter-var-root amap ancestors and apply areduce ' +
  14. 'array-map aset aset-boolean aset-byte aset-char aset-double aset-float ' +
  15. 'aset-int aset-long aset-short assert assoc assoc! assoc-in associative? ' +
  16. 'atom await await-for await1 bases bean bigdec bigint binding bit-and ' +
  17. 'bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left ' +
  18. 'bit-shift-right bit-test bit-xor boolean boolean-array booleans ' +
  19. 'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' +
  20. 'char-escape-string char-name-string char? chars chunk chunk-append ' +
  21. 'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' +
  22. 'class class? clear-agent-errors clojure-version coll? comment commute ' +
  23. 'comp comparator compare compare-and-set! compile complement concat cond ' +
  24. 'condp conj conj! cons constantly construct-proxy contains? count ' +
  25. 'counted? create-ns create-struct cycle dec decimal? declare definline ' +
  26. 'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' +
  27. 'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' +
  28. 'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' +
  29. 'double-array doubles drop drop-last drop-while empty empty? ensure ' +
  30. 'enumeration-seq eval even? every? false? ffirst file-seq filter find ' +
  31. 'find-doc find-ns find-var first float float-array float? floats flush ' +
  32. 'fn fn? fnext for force format future future-call future-cancel ' +
  33. 'future-cancelled? future-done? future? gen-class gen-interface gensym ' +
  34. 'get get-in get-method get-proxy-class get-thread-bindings get-validator ' +
  35. 'hash hash-map hash-set identical? identity if-let if-not ifn? import ' +
  36. 'in-ns inc init-proxy instance? int int-array integer? interleave intern ' +
  37. 'interpose into into-array ints io! isa? iterate iterator-seq juxt key ' +
  38. 'keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list ' +
  39. 'list* list? load load-file load-reader load-string loaded-libs locking ' +
  40. 'long long-array longs loop macroexpand macroexpand-1 make-array ' +
  41. 'make-hierarchy map map? mapcat max max-key memfn memoize merge ' +
  42. 'merge-with meta method-sig methods min min-key mod name namespace neg? ' +
  43. 'newline next nfirst nil? nnext not not-any? not-empty not-every? not= ' +
  44. 'ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ' +
  45. 'ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? ' +
  46. 'or parents partial partition pcalls peek persistent! pmap pop pop! ' +
  47. 'pop-thread-bindings pos? pr pr-str prefer-method prefers ' +
  48. 'primitives-classnames print print-ctor print-doc print-dup print-method ' +
  49. 'print-namespace-doc print-simple print-special-doc print-str printf ' +
  50. 'println println-str prn prn-str promise proxy proxy-call-with-super ' +
  51. 'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' +
  52. 'rand rand-int range ratio? rational? rationalize re-find re-groups ' +
  53. 're-matcher re-matches re-pattern re-seq read read-line read-string ' +
  54. 'reduce ref ref-history-count ref-max-history ref-min-history ref-set ' +
  55. 'refer refer-clojure release-pending-sends rem remove remove-method ' +
  56. 'remove-ns remove-watch repeat repeatedly replace replicate require ' +
  57. 'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' +
  58. 'rsubseq second select-keys send send-off seq seq? seque sequence ' +
  59. 'sequential? set set-validator! set? short short-array shorts ' +
  60. 'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' +
  61. 'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' +
  62. 'split-at split-with str stream? string? struct struct-map subs subseq ' +
  63. 'subvec supers swap! symbol symbol? sync syntax-symbol-anchor take ' +
  64. 'take-last take-nth take-while test the-ns time to-array to-array-2d ' +
  65. 'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' +
  66. 'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' +
  67. 'unchecked-remainder unchecked-subtract underive unquote ' +
  68. 'unquote-splicing update-in update-proxy use val vals var-get var-set ' +
  69. 'var? vary-meta vec vector vector? when when-first when-let when-not ' +
  70. 'while with-bindings with-bindings* with-in-str with-loading-context ' +
  71. 'with-local-vars with-meta with-open with-out-str with-precision xml-seq ' +
  72. 'zero? zipmap');
  73. var keywords = ('throw try var ' +
  74. 'def do fn if let loop monitor-enter monitor-exit new quote recur set!');
  75. var buildinConstants = ("true false nil");
  76. var keywordMapper = this.createKeywordMapper({
  77. "keyword": keywords,
  78. "constant.language": buildinConstants,
  79. "support.function": builtinFunctions
  80. }, "identifier", false, " ");
  81. this.$rules = {
  82. "start": [
  83. {
  84. token: "comment",
  85. regex: ";.*$"
  86. }, {
  87. token: "keyword",
  88. regex: "[\\(|\\)]"
  89. }, {
  90. token: "keyword",
  91. regex: "[\\'\\(]"
  92. }, {
  93. token: "keyword",
  94. regex: "[\\[|\\]]"
  95. }, {
  96. token: "keyword",
  97. regex: "[\\{|\\}|\\#\\{|\\#\\}]"
  98. }, {
  99. token: "keyword",
  100. regex: '[\\&]'
  101. }, {
  102. token: "keyword",
  103. regex: '[\\#\\^\\{]'
  104. }, {
  105. token: "keyword",
  106. regex: '[\\%]'
  107. }, {
  108. token: "keyword",
  109. regex: '[@]'
  110. }, {
  111. token: "constant.numeric",
  112. regex: "0[xX][0-9a-fA-F]+\\b"
  113. }, {
  114. token: "constant.numeric",
  115. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  116. }, {
  117. token: "constant.language",
  118. regex: '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]'
  119. }, {
  120. token: keywordMapper,
  121. regex: "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"
  122. }, {
  123. token: "string",
  124. regex: '"',
  125. next: "string"
  126. }, {
  127. token: "constant",
  128. regex: /:[^()\[\]{}'"\^%`,;\s]+/
  129. }, {
  130. token: "string.regexp",
  131. regex: '/#"(?:\\.|(?:\\")|[^""\n])*"/g'
  132. }
  133. ],
  134. "string": [
  135. {
  136. token: "constant.language.escape",
  137. regex: "\\\\.|\\\\$"
  138. }, {
  139. token: "string",
  140. regex: '[^"\\\\]+'
  141. }, {
  142. token: "string",
  143. regex: '"',
  144. next: "start"
  145. }
  146. ]
  147. };
  148. };
  149. oop.inherits(ClojureHighlightRules, TextHighlightRules);
  150. exports.ClojureHighlightRules = ClojureHighlightRules;
  151. });
  152. ace.define("ace/mode/matching_parens_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  153. var Range = require("../range").Range;
  154. var MatchingParensOutdent = function () { };
  155. (function () {
  156. this.checkOutdent = function (line, input) {
  157. if (!/^\s+$/.test(line))
  158. return false;
  159. return /^\s*\)/.test(input);
  160. };
  161. this.autoOutdent = function (doc, row) {
  162. var line = doc.getLine(row);
  163. var match = line.match(/^(\s*\))/);
  164. if (!match)
  165. return 0;
  166. var column = match[1].length;
  167. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  168. if (!openBracePos || openBracePos.row == row)
  169. return 0;
  170. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  171. doc.replace(new Range(row, 0, row, column - 1), indent);
  172. };
  173. this.$getIndent = function (line) {
  174. var match = line.match(/^(\s+)/);
  175. if (match) {
  176. return match[1];
  177. }
  178. return "";
  179. };
  180. }).call(MatchingParensOutdent.prototype);
  181. exports.MatchingParensOutdent = MatchingParensOutdent;
  182. });
  183. ace.define("ace/mode/clojure",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/clojure_highlight_rules","ace/mode/matching_parens_outdent"], function(require, exports, module){"use strict";
  184. var oop = require("../lib/oop");
  185. var TextMode = require("./text").Mode;
  186. var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules;
  187. var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent;
  188. var Mode = function () {
  189. this.HighlightRules = ClojureHighlightRules;
  190. this.$outdent = new MatchingParensOutdent();
  191. this.$behaviour = this.$defaultBehaviour;
  192. };
  193. oop.inherits(Mode, TextMode);
  194. (function () {
  195. this.lineCommentStart = ";";
  196. this.minorIndentFunctions = ["defn", "defn-", "defmacro", "def", "deftest", "testing"];
  197. this.$toIndent = function (str) {
  198. return str.split('').map(function (ch) {
  199. if (/\s/.exec(ch)) {
  200. return ch;
  201. }
  202. else {
  203. return ' ';
  204. }
  205. }).join('');
  206. };
  207. this.$calculateIndent = function (line, tab) {
  208. var baseIndent = this.$getIndent(line);
  209. var delta = 0;
  210. var isParen, ch;
  211. for (var i = line.length - 1; i >= 0; i--) {
  212. ch = line[i];
  213. if (ch === '(') {
  214. delta--;
  215. isParen = true;
  216. }
  217. else if (ch === '(' || ch === '[' || ch === '{') {
  218. delta--;
  219. isParen = false;
  220. }
  221. else if (ch === ')' || ch === ']' || ch === '}') {
  222. delta++;
  223. }
  224. if (delta < 0) {
  225. break;
  226. }
  227. }
  228. if (delta < 0 && isParen) {
  229. i += 1;
  230. var iBefore = i;
  231. var fn = '';
  232. while (true) {
  233. ch = line[i];
  234. if (ch === ' ' || ch === '\t') {
  235. if (this.minorIndentFunctions.indexOf(fn) !== -1) {
  236. return this.$toIndent(line.substring(0, iBefore - 1) + tab);
  237. }
  238. else {
  239. return this.$toIndent(line.substring(0, i + 1));
  240. }
  241. }
  242. else if (ch === undefined) {
  243. return this.$toIndent(line.substring(0, iBefore - 1) + tab);
  244. }
  245. fn += line[i];
  246. i++;
  247. }
  248. }
  249. else if (delta < 0 && !isParen) {
  250. return this.$toIndent(line.substring(0, i + 1));
  251. }
  252. else if (delta > 0) {
  253. baseIndent = baseIndent.substring(0, baseIndent.length - tab.length);
  254. return baseIndent;
  255. }
  256. else {
  257. return baseIndent;
  258. }
  259. };
  260. this.getNextLineIndent = function (state, line, tab) {
  261. return this.$calculateIndent(line, tab);
  262. };
  263. this.checkOutdent = function (state, line, input) {
  264. return this.$outdent.checkOutdent(line, input);
  265. };
  266. this.autoOutdent = function (state, doc, row) {
  267. this.$outdent.autoOutdent(doc, row);
  268. };
  269. this.$id = "ace/mode/clojure";
  270. this.snippetFileId = "ace/snippets/clojure";
  271. }).call(Mode.prototype);
  272. exports.Mode = Mode;
  273. }); (function() {
  274. ace.require(["ace/mode/clojure"], function(m) {
  275. if (typeof module == "object" && typeof exports == "object" && module) {
  276. module.exports = m;
  277. }
  278. });
  279. })();