Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-c9search.js

raw symbols SCIP
1 ace.define("ace/mode/c9search_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
2 var oop = require("../lib/oop");
3 var lang = require("../lib/lang");
4 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
5 function safeCreateRegexp(source, flag) {
6 try {
7 return new RegExp(source, flag);
8 }
9 catch (e) { }
10 }
11 var C9SearchHighlightRules = function () {
12 this.$rules = {
13 "start": [
14 {
15 tokenNames: ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text", "c9searchresults.keyword"],
16 regex: /(^\s+[0-9]+)(:)(\d*\s?)([^\r\n]+)/,
17 onMatch: function (val, state, stack) {
18 var values = this.splitRegex.exec(val);
19 var types = this.tokenNames;
20 var tokens = [{
21 type: types[0],
22 value: values[1]
23 }, {
24 type: types[1],
25 value: values[2]
26 }];
27 if (values[3]) {
28 if (values[3] == " ")
29 tokens[1] = { type: types[1], value: values[2] + " " };
30 else
31 tokens.push({ type: types[1], value: values[3] });
32 }
33 var regex = stack[1];
34 var str = values[4];
35 var m;
36 var last = 0;
37 if (regex && regex.exec) {
38 regex.lastIndex = 0;
39 while (m = regex.exec(str)) {
40 var skipped = str.substring(last, m.index);
41 last = regex.lastIndex;
42 if (skipped)
43 tokens.push({ type: types[2], value: skipped });
44 if (m[0])
45 tokens.push({ type: types[3], value: m[0] });
46 else if (!skipped)
47 break;
48 }
49 }
50 if (last < str.length)
51 tokens.push({ type: types[2], value: str.substr(last) });
52 return tokens;
53 }
54 },
55 {
56 regex: "^Searching for [^\\r\\n]*$",
57 onMatch: function (val, state, stack) {
58 var parts = val.split("\x01");
59 if (parts.length < 3)
60 return "text";
61 var options, search;
62 var i = 0;
63 var tokens = [{
64 value: parts[i++] + "'",
65 type: "text"
66 }, {
67 value: search = parts[i++],
68 type: "text" // "c9searchresults.keyword"
69 }, {
70 value: "'" + parts[i++],
71 type: "text"
72 }];
73 if (parts[2] !== " in") {
74 tokens.push({
75 value: "'" + parts[i++] + "'",
76 type: "text"
77 }, {
78 value: parts[i++],
79 type: "text"
80 });
81 }
82 tokens.push({
83 value: " " + parts[i++] + " ",
84 type: "text"
85 });
86 if (parts[i + 1]) {
87 options = parts[i + 1];
88 tokens.push({
89 value: "(" + parts[i + 1] + ")",
90 type: "text"
91 });
92 i += 1;
93 }
94 else {
95 i -= 1;
96 }
97 while (i++ < parts.length) {
98 parts[i] && tokens.push({
99 value: parts[i],
100 type: "text"
101 });
102 }
103 if (search) {
104 if (!/regex/.test(options))
105 search = lang.escapeRegExp(search);
106 if (/whole/.test(options))
107 search = "\\b" + search + "\\b";
108 }
109 var regex = search && safeCreateRegexp("(" + search + ")", / sensitive/.test(options) ? "g" : "ig");
110 if (regex) {
111 stack[0] = state;
112 stack[1] = regex;
113 }
114 return tokens;
115 }
116 },
117 {
118 regex: "^(?=Found \\d+ matches)",
119 token: "text",
120 next: "numbers"
121 },
122 {
123 token: "string", // single line
124 regex: "^\\S:?[^:]+",
125 next: "numbers"
126 }
127 ],
128 numbers: [{
129 regex: "\\d+",
130 token: "constant.numeric"
131 }, {
132 regex: "$",
133 token: "text",
134 next: "start"
135 }]
136 };
137 this.normalizeRules();
138 };
139 oop.inherits(C9SearchHighlightRules, TextHighlightRules);
140 exports.C9SearchHighlightRules = C9SearchHighlightRules;
141
142 });
143
144 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
145 var Range = require("../range").Range;
146 var MatchingBraceOutdent = function () { };
147 (function () {
148 this.checkOutdent = function (line, input) {
149 if (!/^\s+$/.test(line))
150 return false;
151 return /^\s*\}/.test(input);
152 };
153 this.autoOutdent = function (doc, row) {
154 var line = doc.getLine(row);
155 var match = line.match(/^(\s*\})/);
156 if (!match)
157 return 0;
158 var column = match[1].length;
159 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
160 if (!openBracePos || openBracePos.row == row)
161 return 0;
162 var indent = this.$getIndent(doc.getLine(openBracePos.row));
163 doc.replace(new Range(row, 0, row, column - 1), indent);
164 };
165 this.$getIndent = function (line) {
166 return line.match(/^\s*/)[0];
167 };
168 }).call(MatchingBraceOutdent.prototype);
169 exports.MatchingBraceOutdent = MatchingBraceOutdent;
170
171 });
172
173 ace.define("ace/mode/folding/c9search",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
174 var oop = require("../../lib/oop");
175 var Range = require("../../range").Range;
176 var BaseFoldMode = require("./fold_mode").FoldMode;
177 var FoldMode = exports.FoldMode = function () { };
178 oop.inherits(FoldMode, BaseFoldMode);
179 (function () {
180 this.foldingStartMarker = /^(\S.*:|Searching for.*)$/;
181 this.foldingStopMarker = /^(\s+|Found.*)$/;
182 this.getFoldWidgetRange = function (session, foldStyle, row) {
183 var lines = session.doc.getAllLines(row);
184 var line = lines[row];
185 var level1 = /^(Found.*|Searching for.*)$/;
186 var level2 = /^(\S.*:|\s*)$/;
187 var re = level1.test(line) ? level1 : level2;
188 var startRow = row;
189 var endRow = row;
190 if (this.foldingStartMarker.test(line)) {
191 for (var i = row + 1, l = session.getLength(); i < l; i++) {
192 if (re.test(lines[i]))
193 break;
194 }
195 endRow = i;
196 }
197 else if (this.foldingStopMarker.test(line)) {
198 for (var i = row - 1; i >= 0; i--) {
199 line = lines[i];
200 if (re.test(line))
201 break;
202 }
203 startRow = i;
204 }
205 if (startRow != endRow) {
206 var col = line.length;
207 if (re === level1)
208 col = line.search(/\(Found[^)]+\)$|$/);
209 return new Range(startRow, col, endRow, 0);
210 }
211 };
212 }).call(FoldMode.prototype);
213
214 });
215
216 ace.define("ace/mode/c9search",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c9search_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/c9search"], function(require, exports, module){"use strict";
217 var oop = require("../lib/oop");
218 var TextMode = require("./text").Mode;
219 var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules;
220 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
221 var C9StyleFoldMode = require("./folding/c9search").FoldMode;
222 var Mode = function () {
223 this.HighlightRules = C9SearchHighlightRules;
224 this.$outdent = new MatchingBraceOutdent();
225 this.foldingRules = new C9StyleFoldMode();
226 };
227 oop.inherits(Mode, TextMode);
228 (function () {
229 this.getNextLineIndent = function (state, line, tab) {
230 var indent = this.$getIndent(line);
231 return indent;
232 };
233 this.checkOutdent = function (state, line, input) {
234 return this.$outdent.checkOutdent(line, input);
235 };
236 this.autoOutdent = function (state, doc, row) {
237 this.$outdent.autoOutdent(doc, row);
238 };
239 this.$id = "ace/mode/c9search";
240 }).call(Mode.prototype);
241 exports.Mode = Mode;
242
243 }); (function() {
244 ace.require(["ace/mode/c9search"], function(m) {
245 if (typeof module == "object" && typeof exports == "object" && module) {
246 module.exports = m;
247 }
248 });
249 })();
250