stackprofiler 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/README.md +1 -1
  4. data/config.ru +3 -2
  5. data/lib/stackprofiler.rb +0 -1
  6. data/lib/stackprofiler/filters/build_tree.rb +3 -4
  7. data/lib/stackprofiler/filters/gem_removal.rb +3 -0
  8. data/lib/stackprofiler/web_ui.rb +34 -11
  9. data/lib/stackprofiler/web_ui/public/css/stackprofiler.css +77 -0
  10. data/lib/stackprofiler/web_ui/public/js/stackprofiler.js +129 -58
  11. data/lib/stackprofiler/web_ui/public/vendor/ace/ace.js +18298 -0
  12. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-beautify.js +334 -0
  13. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-chromevox.js +541 -0
  14. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-elastic_tabstops_lite.js +275 -0
  15. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-emmet.js +1190 -0
  16. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-error_marker.js +6 -0
  17. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-keybinding_menu.js +170 -0
  18. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-language_tools.js +1934 -0
  19. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-linking.js +52 -0
  20. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-modelist.js +187 -0
  21. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-old_ie.js +494 -0
  22. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-searchbox.js +409 -0
  23. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-settings_menu.js +637 -0
  24. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-spellcheck.js +71 -0
  25. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-split.js +246 -0
  26. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-static_highlight.js +154 -0
  27. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-statusbar.js +51 -0
  28. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-textarea.js +632 -0
  29. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-themelist.js +58 -0
  30. data/lib/stackprofiler/web_ui/public/vendor/ace/ext-whitespace.js +181 -0
  31. data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-emacs.js +1182 -0
  32. data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-vim.js +5320 -0
  33. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-haml.js +525 -0
  34. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html.js +2427 -0
  35. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html_ruby.js +2955 -0
  36. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-javascript.js +1025 -0
  37. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-json.js +668 -0
  38. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-ruby.js +839 -0
  39. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-xml.js +637 -0
  40. data/lib/stackprofiler/web_ui/public/vendor/ace/mode-yaml.js +256 -0
  41. data/lib/stackprofiler/web_ui/public/vendor/ace/theme-xcode.js +89 -0
  42. data/lib/stackprofiler/web_ui/public/vendor/ace/worker-coffee.js +7599 -0
  43. data/lib/stackprofiler/web_ui/public/vendor/ace/worker-css.js +8682 -0
  44. data/lib/stackprofiler/web_ui/public/vendor/ace/worker-html.js +11527 -0
  45. data/lib/stackprofiler/web_ui/public/vendor/ace/worker-javascript.js +10429 -0
  46. data/lib/stackprofiler/web_ui/public/vendor/ace/worker-json.js +2319 -0
  47. data/lib/stackprofiler/web_ui/views/index.erb +1 -1
  48. data/lib/stackprofiler/web_ui/views/layout.erb +2 -55
  49. data/stackprofiler.gemspec +2 -4
  50. metadata +42 -19
  51. data/lib/stackprofiler/web_ui/views/code.erb +0 -17
