| 1 |
ace.define("ace/mode/vala_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 ValaHighlightRules = function () { |
| 6 |
this.$rules = { start: [{ token: ['meta.using.vala', |
| 7 |
'keyword.other.using.vala', |
| 8 |
'meta.using.vala', |
| 9 |
'storage.modifier.using.vala', |
| 10 |
'meta.using.vala', |
| 11 |
'punctuation.terminator.vala'], |
| 12 |
regex: '^(\\s*)(using)\\b(?:(\\s*)([^ ;$]+)(\\s*)((?:;)?))?' }, |
| 13 |
{ include: '#code' }], |
| 14 |
'#all-types': [{ include: '#primitive-arrays' }, |
| 15 |
{ include: '#primitive-types' }, |
| 16 |
{ include: '#object-types' }], |
| 17 |
'#annotations': [{ token: ['storage.type.annotation.vala', |
| 18 |
'punctuation.definition.annotation-arguments.begin.vala'], |
| 19 |
regex: '(@[^ (]+)(\\()', |
| 20 |
push: [{ token: 'punctuation.definition.annotation-arguments.end.vala', |
| 21 |
regex: '\\)', |
| 22 |
next: 'pop' }, |
| 23 |
{ token: ['constant.other.key.vala', |
| 24 |
'text', |
| 25 |
'keyword.operator.assignment.vala'], |
| 26 |
regex: '(\\w*)(\\s*)(=)' }, |
| 27 |
{ include: '#code' }, |
| 28 |
{ token: 'punctuation.seperator.property.vala', regex: ',' }, |
| 29 |
{ defaultToken: 'meta.declaration.annotation.vala' }] }, |
| 30 |
{ token: 'storage.type.annotation.vala', regex: '@\\w*' }], |
| 31 |
'#anonymous-classes-and-new': [{ token: 'keyword.control.new.vala', |
| 32 |
regex: '\\bnew\\b', |
| 33 |
push_disabled: [{ token: 'text', |
| 34 |
regex: '(?<=\\)|\\])(?!\\s*{)|(?<=})|(?=;)', |
| 35 |
TODO: 'FIXME: regexp doesn\'t have js equivalent', |
| 36 |
originalRegex: '(?<=\\)|\\])(?!\\s*{)|(?<=})|(?=;)', |
| 37 |
next: 'pop' }, |
| 38 |
{ token: ['storage.type.vala', 'text'], |
| 39 |
regex: '(\\w+)(\\s*)(?=\\[)', |
| 40 |
push: [{ token: 'text', regex: '}|(?=;|\\))', next: 'pop' }, |
| 41 |
{ token: 'text', |
| 42 |
regex: '\\[', |
| 43 |
push: [{ token: 'text', regex: '\\]', next: 'pop' }, |
| 44 |
{ include: '#code' }] }, |
| 45 |
{ token: 'text', |
| 46 |
regex: '{', |
| 47 |
push: [{ token: 'text', regex: '(?=})', next: 'pop' }, |
| 48 |
{ include: '#code' }] }] }, |
| 49 |
{ token: 'text', |
| 50 |
regex: '(?=\\w.*\\()', |
| 51 |
push: [{ token: 'text', |
| 52 |
regex: '(?<=\\))', |
| 53 |
TODO: 'FIXME: regexp doesn\'t have js equivalent', |
| 54 |
originalRegex: '(?<=\\))', |
| 55 |
next: 'pop' }, |
| 56 |
{ include: '#object-types' }, |
| 57 |
{ token: 'text', |
| 58 |
regex: '\\(', |
| 59 |
push: [{ token: 'text', regex: '\\)', next: 'pop' }, |
| 60 |
{ include: '#code' }] }] }, |
| 61 |
{ token: 'meta.inner-class.vala', |
| 62 |
regex: '{', |
| 63 |
push: [{ token: 'meta.inner-class.vala', regex: '}', next: 'pop' }, |
| 64 |
{ include: '#class-body' }, |
| 65 |
{ defaultToken: 'meta.inner-class.vala' }] }] }], |
| 66 |
'#assertions': [{ token: ['keyword.control.assert.vala', |
| 67 |
'meta.declaration.assertion.vala'], |
| 68 |
regex: '\\b(assert|requires|ensures)(\\s)', |
| 69 |
push: [{ token: 'meta.declaration.assertion.vala', |
| 70 |
regex: '$', |
| 71 |
next: 'pop' }, |
| 72 |
{ token: 'keyword.operator.assert.expression-seperator.vala', |
| 73 |
regex: ':' }, |
| 74 |
{ include: '#code' }, |
| 75 |
{ defaultToken: 'meta.declaration.assertion.vala' }] }], |
| 76 |
'#class': [{ token: 'meta.class.vala', |
| 77 |
regex: '(?=\\w?[\\w\\s]*(?:class|(?:@)?interface|enum|struct|namespace)\\s+\\w+)', |
| 78 |
push: [{ token: 'paren.vala', |
| 79 |
regex: '}', |
| 80 |
next: 'pop' }, |
| 81 |
{ include: '#storage-modifiers' }, |
| 82 |
{ include: '#comments' }, |
| 83 |
{ token: ['storage.modifier.vala', |
| 84 |
'meta.class.identifier.vala', |
| 85 |
'entity.name.type.class.vala'], |
| 86 |
regex: '(class|(?:@)?interface|enum|struct|namespace)(\\s+)([\\w\\.]+)' }, |
| 87 |
{ token: 'storage.modifier.extends.vala', |
| 88 |
regex: ':', |
| 89 |
push: [{ token: 'meta.definition.class.inherited.classes.vala', |
| 90 |
regex: '(?={|,)', |
| 91 |
next: 'pop' }, |
| 92 |
{ include: '#object-types-inherited' }, |
| 93 |
{ include: '#comments' }, |
| 94 |
{ defaultToken: 'meta.definition.class.inherited.classes.vala' }] }, |
| 95 |
{ token: ['storage.modifier.implements.vala', |
| 96 |
'meta.definition.class.implemented.interfaces.vala'], |
| 97 |
regex: '(,)(\\s)', |
| 98 |
push: [{ token: 'meta.definition.class.implemented.interfaces.vala', |
| 99 |
regex: '(?=\\{)', |
| 100 |
next: 'pop' }, |
| 101 |
{ include: '#object-types-inherited' }, |
| 102 |
{ include: '#comments' }, |
| 103 |
{ defaultToken: 'meta.definition.class.implemented.interfaces.vala' }] }, |
| 104 |
{ token: 'paren.vala', |
| 105 |
regex: '{', |
| 106 |
push: [{ token: 'paren.vala', regex: '(?=})', next: 'pop' }, |
| 107 |
{ include: '#class-body' }, |
| 108 |
{ defaultToken: 'meta.class.body.vala' }] }, |
| 109 |
{ defaultToken: 'meta.class.vala' }], |
| 110 |
comment: 'attempting to put namespace in here.' }], |
| 111 |
'#class-body': [{ include: '#comments' }, |
| 112 |
{ include: '#class' }, |
| 113 |
{ include: '#enums' }, |
| 114 |
{ include: '#methods' }, |
| 115 |
{ include: '#annotations' }, |
| 116 |
{ include: '#storage-modifiers' }, |
| 117 |
{ include: '#code' }], |
| 118 |
'#code': [{ include: '#comments' }, |
| 119 |
{ include: '#class' }, |
| 120 |
{ token: 'text', |
| 121 |
regex: '{', |
| 122 |
push: [{ token: 'text', regex: '}', next: 'pop' }, |
| 123 |
{ include: '#code' }] }, |
| 124 |
{ include: '#assertions' }, |
| 125 |
{ include: '#parens' }, |
| 126 |
{ include: '#constants-and-special-vars' }, |
| 127 |
{ include: '#anonymous-classes-and-new' }, |
| 128 |
{ include: '#keywords' }, |
| 129 |
{ include: '#storage-modifiers' }, |
| 130 |
{ include: '#strings' }, |
| 131 |
{ include: '#all-types' }], |
| 132 |
'#comments': [{ token: 'punctuation.definition.comment.vala', |
| 133 |
regex: '/\\*\\*/' }, |
| 134 |
{ include: 'text.html.javadoc' }, |
| 135 |
{ include: '#comments-inline' }], |
| 136 |
'#comments-inline': [{ token: 'punctuation.definition.comment.vala', |
| 137 |
regex: '/\\*', |
| 138 |
push: [{ token: 'punctuation.definition.comment.vala', |
| 139 |
regex: '\\*/', |
| 140 |
next: 'pop' }, |
| 141 |
{ defaultToken: 'comment.block.vala' }] }, |
| 142 |
{ token: ['text', |
| 143 |
'punctuation.definition.comment.vala', |
| 144 |
'comment.line.double-slash.vala'], |
| 145 |
regex: '(\\s*)(//)(.*$)' }], |
| 146 |
'#constants-and-special-vars': [{ token: 'constant.language.vala', |
| 147 |
regex: '\\b(?:true|false|null)\\b' }, |
| 148 |
{ token: 'variable.language.vala', |
| 149 |
regex: '\\b(?:this|base)\\b' }, |
| 150 |
{ token: 'constant.numeric.vala', |
| 151 |
regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:[LlFfUuDd]|UL|ul)?\\b' }, |
| 152 |
{ token: ['keyword.operator.dereference.vala', 'constant.other.vala'], |
| 153 |
regex: '((?:\\.)?)\\b([A-Z][A-Z0-9_]+)(?!<|\\.class|\\s*\\w+\\s*=)\\b' }], |
| 154 |
'#enums': [{ token: 'text', |
| 155 |
regex: '^(?=\\s*[A-Z0-9_]+\\s*(?:{|\\(|,))', |
| 156 |
push: [{ token: 'text', regex: '(?=;|})', next: 'pop' }, |
| 157 |
{ token: 'constant.other.enum.vala', |
| 158 |
regex: '\\w+', |
| 159 |
push: [{ token: 'meta.enum.vala', regex: '(?=,|;|})', next: 'pop' }, |
| 160 |
{ include: '#parens' }, |
| 161 |
{ token: 'text', |
| 162 |
regex: '{', |
| 163 |
push: [{ token: 'text', regex: '}', next: 'pop' }, |
| 164 |
{ include: '#class-body' }] }, |
| 165 |
{ defaultToken: 'meta.enum.vala' }] }] }], |
| 166 |
'#keywords': [{ token: 'keyword.control.catch-exception.vala', |
| 167 |
regex: '\\b(?:try|catch|finally|throw)\\b' }, |
| 168 |
{ token: 'keyword.control.vala', regex: '\\?|:|\\?\\?' }, |
| 169 |
{ token: 'keyword.control.vala', |
| 170 |
regex: '\\b(?:return|break|case|continue|default|do|while|for|foreach|switch|if|else|in|yield|get|set|value)\\b' }, |
| 171 |
{ token: 'keyword.operator.vala', |
| 172 |
regex: '\\b(?:typeof|is|as)\\b' }, |
| 173 |
{ token: 'keyword.operator.comparison.vala', |
| 174 |
regex: '==|!=|<=|>=|<>|<|>' }, |
| 175 |
{ token: 'keyword.operator.assignment.vala', regex: '=' }, |
| 176 |
{ token: 'keyword.operator.increment-decrement.vala', |
| 177 |
regex: '\\-\\-|\\+\\+' }, |
| 178 |
{ token: 'keyword.operator.arithmetic.vala', |
| 179 |
regex: '\\-|\\+|\\*|\\/|%' }, |
| 180 |
{ token: 'keyword.operator.logical.vala', regex: '!|&&|\\|\\|' }, |
| 181 |
{ token: 'keyword.operator.dereference.vala', |
| 182 |
regex: '\\.(?=\\S)', |
| 183 |
originalRegex: '(?<=\\S)\\.(?=\\S)' }, |
| 184 |
{ token: 'punctuation.terminator.vala', regex: ';' }, |
| 185 |
{ token: 'keyword.operator.ownership', regex: 'owned|unowned' }], |
| 186 |
'#methods': [{ token: 'meta.method.vala', |
| 187 |
regex: '(?!new)(?=\\w.*\\s+)(?=[^=]+\\()', |
| 188 |
push: [{ token: 'paren.vala', regex: '}|(?=;)', next: 'pop' }, |
| 189 |
{ include: '#storage-modifiers' }, |
| 190 |
{ token: ['entity.name.function.vala', 'meta.method.identifier.vala'], |
| 191 |
regex: '([\\~\\w\\.]+)(\\s*\\()', |
| 192 |
push: [{ token: 'meta.method.identifier.vala', |
| 193 |
regex: '\\)', |
| 194 |
next: 'pop' }, |
| 195 |
{ include: '#parameters' }, |
| 196 |
{ defaultToken: 'meta.method.identifier.vala' }] }, |
| 197 |
{ token: 'meta.method.return-type.vala', |
| 198 |
regex: '(?=\\w.*\\s+\\w+\\s*\\()', |
| 199 |
push: [{ token: 'meta.method.return-type.vala', |
| 200 |
regex: '(?=\\w+\\s*\\()', |
| 201 |
next: 'pop' }, |
| 202 |
{ include: '#all-types' }, |
| 203 |
{ defaultToken: 'meta.method.return-type.vala' }] }, |
| 204 |
{ include: '#throws' }, |
| 205 |
{ token: 'paren.vala', |
| 206 |
regex: '{', |
| 207 |
push: [{ token: 'paren.vala', regex: '(?=})', next: 'pop' }, |
| 208 |
{ include: '#code' }, |
| 209 |
{ defaultToken: 'meta.method.body.vala' }] }, |
| 210 |
{ defaultToken: 'meta.method.vala' }] }], |
| 211 |
'#namespace': [{ token: 'text', |
| 212 |
regex: '^(?=\\s*[A-Z0-9_]+\\s*(?:{|\\(|,))', |
| 213 |
push: [{ token: 'text', regex: '(?=;|})', next: 'pop' }, |
| 214 |
{ token: 'constant.other.namespace.vala', |
| 215 |
regex: '\\w+', |
| 216 |
push: [{ token: 'meta.namespace.vala', regex: '(?=,|;|})', next: 'pop' }, |
| 217 |
{ include: '#parens' }, |
| 218 |
{ token: 'text', |
| 219 |
regex: '{', |
| 220 |
push: [{ token: 'text', regex: '}', next: 'pop' }, |
| 221 |
{ include: '#code' }] }, |
| 222 |
{ defaultToken: 'meta.namespace.vala' }] }], |
| 223 |
comment: 'This is not quite right. See the class grammar right now' }], |
| 224 |
'#object-types': [{ token: 'storage.type.generic.vala', |
| 225 |
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*<', |
| 226 |
push: [{ token: 'storage.type.generic.vala', |
| 227 |
regex: '>|[^\\w\\s,\\?<\\[()\\]]', |
| 228 |
TODO: 'FIXME: regexp doesn\'t have js equivalent', |
| 229 |
originalRegex: '>|[^\\w\\s,\\?<\\[(?:[,]+)\\]]', |
| 230 |
next: 'pop' }, |
| 231 |
{ include: '#object-types' }, |
| 232 |
{ token: 'storage.type.generic.vala', |
| 233 |
regex: '<', |
| 234 |
push: [{ token: 'storage.type.generic.vala', |
| 235 |
regex: '>|[^\\w\\s,\\[\\]<]', |
| 236 |
next: 'pop' }, |
| 237 |
{ defaultToken: 'storage.type.generic.vala' }], |
| 238 |
comment: 'This is just to support <>\'s with no actual type prefix' }, |
| 239 |
{ defaultToken: 'storage.type.generic.vala' }] }, |
| 240 |
{ token: 'storage.type.object.array.vala', |
| 241 |
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*(?=\\[)', |
| 242 |
push: [{ token: 'storage.type.object.array.vala', |
| 243 |
regex: '(?=[^\\]\\s])', |
| 244 |
next: 'pop' }, |
| 245 |
{ token: 'text', |
| 246 |
regex: '\\[', |
| 247 |
push: [{ token: 'text', regex: '\\]', next: 'pop' }, |
| 248 |
{ include: '#code' }] }, |
| 249 |
{ defaultToken: 'storage.type.object.array.vala' }] }, |
| 250 |
{ token: ['storage.type.vala', |
| 251 |
'keyword.operator.dereference.vala', |
| 252 |
'storage.type.vala'], |
| 253 |
regex: '\\b(?:([a-z]\\w*)(\\.))*([A-Z]+\\w*\\b)' }], |
| 254 |
'#object-types-inherited': [{ token: 'entity.other.inherited-class.vala', |
| 255 |
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*<', |
| 256 |
push: [{ token: 'entity.other.inherited-class.vala', |
| 257 |
regex: '>|[^\\w\\s,<]', |
| 258 |
next: 'pop' }, |
| 259 |
{ include: '#object-types' }, |
| 260 |
{ token: 'storage.type.generic.vala', |
| 261 |
regex: '<', |
| 262 |
push: [{ token: 'storage.type.generic.vala', |
| 263 |
regex: '>|[^\\w\\s,<]', |
| 264 |
next: 'pop' }, |
| 265 |
{ defaultToken: 'storage.type.generic.vala' }], |
| 266 |
comment: 'This is just to support <>\'s with no actual type prefix' }, |
| 267 |
{ defaultToken: 'entity.other.inherited-class.vala' }] }, |
| 268 |
{ token: ['entity.other.inherited-class.vala', |
| 269 |
'keyword.operator.dereference.vala', |
| 270 |
'entity.other.inherited-class.vala'], |
| 271 |
regex: '\\b(?:([a-z]\\w*)(\\.))*([A-Z]+\\w*)' }], |
| 272 |
'#parameters': [{ token: 'storage.modifier.vala', regex: 'final' }, |
| 273 |
{ include: '#primitive-arrays' }, |
| 274 |
{ include: '#primitive-types' }, |
| 275 |
{ include: '#object-types' }, |
| 276 |
{ token: 'variable.parameter.vala', regex: '\\w+' }], |
| 277 |
'#parens': [{ token: 'text', |
| 278 |
regex: '\\(', |
| 279 |
push: [{ token: 'text', regex: '\\)', next: 'pop' }, |
| 280 |
{ include: '#code' }] }], |
| 281 |
'#primitive-arrays': [{ token: 'storage.type.primitive.array.vala', |
| 282 |
regex: '\\b(?:bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort|string|void|int8|int16|int32|int64|uint8|uint16|uint32|uint64)(?:\\[\\])*\\b' }], |
| 283 |
'#primitive-types': [{ token: 'storage.type.primitive.vala', |
| 284 |
regex: '\\b(?:var|bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort|string|void|signal|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\\b', |
| 285 |
comment: 'var is not really a primitive, but acts like one in most cases' }], |
| 286 |
'#storage-modifiers': [{ token: 'storage.modifier.vala', |
| 287 |
regex: '\\b(?:public|private|protected|internal|static|final|sealed|virtual|override|abstract|readonly|volatile|dynamic|async|unsafe|out|ref|weak|owned|unowned|const)\\b', |
| 288 |
comment: 'Not sure about unsafe and readonly' }], |
| 289 |
'#strings': [{ token: 'punctuation.definition.string.begin.vala', |
| 290 |
regex: '@"', |
| 291 |
push: [{ token: 'punctuation.definition.string.end.vala', |
| 292 |
regex: '"', |
| 293 |
next: 'pop' }, |
| 294 |
{ token: 'constant.character.escape.vala', |
| 295 |
regex: '\\\\.|%[\\w\\.\\-]+|\\$(?:\\w+|\\([\\w\\s\\+\\-\\*\\/]+\\))' }, |
| 296 |
{ defaultToken: 'string.quoted.interpolated.vala' }] }, |
| 297 |
{ token: 'punctuation.definition.string.begin.vala', |
| 298 |
regex: '"', |
| 299 |
push: [{ token: 'punctuation.definition.string.end.vala', |
| 300 |
regex: '"', |
| 301 |
next: 'pop' }, |
| 302 |
{ token: 'constant.character.escape.vala', regex: '\\\\.' }, |
| 303 |
{ token: 'constant.character.escape.vala', |
| 304 |
regex: '%[\\w\\.\\-]+' }, |
| 305 |
{ defaultToken: 'string.quoted.double.vala' }] }, |
| 306 |
{ token: 'punctuation.definition.string.begin.vala', |
| 307 |
regex: '\'', |
| 308 |
push: [{ token: 'punctuation.definition.string.end.vala', |
| 309 |
regex: '\'', |
| 310 |
next: 'pop' }, |
| 311 |
{ token: 'constant.character.escape.vala', regex: '\\\\.' }, |
| 312 |
{ defaultToken: 'string.quoted.single.vala' }] }, |
| 313 |
{ token: 'punctuation.definition.string.begin.vala', |
| 314 |
regex: '"""', |
| 315 |
push: [{ token: 'punctuation.definition.string.end.vala', |
| 316 |
regex: '"""', |
| 317 |
next: 'pop' }, |
| 318 |
{ token: 'constant.character.escape.vala', |
| 319 |
regex: '%[\\w\\.\\-]+' }, |
| 320 |
{ defaultToken: 'string.quoted.triple.vala' }] }], |
| 321 |
'#throws': [{ token: 'storage.modifier.vala', |
| 322 |
regex: 'throws', |
| 323 |
push: [{ token: 'meta.throwables.vala', regex: '(?={|;)', next: 'pop' }, |
| 324 |
{ include: '#object-types' }, |
| 325 |
{ defaultToken: 'meta.throwables.vala' }] }], |
| 326 |
'#values': [{ include: '#strings' }, |
| 327 |
{ include: '#object-types' }, |
| 328 |
{ include: '#constants-and-special-vars' }] }; |
| 329 |
this.normalizeRules(); |
| 330 |
}; |
| 331 |
ValaHighlightRules.metaData = { |
| 332 |
comment: 'Based heavily on the Java bundle\'s language syntax. TODO:\n* Closures\n* Delegates\n* Properties: Better support for properties.\n* Annotations\n* Error domains\n* Named arguments\n* Array slicing, negative indexes, multidimensional\n* construct blocks\n* lock blocks?\n* regex literals\n* DocBlock syntax highlighting. (Currently importing javadoc)\n* Folding rule for comments.\n', |
| 333 |
fileTypes: ['vala'], |
| 334 |
foldingStartMarker: '(\\{\\s*(//.*)?$|^\\s*// \\{\\{\\{)', |
| 335 |
foldingStopMarker: '^\\s*(\\}|// \\}\\}\\}$)', |
| 336 |
name: 'Vala', |
| 337 |
scopeName: 'source.vala' |
| 338 |
}; |
| 339 |
oop.inherits(ValaHighlightRules, TextHighlightRules); |
| 340 |
exports.ValaHighlightRules = ValaHighlightRules; |
| 341 |
|
| 342 |
}); |
| 343 |
|
| 344 |
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict"; |
| 345 |
var oop = require("../../lib/oop"); |
| 346 |
var Range = require("../../range").Range; |
| 347 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 348 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 349 |
if (commentRegex) { |
| 350 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 351 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 352 |
} |
| 353 |
}; |
| 354 |
oop.inherits(FoldMode, BaseFoldMode); |
| 355 |
(function () { |
| 356 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 357 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 358 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 359 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 360 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 361 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 362 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 363 |
var line = session.getLine(row); |
| 364 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 365 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 366 |
return ""; |
| 367 |
} |
| 368 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 369 |
if (!fw && this.startRegionRe.test(line)) |
| 370 |
return "start"; |
| 371 |
return fw; |
| 372 |
}; |
| 373 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 374 |
var line = session.getLine(row); |
| 375 |
if (this.startRegionRe.test(line)) |
| 376 |
return this.getCommentRegionBlock(session, line, row); |
| 377 |
var match = line.match(this.foldingStartMarker); |
| 378 |
if (match) { |
| 379 |
var i = match.index; |
| 380 |
if (match[1]) |
| 381 |
return this.openingBracketBlock(session, match[1], row, i); |
| 382 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 383 |
if (range && !range.isMultiLine()) { |
| 384 |
if (forceMultiline) { |
| 385 |
range = this.getSectionRange(session, row); |
| 386 |
} |
| 387 |
else if (foldStyle != "all") |
| 388 |
range = null; |
| 389 |
} |
| 390 |
return range; |
| 391 |
} |
| 392 |
if (foldStyle === "markbegin") |
| 393 |
return; |
| 394 |
var match = line.match(this.foldingStopMarker); |
| 395 |
if (match) { |
| 396 |
var i = match.index + match[0].length; |
| 397 |
if (match[1]) |
| 398 |
return this.closingBracketBlock(session, match[1], row, i); |
| 399 |
return session.getCommentFoldRange(row, i, -1); |
| 400 |
} |
| 401 |
}; |
| 402 |
this.getSectionRange = function (session, row) { |
| 403 |
var line = session.getLine(row); |
| 404 |
var startIndent = line.search(/\S/); |
| 405 |
var startRow = row; |
| 406 |
var startColumn = line.length; |
| 407 |
row = row + 1; |
| 408 |
var endRow = row; |
| 409 |
var maxRow = session.getLength(); |
| 410 |
while (++row < maxRow) { |
| 411 |
line = session.getLine(row); |
| 412 |
var indent = line.search(/\S/); |
| 413 |
if (indent === -1) |
| 414 |
continue; |
| 415 |
if (startIndent > indent) |
| 416 |
break; |
| 417 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 418 |
if (subRange) { |
| 419 |
if (subRange.start.row <= startRow) { |
| 420 |
break; |
| 421 |
} |
| 422 |
else if (subRange.isMultiLine()) { |
| 423 |
row = subRange.end.row; |
| 424 |
} |
| 425 |
else if (startIndent == indent) { |
| 426 |
break; |
| 427 |
} |
| 428 |
} |
| 429 |
endRow = row; |
| 430 |
} |
| 431 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 432 |
}; |
| 433 |
this.getCommentRegionBlock = function (session, line, row) { |
| 434 |
var startColumn = line.search(/\s*$/); |
| 435 |
var maxRow = session.getLength(); |
| 436 |
var startRow = row; |
| 437 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 438 |
var depth = 1; |
| 439 |
while (++row < maxRow) { |
| 440 |
line = session.getLine(row); |
| 441 |
var m = re.exec(line); |
| 442 |
if (!m) |
| 443 |
continue; |
| 444 |
if (m[1]) |
| 445 |
depth--; |
| 446 |
else |
| 447 |
depth++; |
| 448 |
if (!depth) |
| 449 |
break; |
| 450 |
} |
| 451 |
var endRow = row; |
| 452 |
if (endRow > startRow) { |
| 453 |
return new Range(startRow, startColumn, endRow, line.length); |
| 454 |
} |
| 455 |
}; |
| 456 |
}).call(FoldMode.prototype); |
| 457 |
|
| 458 |
}); |
| 459 |
|
| 460 |
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict"; |
| 461 |
var Range = require("../range").Range; |
| 462 |
var MatchingBraceOutdent = function () { }; |
| 463 |
(function () { |
| 464 |
this.checkOutdent = function (line, input) { |
| 465 |
if (!/^\s+$/.test(line)) |
| 466 |
return false; |
| 467 |
return /^\s*\}/.test(input); |
| 468 |
}; |
| 469 |
this.autoOutdent = function (doc, row) { |
| 470 |
var line = doc.getLine(row); |
| 471 |
var match = line.match(/^(\s*\})/); |
| 472 |
if (!match) |
| 473 |
return 0; |
| 474 |
var column = match[1].length; |
| 475 |
var openBracePos = doc.findMatchingBracket({ row: row, column: column }); |
| 476 |
if (!openBracePos || openBracePos.row == row) |
| 477 |
return 0; |
| 478 |
var indent = this.$getIndent(doc.getLine(openBracePos.row)); |
| 479 |
doc.replace(new Range(row, 0, row, column - 1), indent); |
| 480 |
}; |
| 481 |
this.$getIndent = function (line) { |
| 482 |
return line.match(/^\s*/)[0]; |
| 483 |
}; |
| 484 |
}).call(MatchingBraceOutdent.prototype); |
| 485 |
exports.MatchingBraceOutdent = MatchingBraceOutdent; |
| 486 |
|
| 487 |
}); |
| 488 |
|
| 489 |
ace.define("ace/mode/vala",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/vala_highlight_rules","ace/mode/folding/cstyle","ace/mode/matching_brace_outdent"], function(require, exports, module){ |
| 490 |
|
| 491 |
|
| 492 |
"use strict"; |
| 493 |
var oop = require("../lib/oop"); |
| 494 |
var TextMode = require("./text").Mode; |
| 495 |
var ValaHighlightRules = require("./vala_highlight_rules").ValaHighlightRules; |
| 496 |
var CStyleFoldMode = require("./folding/cstyle").FoldMode; |
| 497 |
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; |
| 498 |
var Mode = function () { |
| 499 |
this.HighlightRules = ValaHighlightRules; |
| 500 |
this.$outdent = new MatchingBraceOutdent(); |
| 501 |
this.$behaviour = this.$defaultBehaviour; |
| 502 |
this.foldingRules = new CStyleFoldMode(); |
| 503 |
}; |
| 504 |
oop.inherits(Mode, TextMode); |
| 505 |
(function () { |
| 506 |
this.lineCommentStart = "//"; |
| 507 |
this.blockComment = { start: "/*", end: "*/" }; |
| 508 |
this.getNextLineIndent = function (state, line, tab) { |
| 509 |
var indent = this.$getIndent(line); |
| 510 |
var tokenizedLine = this.getTokenizer().getLineTokens(line, state); |
| 511 |
var tokens = tokenizedLine.tokens; |
| 512 |
var endState = tokenizedLine.state; |
| 513 |
if (tokens.length && tokens[tokens.length - 1].type == "comment") { |
| 514 |
return indent; |
| 515 |
} |
| 516 |
if (state == "start" || state == "no_regex") { |
| 517 |
var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/); |
| 518 |
if (match) { |
| 519 |
indent += tab; |
| 520 |
} |
| 521 |
} |
| 522 |
else if (state == "doc-start") { |
| 523 |
if (endState == "start" || endState == "no_regex") { |
| 524 |
return ""; |
| 525 |
} |
| 526 |
var match = line.match(/^\s*(\/?)\*/); |
| 527 |
if (match) { |
| 528 |
if (match[1]) { |
| 529 |
indent += " "; |
| 530 |
} |
| 531 |
indent += "* "; |
| 532 |
} |
| 533 |
} |
| 534 |
return indent; |
| 535 |
}; |
| 536 |
this.checkOutdent = function (state, line, input) { |
| 537 |
return this.$outdent.checkOutdent(line, input); |
| 538 |
}; |
| 539 |
this.autoOutdent = function (state, doc, row) { |
| 540 |
this.$outdent.autoOutdent(doc, row); |
| 541 |
}; |
| 542 |
this.$id = "ace/mode/vala"; |
| 543 |
this.snippetFileId = "ace/snippets/vala"; |
| 544 |
}).call(Mode.prototype); |
| 545 |
exports.Mode = Mode; |
| 546 |
|
| 547 |
}); (function() { |
| 548 |
ace.require(["ace/mode/vala"], function(m) { |
| 549 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 550 |
module.exports = m; |
| 551 |
} |
| 552 |
}); |
| 553 |
})(); |
| 554 |
|