bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
15.1.1
by galaxyAbstractor
Started implementation of a new codeviewer using Ace |
1 |
define('ace/mode/groovy', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/groovy_highlight_rules'], function(require, exports, module) { |
2 |
||
3 |
||
4 |
var oop = require("../lib/oop"); |
|
5 |
var JavaScriptMode = require("./javascript").Mode; |
|
6 |
var Tokenizer = require("../tokenizer").Tokenizer; |
|
7 |
var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRules; |
|
8 |
||
9 |
var Mode = function() { |
|
10 |
JavaScriptMode.call(this); |
|
11 |
this.$tokenizer = new Tokenizer(new GroovyHighlightRules().getRules()); |
|
12 |
};
|
|
13 |
oop.inherits(Mode, JavaScriptMode); |
|
14 |
||
15 |
(function() { |
|
16 |
||
17 |
this.createWorker = function(session) { |
|
18 |
return null; |
|
19 |
}; |
|
20 |
||
21 |
}).call(Mode.prototype); |
|
22 |
||
23 |
exports.Mode = Mode; |
|
24 |
});
|
|
25 |
||
26 |
define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { |
|
27 |
||
28 |
||
29 |
var oop = require("../lib/oop"); |
|
30 |
var TextMode = require("./text").Mode; |
|
31 |
var Tokenizer = require("../tokenizer").Tokenizer; |
|
32 |
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; |
|
33 |
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; |
|
34 |
var Range = require("../range").Range; |
|
35 |
var WorkerClient = require("../worker/worker_client").WorkerClient; |
|
36 |
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; |
|
37 |
var CStyleFoldMode = require("./folding/cstyle").FoldMode; |
|
38 |
||
39 |
var Mode = function() { |
|
40 |
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); |
|
41 |
this.$outdent = new MatchingBraceOutdent(); |
|
42 |
this.$behaviour = new CstyleBehaviour(); |
|
43 |
this.foldingRules = new CStyleFoldMode(); |
|
44 |
};
|
|
45 |
oop.inherits(Mode, TextMode); |
|
46 |
||
47 |
(function() { |
|
48 |
||
49 |
this.lineCommentStart = "//"; |
|
50 |
this.blockComment = {start: "/*", end: "*/"}; |
|
51 |
||
52 |
this.getNextLineIndent = function(state, line, tab) { |
|
53 |
var indent = this.$getIndent(line); |
|
54 |
||
55 |
var tokenizedLine = this.$tokenizer.getLineTokens(line, state); |
|
56 |
var tokens = tokenizedLine.tokens; |
|
57 |
var endState = tokenizedLine.state; |
|
58 |
||
59 |
if (tokens.length && tokens[tokens.length-1].type == "comment") { |
|
60 |
return indent; |
|
61 |
} |
|
62 |
||
63 |
if (state == "start" || state == "no_regex") { |
|
64 |
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); |
|
65 |
if (match) { |
|
66 |
indent += tab; |
|
67 |
} |
|
68 |
} else if (state == "doc-start") { |
|
69 |
if (endState == "start" || endState == "no_regex") { |
|
70 |
return ""; |
|
71 |
} |
|
72 |
var match = line.match(/^\s*(\/?)\*/); |
|
73 |
if (match) { |
|
74 |
if (match[1]) { |
|
75 |
indent += " "; |
|
76 |
} |
|
77 |
indent += "* "; |
|
78 |
} |
|
79 |
} |
|
80 |
||
81 |
return indent; |
|
82 |
}; |
|
83 |
||
84 |
this.checkOutdent = function(state, line, input) { |
|
85 |
return this.$outdent.checkOutdent(line, input); |
|
86 |
}; |
|
87 |
||
88 |
this.autoOutdent = function(state, doc, row) { |
|
89 |
this.$outdent.autoOutdent(doc, row); |
|
90 |
}; |
|
91 |
||
92 |
this.createWorker = function(session) { |
|
93 |
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); |
|
94 |
worker.attachToDocument(session.getDocument()); |
|
95 |
||
96 |
worker.on("jslint", function(results) { |
|
97 |
session.setAnnotations(results.data); |
|
98 |
}); |
|
99 |
||
100 |
worker.on("terminate", function() { |
|
101 |
session.clearAnnotations(); |
|
102 |
}); |
|
103 |
||
104 |
return worker; |
|
105 |
}; |
|
106 |
||
107 |
}).call(Mode.prototype); |
|
108 |
||
109 |
exports.Mode = Mode; |
|
110 |
});
|
|
111 |
||
112 |
define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { |
|
113 |
||
114 |
||
115 |
var oop = require("../lib/oop"); |
|
116 |
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; |
|
117 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
|
118 |
||
119 |
var JavaScriptHighlightRules = function() { |
|
120 |
var keywordMapper = this.createKeywordMapper({ |
|
121 |
"variable.language": |
|
122 |
"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors |
|
123 |
"Namespace|QName|XML|XMLList|" + // E4X |
|
124 |
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + |
|
125 |
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + |
|
126 |
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors |
|
127 |
"SyntaxError|TypeError|URIError|" + |
|
128 |
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions |
|
129 |
"isNaN|parseFloat|parseInt|" + |
|
130 |
"JSON|Math|" + // Other |
|
131 |
"this|arguments|prototype|window|document" , // Pseudo |
|
132 |
"keyword": |
|
133 |
"const|yield|import|get|set|" + |
|
134 |
"break|case|catch|continue|default|delete|do|else|finally|for|function|" + |
|
135 |
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" + |
|
136 |
"__parent__|__count__|escape|unescape|with|__proto__|" + |
|
137 |
"class|enum|extends|super|export|implements|private|public|interface|package|protected|static", |
|
138 |
"storage.type": |
|
139 |
"const|let|var|function", |
|
140 |
"constant.language": |
|
141 |
"null|Infinity|NaN|undefined", |
|
142 |
"support.function": |
|
143 |
"alert", |
|
144 |
"constant.language.boolean": "true|false" |
|
145 |
}, "identifier"); |
|
146 |
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void"; |
|
147 |
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; |
|
148 |
||
149 |
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex |
|
150 |
"u[0-9a-fA-F]{4}|" + // unicode |
|
151 |
"[0-2][0-7]{0,2}|" + // oct |
|
152 |
"3[0-6][0-7]?|" + // oct |
|
153 |
"37[0-7]?|" + // oct |
|
154 |
"[4-7][0-7]?|" + //oct |
|
155 |
".)"; |
|
156 |
||
157 |
this.$rules = { |
|
158 |
"no_regex" : [ |
|
159 |
{ |
|
160 |
token : "comment", |
|
161 |
regex : /\/\/.*$/ |
|
162 |
}, |
|
163 |
DocCommentHighlightRules.getStartRule("doc-start"), |
|
164 |
{ |
|
165 |
token : "comment", // multi line comment |
|
166 |
regex : /\/\*/, |
|
167 |
next : "comment" |
|
168 |
}, { |
|
169 |
token : "string", |
|
170 |
regex : "'(?=.)", |
|
171 |
next : "qstring" |
|
172 |
}, { |
|
173 |
token : "string", |
|
174 |
regex : '"(?=.)', |
|
175 |
next : "qqstring" |
|
176 |
}, { |
|
177 |
token : "constant.numeric", // hex |
|
178 |
regex : /0[xX][0-9a-fA-F]+\b/ |
|
179 |
}, { |
|
180 |
token : "constant.numeric", // float |
|
181 |
regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ |
|
182 |
}, { |
|
183 |
token : [ |
|
184 |
"storage.type", "punctuation.operator", "support.function", |
|
185 |
"punctuation.operator", "entity.name.function", "text","keyword.operator" |
|
186 |
], |
|
187 |
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", |
|
188 |
next: "function_arguments" |
|
189 |
}, { |
|
190 |
token : [ |
|
191 |
"storage.type", "punctuation.operator", "entity.name.function", "text", |
|
192 |
"keyword.operator", "text", "storage.type", "text", "paren.lparen" |
|
193 |
], |
|
194 |
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", |
|
195 |
next: "function_arguments" |
|
196 |
}, { |
|
197 |
token : [ |
|
198 |
"entity.name.function", "text", "keyword.operator", "text", "storage.type", |
|
199 |
"text", "paren.lparen" |
|
200 |
], |
|
201 |
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", |
|
202 |
next: "function_arguments" |
|
203 |
}, { |
|
204 |
token : [ |
|
205 |
"storage.type", "punctuation.operator", "entity.name.function", "text", |
|
206 |
"keyword.operator", "text", |
|
207 |
"storage.type", "text", "entity.name.function", "text", "paren.lparen" |
|
208 |
], |
|
209 |
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", |
|
210 |
next: "function_arguments" |
|
211 |
}, { |
|
212 |
token : [ |
|
213 |
"storage.type", "text", "entity.name.function", "text", "paren.lparen" |
|
214 |
], |
|
215 |
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", |
|
216 |
next: "function_arguments" |
|
217 |
}, { |
|
218 |
token : [ |
|
219 |
"entity.name.function", "text", "punctuation.operator", |
|
220 |
"text", "storage.type", "text", "paren.lparen" |
|
221 |
], |
|
222 |
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", |
|
223 |
next: "function_arguments" |
|
224 |
}, { |
|
225 |
token : [ |
|
226 |
"text", "text", "storage.type", "text", "paren.lparen" |
|
227 |
], |
|
228 |
regex : "(:)(\\s*)(function)(\\s*)(\\()", |
|
229 |
next: "function_arguments" |
|
230 |
}, { |
|
231 |
token : "keyword", |
|
232 |
regex : "(?:" + kwBeforeRe + ")\\b", |
|
233 |
next : "start" |
|
234 |
}, { |
|
235 |
token : ["punctuation.operator", "support.function"], |
|
236 |
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ |
|
237 |
}, { |
|
238 |
token : ["punctuation.operator", "support.function.dom"], |
|
239 |
regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ |
|
240 |
}, { |
|
241 |
token : ["punctuation.operator", "support.constant"], |
|
242 |
regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ |
|
243 |
}, { |
|
244 |
token : ["storage.type", "punctuation.operator", "support.function.firebug"], |
|
245 |
regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ |
|
246 |
}, { |
|
247 |
token : keywordMapper, |
|
248 |
regex : identifierRe |
|
249 |
}, { |
|
250 |
token : "keyword.operator", |
|
251 |
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/, |
|
252 |
next : "start" |
|
253 |
}, { |
|
254 |
token : "punctuation.operator", |
|
255 |
regex : /\?|\:|\,|\;|\./, |
|
256 |
next : "start" |
|
257 |
}, { |
|
258 |
token : "paren.lparen", |
|
259 |
regex : /[\[({]/, |
|
260 |
next : "start" |
|
261 |
}, { |
|
262 |
token : "paren.rparen", |
|
263 |
regex : /[\])}]/ |
|
264 |
}, { |
|
265 |
token : "keyword.operator", |
|
266 |
regex : /\/=?/, |
|
267 |
next : "start" |
|
268 |
}, { |
|
269 |
token: "comment", |
|
270 |
regex: /^#!.*$/ |
|
271 |
} |
|
272 |
], |
|
273 |
"start": [ |
|
274 |
DocCommentHighlightRules.getStartRule("doc-start"), |
|
275 |
{ |
|
276 |
token : "comment", // multi line comment |
|
277 |
regex : "\\/\\*", |
|
278 |
next : "comment_regex_allowed" |
|
279 |
}, { |
|
280 |
token : "comment", |
|
281 |
regex : "\\/\\/.*$", |
|
282 |
next : "start" |
|
283 |
}, { |
|
284 |
token: "string.regexp", |
|
285 |
regex: "\\/", |
|
286 |
next: "regex", |
|
287 |
}, { |
|
288 |
token : "text", |
|
289 |
regex : "\\s+|^$", |
|
290 |
next : "start" |
|
291 |
}, { |
|
292 |
token: "empty", |
|
293 |
regex: "", |
|
294 |
next: "no_regex" |
|
295 |
} |
|
296 |
], |
|
297 |
"regex": [ |
|
298 |
{ |
|
299 |
token: "regexp.keyword.operator", |
|
300 |
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" |
|
301 |
}, { |
|
302 |
token: "string.regexp", |
|
303 |
regex: "/\\w*", |
|
304 |
next: "no_regex", |
|
305 |
}, { |
|
306 |
token : "invalid", |
|
307 |
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ |
|
308 |
}, { |
|
309 |
token : "constant.language.escape", |
|
310 |
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/ |
|
311 |
}, { |
|
312 |
token : "constant.language.delimiter", |
|
313 |
regex: /\|/ |
|
314 |
}, { |
|
315 |
token: "constant.language.escape", |
|
316 |
regex: /\[\^?/, |
|
317 |
next: "regex_character_class", |
|
318 |
}, { |
|
319 |
token: "empty", |
|
320 |
regex: "$", |
|
321 |
next: "no_regex" |
|
322 |
}, { |
|
323 |
defaultToken: "string.regexp" |
|
324 |
} |
|
325 |
], |
|
326 |
"regex_character_class": [ |
|
327 |
{ |
|
328 |
token: "regexp.keyword.operator", |
|
329 |
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" |
|
330 |
}, { |
|
331 |
token: "constant.language.escape", |
|
332 |
regex: "]", |
|
333 |
next: "regex", |
|
334 |
}, { |
|
335 |
token: "constant.language.escape", |
|
336 |
regex: "-" |
|
337 |
}, { |
|
338 |
token: "empty", |
|
339 |
regex: "$", |
|
340 |
next: "no_regex" |
|
341 |
}, { |
|
342 |
defaultToken: "string.regexp.charachterclass" |
|
343 |
} |
|
344 |
], |
|
345 |
"function_arguments": [ |
|
346 |
{ |
|
347 |
token: "variable.parameter", |
|
348 |
regex: identifierRe |
|
349 |
}, { |
|
350 |
token: "punctuation.operator", |
|
351 |
regex: "[, ]+", |
|
352 |
}, { |
|
353 |
token: "punctuation.operator", |
|
354 |
regex: "$", |
|
355 |
}, { |
|
356 |
token: "empty", |
|
357 |
regex: "", |
|
358 |
next: "no_regex" |
|
359 |
} |
|
360 |
], |
|
361 |
"comment_regex_allowed" : [ |
|
362 |
{token : "comment", regex : "\\*\\/", next : "start"}, |
|
363 |
{defaultToken : "comment"} |
|
364 |
], |
|
365 |
"comment" : [ |
|
366 |
{token : "comment", regex : "\\*\\/", next : "no_regex"}, |
|
367 |
{defaultToken : "comment"} |
|
368 |
], |
|
369 |
"qqstring" : [ |
|
370 |
{ |
|
371 |
token : "constant.language.escape", |
|
372 |
regex : escapedRe |
|
373 |
}, { |
|
374 |
token : "string", |
|
375 |
regex : "\\\\$", |
|
376 |
next : "qqstring", |
|
377 |
}, { |
|
378 |
token : "string", |
|
379 |
regex : '"|$', |
|
380 |
next : "no_regex", |
|
381 |
}, { |
|
382 |
defaultToken: "string" |
|
383 |
} |
|
384 |
], |
|
385 |
"qstring" : [ |
|
386 |
{ |
|
387 |
token : "constant.language.escape", |
|
388 |
regex : escapedRe |
|
389 |
}, { |
|
390 |
token : "string", |
|
391 |
regex : "\\\\$", |
|
392 |
next : "qstring", |
|
393 |
}, { |
|
394 |
token : "string", |
|
395 |
regex : "'|$", |
|
396 |
next : "no_regex", |
|
397 |
}, { |
|
398 |
defaultToken: "string" |
|
399 |
} |
|
400 |
] |
|
401 |
}; |
|
402 |
||
403 |
this.embedRules(DocCommentHighlightRules, "doc-", |
|
404 |
[ DocCommentHighlightRules.getEndRule("no_regex") ]); |
|
405 |
};
|
|
406 |
||
407 |
oop.inherits(JavaScriptHighlightRules, TextHighlightRules); |
|
408 |
||
409 |
exports.JavaScriptHighlightRules = JavaScriptHighlightRules; |
|
410 |
});
|
|
411 |
||
412 |
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { |
|
413 |
||
414 |
||
415 |
var oop = require("../lib/oop"); |
|
416 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
|
417 |
||
418 |
var DocCommentHighlightRules = function() { |
|
419 |
||
420 |
this.$rules = { |
|
421 |
"start" : [ { |
|
422 |
token : "comment.doc.tag", |
|
423 |
regex : "@[\\w\\d_]+" // TODO: fix email addresses |
|
424 |
}, { |
|
425 |
token : "comment.doc.tag", |
|
426 |
regex : "\\bTODO\\b" |
|
427 |
}, { |
|
428 |
defaultToken : "comment.doc" |
|
429 |
}] |
|
430 |
}; |
|
431 |
};
|
|
432 |
||
433 |
oop.inherits(DocCommentHighlightRules, TextHighlightRules); |
|
434 |
||
435 |
DocCommentHighlightRules.getStartRule = function(start) { |
|
436 |
return { |
|
437 |
token : "comment.doc", // doc comment |
|
438 |
regex : "\\/\\*(?=\\*)", |
|
439 |
next : start |
|
440 |
}; |
|
441 |
};
|
|
442 |
||
443 |
DocCommentHighlightRules.getEndRule = function (start) { |
|
444 |
return { |
|
445 |
token : "comment.doc", // closing comment |
|
446 |
regex : "\\*\\/", |
|
447 |
next : start |
|
448 |
}; |
|
449 |
};
|
|
450 |
||
451 |
||
452 |
exports.DocCommentHighlightRules = DocCommentHighlightRules; |
|
453 |
||
454 |
});
|
|
455 |
||
456 |
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { |
|
457 |
||
458 |
||
459 |
var Range = require("../range").Range; |
|
460 |
||
461 |
var MatchingBraceOutdent = function() {}; |
|
462 |
||
463 |
(function() { |
|
464 |
||
465 |
this.checkOutdent = function(line, input) { |
|
466 |
if (! /^\s+$/.test(line)) |
|
467 |
return false; |
|
468 |
||
469 |
return /^\s*\}/.test(input); |
|
470 |
}; |
|
471 |
||
472 |
this.autoOutdent = function(doc, row) { |
|
473 |
var line = doc.getLine(row); |
|
474 |
var match = line.match(/^(\s*\})/); |
|
475 |
||
476 |
if (!match) return 0; |
|
477 |
||
478 |
var column = match[1].length; |
|
479 |
var openBracePos = doc.findMatchingBracket({row: row, column: column}); |
|
480 |
||
481 |
if (!openBracePos || openBracePos.row == row) return 0; |
|
482 |
||
483 |
var indent = this.$getIndent(doc.getLine(openBracePos.row)); |
|
484 |
doc.replace(new Range(row, 0, row, column-1), indent); |
|
485 |
}; |
|
486 |
||
487 |
this.$getIndent = function(line) { |
|
488 |
return line.match(/^\s*/)[0]; |
|
489 |
}; |
|
490 |
||
491 |
}).call(MatchingBraceOutdent.prototype); |
|
492 |
||
493 |
exports.MatchingBraceOutdent = MatchingBraceOutdent; |
|
494 |
});
|
|
495 |
||
496 |
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) { |
|
497 |
||
498 |
||
499 |
var oop = require("../../lib/oop"); |
|
500 |
var Behaviour = require("../behaviour").Behaviour; |
|
501 |
var TokenIterator = require("../../token_iterator").TokenIterator; |
|
502 |
var lang = require("../../lib/lang"); |
|
503 |
||
504 |
var SAFE_INSERT_IN_TOKENS = |
|
505 |
["text", "paren.rparen", "punctuation.operator"]; |
|
506 |
var SAFE_INSERT_BEFORE_TOKENS = |
|
507 |
["text", "paren.rparen", "punctuation.operator", "comment"]; |
|
508 |
||
509 |
||
510 |
var autoInsertedBrackets = 0; |
|
511 |
var autoInsertedRow = -1; |
|
512 |
var autoInsertedLineEnd = ""; |
|
513 |
var maybeInsertedBrackets = 0; |
|
514 |
var maybeInsertedRow = -1; |
|
515 |
var maybeInsertedLineStart = ""; |
|
516 |
var maybeInsertedLineEnd = ""; |
|
517 |
||
518 |
var CstyleBehaviour = function () { |
|
519 |
|
|
520 |
CstyleBehaviour.isSaneInsertion = function(editor, session) { |
|
521 |
var cursor = editor.getCursorPosition(); |
|
522 |
var iterator = new TokenIterator(session, cursor.row, cursor.column); |
|
523 |
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) { |
|
524 |
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1); |
|
525 |
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) |
|
526 |
return false; |
|
527 |
} |
|
528 |
iterator.stepForward(); |
|
529 |
return iterator.getCurrentTokenRow() !== cursor.row || |
|
530 |
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS); |
|
531 |
}; |
|
532 |
|
|
533 |
CstyleBehaviour.$matchTokenType = function(token, types) { |
|
534 |
return types.indexOf(token.type || token) > -1; |
|
535 |
}; |
|
536 |
|
|
537 |
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) { |
|
538 |
var cursor = editor.getCursorPosition(); |
|
539 |
var line = session.doc.getLine(cursor.row); |
|
540 |
if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0])) |
|
541 |
autoInsertedBrackets = 0; |
|
542 |
autoInsertedRow = cursor.row; |
|
543 |
autoInsertedLineEnd = bracket + line.substr(cursor.column); |
|
544 |
autoInsertedBrackets++; |
|
545 |
}; |
|
546 |
|
|
547 |
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) { |
|
548 |
var cursor = editor.getCursorPosition(); |
|
549 |
var line = session.doc.getLine(cursor.row); |
|
550 |
if (!this.isMaybeInsertedClosing(cursor, line)) |
|
551 |
maybeInsertedBrackets = 0; |
|
552 |
maybeInsertedRow = cursor.row; |
|
553 |
maybeInsertedLineStart = line.substr(0, cursor.column) + bracket; |
|
554 |
maybeInsertedLineEnd = line.substr(cursor.column); |
|
555 |
maybeInsertedBrackets++; |
|
556 |
}; |
|
557 |
|
|
558 |
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) { |
|
559 |
return autoInsertedBrackets > 0 && |
|
560 |
cursor.row === autoInsertedRow && |
|
561 |
bracket === autoInsertedLineEnd[0] && |
|
562 |
line.substr(cursor.column) === autoInsertedLineEnd; |
|
563 |
}; |
|
564 |
|
|
565 |
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) { |
|
566 |
return maybeInsertedBrackets > 0 && |
|
567 |
cursor.row === maybeInsertedRow && |
|
568 |
line.substr(cursor.column) === maybeInsertedLineEnd && |
|
569 |
line.substr(0, cursor.column) == maybeInsertedLineStart; |
|
570 |
}; |
|
571 |
|
|
572 |
CstyleBehaviour.popAutoInsertedClosing = function() { |
|
573 |
autoInsertedLineEnd = autoInsertedLineEnd.substr(1); |
|
574 |
autoInsertedBrackets--; |
|
575 |
}; |
|
576 |
|
|
577 |
CstyleBehaviour.clearMaybeInsertedClosing = function() { |
|
578 |
maybeInsertedBrackets = 0; |
|
579 |
maybeInsertedRow = -1; |
|
580 |
}; |
|
581 |
||
582 |
this.add("braces", "insertion", function (state, action, editor, session, text) { |
|
583 |
var cursor = editor.getCursorPosition(); |
|
584 |
var line = session.doc.getLine(cursor.row); |
|
585 |
if (text == '{') { |
|
586 |
var selection = editor.getSelectionRange(); |
|
587 |
var selected = session.doc.getTextRange(selection); |
|
588 |
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) { |
|
589 |
return { |
|
590 |
text: '{' + selected + '}', |
|
591 |
selection: false |
|
592 |
}; |
|
593 |
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
|
594 |
if (/[\]\}\)]/.test(line[cursor.column])) { |
|
595 |
CstyleBehaviour.recordAutoInsert(editor, session, "}"); |
|
596 |
return { |
|
597 |
text: '{}', |
|
598 |
selection: [1, 1] |
|
599 |
}; |
|
600 |
} else { |
|
601 |
CstyleBehaviour.recordMaybeInsert(editor, session, "{"); |
|
602 |
return { |
|
603 |
text: '{', |
|
604 |
selection: [1, 1] |
|
605 |
}; |
|
606 |
} |
|
607 |
} |
|
608 |
} else if (text == '}') { |
|
609 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
|
610 |
if (rightChar == '}') { |
|
611 |
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); |
|
612 |
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
|
613 |
CstyleBehaviour.popAutoInsertedClosing(); |
|
614 |
return { |
|
615 |
text: '', |
|
616 |
selection: [1, 1] |
|
617 |
}; |
|
618 |
} |
|
619 |
} |
|
620 |
} else if (text == "\n" || text == "\r\n") { |
|
621 |
var closing = ""; |
|
622 |
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) { |
|
623 |
closing = lang.stringRepeat("}", maybeInsertedBrackets); |
|
624 |
CstyleBehaviour.clearMaybeInsertedClosing(); |
|
625 |
} |
|
626 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
|
627 |
if (rightChar == '}' || closing !== "") { |
|
628 |
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}'); |
|
629 |
if (!openBracePos) |
|
630 |
return null; |
|
631 |
||
632 |
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString()); |
|
633 |
var next_indent = this.$getIndent(line); |
|
634 |
||
635 |
return { |
|
636 |
text: '\n' + indent + '\n' + next_indent + closing, |
|
637 |
selection: [1, indent.length, 1, indent.length] |
|
638 |
}; |
|
639 |
} |
|
640 |
} |
|
641 |
}); |
|
642 |
||
643 |
this.add("braces", "deletion", function (state, action, editor, session, range) { |
|
644 |
var selected = session.doc.getTextRange(range); |
|
645 |
if (!range.isMultiLine() && selected == '{') { |
|
646 |
var line = session.doc.getLine(range.start.row); |
|
647 |
var rightChar = line.substring(range.end.column, range.end.column + 1); |
|
648 |
if (rightChar == '}') { |
|
649 |
range.end.column++; |
|
650 |
return range; |
|
651 |
} else { |
|
652 |
maybeInsertedBrackets--; |
|
653 |
} |
|
654 |
} |
|
655 |
}); |
|
656 |
||
657 |
this.add("parens", "insertion", function (state, action, editor, session, text) { |
|
658 |
if (text == '(') { |
|
659 |
var selection = editor.getSelectionRange(); |
|
660 |
var selected = session.doc.getTextRange(selection); |
|
661 |
if (selected !== "" && editor.getWrapBehavioursEnabled()) { |
|
662 |
return { |
|
663 |
text: '(' + selected + ')', |
|
664 |
selection: false |
|
665 |
}; |
|
666 |
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
|
667 |
CstyleBehaviour.recordAutoInsert(editor, session, ")"); |
|
668 |
return { |
|
669 |
text: '()', |
|
670 |
selection: [1, 1] |
|
671 |
}; |
|
672 |
} |
|
673 |
} else if (text == ')') { |
|
674 |
var cursor = editor.getCursorPosition(); |
|
675 |
var line = session.doc.getLine(cursor.row); |
|
676 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
|
677 |
if (rightChar == ')') { |
|
678 |
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); |
|
679 |
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
|
680 |
CstyleBehaviour.popAutoInsertedClosing(); |
|
681 |
return { |
|
682 |
text: '', |
|
683 |
selection: [1, 1] |
|
684 |
}; |
|
685 |
} |
|
686 |
} |
|
687 |
} |
|
688 |
}); |
|
689 |
||
690 |
this.add("parens", "deletion", function (state, action, editor, session, range) { |
|
691 |
var selected = session.doc.getTextRange(range); |
|
692 |
if (!range.isMultiLine() && selected == '(') { |
|
693 |
var line = session.doc.getLine(range.start.row); |
|
694 |
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
|
695 |
if (rightChar == ')') { |
|
696 |
range.end.column++; |
|
697 |
return range; |
|
698 |
} |
|
699 |
} |
|
700 |
}); |
|
701 |
||
702 |
this.add("brackets", "insertion", function (state, action, editor, session, text) { |
|
703 |
if (text == '[') { |
|
704 |
var selection = editor.getSelectionRange(); |
|
705 |
var selected = session.doc.getTextRange(selection); |
|
706 |
if (selected !== "" && editor.getWrapBehavioursEnabled()) { |
|
707 |
return { |
|
708 |
text: '[' + selected + ']', |
|
709 |
selection: false |
|
710 |
}; |
|
711 |
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
|
712 |
CstyleBehaviour.recordAutoInsert(editor, session, "]"); |
|
713 |
return { |
|
714 |
text: '[]', |
|
715 |
selection: [1, 1] |
|
716 |
}; |
|
717 |
} |
|
718 |
} else if (text == ']') { |
|
719 |
var cursor = editor.getCursorPosition(); |
|
720 |
var line = session.doc.getLine(cursor.row); |
|
721 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
|
722 |
if (rightChar == ']') { |
|
723 |
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); |
|
724 |
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
|
725 |
CstyleBehaviour.popAutoInsertedClosing(); |
|
726 |
return { |
|
727 |
text: '', |
|
728 |
selection: [1, 1] |
|
729 |
}; |
|
730 |
} |
|
731 |
} |
|
732 |
} |
|
733 |
}); |
|
734 |
||
735 |
this.add("brackets", "deletion", function (state, action, editor, session, range) { |
|
736 |
var selected = session.doc.getTextRange(range); |
|
737 |
if (!range.isMultiLine() && selected == '[') { |
|
738 |
var line = session.doc.getLine(range.start.row); |
|
739 |
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
|
740 |
if (rightChar == ']') { |
|
741 |
range.end.column++; |
|
742 |
return range; |
|
743 |
} |
|
744 |
} |
|
745 |
}); |
|
746 |
||
747 |
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { |
|
748 |
if (text == '"' || text == "'") { |
|
749 |
var quote = text; |
|
750 |
var selection = editor.getSelectionRange(); |
|
751 |
var selected = session.doc.getTextRange(selection); |
|
752 |
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { |
|
753 |
return { |
|
754 |
text: quote + selected + quote, |
|
755 |
selection: false |
|
756 |
}; |
|
757 |
} else { |
|
758 |
var cursor = editor.getCursorPosition(); |
|
759 |
var line = session.doc.getLine(cursor.row); |
|
760 |
var leftChar = line.substring(cursor.column-1, cursor.column); |
|
761 |
if (leftChar == '\\') { |
|
762 |
return null; |
|
763 |
} |
|
764 |
var tokens = session.getTokens(selection.start.row); |
|
765 |
var col = 0, token; |
|
766 |
var quotepos = -1; // Track whether we're inside an open quote. |
|
767 |
||
768 |
for (var x = 0; x < tokens.length; x++) { |
|
769 |
token = tokens[x]; |
|
770 |
if (token.type == "string") { |
|
771 |
quotepos = -1; |
|
772 |
} else if (quotepos < 0) { |
|
773 |
quotepos = token.value.indexOf(quote); |
|
774 |
} |
|
775 |
if ((token.value.length + col) > selection.start.column) { |
|
776 |
break; |
|
777 |
} |
|
778 |
col += tokens[x].value.length; |
|
779 |
} |
|
780 |
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { |
|
781 |
if (!CstyleBehaviour.isSaneInsertion(editor, session)) |
|
782 |
return; |
|
783 |
return { |
|
784 |
text: quote + quote, |
|
785 |
selection: [1,1] |
|
786 |
}; |
|
787 |
} else if (token && token.type === "string") { |
|
788 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
|
789 |
if (rightChar == quote) { |
|
790 |
return { |
|
791 |
text: '', |
|
792 |
selection: [1, 1] |
|
793 |
}; |
|
794 |
} |
|
795 |
} |
|
796 |
} |
|
797 |
} |
|
798 |
}); |
|
799 |
||
800 |
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { |
|
801 |
var selected = session.doc.getTextRange(range); |
|
802 |
if (!range.isMultiLine() && (selected == '"' || selected == "'")) { |
|
803 |
var line = session.doc.getLine(range.start.row); |
|
804 |
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
|
805 |
if (rightChar == selected) { |
|
806 |
range.end.column++; |
|
807 |
return range; |
|
808 |
} |
|
809 |
} |
|
810 |
}); |
|
811 |
||
812 |
};
|
|
813 |
||
814 |
oop.inherits(CstyleBehaviour, Behaviour); |
|
815 |
||
816 |
exports.CstyleBehaviour = CstyleBehaviour; |
|
817 |
});
|
|
818 |
||
819 |
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { |
|
820 |
||
821 |
||
822 |
var oop = require("../../lib/oop"); |
|
823 |
var Range = require("../../range").Range; |
|
824 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
|
825 |
||
826 |
var FoldMode = exports.FoldMode = function(commentRegex) { |
|
827 |
if (commentRegex) { |
|
828 |
this.foldingStartMarker = new RegExp( |
|
829 |
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) |
|
830 |
); |
|
831 |
this.foldingStopMarker = new RegExp( |
|
832 |
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) |
|
833 |
); |
|
834 |
} |
|
835 |
};
|
|
836 |
oop.inherits(FoldMode, BaseFoldMode); |
|
837 |
||
838 |
(function() { |
|
839 |
||
840 |
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; |
|
841 |
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; |
|
842 |
||
843 |
this.getFoldWidgetRange = function(session, foldStyle, row) { |
|
844 |
var line = session.getLine(row); |
|
845 |
var match = line.match(this.foldingStartMarker); |
|
846 |
if (match) { |
|
847 |
var i = match.index; |
|
848 |
||
849 |
if (match[1]) |
|
850 |
return this.openingBracketBlock(session, match[1], row, i); |
|
851 |
||
852 |
return session.getCommentFoldRange(row, i + match[0].length, 1); |
|
853 |
} |
|
854 |
||
855 |
if (foldStyle !== "markbeginend") |
|
856 |
return; |
|
857 |
||
858 |
var match = line.match(this.foldingStopMarker); |
|
859 |
if (match) { |
|
860 |
var i = match.index + match[0].length; |
|
861 |
||
862 |
if (match[1]) |
|
863 |
return this.closingBracketBlock(session, match[1], row, i); |
|
864 |
||
865 |
return session.getCommentFoldRange(row, i, -1); |
|
866 |
} |
|
867 |
}; |
|
868 |
||
869 |
}).call(FoldMode.prototype); |
|
870 |
||
871 |
});
|
|
872 |
define('ace/mode/groovy_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { |
|
873 |
||
874 |
||
875 |
var oop = require("../lib/oop"); |
|
876 |
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; |
|
877 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
|
878 |
||
879 |
var GroovyHighlightRules = function() { |
|
880 |
||
881 |
var keywords = ( |
|
882 |
"assert|with|abstract|continue|for|new|switch|" + |
|
883 |
"assert|default|goto|package|synchronized|" + |
|
884 |
"boolean|do|if|private|this|" + |
|
885 |
"break|double|implements|protected|throw|" + |
|
886 |
"byte|else|import|public|throws|" + |
|
887 |
"case|enum|instanceof|return|transient|" + |
|
888 |
"catch|extends|int|short|try|" + |
|
889 |
"char|final|interface|static|void|" + |
|
890 |
"class|finally|long|strictfp|volatile|" + |
|
891 |
"def|float|native|super|while" |
|
892 |
); |
|
893 |
||
894 |
var buildinConstants = ( |
|
895 |
"null|Infinity|NaN|undefined" |
|
896 |
); |
|
897 |
||
898 |
var langClasses = ( |
|
899 |
"AbstractMethodError|AssertionError|ClassCircularityError|"+ |
|
900 |
"ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ |
|
901 |
"ExceptionInInitializerError|IllegalAccessError|"+ |
|
902 |
"IllegalThreadStateException|InstantiationError|InternalError|"+ |
|
903 |
"NegativeArraySizeException|NoSuchFieldError|Override|Process|"+ |
|
904 |
"ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+ |
|
905 |
"SuppressWarnings|TypeNotPresentException|UnknownError|"+ |
|
906 |
"UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+ |
|
907 |
"InstantiationException|IndexOutOfBoundsException|"+ |
|
908 |
"ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+ |
|
909 |
"NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+ |
|
910 |
"SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+ |
|
911 |
"InterruptedException|NoSuchMethodException|IllegalAccessException|"+ |
|
912 |
"UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+ |
|
913 |
"Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+ |
|
914 |
"NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+ |
|
915 |
"NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+ |
|
916 |
"Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+ |
|
917 |
"Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+ |
|
918 |
"StackOverflowError|OutOfMemoryError|VirtualMachineError|"+ |
|
919 |
"ArrayStoreException|ClassCastException|LinkageError|"+ |
|
920 |
"NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+ |
|
921 |
"Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+ |
|
922 |
"Cloneable|Class|CharSequence|Comparable|String|Object" |
|
923 |
); |
|
924 |
||
925 |
var keywordMapper = this.createKeywordMapper({ |
|
926 |
"variable.language": "this", |
|
927 |
"keyword": keywords, |
|
928 |
"support.function": langClasses, |
|
929 |
"constant.language": buildinConstants |
|
930 |
}, "identifier"); |
|
931 |
||
932 |
this.$rules = { |
|
933 |
"start" : [ |
|
934 |
{ |
|
935 |
token : "comment", |
|
936 |
regex : "\\/\\/.*$" |
|
937 |
}, |
|
938 |
DocCommentHighlightRules.getStartRule("doc-start"), |
|
939 |
{ |
|
940 |
token : "comment", // multi line comment |
|
941 |
regex : "\\/\\*", |
|
942 |
next : "comment" |
|
943 |
}, { |
|
944 |
token : "string.regexp", |
|
945 |
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" |
|
946 |
}, { |
|
947 |
token : "string", |
|
948 |
regex : '"""', |
|
949 |
next : "qqstring" |
|
950 |
}, { |
|
951 |
token : "string", |
|
952 |
regex : "'''", |
|
953 |
next : "qstring" |
|
954 |
}, { |
|
955 |
token : "string", // single line |
|
956 |
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' |
|
957 |
}, { |
|
958 |
token : "string", // single line |
|
959 |
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" |
|
960 |
}, { |
|
961 |
token : "constant.numeric", // hex |
|
962 |
regex : "0[xX][0-9a-fA-F]+\\b" |
|
963 |
}, { |
|
964 |
token : "constant.numeric", // float |
|
965 |
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" |
|
966 |
}, { |
|
967 |
token : "constant.language.boolean", |
|
968 |
regex : "(?:true|false)\\b" |
|
969 |
}, { |
|
970 |
token : keywordMapper, |
|
971 |
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" |
|
972 |
}, { |
|
973 |
token : "keyword.operator", |
|
974 |
regex : "\\?:|\\?\\.|\\*\\.|<=>|=~|==~|\\.@|\\*\\.@|\\.&|as|in|is|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" |
|
975 |
}, { |
|
976 |
token : "lparen", |
|
977 |
regex : "[[({]" |
|
978 |
}, { |
|
979 |
token : "rparen", |
|
980 |
regex : "[\\])}]" |
|
981 |
}, { |
|
982 |
token : "text", |
|
983 |
regex : "\\s+" |
|
984 |
} |
|
985 |
], |
|
986 |
"comment" : [ |
|
987 |
{ |
|
988 |
token : "comment", // closing comment |
|
989 |
regex : ".*?\\*\\/", |
|
990 |
next : "start" |
|
991 |
}, { |
|
992 |
token : "comment", // comment spanning whole line |
|
993 |
regex : ".+" |
|
994 |
} |
|
995 |
], |
|
996 |
"qqstring" : [ |
|
997 |
{ |
|
998 |
token : "constant.language.escape", |
|
999 |
regex : /\\(?:u[0-9A-Fa-f]{4}|.|$)/ |
|
1000 |
}, { |
|
1001 |
token : "constant.language.escape", |
|
1002 |
regex : /\$[\w\d]+/ |
|
1003 |
}, { |
|
1004 |
token : "constant.language.escape", |
|
1005 |
regex : /\$\{[^"\}]+\}?/ |
|
1006 |
}, { |
|
1007 |
token : "string", |
|
1008 |
regex : '"{3,5}', |
|
1009 |
next : "start" |
|
1010 |
}, { |
|
1011 |
token : "string", |
|
1012 |
regex : '.+?' |
|
1013 |
} |
|
1014 |
], |
|
1015 |
"qstring" : [ |
|
1016 |
{ |
|
1017 |
token : "constant.language.escape", |
|
1018 |
regex : /\\(?:u[0-9A-Fa-f]{4}|.|$)/ |
|
1019 |
}, { |
|
1020 |
token : "string", |
|
1021 |
regex : "'{3,5}", |
|
1022 |
next : "start" |
|
1023 |
}, { |
|
1024 |
token : "string", |
|
1025 |
regex : ".+?" |
|
1026 |
} |
|
1027 |
] |
|
1028 |
}; |
|
1029 |
||
1030 |
this.embedRules(DocCommentHighlightRules, "doc-", |
|
1031 |
[ DocCommentHighlightRules.getEndRule("start") ]); |
|
1032 |
};
|
|
1033 |
||
1034 |
oop.inherits(GroovyHighlightRules, TextHighlightRules); |
|
1035 |
||
1036 |
exports.GroovyHighlightRules = GroovyHighlightRules; |
|
1037 |
});
|