stackprofiler 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +1 -1
- data/config.ru +3 -2
- data/lib/stackprofiler.rb +0 -1
- data/lib/stackprofiler/filters/build_tree.rb +3 -4
- data/lib/stackprofiler/filters/gem_removal.rb +3 -0
- data/lib/stackprofiler/web_ui.rb +34 -11
- data/lib/stackprofiler/web_ui/public/css/stackprofiler.css +77 -0
- data/lib/stackprofiler/web_ui/public/js/stackprofiler.js +129 -58
- data/lib/stackprofiler/web_ui/public/vendor/ace/ace.js +18298 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-beautify.js +334 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-chromevox.js +541 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-elastic_tabstops_lite.js +275 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-emmet.js +1190 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-error_marker.js +6 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-keybinding_menu.js +170 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-language_tools.js +1934 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-linking.js +52 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-modelist.js +187 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-old_ie.js +494 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-searchbox.js +409 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-settings_menu.js +637 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-spellcheck.js +71 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-split.js +246 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-static_highlight.js +154 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-statusbar.js +51 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-textarea.js +632 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-themelist.js +58 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-whitespace.js +181 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-emacs.js +1182 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-vim.js +5320 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-haml.js +525 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html.js +2427 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html_ruby.js +2955 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-javascript.js +1025 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-json.js +668 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-ruby.js +839 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-xml.js +637 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-yaml.js +256 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/theme-xcode.js +89 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-coffee.js +7599 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-css.js +8682 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-html.js +11527 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-javascript.js +10429 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-json.js +2319 -0
- data/lib/stackprofiler/web_ui/views/index.erb +1 -1
- data/lib/stackprofiler/web_ui/views/layout.erb +2 -55
- data/stackprofiler.gemspec +2 -4
- metadata +42 -19
- data/lib/stackprofiler/web_ui/views/code.erb +0 -17
@@ -0,0 +1,668 @@
|
|
1
|
+
ace.define("ace/mode/json_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 JsonHighlightRules = function() {
|
8
|
+
this.$rules = {
|
9
|
+
"start" : [
|
10
|
+
{
|
11
|
+
token : "variable", // single line
|
12
|
+
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
|
13
|
+
}, {
|
14
|
+
token : "string", // single line
|
15
|
+
regex : '"',
|
16
|
+
next : "string"
|
17
|
+
}, {
|
18
|
+
token : "constant.numeric", // hex
|
19
|
+
regex : "0[xX][0-9a-fA-F]+\\b"
|
20
|
+
}, {
|
21
|
+
token : "constant.numeric", // float
|
22
|
+
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
23
|
+
}, {
|
24
|
+
token : "constant.language.boolean",
|
25
|
+
regex : "(?:true|false)\\b"
|
26
|
+
}, {
|
27
|
+
token : "invalid.illegal", // single quoted strings are not allowed
|
28
|
+
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
29
|
+
}, {
|
30
|
+
token : "invalid.illegal", // comments are not allowed
|
31
|
+
regex : "\\/\\/.*$"
|
32
|
+
}, {
|
33
|
+
token : "paren.lparen",
|
34
|
+
regex : "[[({]"
|
35
|
+
}, {
|
36
|
+
token : "paren.rparen",
|
37
|
+
regex : "[\\])}]"
|
38
|
+
}, {
|
39
|
+
token : "text",
|
40
|
+
regex : "\\s+"
|
41
|
+
}
|
42
|
+
],
|
43
|
+
"string" : [
|
44
|
+
{
|
45
|
+
token : "constant.language.escape",
|
46
|
+
regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
|
47
|
+
}, {
|
48
|
+
token : "string",
|
49
|
+
regex : '[^"\\\\]+'
|
50
|
+
}, {
|
51
|
+
token : "string",
|
52
|
+
regex : '"',
|
53
|
+
next : "start"
|
54
|
+
}, {
|
55
|
+
token : "string",
|
56
|
+
regex : "",
|
57
|
+
next : "start"
|
58
|
+
}
|
59
|
+
]
|
60
|
+
};
|
61
|
+
|
62
|
+
};
|
63
|
+
|
64
|
+
oop.inherits(JsonHighlightRules, TextHighlightRules);
|
65
|
+
|
66
|
+
exports.JsonHighlightRules = JsonHighlightRules;
|
67
|
+
});
|
68
|
+
|
69
|
+
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
70
|
+
"use strict";
|
71
|
+
|
72
|
+
var Range = require("../range").Range;
|
73
|
+
|
74
|
+
var MatchingBraceOutdent = function() {};
|
75
|
+
|
76
|
+
(function() {
|
77
|
+
|
78
|
+
this.checkOutdent = function(line, input) {
|
79
|
+
if (! /^\s+$/.test(line))
|
80
|
+
return false;
|
81
|
+
|
82
|
+
return /^\s*\}/.test(input);
|
83
|
+
};
|
84
|
+
|
85
|
+
this.autoOutdent = function(doc, row) {
|
86
|
+
var line = doc.getLine(row);
|
87
|
+
var match = line.match(/^(\s*\})/);
|
88
|
+
|
89
|
+
if (!match) return 0;
|
90
|
+
|
91
|
+
var column = match[1].length;
|
92
|
+
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
93
|
+
|
94
|
+
if (!openBracePos || openBracePos.row == row) return 0;
|
95
|
+
|
96
|
+
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
97
|
+
doc.replace(new Range(row, 0, row, column-1), indent);
|
98
|
+
};
|
99
|
+
|
100
|
+
this.$getIndent = function(line) {
|
101
|
+
return line.match(/^\s*/)[0];
|
102
|
+
};
|
103
|
+
|
104
|
+
}).call(MatchingBraceOutdent.prototype);
|
105
|
+
|
106
|
+
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
107
|
+
});
|
108
|
+
|
109
|
+
ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
|
110
|
+
"use strict";
|
111
|
+
|
112
|
+
var oop = require("../../lib/oop");
|
113
|
+
var Behaviour = require("../behaviour").Behaviour;
|
114
|
+
var TokenIterator = require("../../token_iterator").TokenIterator;
|
115
|
+
var lang = require("../../lib/lang");
|
116
|
+
|
117
|
+
var SAFE_INSERT_IN_TOKENS =
|
118
|
+
["text", "paren.rparen", "punctuation.operator"];
|
119
|
+
var SAFE_INSERT_BEFORE_TOKENS =
|
120
|
+
["text", "paren.rparen", "punctuation.operator", "comment"];
|
121
|
+
|
122
|
+
var context;
|
123
|
+
var contextCache = {};
|
124
|
+
var initContext = function(editor) {
|
125
|
+
var id = -1;
|
126
|
+
if (editor.multiSelect) {
|
127
|
+
id = editor.selection.index;
|
128
|
+
if (contextCache.rangeCount != editor.multiSelect.rangeCount)
|
129
|
+
contextCache = {rangeCount: editor.multiSelect.rangeCount};
|
130
|
+
}
|
131
|
+
if (contextCache[id])
|
132
|
+
return context = contextCache[id];
|
133
|
+
context = contextCache[id] = {
|
134
|
+
autoInsertedBrackets: 0,
|
135
|
+
autoInsertedRow: -1,
|
136
|
+
autoInsertedLineEnd: "",
|
137
|
+
maybeInsertedBrackets: 0,
|
138
|
+
maybeInsertedRow: -1,
|
139
|
+
maybeInsertedLineStart: "",
|
140
|
+
maybeInsertedLineEnd: ""
|
141
|
+
};
|
142
|
+
};
|
143
|
+
|
144
|
+
var CstyleBehaviour = function() {
|
145
|
+
this.add("braces", "insertion", function(state, action, editor, session, text) {
|
146
|
+
var cursor = editor.getCursorPosition();
|
147
|
+
var line = session.doc.getLine(cursor.row);
|
148
|
+
if (text == '{') {
|
149
|
+
initContext(editor);
|
150
|
+
var selection = editor.getSelectionRange();
|
151
|
+
var selected = session.doc.getTextRange(selection);
|
152
|
+
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
|
153
|
+
return {
|
154
|
+
text: '{' + selected + '}',
|
155
|
+
selection: false
|
156
|
+
};
|
157
|
+
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
158
|
+
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
|
159
|
+
CstyleBehaviour.recordAutoInsert(editor, session, "}");
|
160
|
+
return {
|
161
|
+
text: '{}',
|
162
|
+
selection: [1, 1]
|
163
|
+
};
|
164
|
+
} else {
|
165
|
+
CstyleBehaviour.recordMaybeInsert(editor, session, "{");
|
166
|
+
return {
|
167
|
+
text: '{',
|
168
|
+
selection: [1, 1]
|
169
|
+
};
|
170
|
+
}
|
171
|
+
}
|
172
|
+
} else if (text == '}') {
|
173
|
+
initContext(editor);
|
174
|
+
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
175
|
+
if (rightChar == '}') {
|
176
|
+
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
|
177
|
+
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
|
178
|
+
CstyleBehaviour.popAutoInsertedClosing();
|
179
|
+
return {
|
180
|
+
text: '',
|
181
|
+
selection: [1, 1]
|
182
|
+
};
|
183
|
+
}
|
184
|
+
}
|
185
|
+
} else if (text == "\n" || text == "\r\n") {
|
186
|
+
initContext(editor);
|
187
|
+
var closing = "";
|
188
|
+
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
|
189
|
+
closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
|
190
|
+
CstyleBehaviour.clearMaybeInsertedClosing();
|
191
|
+
}
|
192
|
+
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
193
|
+
if (rightChar === '}') {
|
194
|
+
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
|
195
|
+
if (!openBracePos)
|
196
|
+
return null;
|
197
|
+
var next_indent = this.$getIndent(session.getLine(openBracePos.row));
|
198
|
+
} else if (closing) {
|
199
|
+
var next_indent = this.$getIndent(line);
|
200
|
+
} else {
|
201
|
+
CstyleBehaviour.clearMaybeInsertedClosing();
|
202
|
+
return;
|
203
|
+
}
|
204
|
+
var indent = next_indent + session.getTabString();
|
205
|
+
|
206
|
+
return {
|
207
|
+
text: '\n' + indent + '\n' + next_indent + closing,
|
208
|
+
selection: [1, indent.length, 1, indent.length]
|
209
|
+
};
|
210
|
+
} else {
|
211
|
+
CstyleBehaviour.clearMaybeInsertedClosing();
|
212
|
+
}
|
213
|
+
});
|
214
|
+
|
215
|
+
this.add("braces", "deletion", function(state, action, editor, session, range) {
|
216
|
+
var selected = session.doc.getTextRange(range);
|
217
|
+
if (!range.isMultiLine() && selected == '{') {
|
218
|
+
initContext(editor);
|
219
|
+
var line = session.doc.getLine(range.start.row);
|
220
|
+
var rightChar = line.substring(range.end.column, range.end.column + 1);
|
221
|
+
if (rightChar == '}') {
|
222
|
+
range.end.column++;
|
223
|
+
return range;
|
224
|
+
} else {
|
225
|
+
context.maybeInsertedBrackets--;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
});
|
229
|
+
|
230
|
+
this.add("parens", "insertion", function(state, action, editor, session, text) {
|
231
|
+
if (text == '(') {
|
232
|
+
initContext(editor);
|
233
|
+
var selection = editor.getSelectionRange();
|
234
|
+
var selected = session.doc.getTextRange(selection);
|
235
|
+
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
|
236
|
+
return {
|
237
|
+
text: '(' + selected + ')',
|
238
|
+
selection: false
|
239
|
+
};
|
240
|
+
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
241
|
+
CstyleBehaviour.recordAutoInsert(editor, session, ")");
|
242
|
+
return {
|
243
|
+
text: '()',
|
244
|
+
selection: [1, 1]
|
245
|
+
};
|
246
|
+
}
|
247
|
+
} else if (text == ')') {
|
248
|
+
initContext(editor);
|
249
|
+
var cursor = editor.getCursorPosition();
|
250
|
+
var line = session.doc.getLine(cursor.row);
|
251
|
+
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
252
|
+
if (rightChar == ')') {
|
253
|
+
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
|
254
|
+
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
|
255
|
+
CstyleBehaviour.popAutoInsertedClosing();
|
256
|
+
return {
|
257
|
+
text: '',
|
258
|
+
selection: [1, 1]
|
259
|
+
};
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
});
|
264
|
+
|
265
|
+
this.add("parens", "deletion", function(state, action, editor, session, range) {
|
266
|
+
var selected = session.doc.getTextRange(range);
|
267
|
+
if (!range.isMultiLine() && selected == '(') {
|
268
|
+
initContext(editor);
|
269
|
+
var line = session.doc.getLine(range.start.row);
|
270
|
+
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
|
271
|
+
if (rightChar == ')') {
|
272
|
+
range.end.column++;
|
273
|
+
return range;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
});
|
277
|
+
|
278
|
+
this.add("brackets", "insertion", function(state, action, editor, session, text) {
|
279
|
+
if (text == '[') {
|
280
|
+
initContext(editor);
|
281
|
+
var selection = editor.getSelectionRange();
|
282
|
+
var selected = session.doc.getTextRange(selection);
|
283
|
+
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
|
284
|
+
return {
|
285
|
+
text: '[' + selected + ']',
|
286
|
+
selection: false
|
287
|
+
};
|
288
|
+
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
289
|
+
CstyleBehaviour.recordAutoInsert(editor, session, "]");
|
290
|
+
return {
|
291
|
+
text: '[]',
|
292
|
+
selection: [1, 1]
|
293
|
+
};
|
294
|
+
}
|
295
|
+
} else if (text == ']') {
|
296
|
+
initContext(editor);
|
297
|
+
var cursor = editor.getCursorPosition();
|
298
|
+
var line = session.doc.getLine(cursor.row);
|
299
|
+
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
300
|
+
if (rightChar == ']') {
|
301
|
+
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
|
302
|
+
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
|
303
|
+
CstyleBehaviour.popAutoInsertedClosing();
|
304
|
+
return {
|
305
|
+
text: '',
|
306
|
+
selection: [1, 1]
|
307
|
+
};
|
308
|
+
}
|
309
|
+
}
|
310
|
+
}
|
311
|
+
});
|
312
|
+
|
313
|
+
this.add("brackets", "deletion", function(state, action, editor, session, range) {
|
314
|
+
var selected = session.doc.getTextRange(range);
|
315
|
+
if (!range.isMultiLine() && selected == '[') {
|
316
|
+
initContext(editor);
|
317
|
+
var line = session.doc.getLine(range.start.row);
|
318
|
+
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
|
319
|
+
if (rightChar == ']') {
|
320
|
+
range.end.column++;
|
321
|
+
return range;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
});
|
325
|
+
|
326
|
+
this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
|
327
|
+
if (text == '"' || text == "'") {
|
328
|
+
initContext(editor);
|
329
|
+
var quote = text;
|
330
|
+
var selection = editor.getSelectionRange();
|
331
|
+
var selected = session.doc.getTextRange(selection);
|
332
|
+
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
|
333
|
+
return {
|
334
|
+
text: quote + selected + quote,
|
335
|
+
selection: false
|
336
|
+
};
|
337
|
+
} else {
|
338
|
+
var cursor = editor.getCursorPosition();
|
339
|
+
var line = session.doc.getLine(cursor.row);
|
340
|
+
var leftChar = line.substring(cursor.column-1, cursor.column);
|
341
|
+
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
342
|
+
|
343
|
+
var token = session.getTokenAt(cursor.row, cursor.column);
|
344
|
+
var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
|
345
|
+
if (leftChar == "\\" && token && /escape/.test(token.type))
|
346
|
+
return null;
|
347
|
+
|
348
|
+
var stringBefore = token && /string/.test(token.type);
|
349
|
+
var stringAfter = !rightToken || /string/.test(rightToken.type);
|
350
|
+
|
351
|
+
var pair;
|
352
|
+
if (rightChar == quote) {
|
353
|
+
pair = stringBefore !== stringAfter;
|
354
|
+
} else {
|
355
|
+
if (stringBefore && !stringAfter)
|
356
|
+
return null; // wrap string with different quote
|
357
|
+
if (stringBefore && stringAfter)
|
358
|
+
return null; // do not pair quotes inside strings
|
359
|
+
var wordRe = session.$mode.tokenRe;
|
360
|
+
wordRe.lastIndex = 0;
|
361
|
+
var isWordBefore = wordRe.test(leftChar);
|
362
|
+
wordRe.lastIndex = 0;
|
363
|
+
var isWordAfter = wordRe.test(leftChar);
|
364
|
+
if (isWordBefore || isWordAfter)
|
365
|
+
return null; // before or after alphanumeric
|
366
|
+
if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
|
367
|
+
return null; // there is rightChar and it isn't closing
|
368
|
+
pair = true;
|
369
|
+
}
|
370
|
+
return {
|
371
|
+
text: pair ? quote + quote : "",
|
372
|
+
selection: [1,1]
|
373
|
+
};
|
374
|
+
}
|
375
|
+
}
|
376
|
+
});
|
377
|
+
|
378
|
+
this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
|
379
|
+
var selected = session.doc.getTextRange(range);
|
380
|
+
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
|
381
|
+
initContext(editor);
|
382
|
+
var line = session.doc.getLine(range.start.row);
|
383
|
+
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
|
384
|
+
if (rightChar == selected) {
|
385
|
+
range.end.column++;
|
386
|
+
return range;
|
387
|
+
}
|
388
|
+
}
|
389
|
+
});
|
390
|
+
|
391
|
+
};
|
392
|
+
|
393
|
+
|
394
|
+
CstyleBehaviour.isSaneInsertion = function(editor, session) {
|
395
|
+
var cursor = editor.getCursorPosition();
|
396
|
+
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
397
|
+
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
|
398
|
+
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
|
399
|
+
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
|
400
|
+
return false;
|
401
|
+
}
|
402
|
+
iterator.stepForward();
|
403
|
+
return iterator.getCurrentTokenRow() !== cursor.row ||
|
404
|
+
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
|
405
|
+
};
|
406
|
+
|
407
|
+
CstyleBehaviour.$matchTokenType = function(token, types) {
|
408
|
+
return types.indexOf(token.type || token) > -1;
|
409
|
+
};
|
410
|
+
|
411
|
+
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
|
412
|
+
var cursor = editor.getCursorPosition();
|
413
|
+
var line = session.doc.getLine(cursor.row);
|
414
|
+
if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
|
415
|
+
context.autoInsertedBrackets = 0;
|
416
|
+
context.autoInsertedRow = cursor.row;
|
417
|
+
context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
|
418
|
+
context.autoInsertedBrackets++;
|
419
|
+
};
|
420
|
+
|
421
|
+
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
|
422
|
+
var cursor = editor.getCursorPosition();
|
423
|
+
var line = session.doc.getLine(cursor.row);
|
424
|
+
if (!this.isMaybeInsertedClosing(cursor, line))
|
425
|
+
context.maybeInsertedBrackets = 0;
|
426
|
+
context.maybeInsertedRow = cursor.row;
|
427
|
+
context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
|
428
|
+
context.maybeInsertedLineEnd = line.substr(cursor.column);
|
429
|
+
context.maybeInsertedBrackets++;
|
430
|
+
};
|
431
|
+
|
432
|
+
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
|
433
|
+
return context.autoInsertedBrackets > 0 &&
|
434
|
+
cursor.row === context.autoInsertedRow &&
|
435
|
+
bracket === context.autoInsertedLineEnd[0] &&
|
436
|
+
line.substr(cursor.column) === context.autoInsertedLineEnd;
|
437
|
+
};
|
438
|
+
|
439
|
+
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
|
440
|
+
return context.maybeInsertedBrackets > 0 &&
|
441
|
+
cursor.row === context.maybeInsertedRow &&
|
442
|
+
line.substr(cursor.column) === context.maybeInsertedLineEnd &&
|
443
|
+
line.substr(0, cursor.column) == context.maybeInsertedLineStart;
|
444
|
+
};
|
445
|
+
|
446
|
+
CstyleBehaviour.popAutoInsertedClosing = function() {
|
447
|
+
context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
|
448
|
+
context.autoInsertedBrackets--;
|
449
|
+
};
|
450
|
+
|
451
|
+
CstyleBehaviour.clearMaybeInsertedClosing = function() {
|
452
|
+
if (context) {
|
453
|
+
context.maybeInsertedBrackets = 0;
|
454
|
+
context.maybeInsertedRow = -1;
|
455
|
+
}
|
456
|
+
};
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
oop.inherits(CstyleBehaviour, Behaviour);
|
461
|
+
|
462
|
+
exports.CstyleBehaviour = CstyleBehaviour;
|
463
|
+
});
|
464
|
+
|
465
|
+
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
466
|
+
"use strict";
|
467
|
+
|
468
|
+
var oop = require("../../lib/oop");
|
469
|
+
var Range = require("../../range").Range;
|
470
|
+
var BaseFoldMode = require("./fold_mode").FoldMode;
|
471
|
+
|
472
|
+
var FoldMode = exports.FoldMode = function(commentRegex) {
|
473
|
+
if (commentRegex) {
|
474
|
+
this.foldingStartMarker = new RegExp(
|
475
|
+
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
476
|
+
);
|
477
|
+
this.foldingStopMarker = new RegExp(
|
478
|
+
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
479
|
+
);
|
480
|
+
}
|
481
|
+
};
|
482
|
+
oop.inherits(FoldMode, BaseFoldMode);
|
483
|
+
|
484
|
+
(function() {
|
485
|
+
|
486
|
+
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
|
487
|
+
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
|
488
|
+
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
489
|
+
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
490
|
+
this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
|
491
|
+
this._getFoldWidgetBase = this.getFoldWidget;
|
492
|
+
this.getFoldWidget = function(session, foldStyle, row) {
|
493
|
+
var line = session.getLine(row);
|
494
|
+
|
495
|
+
if (this.singleLineBlockCommentRe.test(line)) {
|
496
|
+
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
497
|
+
return "";
|
498
|
+
}
|
499
|
+
|
500
|
+
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
501
|
+
|
502
|
+
if (!fw && this.startRegionRe.test(line))
|
503
|
+
return "start"; // lineCommentRegionStart
|
504
|
+
|
505
|
+
return fw;
|
506
|
+
};
|
507
|
+
|
508
|
+
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
509
|
+
var line = session.getLine(row);
|
510
|
+
|
511
|
+
if (this.startRegionRe.test(line))
|
512
|
+
return this.getCommentRegionBlock(session, line, row);
|
513
|
+
|
514
|
+
var match = line.match(this.foldingStartMarker);
|
515
|
+
if (match) {
|
516
|
+
var i = match.index;
|
517
|
+
|
518
|
+
if (match[1])
|
519
|
+
return this.openingBracketBlock(session, match[1], row, i);
|
520
|
+
|
521
|
+
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
522
|
+
|
523
|
+
if (range && !range.isMultiLine()) {
|
524
|
+
if (forceMultiline) {
|
525
|
+
range = this.getSectionRange(session, row);
|
526
|
+
} else if (foldStyle != "all")
|
527
|
+
range = null;
|
528
|
+
}
|
529
|
+
|
530
|
+
return range;
|
531
|
+
}
|
532
|
+
|
533
|
+
if (foldStyle === "markbegin")
|
534
|
+
return;
|
535
|
+
|
536
|
+
var match = line.match(this.foldingStopMarker);
|
537
|
+
if (match) {
|
538
|
+
var i = match.index + match[0].length;
|
539
|
+
|
540
|
+
if (match[1])
|
541
|
+
return this.closingBracketBlock(session, match[1], row, i);
|
542
|
+
|
543
|
+
return session.getCommentFoldRange(row, i, -1);
|
544
|
+
}
|
545
|
+
};
|
546
|
+
|
547
|
+
this.getSectionRange = function(session, row) {
|
548
|
+
var line = session.getLine(row);
|
549
|
+
var startIndent = line.search(/\S/);
|
550
|
+
var startRow = row;
|
551
|
+
var startColumn = line.length;
|
552
|
+
row = row + 1;
|
553
|
+
var endRow = row;
|
554
|
+
var maxRow = session.getLength();
|
555
|
+
while (++row < maxRow) {
|
556
|
+
line = session.getLine(row);
|
557
|
+
var indent = line.search(/\S/);
|
558
|
+
if (indent === -1)
|
559
|
+
continue;
|
560
|
+
if (startIndent > indent)
|
561
|
+
break;
|
562
|
+
var subRange = this.getFoldWidgetRange(session, "all", row);
|
563
|
+
|
564
|
+
if (subRange) {
|
565
|
+
if (subRange.start.row <= startRow) {
|
566
|
+
break;
|
567
|
+
} else if (subRange.isMultiLine()) {
|
568
|
+
row = subRange.end.row;
|
569
|
+
} else if (startIndent == indent) {
|
570
|
+
break;
|
571
|
+
}
|
572
|
+
}
|
573
|
+
endRow = row;
|
574
|
+
}
|
575
|
+
|
576
|
+
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
577
|
+
};
|
578
|
+
|
579
|
+
this.getCommentRegionBlock = function(session, line, row) {
|
580
|
+
var startColumn = line.search(/\s*$/);
|
581
|
+
var maxRow = session.getLength();
|
582
|
+
var startRow = row;
|
583
|
+
|
584
|
+
var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
|
585
|
+
var depth = 1;
|
586
|
+
while (++row < maxRow) {
|
587
|
+
line = session.getLine(row);
|
588
|
+
var m = re.exec(line);
|
589
|
+
if (!m) continue;
|
590
|
+
if (m[1]) depth--;
|
591
|
+
else depth++;
|
592
|
+
|
593
|
+
if (!depth) break;
|
594
|
+
}
|
595
|
+
|
596
|
+
var endRow = row;
|
597
|
+
if (endRow > startRow) {
|
598
|
+
return new Range(startRow, startColumn, endRow, line.length);
|
599
|
+
}
|
600
|
+
};
|
601
|
+
|
602
|
+
}).call(FoldMode.prototype);
|
603
|
+
|
604
|
+
});
|
605
|
+
|
606
|
+
ace.define("ace/mode/json",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/json_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle","ace/worker/worker_client"], function(require, exports, module) {
|
607
|
+
"use strict";
|
608
|
+
|
609
|
+
var oop = require("../lib/oop");
|
610
|
+
var TextMode = require("./text").Mode;
|
611
|
+
var HighlightRules = require("./json_highlight_rules").JsonHighlightRules;
|
612
|
+
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
613
|
+
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
614
|
+
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
615
|
+
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
616
|
+
|
617
|
+
var Mode = function() {
|
618
|
+
this.HighlightRules = HighlightRules;
|
619
|
+
this.$outdent = new MatchingBraceOutdent();
|
620
|
+
this.$behaviour = new CstyleBehaviour();
|
621
|
+
this.foldingRules = new CStyleFoldMode();
|
622
|
+
};
|
623
|
+
oop.inherits(Mode, TextMode);
|
624
|
+
|
625
|
+
(function() {
|
626
|
+
|
627
|
+
this.getNextLineIndent = function(state, line, tab) {
|
628
|
+
var indent = this.$getIndent(line);
|
629
|
+
|
630
|
+
if (state == "start") {
|
631
|
+
var match = line.match(/^.*[\{\(\[]\s*$/);
|
632
|
+
if (match) {
|
633
|
+
indent += tab;
|
634
|
+
}
|
635
|
+
}
|
636
|
+
|
637
|
+
return indent;
|
638
|
+
};
|
639
|
+
|
640
|
+
this.checkOutdent = function(state, line, input) {
|
641
|
+
return this.$outdent.checkOutdent(line, input);
|
642
|
+
};
|
643
|
+
|
644
|
+
this.autoOutdent = function(state, doc, row) {
|
645
|
+
this.$outdent.autoOutdent(doc, row);
|
646
|
+
};
|
647
|
+
|
648
|
+
this.createWorker = function(session) {
|
649
|
+
var worker = new WorkerClient(["ace"], "ace/mode/json_worker", "JsonWorker");
|
650
|
+
worker.attachToDocument(session.getDocument());
|
651
|
+
|
652
|
+
worker.on("error", function(e) {
|
653
|
+
session.setAnnotations([e.data]);
|
654
|
+
});
|
655
|
+
|
656
|
+
worker.on("ok", function() {
|
657
|
+
session.clearAnnotations();
|
658
|
+
});
|
659
|
+
|
660
|
+
return worker;
|
661
|
+
};
|
662
|
+
|
663
|
+
|
664
|
+
this.$id = "ace/mode/json";
|
665
|
+
}).call(Mode.prototype);
|
666
|
+
|
667
|
+
exports.Mode = Mode;
|
668
|
+
});
|