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