@@ -0,0 +1,637 @@
1
+ ace.define("ace/mode/xml_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 XmlHighlightRules = function(normalize) {
8
+ this.$rules = {
9
+ start : [
10
+ {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
11
+ {
12
+ token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
13
+ regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
14
+ },
15
+ {
16
+ token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
17
+ regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "processing_instruction",
18
+ },
19
+ {token : "comment.xml", regex : "<\\!--", next : "comment"},
20
+ {
21
+ token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
22
+ regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
23
+ },
24
+ {include : "tag"},
25
+ {token : "text.end-tag-open.xml", regex: "</"},
26
+ {token : "text.tag-open.xml", regex: "<"},
27
+ {include : "reference"},
28
+ {defaultToken : "text.xml"}
29
+ ],
30
+
31
+ xml_decl : [{
32
+ token : "entity.other.attribute-name.decl-attribute-name.xml",
33
+ regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
34
+ }, {
35
+ token : "keyword.operator.decl-attribute-equals.xml",
36
+ regex : "="
37
+ }, {
38
+ include: "whitespace"
39
+ }, {
40
+ include: "string"
41
+ }, {
42
+ token : "punctuation.xml-decl.xml",
43
+ regex : "\\?>",
44
+ next : "start"
45
+ }],
46
+
47
+ processing_instruction : [
48
+ {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
49
+ {defaultToken : "instruction.xml"}
50
+ ],
51
+
52
+ doctype : [
53
+ {include : "whitespace"},
54
+ {include : "string"},
55
+ {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
56
+ {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
57
+ {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
58
+ ],
59
+
60
+ int_subset : [{
61
+ token : "text.xml",
62
+ regex : "\\s+"
63
+ }, {
64
+ token: "punctuation.int-subset.xml",
65
+ regex: "]",
66
+ next: "pop"
67
+ }, {
68
+ token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
69
+ regex : "(<\\!)([-_a-zA-Z0-9]+)",
70
+ push : [{
71
+ token : "text",
72
+ regex : "\\s+"
73
+ },
74
+ {
75
+ token : "punctuation.markup-decl.xml",
76
+ regex : ">",
77
+ next : "pop"
78
+ },
79
+ {include : "string"}]
80
+ }],
81
+
82
+ cdata : [
83
+ {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
84
+ {token : "text.xml", regex : "\\s+"},
85
+ {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
86
+ ],
87
+
88
+ comment : [
89
+ {token : "comment.xml", regex : "-->", next : "start"},
90
+ {defaultToken : "comment.xml"}
91
+ ],
92
+
93
+ reference : [{
94
+ token : "constant.language.escape.reference.xml",
95
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
96
+ }],
97
+
98
+ attr_reference : [{
99
+ token : "constant.language.escape.reference.attribute-value.xml",
100
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
101
+ }],
102
+
103
+ tag : [{
104
+ token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
105
+ regex : "(?:(<)|(</))((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
106
+ next: [
107
+ {include : "attributes"},
108
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
109
+ ]
110
+ }],
111
+
112
+ tag_whitespace : [
113
+ {token : "text.tag-whitespace.xml", regex : "\\s+"}
114
+ ],
115
+ whitespace : [
116
+ {token : "text.whitespace.xml", regex : "\\s+"}
117
+ ],
118
+ string: [{
119
+ token : "string.xml",
120
+ regex : "'",
121
+ push : [
122
+ {token : "string.xml", regex: "'", next: "pop"},
123
+ {defaultToken : "string.xml"}
124
+ ]
125
+ }, {
126
+ token : "string.xml",
127
+ regex : '"',
128
+ push : [
129
+ {token : "string.xml", regex: '"', next: "pop"},
130
+ {defaultToken : "string.xml"}
131
+ ]
132
+ }],
133
+
134
+ attributes: [{
135
+ token : "entity.other.attribute-name.xml",
136
+ regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
137
+ }, {
138
+ token : "keyword.operator.attribute-equals.xml",
139
+ regex : "="
140
+ }, {
141
+ include: "tag_whitespace"
142
+ }, {
143
+ include: "attribute_value"
144
+ }],
145
+
146
+ attribute_value: [{
147
+ token : "string.attribute-value.xml",
148
+ regex : "'",
149
+ push : [
150
+ {token : "string.attribute-value.xml", regex: "'", next: "pop"},
151
+ {include : "attr_reference"},
152
+ {defaultToken : "string.attribute-value.xml"}
153
+ ]
154
+ }, {
155
+ token : "string.attribute-value.xml",
156
+ regex : '"',
157
+ push : [
158
+ {token : "string.attribute-value.xml", regex: '"', next: "pop"},
159
+ {include : "attr_reference"},
160
+ {defaultToken : "string.attribute-value.xml"}
161
+ ]
162
+ }]
163
+ };
164
+
165
+ if (this.constructor === XmlHighlightRules)
166
+ this.normalizeRules();
167
+ };
168
+
169
+
170
+ (function() {
171
+
172
+ this.embedTagRules = function(HighlightRules, prefix, tag){
173
+ this.$rules.tag.unshift({
174
+ token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
175
+ regex : "(<)(" + tag + "(?=\\s|>|$))",
176
+ next: [
177
+ {include : "attributes"},
178
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
179
+ ]
180
+ });
181
+
182
+ this.$rules[tag + "-end"] = [
183
+ {include : "attributes"},
184
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
185
+ onMatch : function(value, currentState, stack) {
186
+ stack.splice(0);
187
+ return this.token;
188
+ }}
189
+ ]
190
+
191
+ this.embedRules(HighlightRules, prefix, [{
192
+ token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
193
+ regex : "(</)(" + tag + "(?=\\s|>|$))",
194
+ next: tag + "-end"
195
+ }, {
196
+ token: "string.cdata.xml",
197
+ regex : "<\\!\\[CDATA\\["
198
+ }, {
199
+ token: "string.cdata.xml",
200
+ regex : "\\]\\]>"
201
+ }]);
202
+ };
203
+
204
+ }).call(TextHighlightRules.prototype);
205
+
206
+ oop.inherits(XmlHighlightRules, TextHighlightRules);
207
+
208
+ exports.XmlHighlightRules = XmlHighlightRules;
209
+ });
210
+
211
+ ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
212
+ "use strict";
213
+
214
+ var oop = require("../../lib/oop");
215
+ var Behaviour = require("../behaviour").Behaviour;
216
+ var TokenIterator = require("../../token_iterator").TokenIterator;
217
+ var lang = require("../../lib/lang");
218
+
219
+ function is(token, type) {
220
+ return token.type.lastIndexOf(type + ".xml") > -1;
221
+ }
222
+
223
+ var XmlBehaviour = function () {
224
+
225
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
226
+ if (text == '"' || text == "'") {
227
+ var quote = text;
228
+ var selected = session.doc.getTextRange(editor.getSelectionRange());
229
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
230
+ return {
231
+ text: quote + selected + quote,
232
+ selection: false
233
+ };
234
+ }
235
+
236
+ var cursor = editor.getCursorPosition();
237
+ var line = session.doc.getLine(cursor.row);
238
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
239
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
240
+ var token = iterator.getCurrentToken();
241
+
242
+ if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
243
+ return {
244
+ text: "",
245
+ selection: [1, 1]
246
+ };
247
+ }
248
+
249
+ if (!token)
250
+ token = iterator.stepBackward();
251
+
252
+ if (!token)
253
+ return;
254
+
255
+ while (is(token, "tag-whitespace") || is(token, "whitespace")) {
256
+ token = iterator.stepBackward();
257
+ }
258
+ var rightSpace = !rightChar || rightChar.match(/\s/);
259
+ if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
260
+ return {
261
+ text: quote + quote,
262
+ selection: [1, 1]
263
+ };
264
+ }
265
+ }
266
+ });
267
+
268
+ this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
269
+ var selected = session.doc.getTextRange(range);
270
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
271
+ var line = session.doc.getLine(range.start.row);
272
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
273
+ if (rightChar == selected) {
274
+ range.end.column++;
275
+ return range;
276
+ }
277
+ }
278
+ });
279
+
280
+ this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
281
+ if (text == '>') {
282
+ var position = editor.getCursorPosition();
283
+ var iterator = new TokenIterator(session, position.row, position.column);
284
+ var token = iterator.getCurrentToken() || iterator.stepBackward();
285
+ if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
286
+ return;
287
+ if (is(token, "reference.attribute-value"))
288
+ return;
289
+ if (is(token, "attribute-value")) {
290
+ var firstChar = token.value.charAt(0);
291
+ if (firstChar == '"' || firstChar == "'") {
292
+ var lastChar = token.value.charAt(token.value.length - 1);
293
+ var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
294
+ if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
295
+ return;
296
+ }
297
+ }
298
+ while (!is(token, "tag-name")) {
299
+ token = iterator.stepBackward();
300
+ }
301
+
302
+ var tokenRow = iterator.getCurrentTokenRow();
303
+ var tokenColumn = iterator.getCurrentTokenColumn();
304
+ if (is(iterator.stepBackward(), "end-tag-open"))
305
+ return;
306
+
307
+ var element = token.value;
308
+ if (tokenRow == position.row)
309
+ element = element.substring(0, position.column - tokenColumn);
310
+
311
+ if (this.voidElements.hasOwnProperty(element.toLowerCase()))
312
+ return;
313
+
314
+ return {
315
+ text: ">" + "</" + element + ">",
316
+ selection: [1, 1]
317
+ };
318
+ }
319
+ });
320
+
321
+ this.add("autoindent", "insertion", function (state, action, editor, session, text) {
322
+ if (text == "\n") {
323
+ var cursor = editor.getCursorPosition();
324
+ var line = session.getLine(cursor.row);
325
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
326
+ var token = iterator.getCurrentToken();
327
+
328
+ if (token && token.type.indexOf("tag-close") !== -1) {
329
+ while (token && token.type.indexOf("tag-name") === -1) {
330
+ token = iterator.stepBackward();
331
+ }
332
+
333
+ if (!token) {
334
+ return;
335
+ }
336
+
337
+ var tag = token.value;
338
+ var row = iterator.getCurrentTokenRow();
339
+ token = iterator.stepBackward();
340
+ if (!token || token.type.indexOf("end-tag") !== -1) {
341
+ return;
342
+ }
343
+
344
+ if (this.voidElements && !this.voidElements[tag]) {
345
+ var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
346
+ var line = session.getLine(row);
347
+ var nextIndent = this.$getIndent(line);
348
+ var indent = nextIndent + session.getTabString();
349
+
350
+ if (nextToken && nextToken.value === "</") {
351
+ return {
352
+ text: "\n" + indent + "\n" + nextIndent,
353
+ selection: [1, indent.length, 1, indent.length]
354
+ };
355
+ } else {
356
+ return {
357
+ text: "\n" + indent
358
+ };
359
+ }
360
+ }
361
+ }
362
+ }
363
+ });
364
+
365
+ };
366
+
367
+ oop.inherits(XmlBehaviour, Behaviour);
368
+
369
+ exports.XmlBehaviour = XmlBehaviour;
370
+ });
371
+
372
+ ace.define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/range","ace/mode/folding/fold_mode","ace/token_iterator"], function(require, exports, module) {
373
+ "use strict";
374
+
375
+ var oop = require("../../lib/oop");
376
+ var lang = require("../../lib/lang");
377
+ var Range = require("../../range").Range;
378
+ var BaseFoldMode = require("./fold_mode").FoldMode;
379
+ var TokenIterator = require("../../token_iterator").TokenIterator;
380
+
381
+ var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
382
+ BaseFoldMode.call(this);
383
+ this.voidElements = voidElements || {};
384
+ this.optionalEndTags = oop.mixin({}, this.voidElements);
385
+ if (optionalEndTags)
386
+ oop.mixin(this.optionalEndTags, optionalEndTags);
387
+
388
+ };
389
+ oop.inherits(FoldMode, BaseFoldMode);
390
+
391
+ var Tag = function() {
392
+ this.tagName = "";
393
+ this.closing = false;
394
+ this.selfClosing = false;
395
+ this.start = {row: 0, column: 0};
396
+ this.end = {row: 0, column: 0};
397
+ };
398
+
399
+ function is(token, type) {
400
+ return token.type.lastIndexOf(type + ".xml") > -1;
401
+ }
402
+
403
+ (function() {
404
+
405
+ this.getFoldWidget = function(session, foldStyle, row) {
406
+ var tag = this._getFirstTagInLine(session, row);
407
+
408
+ if (!tag)
409
+ return "";
410
+
411
+ if (tag.closing || (!tag.tagName && tag.selfClosing))
412
+ return foldStyle == "markbeginend" ? "end" : "";
413
+
414
+ if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
415
+ return "";
416
+
417
+ if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
418
+ return "";
419
+
420
+ return "start";
421
+ };
422
+ this._getFirstTagInLine = function(session, row) {
423
+ var tokens = session.getTokens(row);
424
+ var tag = new Tag();
425
+
426
+ for (var i = 0; i < tokens.length; i++) {
427
+ var token = tokens[i];
428
+ if (is(token, "tag-open")) {
429
+ tag.end.column = tag.start.column + token.value.length;
430
+ tag.closing = is(token, "end-tag-open");
431
+ token = tokens[++i];
432
+ if (!token)
433
+ return null;
434
+ tag.tagName = token.value;
435
+ tag.end.column += token.value.length;
436
+ for (i++; i < tokens.length; i++) {
437
+ token = tokens[i];
438
+ tag.end.column += token.value.length;
439
+ if (is(token, "tag-close")) {
440
+ tag.selfClosing = token.value == '/>';
441
+ break;
442
+ }
443
+ }
444
+ return tag;
445
+ } else if (is(token, "tag-close")) {
446
+ tag.selfClosing = token.value == '/>';
447
+ return tag;
448
+ }
449
+ tag.start.column += token.value.length;
450
+ }
451
+
452
+ return null;
453
+ };
454
+
455
+ this._findEndTagInLine = function(session, row, tagName, startColumn) {
456
+ var tokens = session.getTokens(row);
457
+ var column = 0;
458
+ for (var i = 0; i < tokens.length; i++) {
459
+ var token = tokens[i];
460
+ column += token.value.length;
461
+ if (column < startColumn)
462
+ continue;
463
+ if (is(token, "end-tag-open")) {
464
+ token = tokens[i + 1];
465
+ if (token && token.value == tagName)
466
+ return true;
467
+ }
468
+ }
469
+ return false;
470
+ };
471
+ this._readTagForward = function(iterator) {
472
+ var token = iterator.getCurrentToken();
473
+ if (!token)
474
+ return null;
475
+
476
+ var tag = new Tag();
477
+ do {
478
+ if (is(token, "tag-open")) {
479
+ tag.closing = is(token, "end-tag-open");
480
+ tag.start.row = iterator.getCurrentTokenRow();
481
+ tag.start.column = iterator.getCurrentTokenColumn();
482
+ } else if (is(token, "tag-name")) {
483
+ tag.tagName = token.value;
484
+ } else if (is(token, "tag-close")) {
485
+ tag.selfClosing = token.value == "/>";
486
+ tag.end.row = iterator.getCurrentTokenRow();
487
+ tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
488
+ iterator.stepForward();
489
+ return tag;
490
+ }
491
+ } while(token = iterator.stepForward());
492
+
493
+ return null;
494
+ };
495
+
496
+ this._readTagBackward = function(iterator) {
497
+ var token = iterator.getCurrentToken();
498
+ if (!token)
499
+ return null;
500
+
501
+ var tag = new Tag();
502
+ do {
503
+ if (is(token, "tag-open")) {
504
+ tag.closing = is(token, "end-tag-open");
505
+ tag.start.row = iterator.getCurrentTokenRow();
506
+ tag.start.column = iterator.getCurrentTokenColumn();
507
+ iterator.stepBackward();
508
+ return tag;
509
+ } else if (is(token, "tag-name")) {
510
+ tag.tagName = token.value;
511
+ } else if (is(token, "tag-close")) {
512
+ tag.selfClosing = token.value == "/>";
513
+ tag.end.row = iterator.getCurrentTokenRow();
514
+ tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
515
+ }
516
+ } while(token = iterator.stepBackward());
517
+
518
+ return null;
519
+ };
520
+
521
+ this._pop = function(stack, tag) {
522
+ while (stack.length) {
523
+
524
+ var top = stack[stack.length-1];
525
+ if (!tag || top.tagName == tag.tagName) {
526
+ return stack.pop();
527
+ }
528
+ else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
529
+ stack.pop();
530
+ continue;
531
+ } else {
532
+ return null;
533
+ }
534
+ }
535
+ };
536
+
537
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
538
+ var firstTag = this._getFirstTagInLine(session, row);
539
+
540
+ if (!firstTag)
541
+ return null;
542
+
543
+ var isBackward = firstTag.closing || firstTag.selfClosing;
544
+ var stack = [];
545
+ var tag;
546
+
547
+ if (!isBackward) {
548
+ var iterator = new TokenIterator(session, row, firstTag.start.column);
549
+ var start = {
550
+ row: row,
551
+ column: firstTag.start.column + firstTag.tagName.length + 2
552
+ };
553
+ while (tag = this._readTagForward(iterator)) {
554
+ if (tag.selfClosing) {
555
+ if (!stack.length) {
556
+ tag.start.column += tag.tagName.length + 2;
557
+ tag.end.column -= 2;
558
+ return Range.fromPoints(tag.start, tag.end);
559
+ } else
560
+ continue;
561
+ }
562
+
563
+ if (tag.closing) {
564
+ this._pop(stack, tag);
565
+ if (stack.length == 0)
566
+ return Range.fromPoints(start, tag.start);
567
+ }
568
+ else {
569
+ stack.push(tag);
570
+ }
571
+ }
572
+ }
573
+ else {
574
+ var iterator = new TokenIterator(session, row, firstTag.end.column);
575
+ var end = {
576
+ row: row,
577
+ column: firstTag.start.column
578
+ };
579
+
580
+ while (tag = this._readTagBackward(iterator)) {
581
+ if (tag.selfClosing) {
582
+ if (!stack.length) {
583
+ tag.start.column += tag.tagName.length + 2;
584
+ tag.end.column -= 2;
585
+ return Range.fromPoints(tag.start, tag.end);
586
+ } else
587
+ continue;
588
+ }
589
+
590
+ if (!tag.closing) {
591
+ this._pop(stack, tag);
592
+ if (stack.length == 0) {
593
+ tag.start.column += tag.tagName.length + 2;
594
+ return Range.fromPoints(tag.start, end);
595
+ }
596
+ }
597
+ else {
598
+ stack.push(tag);
599
+ }
600
+ }
601
+ }
602
+
603
+ };
604
+
605
+ }).call(FoldMode.prototype);
606
+
607
+ });
608
+
609
+ ace.define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml"], function(require, exports, module) {
610
+ "use strict";
611
+
612
+ var oop = require("../lib/oop");
613
+ var lang = require("../lib/lang");
614
+ var TextMode = require("./text").Mode;
615
+ var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
616
+ var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
617
+ var XmlFoldMode = require("./folding/xml").FoldMode;
618
+
619
+ var Mode = function() {
620
+ this.HighlightRules = XmlHighlightRules;
621
+ this.$behaviour = new XmlBehaviour();
622
+ this.foldingRules = new XmlFoldMode();
623
+ };
624
+
625
+ oop.inherits(Mode, TextMode);
626
+
627
+ (function() {
628
+
629
+ this.voidElements = lang.arrayToMap([]);
630
+
631
+ this.blockComment = {start: "<!--", end: "-->"};
632
+
633
+ this.$id = "ace/mode/xml";
634
+ }).call(Mode.prototype);
635
+
636
+ exports.Mode = Mode;
637
+ });