Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-clojure.js

raw symbols SCIP
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", //parens
88 regex: "[\\(|\\)]"
89 }, {
90 token: "keyword", //lists
91 regex: "[\\'\\(]"
92 }, {
93 token: "keyword", //vectors
94 regex: "[\\[|\\]]"
95 }, {
96 token: "string.regexp", //Regular Expressions
97 regex: '#"',
98 next: "regex"
99 }, {
100 token: "keyword", //sets and maps
101 regex: "[\\{|\\}|\\#\\{|\\#\\}]"
102 }, {
103 token: "keyword", // ampersands
104 regex: '[\\&]'
105 }, {
106 token: "keyword", // metadata
107 regex: '[\\#\\^\\{]'
108 }, {
109 token: "keyword", // anonymous fn syntactic sugar
110 regex: '[\\%]'
111 }, {
112 token: "keyword", // deref reader macro
113 regex: '[@]'
114 }, {
115 token: "constant.numeric", // hex
116 regex: "0[xX][0-9a-fA-F]+\\b"
117 }, {
118 token: "constant.numeric", // float
119 regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
120 }, {
121 token: "constant.language",
122 regex: '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]'
123 }, {
124 token: keywordMapper,
125 regex: "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"
126 }, {
127 token: "string", // single line
128 regex: '"',
129 next: "string"
130 }, {
131 token: "constant", // symbol
132 regex: /:[^()\[\]{}'"\^%`,;\s]+/
133 }
134 ],
135 "string": [
136 {
137 token: "constant.language.escape",
138 regex: "\\\\.|\\\\$"
139 }, {
140 token: "string",
141 regex: '"',
142 next: "start"
143 }, {
144 defaultToken: "string"
145 }
146 ],
147 "regex": [
148 {
149 token: "regexp.keyword.operator",
150 regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
151 }, {
152 token: "string.regexp",
153 regex: '"',
154 next: "start"
155 }, {
156 token: "constant.language.escape",
157 regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
158 }, {
159 token: "constant.language.delimiter",
160 regex: /\|/
161 }, {
162 token: "constant.language.escape",
163 regex: /\[\^?/,
164 next: "regex_character_class"
165 }, {
166 defaultToken: "string.regexp"
167 }
168 ],
169 "regex_character_class": [
170 {
171 token: "regexp.charclass.keyword.operator",
172 regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
173 }, {
174 token: "constant.language.escape",
175 regex: "]",
176 next: "regex"
177 }, {
178 token: "constant.language.escape",
179 regex: "-"
180 }, {
181 defaultToken: "string.regexp.charachterclass"
182 }
183 ]
184 };
185 };
186 oop.inherits(ClojureHighlightRules, TextHighlightRules);
187 exports.ClojureHighlightRules = ClojureHighlightRules;
188
189 });
190
191 ace.define("ace/mode/matching_parens_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
192 var Range = require("../range").Range;
193 var MatchingParensOutdent = function () { };
194 (function () {
195 this.checkOutdent = function (line, input) {
196 if (!/^\s+$/.test(line))
197 return false;
198 return /^\s*\)/.test(input);
199 };
200 this.autoOutdent = function (doc, row) {
201 var line = doc.getLine(row);
202 var match = line.match(/^(\s*\))/);
203 if (!match)
204 return 0;
205 var column = match[1].length;
206 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
207 if (!openBracePos || openBracePos.row == row)
208 return 0;
209 var indent = this.$getIndent(doc.getLine(openBracePos.row));
210 doc.replace(new Range(row, 0, row, column - 1), indent);
211 };
212 this.$getIndent = function (line) {
213 var match = line.match(/^(\s+)/);
214 if (match) {
215 return match[1];
216 }
217 return "";
218 };
219 }).call(MatchingParensOutdent.prototype);
220 exports.MatchingParensOutdent = MatchingParensOutdent;
221
222 });
223
224 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";
225 var oop = require("../lib/oop");
226 var TextMode = require("./text").Mode;
227 var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules;
228 var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent;
229 var Mode = function () {
230 this.HighlightRules = ClojureHighlightRules;
231 this.$outdent = new MatchingParensOutdent();
232 this.$behaviour = this.$defaultBehaviour;
233 };
234 oop.inherits(Mode, TextMode);
235 (function () {
236 this.lineCommentStart = ";";
237 this.minorIndentFunctions = ["defn", "defn-", "defmacro", "def", "deftest", "testing"];
238 this.$toIndent = function (str) {
239 return str.split('').map(function (ch) {
240 if (/\s/.exec(ch)) {
241 return ch;
242 }
243 else {
244 return ' ';
245 }
246 }).join('');
247 };
248 this.$calculateIndent = function (line, tab) {
249 var baseIndent = this.$getIndent(line);
250 var delta = 0;
251 var isParen, ch;
252 for (var i = line.length - 1; i >= 0; i--) {
253 ch = line[i];
254 if (ch === '(') {
255 delta--;
256 isParen = true;
257 }
258 else if (ch === '(' || ch === '[' || ch === '{') {
259 delta--;
260 isParen = false;
261 }
262 else if (ch === ')' || ch === ']' || ch === '}') {
263 delta++;
264 }
265 if (delta < 0) {
266 break;
267 }
268 }
269 if (delta < 0 && isParen) {
270 i += 1;
271 var iBefore = i;
272 var fn = '';
273 while (true) {
274 ch = line[i];
275 if (ch === ' ' || ch === '\t') {
276 if (this.minorIndentFunctions.indexOf(fn) !== -1) {
277 return this.$toIndent(line.substring(0, iBefore - 1) + tab);
278 }
279 else {
280 return this.$toIndent(line.substring(0, i + 1));
281 }
282 }
283 else if (ch === undefined) {
284 return this.$toIndent(line.substring(0, iBefore - 1) + tab);
285 }
286 fn += line[i];
287 i++;
288 }
289 }
290 else if (delta < 0 && !isParen) {
291 return this.$toIndent(line.substring(0, i + 1));
292 }
293 else if (delta > 0) {
294 baseIndent = baseIndent.substring(0, baseIndent.length - tab.length);
295 return baseIndent;
296 }
297 else {
298 return baseIndent;
299 }
300 };
301 this.getNextLineIndent = function (state, line, tab) {
302 return this.$calculateIndent(line, tab);
303 };
304 this.checkOutdent = function (state, line, input) {
305 return this.$outdent.checkOutdent(line, input);
306 };
307 this.autoOutdent = function (state, doc, row) {
308 this.$outdent.autoOutdent(doc, row);
309 };
310 this.$id = "ace/mode/clojure";
311 this.snippetFileId = "ace/snippets/clojure";
312 }).call(Mode.prototype);
313 exports.Mode = Mode;
314
315 }); (function() {
316 ace.require(["ace/mode/clojure"], function(m) {
317 if (typeof module == "object" && typeof exports == "object" && module) {
318 module.exports = m;
319 }
320 });
321 })();
322