1
|
ace.define("ace/mode/elixir_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var oop = require("../lib/oop");
|
5
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
6
|
|
7
|
var ElixirHighlightRules = function() {
|
8
|
|
9
|
this.$rules = { start:
|
10
|
[ { token:
|
11
|
[ 'meta.module.elixir',
|
12
|
'keyword.control.module.elixir',
|
13
|
'meta.module.elixir',
|
14
|
'entity.name.type.module.elixir' ],
|
15
|
regex: '^(\\s*)(defmodule)(\\s+)((?:[A-Z]\\w*\\s*\\.\\s*)*[A-Z]\\w*)' },
|
16
|
{ token: 'comment.documentation.heredoc',
|
17
|
regex: '@(?:module|type)?doc (?:~[a-z])?"""',
|
18
|
push:
|
19
|
[ { token: 'comment.documentation.heredoc',
|
20
|
regex: '\\s*"""',
|
21
|
next: 'pop' },
|
22
|
{ include: '#interpolated_elixir' },
|
23
|
{ include: '#escaped_char' },
|
24
|
{ defaultToken: 'comment.documentation.heredoc' } ],
|
25
|
comment: '@doc with heredocs is treated as documentation' },
|
26
|
{ token: 'comment.documentation.heredoc',
|
27
|
regex: '@(?:module|type)?doc ~[A-Z]"""',
|
28
|
push:
|
29
|
[ { token: 'comment.documentation.heredoc',
|
30
|
regex: '\\s*"""',
|
31
|
next: 'pop' },
|
32
|
{ defaultToken: 'comment.documentation.heredoc' } ],
|
33
|
comment: '@doc with heredocs is treated as documentation' },
|
34
|
{ token: 'comment.documentation.heredoc',
|
35
|
regex: '@(?:module|type)?doc (?:~[a-z])?\'\'\'',
|
36
|
push:
|
37
|
[ { token: 'comment.documentation.heredoc',
|
38
|
regex: '\\s*\'\'\'',
|
39
|
next: 'pop' },
|
40
|
{ include: '#interpolated_elixir' },
|
41
|
{ include: '#escaped_char' },
|
42
|
{ defaultToken: 'comment.documentation.heredoc' } ],
|
43
|
comment: '@doc with heredocs is treated as documentation' },
|
44
|
{ token: 'comment.documentation.heredoc',
|
45
|
regex: '@(?:module|type)?doc ~[A-Z]\'\'\'',
|
46
|
push:
|
47
|
[ { token: 'comment.documentation.heredoc',
|
48
|
regex: '\\s*\'\'\'',
|
49
|
next: 'pop' },
|
50
|
{ defaultToken: 'comment.documentation.heredoc' } ],
|
51
|
comment: '@doc with heredocs is treated as documentation' },
|
52
|
{ token: 'comment.documentation.false',
|
53
|
regex: '@(?:module|type)?doc false',
|
54
|
comment: '@doc false is treated as documentation' },
|
55
|
{ token: 'comment.documentation.string',
|
56
|
regex: '@(?:module|type)?doc "',
|
57
|
push:
|
58
|
[ { token: 'comment.documentation.string',
|
59
|
regex: '"',
|
60
|
next: 'pop' },
|
61
|
{ include: '#interpolated_elixir' },
|
62
|
{ include: '#escaped_char' },
|
63
|
{ defaultToken: 'comment.documentation.string' } ],
|
64
|
comment: '@doc with string is treated as documentation' },
|
65
|
{ token: 'keyword.control.elixir',
|
66
|
regex: '\\b(?:do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])',
|
67
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
68
|
originalRegex: '(?<!\\.)\\b(do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])' },
|
69
|
{ token: 'keyword.operator.elixir',
|
70
|
regex: '\\b(?:and|not|or|when|xor|in|inlist|inbits)\\b',
|
71
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
72
|
originalRegex: '(?<!\\.)\\b(and|not|or|when|xor|in|inlist|inbits)\\b',
|
73
|
comment: ' as above, just doesn\'t need a \'end\' and does a logic operation' },
|
74
|
{ token: 'constant.language.elixir',
|
75
|
regex: '\\b(?:nil|true|false)\\b(?![?!])' },
|
76
|
{ token: 'variable.language.elixir',
|
77
|
regex: '\\b__(?:CALLER|ENV|MODULE|DIR)__\\b(?![?!])' },
|
78
|
{ token:
|
79
|
[ 'punctuation.definition.variable.elixir',
|
80
|
'variable.other.readwrite.module.elixir' ],
|
81
|
regex: '(@)([a-zA-Z_]\\w*)' },
|
82
|
{ token:
|
83
|
[ 'punctuation.definition.variable.elixir',
|
84
|
'variable.other.anonymous.elixir' ],
|
85
|
regex: '(&)(\\d*)' },
|
86
|
{ token: 'variable.other.constant.elixir',
|
87
|
regex: '\\b[A-Z]\\w*\\b' },
|
88
|
{ token: 'constant.numeric.elixir',
|
89
|
regex: '\\b(?:0x[\\da-fA-F](?:_?[\\da-fA-F])*|\\d(?:_?\\d)*(?:\\.(?![^[:space:][:digit:]])(?:_?\\d)*)?(?:[eE][-+]?\\d(?:_?\\d)*)?|0b[01]+|0o[0-7]+)\\b',
|
90
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
91
|
originalRegex: '\\b(0x\\h(?>_?\\h)*|\\d(?>_?\\d)*(\\.(?![^[:space:][:digit:]])(?>_?\\d)*)?([eE][-+]?\\d(?>_?\\d)*)?|0b[01]+|0o[0-7]+)\\b' },
|
92
|
{ token: 'punctuation.definition.constant.elixir',
|
93
|
regex: ':\'',
|
94
|
push:
|
95
|
[ { token: 'punctuation.definition.constant.elixir',
|
96
|
regex: '\'',
|
97
|
next: 'pop' },
|
98
|
{ include: '#interpolated_elixir' },
|
99
|
{ include: '#escaped_char' },
|
100
|
{ defaultToken: 'constant.other.symbol.single-quoted.elixir' } ] },
|
101
|
{ token: 'punctuation.definition.constant.elixir',
|
102
|
regex: ':"',
|
103
|
push:
|
104
|
[ { token: 'punctuation.definition.constant.elixir',
|
105
|
regex: '"',
|
106
|
next: 'pop' },
|
107
|
{ include: '#interpolated_elixir' },
|
108
|
{ include: '#escaped_char' },
|
109
|
{ defaultToken: 'constant.other.symbol.double-quoted.elixir' } ] },
|
110
|
{ token: 'punctuation.definition.string.begin.elixir',
|
111
|
regex: '(?:\'\'\')',
|
112
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
113
|
originalRegex: '(?>\'\'\')',
|
114
|
push:
|
115
|
[ { token: 'punctuation.definition.string.end.elixir',
|
116
|
regex: '^\\s*\'\'\'',
|
117
|
next: 'pop' },
|
118
|
{ include: '#interpolated_elixir' },
|
119
|
{ include: '#escaped_char' },
|
120
|
{ defaultToken: 'support.function.variable.quoted.single.heredoc.elixir' } ],
|
121
|
comment: 'Single-quoted heredocs' },
|
122
|
{ token: 'punctuation.definition.string.begin.elixir',
|
123
|
regex: '\'',
|
124
|
push:
|
125
|
[ { token: 'punctuation.definition.string.end.elixir',
|
126
|
regex: '\'',
|
127
|
next: 'pop' },
|
128
|
{ include: '#interpolated_elixir' },
|
129
|
{ include: '#escaped_char' },
|
130
|
{ defaultToken: 'support.function.variable.quoted.single.elixir' } ],
|
131
|
comment: 'single quoted string (allows for interpolation)' },
|
132
|
{ token: 'punctuation.definition.string.begin.elixir',
|
133
|
regex: '(?:""")',
|
134
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
135
|
originalRegex: '(?>""")',
|
136
|
push:
|
137
|
[ { token: 'punctuation.definition.string.end.elixir',
|
138
|
regex: '^\\s*"""',
|
139
|
next: 'pop' },
|
140
|
{ include: '#interpolated_elixir' },
|
141
|
{ include: '#escaped_char' },
|
142
|
{ defaultToken: 'string.quoted.double.heredoc.elixir' } ],
|
143
|
comment: 'Double-quoted heredocs' },
|
144
|
{ token: 'punctuation.definition.string.begin.elixir',
|
145
|
regex: '"',
|
146
|
push:
|
147
|
[ { token: 'punctuation.definition.string.end.elixir',
|
148
|
regex: '"',
|
149
|
next: 'pop' },
|
150
|
{ include: '#interpolated_elixir' },
|
151
|
{ include: '#escaped_char' },
|
152
|
{ defaultToken: 'string.quoted.double.elixir' } ],
|
153
|
comment: 'double quoted string (allows for interpolation)' },
|
154
|
{ token: 'punctuation.definition.string.begin.elixir',
|
155
|
regex: '~[a-z](?:""")',
|
156
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
157
|
originalRegex: '~[a-z](?>""")',
|
158
|
push:
|
159
|
[ { token: 'punctuation.definition.string.end.elixir',
|
160
|
regex: '^\\s*"""',
|
161
|
next: 'pop' },
|
162
|
{ include: '#interpolated_elixir' },
|
163
|
{ include: '#escaped_char' },
|
164
|
{ defaultToken: 'string.quoted.double.heredoc.elixir' } ],
|
165
|
comment: 'Double-quoted heredocs sigils' },
|
166
|
{ token: 'punctuation.definition.string.begin.elixir',
|
167
|
regex: '~[a-z]\\{',
|
168
|
push:
|
169
|
[ { token: 'punctuation.definition.string.end.elixir',
|
170
|
regex: '\\}[a-z]*',
|
171
|
next: 'pop' },
|
172
|
{ include: '#interpolated_elixir' },
|
173
|
{ include: '#escaped_char' },
|
174
|
{ defaultToken: 'string.interpolated.elixir' } ],
|
175
|
comment: 'sigil (allow for interpolation)' },
|
176
|
{ token: 'punctuation.definition.string.begin.elixir',
|
177
|
regex: '~[a-z]\\[',
|
178
|
push:
|
179
|
[ { token: 'punctuation.definition.string.end.elixir',
|
180
|
regex: '\\][a-z]*',
|
181
|
next: 'pop' },
|
182
|
{ include: '#interpolated_elixir' },
|
183
|
{ include: '#escaped_char' },
|
184
|
{ defaultToken: 'string.interpolated.elixir' } ],
|
185
|
comment: 'sigil (allow for interpolation)' },
|
186
|
{ token: 'punctuation.definition.string.begin.elixir',
|
187
|
regex: '~[a-z]\\<',
|
188
|
push:
|
189
|
[ { token: 'punctuation.definition.string.end.elixir',
|
190
|
regex: '\\>[a-z]*',
|
191
|
next: 'pop' },
|
192
|
{ include: '#interpolated_elixir' },
|
193
|
{ include: '#escaped_char' },
|
194
|
{ defaultToken: 'string.interpolated.elixir' } ],
|
195
|
comment: 'sigil (allow for interpolation)' },
|
196
|
{ token: 'punctuation.definition.string.begin.elixir',
|
197
|
regex: '~[a-z]\\(',
|
198
|
push:
|
199
|
[ { token: 'punctuation.definition.string.end.elixir',
|
200
|
regex: '\\)[a-z]*',
|
201
|
next: 'pop' },
|
202
|
{ include: '#interpolated_elixir' },
|
203
|
{ include: '#escaped_char' },
|
204
|
{ defaultToken: 'string.interpolated.elixir' } ],
|
205
|
comment: 'sigil (allow for interpolation)' },
|
206
|
{ token: 'punctuation.definition.string.begin.elixir',
|
207
|
regex: '~[a-z][^\\w]',
|
208
|
push:
|
209
|
[ { token: 'punctuation.definition.string.end.elixir',
|
210
|
regex: '[^\\w][a-z]*',
|
211
|
next: 'pop' },
|
212
|
{ include: '#interpolated_elixir' },
|
213
|
{ include: '#escaped_char' },
|
214
|
{ include: '#escaped_char' },
|
215
|
{ defaultToken: 'string.interpolated.elixir' } ],
|
216
|
comment: 'sigil (allow for interpolation)' },
|
217
|
{ token: 'punctuation.definition.string.begin.elixir',
|
218
|
regex: '~[A-Z](?:""")',
|
219
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
220
|
originalRegex: '~[A-Z](?>""")',
|
221
|
push:
|
222
|
[ { token: 'punctuation.definition.string.end.elixir',
|
223
|
regex: '^\\s*"""',
|
224
|
next: 'pop' },
|
225
|
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
226
|
comment: 'Double-quoted heredocs sigils' },
|
227
|
{ token: 'punctuation.definition.string.begin.elixir',
|
228
|
regex: '~[A-Z]\\{',
|
229
|
push:
|
230
|
[ { token: 'punctuation.definition.string.end.elixir',
|
231
|
regex: '\\}[a-z]*',
|
232
|
next: 'pop' },
|
233
|
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
234
|
comment: 'sigil (without interpolation)' },
|
235
|
{ token: 'punctuation.definition.string.begin.elixir',
|
236
|
regex: '~[A-Z]\\[',
|
237
|
push:
|
238
|
[ { token: 'punctuation.definition.string.end.elixir',
|
239
|
regex: '\\][a-z]*',
|
240
|
next: 'pop' },
|
241
|
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
242
|
comment: 'sigil (without interpolation)' },
|
243
|
{ token: 'punctuation.definition.string.begin.elixir',
|
244
|
regex: '~[A-Z]\\<',
|
245
|
push:
|
246
|
[ { token: 'punctuation.definition.string.end.elixir',
|
247
|
regex: '\\>[a-z]*',
|
248
|
next: 'pop' },
|
249
|
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
250
|
comment: 'sigil (without interpolation)' },
|
251
|
{ token: 'punctuation.definition.string.begin.elixir',
|
252
|
regex: '~[A-Z]\\(',
|
253
|
push:
|
254
|
[ { token: 'punctuation.definition.string.end.elixir',
|
255
|
regex: '\\)[a-z]*',
|
256
|
next: 'pop' },
|
257
|
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
258
|
comment: 'sigil (without interpolation)' },
|
259
|
{ token: 'punctuation.definition.string.begin.elixir',
|
260
|
regex: '~[A-Z][^\\w]',
|
261
|
push:
|
262
|
[ { token: 'punctuation.definition.string.end.elixir',
|
263
|
regex: '[^\\w][a-z]*',
|
264
|
next: 'pop' },
|
265
|
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
266
|
comment: 'sigil (without interpolation)' },
|
267
|
{ token: ['punctuation.definition.constant.elixir', 'constant.other.symbol.elixir'],
|
268
|
regex: '(:)([a-zA-Z_][\\w@]*(?:[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(?:\\^\\^)?)',
|
269
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
270
|
originalRegex: '(?<!:)(:)(?>[a-zA-Z_][\\w@]*(?>[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(\\^\\^)?)',
|
271
|
comment: 'symbols' },
|
272
|
{ token: 'punctuation.definition.constant.elixir',
|
273
|
regex: '(?:[a-zA-Z_][\\w@]*(?:[?!])?):(?!:)',
|
274
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
275
|
originalRegex: '(?>[a-zA-Z_][\\w@]*(?>[?!])?)(:)(?!:)',
|
276
|
comment: 'symbols' },
|
277
|
{ token:
|
278
|
[ 'punctuation.definition.comment.elixir',
|
279
|
'comment.line.number-sign.elixir' ],
|
280
|
regex: '(#)(.*)' },
|
281
|
{ token: 'constant.numeric.elixir',
|
282
|
regex: '\\?(?:\\\\(?:x[\\da-fA-F]{1,2}(?![\\da-fA-F])\\b|[^xMC])|[^\\s\\\\])',
|
283
|
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
284
|
originalRegex: '(?<!\\w)\\?(\\\\(x\\h{1,2}(?!\\h)\\b|[^xMC])|[^\\s\\\\])',
|
285
|
comment: '\n\t\t\tmatches questionmark-letters.\n\n\t\t\texamples (1st alternation = hex):\n\t\t\t?\\x1 ?\\x61\n\n\t\t\texamples (2rd alternation = escaped):\n\t\t\t?\\n ?\\b\n\n\t\t\texamples (3rd alternation = normal):\n\t\t\t?a ?A ?0 \n\t\t\t?* ?" ?( \n\t\t\t?. ?#\n\t\t\t\n\t\t\tthe negative lookbehind prevents against matching\n\t\t\tp(42.tainted?)\n\t\t\t' },
|
286
|
{ token: 'keyword.operator.assignment.augmented.elixir',
|
287
|
regex: '\\+=|\\-=|\\|\\|=|~=|&&=' },
|
288
|
{ token: 'keyword.operator.comparison.elixir',
|
289
|
regex: '===?|!==?|<=?|>=?' },
|
290
|
{ token: 'keyword.operator.bitwise.elixir',
|
291
|
regex: '\\|{3}|&{3}|\\^{3}|<{3}|>{3}|~{3}' },
|
292
|
{ token: 'keyword.operator.logical.elixir',
|
293
|
regex: '!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b',
|
294
|
originalRegex: '(?<=[ \\t])!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b' },
|
295
|
{ token: 'keyword.operator.arithmetic.elixir',
|
296
|
regex: '\\*|\\+|\\-|/' },
|
297
|
{ token: 'keyword.operator.other.elixir',
|
298
|
regex: '\\||\\+\\+|\\-\\-|\\*\\*|\\\\\\\\|\\<\\-|\\<\\>|\\<\\<|\\>\\>|\\:\\:|\\.\\.|\\|>|~|=>' },
|
299
|
{ token: 'keyword.operator.assignment.elixir', regex: '=' },
|
300
|
{ token: 'punctuation.separator.other.elixir', regex: ':' },
|
301
|
{ token: 'punctuation.separator.statement.elixir',
|
302
|
regex: '\\;' },
|
303
|
{ token: 'punctuation.separator.object.elixir', regex: ',' },
|
304
|
{ token: 'punctuation.separator.method.elixir', regex: '\\.' },
|
305
|
{ token: 'punctuation.section.scope.elixir', regex: '\\{|\\}' },
|
306
|
{ token: 'punctuation.section.array.elixir', regex: '\\[|\\]' },
|
307
|
{ token: 'punctuation.section.function.elixir',
|
308
|
regex: '\\(|\\)' } ],
|
309
|
'#escaped_char':
|
310
|
[ { token: 'constant.character.escape.elixir',
|
311
|
regex: '\\\\(?:x[\\da-fA-F]{1,2}|.)' } ],
|
312
|
'#interpolated_elixir':
|
313
|
[ { token:
|
314
|
[ 'source.elixir.embedded.source',
|
315
|
'source.elixir.embedded.source.empty' ],
|
316
|
regex: '(#\\{)(\\})' },
|
317
|
{ todo:
|
318
|
{ token: 'punctuation.section.embedded.elixir',
|
319
|
regex: '#\\{',
|
320
|
push:
|
321
|
[ { token: 'punctuation.section.embedded.elixir',
|
322
|
regex: '\\}',
|
323
|
next: 'pop' },
|
324
|
{ include: '#nest_curly_and_self' },
|
325
|
{ include: '$self' },
|
326
|
{ defaultToken: 'source.elixir.embedded.source' } ] } } ],
|
327
|
'#nest_curly_and_self':
|
328
|
[ { token: 'punctuation.section.scope.elixir',
|
329
|
regex: '\\{',
|
330
|
push:
|
331
|
[ { token: 'punctuation.section.scope.elixir',
|
332
|
regex: '\\}',
|
333
|
next: 'pop' },
|
334
|
{ include: '#nest_curly_and_self' } ] },
|
335
|
{ include: '$self' } ],
|
336
|
'#regex_sub':
|
337
|
[ { include: '#interpolated_elixir' },
|
338
|
{ include: '#escaped_char' },
|
339
|
{ token:
|
340
|
[ 'punctuation.definition.arbitrary-repitition.elixir',
|
341
|
'string.regexp.arbitrary-repitition.elixir',
|
342
|
'string.regexp.arbitrary-repitition.elixir',
|
343
|
'punctuation.definition.arbitrary-repitition.elixir' ],
|
344
|
regex: '(\\{)(\\d+)((?:,\\d+)?)(\\})' },
|
345
|
{ token: 'punctuation.definition.character-class.elixir',
|
346
|
regex: '\\[(?:\\^?\\])?',
|
347
|
push:
|
348
|
[ { token: 'punctuation.definition.character-class.elixir',
|
349
|
regex: '\\]',
|
350
|
next: 'pop' },
|
351
|
{ include: '#escaped_char' },
|
352
|
{ defaultToken: 'string.regexp.character-class.elixir' } ] },
|
353
|
{ token: 'punctuation.definition.group.elixir',
|
354
|
regex: '\\(',
|
355
|
push:
|
356
|
[ { token: 'punctuation.definition.group.elixir',
|
357
|
regex: '\\)',
|
358
|
next: 'pop' },
|
359
|
{ include: '#regex_sub' },
|
360
|
{ defaultToken: 'string.regexp.group.elixir' } ] },
|
361
|
{ token:
|
362
|
[ 'punctuation.definition.comment.elixir',
|
363
|
'comment.line.number-sign.elixir' ],
|
364
|
regex: '(?:^|\\s)(#)(\\s[[a-zA-Z0-9,. \\t?!-][^\\x00-\\x7F]]*$)',
|
365
|
originalRegex: '(?<=^|\\s)(#)\\s[[a-zA-Z0-9,. \\t?!-][^\\x{00}-\\x{7F}]]*$',
|
366
|
comment: 'We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags.' } ] };
|
367
|
|
368
|
this.normalizeRules();
|
369
|
};
|
370
|
|
371
|
ElixirHighlightRules.metaData = { comment: 'Textmate bundle for Elixir Programming Language.',
|
372
|
fileTypes: [ 'ex', 'exs' ],
|
373
|
firstLineMatch: '^#!/.*\\belixir',
|
374
|
foldingStartMarker: '(after|else|catch|rescue|\\-\\>|\\{|\\[|do)\\s*$',
|
375
|
foldingStopMarker: '^\\s*((\\}|\\]|after|else|catch|rescue)\\s*$|end\\b)',
|
376
|
keyEquivalent: '^~E',
|
377
|
name: 'Elixir',
|
378
|
scopeName: 'source.elixir' };
|
379
|
|
380
|
|
381
|
oop.inherits(ElixirHighlightRules, TextHighlightRules);
|
382
|
|
383
|
exports.ElixirHighlightRules = ElixirHighlightRules;
|
384
|
});
|
385
|
|
386
|
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
|
387
|
"use strict";
|
388
|
|
389
|
var oop = require("../../lib/oop");
|
390
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
391
|
var Range = require("../../range").Range;
|
392
|
|
393
|
var FoldMode = exports.FoldMode = function() {};
|
394
|
oop.inherits(FoldMode, BaseFoldMode);
|
395
|
|
396
|
(function() {
|
397
|
|
398
|
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
399
|
var range = this.indentationBlock(session, row);
|
400
|
if (range)
|
401
|
return range;
|
402
|
|
403
|
var re = /\S/;
|
404
|
var line = session.getLine(row);
|
405
|
var startLevel = line.search(re);
|
406
|
if (startLevel == -1 || line[startLevel] != "#")
|
407
|
return;
|
408
|
|
409
|
var startColumn = line.length;
|
410
|
var maxRow = session.getLength();
|
411
|
var startRow = row;
|
412
|
var endRow = row;
|
413
|
|
414
|
while (++row < maxRow) {
|
415
|
line = session.getLine(row);
|
416
|
var level = line.search(re);
|
417
|
|
418
|
if (level == -1)
|
419
|
continue;
|
420
|
|
421
|
if (line[level] != "#")
|
422
|
break;
|
423
|
|
424
|
endRow = row;
|
425
|
}
|
426
|
|
427
|
if (endRow > startRow) {
|
428
|
var endColumn = session.getLine(endRow).length;
|
429
|
return new Range(startRow, startColumn, endRow, endColumn);
|
430
|
}
|
431
|
};
|
432
|
this.getFoldWidget = function(session, foldStyle, row) {
|
433
|
var line = session.getLine(row);
|
434
|
var indent = line.search(/\S/);
|
435
|
var next = session.getLine(row + 1);
|
436
|
var prev = session.getLine(row - 1);
|
437
|
var prevIndent = prev.search(/\S/);
|
438
|
var nextIndent = next.search(/\S/);
|
439
|
|
440
|
if (indent == -1) {
|
441
|
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
|
442
|
return "";
|
443
|
}
|
444
|
if (prevIndent == -1) {
|
445
|
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
|
446
|
session.foldWidgets[row - 1] = "";
|
447
|
session.foldWidgets[row + 1] = "";
|
448
|
return "start";
|
449
|
}
|
450
|
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
|
451
|
if (session.getLine(row - 2).search(/\S/) == -1) {
|
452
|
session.foldWidgets[row - 1] = "start";
|
453
|
session.foldWidgets[row + 1] = "";
|
454
|
return "";
|
455
|
}
|
456
|
}
|
457
|
|
458
|
if (prevIndent!= -1 && prevIndent < indent)
|
459
|
session.foldWidgets[row - 1] = "start";
|
460
|
else
|
461
|
session.foldWidgets[row - 1] = "";
|
462
|
|
463
|
if (indent < nextIndent)
|
464
|
return "start";
|
465
|
else
|
466
|
return "";
|
467
|
};
|
468
|
|
469
|
}).call(FoldMode.prototype);
|
470
|
|
471
|
});
|
472
|
|
473
|
ace.define("ace/mode/elixir",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/elixir_highlight_rules","ace/mode/folding/coffee"], function(require, exports, module) {
|
474
|
"use strict";
|
475
|
|
476
|
var oop = require("../lib/oop");
|
477
|
var TextMode = require("./text").Mode;
|
478
|
var ElixirHighlightRules = require("./elixir_highlight_rules").ElixirHighlightRules;
|
479
|
var FoldMode = require("./folding/coffee").FoldMode;
|
480
|
|
481
|
var Mode = function() {
|
482
|
this.HighlightRules = ElixirHighlightRules;
|
483
|
this.foldingRules = new FoldMode();
|
484
|
this.$behaviour = this.$defaultBehaviour;
|
485
|
};
|
486
|
oop.inherits(Mode, TextMode);
|
487
|
|
488
|
(function() {
|
489
|
this.lineCommentStart = "#";
|
490
|
this.$id = "ace/mode/elixir";
|
491
|
}).call(Mode.prototype);
|
492
|
|
493
|
exports.Mode = Mode;
|
494
|
}); (function() {
|
495
|
ace.require(["ace/mode/elixir"], function(m) {
|
496
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
497
|
module.exports = m;
|
498
|
}
|
499
|
});
|
500
|
})();
|
501
|
|