UNPKG

702 kBJavaScriptView Raw
1/******/ (() => { // webpackBootstrap
2/******/ var __webpack_modules__ = ({
3
4/***/ 68:
5/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6
7/*
8colors.js
9
10Copyright (c) 2010
11
12Marak Squires
13Alexis Sellier (cloudhead)
14
15Permission is hereby granted, free of charge, to any person obtaining a copy
16of this software and associated documentation files (the "Software"), to deal
17in the Software without restriction, including without limitation the rights
18to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19copies of the Software, and to permit persons to whom the Software is
20furnished to do so, subject to the following conditions:
21
22The above copyright notice and this permission notice shall be included in
23all copies or substantial portions of the Software.
24
25THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31THE SOFTWARE.
32
33*/
34
35var isHeadless = false;
36
37if (typeof module !== 'undefined') {
38 isHeadless = true;
39}
40
41if (!isHeadless) {
42 var exports = {};
43 var module = {};
44 var colors = exports;
45 exports.mode = "browser";
46} else {
47 exports.mode = "console";
48}
49
50//
51// Prototypes the string object to have additional method calls that add terminal colors
52//
53var addProperty = function (color, func) {
54 exports[color] = function (str) {
55 return func.apply(str);
56 };
57 String.prototype.__defineGetter__(color, func);
58};
59
60function stylize(str, style) {
61
62 var styles;
63
64 if (exports.mode === 'console') {
65 styles = {
66 //styles
67 'bold' : ['\x1B[1m', '\x1B[22m'],
68 'italic' : ['\x1B[3m', '\x1B[23m'],
69 'underline' : ['\x1B[4m', '\x1B[24m'],
70 'inverse' : ['\x1B[7m', '\x1B[27m'],
71 'strikethrough' : ['\x1B[9m', '\x1B[29m'],
72 //text colors
73 //grayscale
74 'white' : ['\x1B[37m', '\x1B[39m'],
75 'grey' : ['\x1B[90m', '\x1B[39m'],
76 'black' : ['\x1B[30m', '\x1B[39m'],
77 //colors
78 'blue' : ['\x1B[34m', '\x1B[39m'],
79 'cyan' : ['\x1B[36m', '\x1B[39m'],
80 'green' : ['\x1B[32m', '\x1B[39m'],
81 'magenta' : ['\x1B[35m', '\x1B[39m'],
82 'red' : ['\x1B[31m', '\x1B[39m'],
83 'yellow' : ['\x1B[33m', '\x1B[39m'],
84 //background colors
85 //grayscale
86 'whiteBG' : ['\x1B[47m', '\x1B[49m'],
87 'greyBG' : ['\x1B[49;5;8m', '\x1B[49m'],
88 'blackBG' : ['\x1B[40m', '\x1B[49m'],
89 //colors
90 'blueBG' : ['\x1B[44m', '\x1B[49m'],
91 'cyanBG' : ['\x1B[46m', '\x1B[49m'],
92 'greenBG' : ['\x1B[42m', '\x1B[49m'],
93 'magentaBG' : ['\x1B[45m', '\x1B[49m'],
94 'redBG' : ['\x1B[41m', '\x1B[49m'],
95 'yellowBG' : ['\x1B[43m', '\x1B[49m']
96 };
97 } else if (exports.mode === 'browser') {
98 styles = {
99 //styles
100 'bold' : ['<b>', '</b>'],
101 'italic' : ['<i>', '</i>'],
102 'underline' : ['<u>', '</u>'],
103 'inverse' : ['<span style="background-color:black;color:white;">', '</span>'],
104 'strikethrough' : ['<del>', '</del>'],
105 //text colors
106 //grayscale
107 'white' : ['<span style="color:white;">', '</span>'],
108 'grey' : ['<span style="color:gray;">', '</span>'],
109 'black' : ['<span style="color:black;">', '</span>'],
110 //colors
111 'blue' : ['<span style="color:blue;">', '</span>'],
112 'cyan' : ['<span style="color:cyan;">', '</span>'],
113 'green' : ['<span style="color:green;">', '</span>'],
114 'magenta' : ['<span style="color:magenta;">', '</span>'],
115 'red' : ['<span style="color:red;">', '</span>'],
116 'yellow' : ['<span style="color:yellow;">', '</span>'],
117 //background colors
118 //grayscale
119 'whiteBG' : ['<span style="background-color:white;">', '</span>'],
120 'greyBG' : ['<span style="background-color:gray;">', '</span>'],
121 'blackBG' : ['<span style="background-color:black;">', '</span>'],
122 //colors
123 'blueBG' : ['<span style="background-color:blue;">', '</span>'],
124 'cyanBG' : ['<span style="background-color:cyan;">', '</span>'],
125 'greenBG' : ['<span style="background-color:green;">', '</span>'],
126 'magentaBG' : ['<span style="background-color:magenta;">', '</span>'],
127 'redBG' : ['<span style="background-color:red;">', '</span>'],
128 'yellowBG' : ['<span style="background-color:yellow;">', '</span>']
129 };
130 } else if (exports.mode === 'none') {
131 return str + '';
132 } else {
133 console.log('unsupported mode, try "browser", "console" or "none"');
134 }
135 return styles[style][0] + str + styles[style][1];
136}
137
138function applyTheme(theme) {
139
140 //
141 // Remark: This is a list of methods that exist
142 // on String that you should not overwrite.
143 //
144 var stringPrototypeBlacklist = [
145 '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
146 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
147 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
148 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
149 ];
150
151 Object.keys(theme).forEach(function (prop) {
152 if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
153 console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
154 }
155 else {
156 if (typeof(theme[prop]) === 'string') {
157 addProperty(prop, function () {
158 return exports[theme[prop]](this);
159 });
160 }
161 else {
162 addProperty(prop, function () {
163 var ret = this;
164 for (var t = 0; t < theme[prop].length; t++) {
165 ret = exports[theme[prop][t]](ret);
166 }
167 return ret;
168 });
169 }
170 }
171 });
172}
173
174
175//
176// Iterate through all default styles and colors
177//
178var x = ['bold', 'underline', 'strikethrough', 'italic', 'inverse', 'grey', 'black', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta', 'greyBG', 'blackBG', 'yellowBG', 'redBG', 'greenBG', 'blueBG', 'whiteBG', 'cyanBG', 'magentaBG'];
179x.forEach(function (style) {
180
181 // __defineGetter__ at the least works in more browsers
182 // http://robertnyman.com/javascript/javascript-getters-setters.html
183 // Object.defineProperty only works in Chrome
184 addProperty(style, function () {
185 return stylize(this, style);
186 });
187});
188
189function sequencer(map) {
190 return function () {
191 if (!isHeadless) {
192 return this.replace(/( )/, '$1');
193 }
194 var exploded = this.split(""), i = 0;
195 exploded = exploded.map(map);
196 return exploded.join("");
197 };
198}
199
200var rainbowMap = (function () {
201 var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
202 return function (letter, i, exploded) {
203 if (letter === " ") {
204 return letter;
205 } else {
206 return stylize(letter, rainbowColors[i++ % rainbowColors.length]);
207 }
208 };
209})();
210
211exports.themes = {};
212
213exports.addSequencer = function (name, map) {
214 addProperty(name, sequencer(map));
215};
216
217exports.addSequencer('rainbow', rainbowMap);
218exports.addSequencer('zebra', function (letter, i, exploded) {
219 return i % 2 === 0 ? letter : letter.inverse;
220});
221
222exports.setTheme = function (theme) {
223 if (typeof theme === 'string') {
224 try {
225 exports.themes[theme] = __webpack_require__(69)(theme);
226 applyTheme(exports.themes[theme]);
227 return exports.themes[theme];
228 } catch (err) {
229 console.log(err);
230 return err;
231 }
232 } else {
233 applyTheme(theme);
234 }
235};
236
237
238addProperty('stripColors', function () {
239 return ("" + this).replace(/\x1B\[\d+m/g, '');
240});
241
242// please no
243function zalgo(text, options) {
244 var soul = {
245 "up" : [
246 '̍', '̎', '̄', '̅',
247 '̿', '̑', '̆', '̐',
248 '͒', '͗', '͑', '̇',
249 '̈', '̊', '͂', '̓',
250 '̈', '͊', '͋', '͌',
251 '̃', '̂', '̌', '͐',
252 '̀', '́', '̋', '̏',
253 '̒', '̓', '̔', '̽',
254 '̉', 'ͣ', 'ͤ', 'ͥ',
255 'ͦ', 'ͧ', 'ͨ', 'ͩ',
256 'ͪ', 'ͫ', 'ͬ', 'ͭ',
257 'ͮ', 'ͯ', '̾', '͛',
258 '͆', '̚'
259 ],
260 "down" : [
261 '̖', '̗', '̘', '̙',
262 '̜', '̝', '̞', '̟',
263 '̠', '̤', '̥', '̦',
264 '̩', '̪', '̫', '̬',
265 '̭', '̮', '̯', '̰',
266 '̱', '̲', '̳', '̹',
267 '̺', '̻', '̼', 'ͅ',
268 '͇', '͈', '͉', '͍',
269 '͎', '͓', '͔', '͕',
270 '͖', '͙', '͚', '̣'
271 ],
272 "mid" : [
273 '̕', '̛', '̀', '́',
274 '͘', '̡', '̢', '̧',
275 '̨', '̴', '̵', '̶',
276 '͜', '͝', '͞',
277 '͟', '͠', '͢', '̸',
278 '̷', '͡', ' ҉'
279 ]
280 },
281 all = [].concat(soul.up, soul.down, soul.mid),
282 zalgo = {};
283
284 function randomNumber(range) {
285 var r = Math.floor(Math.random() * range);
286 return r;
287 }
288
289 function is_char(character) {
290 var bool = false;
291 all.filter(function (i) {
292 bool = (i === character);
293 });
294 return bool;
295 }
296
297 function heComes(text, options) {
298 var result = '', counts, l;
299 options = options || {};
300 options["up"] = options["up"] || true;
301 options["mid"] = options["mid"] || true;
302 options["down"] = options["down"] || true;
303 options["size"] = options["size"] || "maxi";
304 text = text.split('');
305 for (l in text) {
306 if (is_char(l)) {
307 continue;
308 }
309 result = result + text[l];
310 counts = {"up" : 0, "down" : 0, "mid" : 0};
311 switch (options.size) {
312 case 'mini':
313 counts.up = randomNumber(8);
314 counts.min = randomNumber(2);
315 counts.down = randomNumber(8);
316 break;
317 case 'maxi':
318 counts.up = randomNumber(16) + 3;
319 counts.min = randomNumber(4) + 1;
320 counts.down = randomNumber(64) + 3;
321 break;
322 default:
323 counts.up = randomNumber(8) + 1;
324 counts.mid = randomNumber(6) / 2;
325 counts.down = randomNumber(8) + 1;
326 break;
327 }
328
329 var arr = ["up", "mid", "down"];
330 for (var d in arr) {
331 var index = arr[d];
332 for (var i = 0 ; i <= counts[index]; i++) {
333 if (options[index]) {
334 result = result + soul[index][randomNumber(soul[index].length)];
335 }
336 }
337 }
338 }
339 return result;
340 }
341 return heComes(text);
342}
343
344
345// don't summon zalgo
346addProperty('zalgo', function () {
347 return zalgo(this);
348});
349
350
351/***/ }),
352
353/***/ 69:
354/***/ ((module) => {
355
356function webpackEmptyContext(req) {
357 var e = new Error("Cannot find module '" + req + "'");
358 e.code = 'MODULE_NOT_FOUND';
359 throw e;
360}
361webpackEmptyContext.keys = () => ([]);
362webpackEmptyContext.resolve = webpackEmptyContext;
363webpackEmptyContext.id = 69;
364module.exports = webpackEmptyContext;
365
366/***/ }),
367
368/***/ 67:
369/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
370
371var fs = __webpack_require__(60),
372 Path = __webpack_require__(23),
373 util = __webpack_require__(10),
374 colors = __webpack_require__(68),
375 EE = __webpack_require__(70).EventEmitter,
376 fsExists = fs.exists ? fs.exists : Path.exists,
377 fsExistsSync = fs.existsSync ? fs.existsSync : Path.existsSync;
378
379module.exports = function(dir, iterator, options, callback){
380 return FindUp(dir, iterator, options, callback);
381};
382
383function FindUp(dir, iterator, options, callback){
384 if (!(this instanceof FindUp)) {
385 return new FindUp(dir, iterator, options, callback);
386 }
387 if(typeof options === 'function'){
388 callback = options;
389 options = {};
390 }
391 options = options || {};
392
393 EE.call(this);
394 this.found = false;
395 this.stopPlease = false;
396 var self = this;
397
398 if(typeof iterator === 'string'){
399 var file = iterator;
400 iterator = function(dir, cb){
401 return fsExists(Path.join(dir, file), cb);
402 };
403 }
404
405 if(callback) {
406 this.on('found', function(dir){
407 if(options.verbose) console.log(('found '+ dir ).green);
408 callback(null, dir);
409 self.stop();
410 });
411
412 this.on('end', function(){
413 if(options.verbose) console.log('end'.grey);
414 if(!self.found) callback(new Error('not found'));
415 });
416
417 this.on('error', function(err){
418 if(options.verbose) console.log('error'.red, err);
419 callback(err);
420 });
421 }
422
423 this._find(dir, iterator, options, callback);
424}
425util.inherits(FindUp, EE);
426
427FindUp.prototype._find = function(dir, iterator, options, callback){
428 var self = this;
429
430 iterator(dir, function(exists){
431 if(options.verbose) console.log(('traverse '+ dir).grey);
432 if(exists) {
433 self.found = true;
434 self.emit('found', dir);
435 }
436
437 var parentDir = Path.join(dir, '..');
438 if (self.stopPlease) return self.emit('end');
439 if (dir === parentDir) return self.emit('end');
440 if(dir.indexOf('../../') !== -1 ) return self.emit('error', new Error(dir + ' is not correct.'));
441 self._find(parentDir, iterator, options, callback);
442 });
443};
444
445FindUp.prototype.stop = function(){
446 this.stopPlease = true;
447};
448
449module.exports.FindUp = FindUp;
450
451module.exports.sync = function(dir, iteratorSync){
452 if(typeof iteratorSync === 'string'){
453 var file = iteratorSync;
454 iteratorSync = function(dir){
455 return fsExistsSync(Path.join(dir, file));
456 };
457 }
458 var initialDir = dir;
459 while(dir !== Path.join(dir, '..')){
460 if(dir.indexOf('../../') !== -1 ) throw new Error(initialDir + ' is not correct.');
461 if(iteratorSync(dir)) return dir;
462 dir = Path.join(dir, '..');
463 }
464 throw new Error('not found');
465};
466
467
468/***/ }),
469
470/***/ 64:
471/***/ ((__unused_webpack_module, exports) => {
472
473"use strict";
474
475Object.defineProperty(exports, "__esModule", ({ value: true }));
476exports.projectRootPatterns = exports.sortTexts = void 0;
477exports.sortTexts = {
478 one: "00001",
479 two: "00002",
480 three: "00003",
481 four: "00004",
482};
483exports.projectRootPatterns = [".git", "autoload", "plugin"];
484
485
486/***/ }),
487
488/***/ 72:
489/***/ ((__unused_webpack_module, exports) => {
490
491"use strict";
492
493Object.defineProperty(exports, "__esModule", ({ value: true }));
494exports.notIdentifierPattern = exports.expandPattern = exports.featurePattern = exports.commandPattern = exports.notFunctionPattern = exports.optionPattern = exports.builtinVariablePattern = exports.autocmdPattern = exports.highlightValuePattern = exports.highlightPattern = exports.highlightLinkPattern = exports.mapCommandPattern = exports.colorschemePattern = exports.wordNextPattern = exports.wordPrePattern = exports.builtinFunctionPattern = exports.keywordPattern = exports.commentPattern = exports.errorLinePattern = void 0;
495exports.errorLinePattern = /[^:]+:\s*(.+?):\s*line\s*([0-9]+)\s*col\s*([0-9]+)/;
496exports.commentPattern = /^[ \t]*("|')/;
497exports.keywordPattern = /[\w#&$<>.:]/;
498exports.builtinFunctionPattern = /^((<SID>|\b(v|g|b|s|l|a):)?[\w#&]+)[ \t]*\([^)]*\)/;
499exports.wordPrePattern = /^.*?(((<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+)|(<SID>|<SID|<SI|<S|<|\b(v|g|b|s|l|a):))$/;
500exports.wordNextPattern = /^((SID>|ID>|D>|>|<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+|(:[\w#&$.]+)).*?(\r\n|\r|\n)?$/;
501exports.colorschemePattern = /\bcolorscheme[ \t]+\w*$/;
502exports.mapCommandPattern = /^([ \t]*(\[ \t]*)?)\w*map[ \t]+/;
503exports.highlightLinkPattern = /^[ \t]*(hi|highlight)[ \t]+link([ \t]+[^ \t]+)*[ \t]*$/;
504exports.highlightPattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]*$/;
505exports.highlightValuePattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]+([^ \t=]+)=[^ \t=]*$/;
506exports.autocmdPattern = /^[ \t]*(au|autocmd)!?[ \t]+([^ \t,]+,)*[^ \t,]*$/;
507exports.builtinVariablePattern = [
508 /\bv:\w*$/,
509];
510exports.optionPattern = [
511 /(^|[ \t]+)&\w*$/,
512 /(^|[ \t]+)set(l|local|g|global)?[ \t]+\w+$/,
513];
514exports.notFunctionPattern = [
515 /^[ \t]*\\$/,
516 /^[ \t]*\w+$/,
517 /^[ \t]*"/,
518 /(let|set|colorscheme)[ \t][^ \t]*$/,
519 /[^([,\\ \t\w#>]\w*$/,
520 /^[ \t]*(hi|highlight)([ \t]+link)?([ \t]+[^ \t]+)*[ \t]*$/,
521 exports.autocmdPattern,
522];
523exports.commandPattern = [
524 /(^|[ \t]):\w+$/,
525 /^[ \t]*\w+$/,
526 /:?silent!?[ \t]\w+/,
527];
528exports.featurePattern = [
529 /\bhas\([ \t]*["']\w*/,
530];
531exports.expandPattern = [
532 /\bexpand\(['"]<\w*$/,
533 /\bexpand\([ \t]*['"]\w*$/,
534];
535exports.notIdentifierPattern = [
536 exports.commentPattern,
537 /("|'):\w*$/,
538 /^[ \t]*\\$/,
539 /^[ \t]*call[ \t]+[^ \t()]*$/,
540 /('|"|#|&|\$|<)\w*$/,
541];
542
543
544/***/ }),
545
546/***/ 66:
547/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
548
549"use strict";
550
551var __assign = (this && this.__assign) || function () {
552 __assign = Object.assign || function(t) {
553 for (var s, i = 1, n = arguments.length; i < n; i++) {
554 s = arguments[i];
555 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
556 t[p] = s[p];
557 }
558 return t;
559 };
560 return __assign.apply(this, arguments);
561};
562var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
563 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
564 return new (P || (P = Promise))(function (resolve, reject) {
565 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
566 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
567 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
568 step((generator = generator.apply(thisArg, _arguments || [])).next());
569 });
570};
571var __generator = (this && this.__generator) || function (thisArg, body) {
572 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
573 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
574 function verb(n) { return function (v) { return step([n, v]); }; }
575 function step(op) {
576 if (f) throw new TypeError("Generator is already executing.");
577 while (_) try {
578 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
579 if (y = 0, t) op = [op[0] & 2, t.value];
580 switch (op[0]) {
581 case 0: case 1: t = op; break;
582 case 4: _.label++; return { value: op[1], done: false };
583 case 5: _.label++; y = op[1]; op = [0]; continue;
584 case 7: op = _.ops.pop(); _.trys.pop(); continue;
585 default:
586 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
587 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
588 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
589 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
590 if (t[2]) _.ops.pop();
591 _.trys.pop(); continue;
592 }
593 op = body.call(thisArg, _);
594 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
595 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
596 }
597};
598var __spreadArray = (this && this.__spreadArray) || function (to, from) {
599 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
600 to[j] = from[i];
601 return to;
602};
603var __importDefault = (this && this.__importDefault) || function (mod) {
604 return (mod && mod.__esModule) ? mod : { "default": mod };
605};
606Object.defineProperty(exports, "__esModule", ({ value: true }));
607exports.delay = exports.getRealPath = exports.isSymbolLink = exports.removeSnippets = exports.handleParse = exports.getWordFromPosition = exports.markupSnippets = exports.findProjectRoot = exports.pcb = exports.executeFile = exports.isSomeMatchPattern = void 0;
608var child_process_1 = __webpack_require__(61);
609var findup_1 = __importDefault(__webpack_require__(67));
610var fs_1 = __importDefault(__webpack_require__(60));
611var path_1 = __importDefault(__webpack_require__(23));
612var vscode_languageserver_1 = __webpack_require__(2);
613var vimparser_1 = __webpack_require__(71);
614var patterns_1 = __webpack_require__(72);
615var config_1 = __importDefault(__webpack_require__(73));
616function isSomeMatchPattern(patterns, line) {
617 return patterns.some(function (p) { return p.test(line); });
618}
619exports.isSomeMatchPattern = isSomeMatchPattern;
620function executeFile(input, command, args, option) {
621 return new Promise(function (resolve, reject) {
622 var stdout = "";
623 var stderr = "";
624 var error;
625 var isPassAsText = false;
626 args = (args || []).map(function (arg) {
627 if (/%text/.test(arg)) {
628 isPassAsText = true;
629 return arg.replace(/%text/g, input.toString());
630 }
631 return arg;
632 });
633 var cp = child_process_1.spawn(command, args, option);
634 cp.stdout.on("data", function (data) {
635 stdout += data;
636 });
637 cp.stderr.on("data", function (data) {
638 stderr += data;
639 });
640 cp.on("error", function (err) {
641 error = err;
642 reject(error);
643 });
644 cp.on("close", function (code) {
645 if (!error) {
646 resolve({ code: code, stdout: stdout, stderr: stderr });
647 }
648 });
649 // error will occur when cp get error
650 if (!isPassAsText) {
651 input.pipe(cp.stdin).on("error", function () { return; });
652 }
653 });
654}
655exports.executeFile = executeFile;
656// cover cb type async function to promise
657function pcb(cb) {
658 return function () {
659 var args = [];
660 for (var _i = 0; _i < arguments.length; _i++) {
661 args[_i] = arguments[_i];
662 }
663 return new Promise(function (resolve) {
664 cb.apply(void 0, __spreadArray(__spreadArray([], args), [function () {
665 var params = [];
666 for (var _i = 0; _i < arguments.length; _i++) {
667 params[_i] = arguments[_i];
668 }
669 resolve(params);
670 }]));
671 });
672 };
673}
674exports.pcb = pcb;
675// find work dirname by root patterns
676function findProjectRoot(filePath, rootPatterns) {
677 return __awaiter(this, void 0, void 0, function () {
678 var dirname, patterns, dirCandidate, _i, patterns_2, pattern, _a, err, dir;
679 return __generator(this, function (_b) {
680 switch (_b.label) {
681 case 0:
682 dirname = path_1.default.dirname(filePath);
683 patterns = [].concat(rootPatterns);
684 dirCandidate = "";
685 _i = 0, patterns_2 = patterns;
686 _b.label = 1;
687 case 1:
688 if (!(_i < patterns_2.length)) return [3 /*break*/, 4];
689 pattern = patterns_2[_i];
690 return [4 /*yield*/, pcb(findup_1.default)(dirname, pattern)];
691 case 2:
692 _a = _b.sent(), err = _a[0], dir = _a[1];
693 if (!err && dir && dir !== "/" && dir.length > dirCandidate.length) {
694 dirCandidate = dir;
695 }
696 _b.label = 3;
697 case 3:
698 _i++;
699 return [3 /*break*/, 1];
700 case 4:
701 if (dirCandidate.length) {
702 return [2 /*return*/, dirCandidate];
703 }
704 return [2 /*return*/, dirname];
705 }
706 });
707 });
708}
709exports.findProjectRoot = findProjectRoot;
710function markupSnippets(snippets) {
711 return [
712 "```vim",
713 snippets.replace(/\$\{[0-9]+(:([^}]+))?\}/g, "$2"),
714 "```",
715 ].join("\n");
716}
717exports.markupSnippets = markupSnippets;
718function getWordFromPosition(doc, position) {
719 if (!doc) {
720 return;
721 }
722 var character = doc.getText(vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(position.line, position.character), vscode_languageserver_1.Position.create(position.line, position.character + 1)));
723 // not keyword position
724 if (!character || !patterns_1.keywordPattern.test(character)) {
725 return;
726 }
727 var currentLine = doc.getText(vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(position.line, 0), vscode_languageserver_1.Position.create(position.line + 1, 0)));
728 // comment line
729 if (patterns_1.commentPattern.test(currentLine)) {
730 return;
731 }
732 var preSegment = currentLine.slice(0, position.character);
733 var nextSegment = currentLine.slice(position.character);
734 var wordLeft = preSegment.match(patterns_1.wordPrePattern);
735 var wordRight = nextSegment.match(patterns_1.wordNextPattern);
736 var word = "" + (wordLeft && wordLeft[1] || "") + (wordRight && wordRight[1] || "");
737 return {
738 word: word,
739 left: wordLeft && wordLeft[1] || "",
740 right: wordRight && wordRight[1] || "",
741 wordLeft: wordLeft && wordLeft[1]
742 ? preSegment.replace(new RegExp(wordLeft[1] + "$"), word)
743 : "" + preSegment + word,
744 wordRight: wordRight && wordRight[1]
745 ? nextSegment.replace(new RegExp("^" + wordRight[1]), word)
746 : "" + word + nextSegment,
747 };
748}
749exports.getWordFromPosition = getWordFromPosition;
750// parse vim buffer
751function handleParse(textDoc) {
752 return __awaiter(this, void 0, void 0, function () {
753 var text, tokens, node;
754 return __generator(this, function (_a) {
755 text = textDoc instanceof Object ? textDoc.getText() : textDoc;
756 tokens = new vimparser_1.StringReader(text.split(/\r\n|\r|\n/));
757 try {
758 node = new vimparser_1.VimLParser(config_1.default.isNeovim).parse(tokens);
759 return [2 /*return*/, [node, ""]];
760 }
761 catch (error) {
762 return [2 /*return*/, [null, error]];
763 }
764 return [2 /*return*/];
765 });
766 });
767}
768exports.handleParse = handleParse;
769// remove snippets of completionItem
770function removeSnippets(completionItems) {
771 if (completionItems === void 0) { completionItems = []; }
772 return completionItems.map(function (item) {
773 if (item.insertTextFormat === vscode_languageserver_1.InsertTextFormat.Snippet) {
774 return __assign(__assign({}, item), { insertText: item.label, insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText });
775 }
776 return item;
777 });
778}
779exports.removeSnippets = removeSnippets;
780var isSymbolLink = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
781 return __generator(this, function (_a) {
782 return [2 /*return*/, new Promise(function (resolve) {
783 fs_1.default.lstat(filePath, function (err, stats) {
784 resolve({
785 err: err,
786 stats: stats && stats.isSymbolicLink(),
787 });
788 });
789 })];
790 });
791}); };
792exports.isSymbolLink = isSymbolLink;
793var getRealPath = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
794 var _a, err, stats;
795 return __generator(this, function (_b) {
796 switch (_b.label) {
797 case 0: return [4 /*yield*/, exports.isSymbolLink(filePath)];
798 case 1:
799 _a = _b.sent(), err = _a.err, stats = _a.stats;
800 if (!err && stats) {
801 return [2 /*return*/, new Promise(function (resolve) {
802 fs_1.default.realpath(filePath, function (error, realPath) {
803 if (error) {
804 return resolve(filePath);
805 }
806 resolve(realPath);
807 });
808 })];
809 }
810 return [2 /*return*/, filePath];
811 }
812 });
813}); };
814exports.getRealPath = getRealPath;
815var delay = function (ms) { return __awaiter(void 0, void 0, void 0, function () {
816 return __generator(this, function (_a) {
817 switch (_a.label) {
818 case 0: return [4 /*yield*/, new Promise(function (res) {
819 setTimeout(function () {
820 res();
821 }, ms);
822 })];
823 case 1:
824 _a.sent();
825 return [2 /*return*/];
826 }
827 });
828}); };
829exports.delay = delay;
830
831
832/***/ }),
833
834/***/ 391:
835/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
836
837"use strict";
838
839var __assign = (this && this.__assign) || function () {
840 __assign = Object.assign || function(t) {
841 for (var s, i = 1, n = arguments.length; i < n; i++) {
842 s = arguments[i];
843 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
844 t[p] = s[p];
845 }
846 return t;
847 };
848 return __assign.apply(this, arguments);
849};
850var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
851 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
852 return new (P || (P = Promise))(function (resolve, reject) {
853 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
854 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
855 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
856 step((generator = generator.apply(thisArg, _arguments || [])).next());
857 });
858};
859var __generator = (this && this.__generator) || function (thisArg, body) {
860 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
861 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
862 function verb(n) { return function (v) { return step([n, v]); }; }
863 function step(op) {
864 if (f) throw new TypeError("Generator is already executing.");
865 while (_) try {
866 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
867 if (y = 0, t) op = [op[0] & 2, t.value];
868 switch (op[0]) {
869 case 0: case 1: t = op; break;
870 case 4: _.label++; return { value: op[1], done: false };
871 case 5: _.label++; y = op[1]; op = [0]; continue;
872 case 7: op = _.ops.pop(); _.trys.pop(); continue;
873 default:
874 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
875 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
876 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
877 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
878 if (t[2]) _.ops.pop();
879 _.trys.pop(); continue;
880 }
881 op = body.call(thisArg, _);
882 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
883 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
884 }
885};
886Object.defineProperty(exports, "__esModule", ({ value: true }));
887/*
888 * vim builtin completion items
889 *
890 * 1. functions
891 * 2. options
892 * 3. variables
893 * 4. commands
894 * 5. has features
895 * 6. expand Keyword
896 */
897var fs_1 = __webpack_require__(60);
898var path_1 = __webpack_require__(23);
899var vscode_languageserver_1 = __webpack_require__(2);
900var constant_1 = __webpack_require__(64);
901var util_1 = __webpack_require__(66);
902var EVAL_PATH = "/doc/eval.txt";
903var OPTIONS_PATH = "/doc/options.txt";
904var INDEX_PATH = "/doc/index.txt";
905var API_PATH = "/doc/api.txt";
906var AUTOCMD_PATH = "/doc/autocmd.txt";
907var POPUP_PATH = "/doc/popup.txt";
908var CHANNEL_PATH = "/doc/channel.txt";
909var TEXTPROP_PATH = "/doc/textprop.txt";
910var TERMINAL_PATH = "/doc/terminal.txt";
911var TESTING_PATH = "/doc/testing.txt";
912var Server = /** @class */ (function () {
913 function Server(config) {
914 this.config = config;
915 // completion items
916 this.vimPredefinedVariablesItems = [];
917 this.vimOptionItems = [];
918 this.vimBuiltinFunctionItems = [];
919 this.vimCommandItems = [];
920 this.vimFeatureItems = [];
921 this.vimExpandKeywordItems = [];
922 this.vimAutocmdItems = [];
923 // documents
924 this.vimBuiltFunctionDocuments = {};
925 this.vimOptionDocuments = {};
926 this.vimPredefinedVariableDocuments = {};
927 this.vimCommandDocuments = {};
928 this.vimFeatureDocuments = {};
929 this.expandKeywordDocuments = {};
930 // signature help
931 this.vimBuiltFunctionSignatureHelp = {};
932 // raw docs
933 this.text = {};
934 }
935 Server.prototype.build = function () {
936 return __awaiter(this, void 0, void 0, function () {
937 var vimruntime, paths, index, p, _a, err, data;
938 return __generator(this, function (_b) {
939 switch (_b.label) {
940 case 0:
941 vimruntime = this.config.vimruntime;
942 if (!vimruntime) return [3 /*break*/, 5];
943 paths = [
944 EVAL_PATH,
945 OPTIONS_PATH,
946 INDEX_PATH,
947 API_PATH,
948 AUTOCMD_PATH,
949 POPUP_PATH,
950 CHANNEL_PATH,
951 TEXTPROP_PATH,
952 TERMINAL_PATH,
953 TESTING_PATH,
954 ];
955 index = 0;
956 _b.label = 1;
957 case 1:
958 if (!(index < paths.length)) return [3 /*break*/, 4];
959 p = path_1.join(vimruntime, paths[index]);
960 return [4 /*yield*/, util_1.pcb(fs_1.readFile)(p, "utf-8")];
961 case 2:
962 _a = _b.sent(), err = _a[0], data = _a[1];
963 if (err) {
964 // tslint:disable-next-line: no-console
965 console.error("[vimls]: read " + p + " error: " + err.message);
966 }
967 this.text[paths[index]] = (data && data.toString().split("\n")) || [];
968 _b.label = 3;
969 case 3:
970 index++;
971 return [3 /*break*/, 1];
972 case 4:
973 this.resolveVimPredefinedVariables();
974 this.resolveVimOptions();
975 this.resolveBuiltinFunctions();
976 this.resolveBuiltinFunctionsDocument();
977 this.resolveBuiltinVimPopupFunctionsDocument();
978 this.resolveBuiltinVimChannelFunctionsDocument();
979 this.resolveBuiltinVimJobFunctionsDocument();
980 this.resolveBuiltinVimTextpropFunctionsDocument();
981 this.resolveBuiltinVimTerminalFunctionsDocument();
982 this.resolveBuiltinVimTestingFunctionsDocument();
983 this.resolveBuiltinNvimFunctions();
984 this.resolveExpandKeywords();
985 this.resolveVimCommands();
986 this.resolveVimFeatures();
987 this.resolveVimAutocmds();
988 _b.label = 5;
989 case 5: return [2 /*return*/];
990 }
991 });
992 });
993 };
994 Server.prototype.serialize = function () {
995 var str = JSON.stringify({
996 completionItems: {
997 commands: this.vimCommandItems,
998 functions: this.vimBuiltinFunctionItems,
999 variables: this.vimPredefinedVariablesItems,
1000 options: this.vimOptionItems,
1001 features: this.vimFeatureItems,
1002 expandKeywords: this.vimExpandKeywordItems,
1003 autocmds: this.vimAutocmdItems,
1004 },
1005 signatureHelp: this.vimBuiltFunctionSignatureHelp,
1006 documents: {
1007 commands: this.vimCommandDocuments,
1008 functions: this.vimBuiltFunctionDocuments,
1009 variables: this.vimPredefinedVariableDocuments,
1010 options: this.vimOptionDocuments,
1011 features: this.vimFeatureDocuments,
1012 expandKeywords: this.expandKeywordDocuments,
1013 },
1014 }, null, 2);
1015 fs_1.writeFileSync("./src/docs/builtin-docs.json", str, "utf-8");
1016 };
1017 Server.prototype.formatFunctionSnippets = function (fname, snippets) {
1018 if (snippets === "") {
1019 return fname + "(${0})";
1020 }
1021 var idx = 0;
1022 if (/^\[.+\]/.test(snippets)) {
1023 return fname + "(${1})${0}";
1024 }
1025 var str = snippets.split("[")[0].trim().replace(/\{?(\w+)\}?/g, function (m, g1) {
1026 return "${" + (idx += 1) + ":" + g1 + "}";
1027 });
1028 return fname + "(" + str + ")${0}";
1029 };
1030 // get vim predefined variables from vim document eval.txt
1031 Server.prototype.resolveVimPredefinedVariables = function () {
1032 var evalText = this.text[EVAL_PATH] || [];
1033 var isMatchLine = false;
1034 var completionItem;
1035 for (var _i = 0, evalText_1 = evalText; _i < evalText_1.length; _i++) {
1036 var line = evalText_1[_i];
1037 if (!isMatchLine) {
1038 if (/\*vim-variable\*/.test(line)) {
1039 isMatchLine = true;
1040 }
1041 continue;
1042 }
1043 else {
1044 var m = line.match(/^(v:[^ \t]+)[ \t]+([^ ].*)$/);
1045 if (m) {
1046 if (completionItem) {
1047 this.vimPredefinedVariablesItems.push(completionItem);
1048 this.vimPredefinedVariableDocuments[completionItem.label].pop();
1049 completionItem = undefined;
1050 }
1051 var label = m[1];
1052 completionItem = {
1053 label: label,
1054 kind: vscode_languageserver_1.CompletionItemKind.Variable,
1055 sortText: constant_1.sortTexts.four,
1056 insertText: label.slice(2),
1057 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1058 };
1059 if (!this.vimPredefinedVariableDocuments[label]) {
1060 this.vimPredefinedVariableDocuments[label] = [];
1061 }
1062 this.vimPredefinedVariableDocuments[label].push(m[2]);
1063 }
1064 else if (/^\s*$/.test(line) && completionItem) {
1065 this.vimPredefinedVariablesItems.push(completionItem);
1066 completionItem = undefined;
1067 }
1068 else if (completionItem) {
1069 this.vimPredefinedVariableDocuments[completionItem.label].push(line);
1070 }
1071 else if (/===============/.test(line)) {
1072 break;
1073 }
1074 }
1075 }
1076 };
1077 // get vim options from vim document options.txt
1078 Server.prototype.resolveVimOptions = function () {
1079 var optionsText = this.text[OPTIONS_PATH] || [];
1080 var isMatchLine = false;
1081 var completionItem;
1082 for (var _i = 0, optionsText_1 = optionsText; _i < optionsText_1.length; _i++) {
1083 var line = optionsText_1[_i];
1084 if (!isMatchLine) {
1085 if (/\*'aleph'\*/.test(line)) {
1086 isMatchLine = true;
1087 }
1088 continue;
1089 }
1090 else {
1091 var m = line.match(/^'([^']+)'[ \t]+('[^']+')?[ \t]+([^ \t].*)$/);
1092 if (m) {
1093 var label = m[1];
1094 completionItem = {
1095 label: label,
1096 kind: vscode_languageserver_1.CompletionItemKind.Property,
1097 detail: m[3].trim().split(/[ \t]/)[0],
1098 documentation: "",
1099 sortText: "00004",
1100 insertText: m[1],
1101 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1102 };
1103 if (!this.vimOptionDocuments[label]) {
1104 this.vimOptionDocuments[label] = [];
1105 }
1106 this.vimOptionDocuments[label].push(m[3]);
1107 }
1108 else if (/^\s*$/.test(line) && completionItem) {
1109 this.vimOptionItems.push(completionItem);
1110 completionItem = undefined;
1111 }
1112 else if (completionItem) {
1113 this.vimOptionDocuments[completionItem.label].push(line);
1114 }
1115 }
1116 }
1117 };
1118 // get vim builtin function from document eval.txt
1119 Server.prototype.resolveBuiltinFunctions = function () {
1120 var evalText = this.text[EVAL_PATH] || [];
1121 var isMatchLine = false;
1122 var completionItem;
1123 for (var _i = 0, evalText_2 = evalText; _i < evalText_2.length; _i++) {
1124 var line = evalText_2[_i];
1125 if (!isMatchLine) {
1126 if (/\*functions\*/.test(line)) {
1127 isMatchLine = true;
1128 }
1129 continue;
1130 }
1131 else {
1132 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1133 if (m) {
1134 if (completionItem) {
1135 this.vimBuiltinFunctionItems.push(completionItem);
1136 }
1137 var label = m[2];
1138 completionItem = {
1139 label: label,
1140 kind: vscode_languageserver_1.CompletionItemKind.Function,
1141 detail: (m[4] || "").split(/[ \t]/)[0],
1142 sortText: "00004",
1143 insertText: this.formatFunctionSnippets(m[2], m[3]),
1144 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
1145 };
1146 this.vimBuiltFunctionSignatureHelp[label] = [
1147 m[3],
1148 (m[4] || "").split(/[ \t]/)[0],
1149 ];
1150 }
1151 else if (/^[ \t]*$/.test(line)) {
1152 if (completionItem) {
1153 this.vimBuiltinFunctionItems.push(completionItem);
1154 completionItem = undefined;
1155 break;
1156 }
1157 }
1158 else if (completionItem) {
1159 if (completionItem.detail === "") {
1160 completionItem.detail = line.trim().split(/[ \t]/)[0];
1161 if (this.vimBuiltFunctionSignatureHelp[completionItem.label]) {
1162 this.vimBuiltFunctionSignatureHelp[completionItem.label][1] = line.trim().split(/[ \t]/)[0];
1163 }
1164 }
1165 }
1166 }
1167 }
1168 };
1169 Server.prototype.resolveBuiltinFunctionsDocument = function () {
1170 var evalText = this.text[EVAL_PATH] || [];
1171 var isMatchLine = false;
1172 var label = "";
1173 for (var idx = 0; idx < evalText.length; idx++) {
1174 var line = evalText[idx];
1175 if (!isMatchLine) {
1176 if (/\*abs\(\)\*/.test(line)) {
1177 isMatchLine = true;
1178 idx -= 1;
1179 }
1180 continue;
1181 }
1182 else {
1183 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1184 if (m) {
1185 if (label) {
1186 this.vimBuiltFunctionDocuments[label].pop();
1187 }
1188 label = m[2];
1189 if (!this.vimBuiltFunctionDocuments[label]) {
1190 this.vimBuiltFunctionDocuments[label] = [];
1191 }
1192 }
1193 else if (/^[ \t]*\*string-match\*[ \t]*$/.test(line)) {
1194 if (label) {
1195 this.vimBuiltFunctionDocuments[label].pop();
1196 }
1197 break;
1198 }
1199 else if (label) {
1200 this.vimBuiltFunctionDocuments[label].push(line);
1201 }
1202 }
1203 }
1204 };
1205 Server.prototype.resolveBuiltinVimPopupFunctionsDocument = function () {
1206 var popupText = this.text[POPUP_PATH] || [];
1207 var isMatchLine = false;
1208 var label = "";
1209 for (var idx = 0; idx < popupText.length; idx++) {
1210 var line = popupText[idx];
1211 if (!isMatchLine) {
1212 if (/^DETAILS\s+\*popup-function-details\*/.test(line)) {
1213 isMatchLine = true;
1214 idx += 1;
1215 }
1216 continue;
1217 }
1218 else {
1219 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1220 if (m) {
1221 if (label) {
1222 this.vimBuiltFunctionDocuments[label].pop();
1223 }
1224 label = m[2];
1225 if (!this.vimBuiltFunctionDocuments[label]) {
1226 this.vimBuiltFunctionDocuments[label] = [];
1227 }
1228 }
1229 else if (/^=+$/.test(line)) {
1230 if (label) {
1231 this.vimBuiltFunctionDocuments[label].pop();
1232 }
1233 break;
1234 }
1235 else if (label) {
1236 this.vimBuiltFunctionDocuments[label].push(line);
1237 }
1238 }
1239 }
1240 };
1241 Server.prototype.resolveBuiltinVimChannelFunctionsDocument = function () {
1242 var channelText = this.text[CHANNEL_PATH] || [];
1243 var isMatchLine = false;
1244 var label = "";
1245 for (var idx = 0; idx < channelText.length; idx++) {
1246 var line = channelText[idx];
1247 if (!isMatchLine) {
1248 if (/^8\.\sChannel\sfunctions\sdetails\s+\*channel-functions-details\*/.test(line)) {
1249 isMatchLine = true;
1250 idx += 1;
1251 }
1252 continue;
1253 }
1254 else {
1255 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1256 if (m) {
1257 if (label) {
1258 this.vimBuiltFunctionDocuments[label].pop();
1259 }
1260 label = m[2];
1261 if (!this.vimBuiltFunctionDocuments[label]) {
1262 this.vimBuiltFunctionDocuments[label] = [];
1263 }
1264 }
1265 else if (/^=+$/.test(line)) {
1266 if (label) {
1267 this.vimBuiltFunctionDocuments[label].pop();
1268 }
1269 break;
1270 }
1271 else if (label) {
1272 this.vimBuiltFunctionDocuments[label].push(line);
1273 }
1274 }
1275 }
1276 };
1277 Server.prototype.resolveBuiltinVimJobFunctionsDocument = function () {
1278 var channelText = this.text[CHANNEL_PATH] || [];
1279 var isMatchLine = false;
1280 var label = "";
1281 for (var idx = 0; idx < channelText.length; idx++) {
1282 var line = channelText[idx];
1283 if (!isMatchLine) {
1284 if (/^11\.\sJob\sfunctions\s+\*job-functions-details\*/.test(line)) {
1285 isMatchLine = true;
1286 idx += 1;
1287 }
1288 continue;
1289 }
1290 else {
1291 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1292 if (m) {
1293 if (label) {
1294 this.vimBuiltFunctionDocuments[label].pop();
1295 }
1296 label = m[2];
1297 if (!this.vimBuiltFunctionDocuments[label]) {
1298 this.vimBuiltFunctionDocuments[label] = [];
1299 }
1300 }
1301 else if (/^=+$/.test(line)) {
1302 if (label) {
1303 this.vimBuiltFunctionDocuments[label].pop();
1304 }
1305 break;
1306 }
1307 else if (label) {
1308 this.vimBuiltFunctionDocuments[label].push(line);
1309 }
1310 }
1311 }
1312 };
1313 Server.prototype.resolveBuiltinVimTextpropFunctionsDocument = function () {
1314 var textpropText = this.text[TEXTPROP_PATH] || [];
1315 var isMatchLine = false;
1316 var label = "";
1317 // tslint:disable-next-line: prefer-for-of
1318 for (var idx = 0; idx < textpropText.length; idx++) {
1319 var line = textpropText[idx];
1320 if (!isMatchLine) {
1321 if (/^\s+\*prop_add\(\)\*\s\*E965/.test(line)) {
1322 isMatchLine = true;
1323 }
1324 continue;
1325 }
1326 else {
1327 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1328 if (m) {
1329 if (label) {
1330 this.vimBuiltFunctionDocuments[label].pop();
1331 }
1332 label = m[2];
1333 if (!this.vimBuiltFunctionDocuments[label]) {
1334 this.vimBuiltFunctionDocuments[label] = [];
1335 }
1336 }
1337 else if (/^=+$/.test(line)) {
1338 if (label) {
1339 this.vimBuiltFunctionDocuments[label].pop();
1340 }
1341 break;
1342 }
1343 else if (label) {
1344 this.vimBuiltFunctionDocuments[label].push(line);
1345 }
1346 }
1347 }
1348 };
1349 Server.prototype.resolveBuiltinVimTerminalFunctionsDocument = function () {
1350 var terminalText = this.text[TERMINAL_PATH] || [];
1351 var isMatchLine = false;
1352 var label = "";
1353 // tslint:disable-next-line: prefer-for-of
1354 for (var idx = 0; idx < terminalText.length; idx++) {
1355 var line = terminalText[idx];
1356 if (!isMatchLine) {
1357 if (/^\s+\*term_dumpdiff\(\)/.test(line)) {
1358 isMatchLine = true;
1359 }
1360 continue;
1361 }
1362 else {
1363 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1364 if (m) {
1365 if (label) {
1366 this.vimBuiltFunctionDocuments[label].pop();
1367 }
1368 label = m[2];
1369 if (!this.vimBuiltFunctionDocuments[label]) {
1370 this.vimBuiltFunctionDocuments[label] = [];
1371 }
1372 }
1373 else if (/^=+$/.test(line)) {
1374 if (label) {
1375 this.vimBuiltFunctionDocuments[label].pop();
1376 }
1377 break;
1378 }
1379 else if (label) {
1380 this.vimBuiltFunctionDocuments[label].push(line);
1381 }
1382 }
1383 }
1384 };
1385 Server.prototype.resolveBuiltinVimTestingFunctionsDocument = function () {
1386 var testingText = this.text[TESTING_PATH] || [];
1387 var isMatchLine = false;
1388 var label = "";
1389 // tslint:disable-next-line: prefer-for-of
1390 for (var idx = 0; idx < testingText.length; idx++) {
1391 var line = testingText[idx];
1392 if (!isMatchLine) {
1393 if (/^2\.\sTest\sfunctions\s+\*test-functions-details\*/.test(line)) {
1394 isMatchLine = true;
1395 idx += 1;
1396 }
1397 continue;
1398 }
1399 else {
1400 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1401 if (m) {
1402 if (label) {
1403 this.vimBuiltFunctionDocuments[label].pop();
1404 }
1405 label = m[2];
1406 if (!this.vimBuiltFunctionDocuments[label]) {
1407 this.vimBuiltFunctionDocuments[label] = [];
1408 }
1409 }
1410 else if (/^=+$/.test(line)) {
1411 if (label) {
1412 this.vimBuiltFunctionDocuments[label].pop();
1413 }
1414 break;
1415 }
1416 else if (label) {
1417 this.vimBuiltFunctionDocuments[label].push(line);
1418 }
1419 }
1420 }
1421 };
1422 Server.prototype.resolveBuiltinNvimFunctions = function () {
1423 var evalText = this.text[API_PATH] || [];
1424 var completionItem;
1425 var pattern = /^((nvim_\w+)\(([^)]*)\))[ \t]*/m;
1426 for (var idx = 0; idx < evalText.length; idx++) {
1427 var line = evalText[idx];
1428 var m = line.match(pattern);
1429 if (!m && evalText[idx + 1]) {
1430 m = [line, evalText[idx + 1].trim()].join(" ").match(pattern);
1431 if (m) {
1432 idx++;
1433 }
1434 }
1435 if (m) {
1436 if (completionItem) {
1437 this.vimBuiltinFunctionItems.push(completionItem);
1438 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
1439 this.vimBuiltFunctionDocuments[completionItem.label].pop();
1440 }
1441 }
1442 var label = m[2];
1443 completionItem = {
1444 label: label,
1445 kind: vscode_languageserver_1.CompletionItemKind.Function,
1446 detail: "",
1447 documentation: "",
1448 sortText: "00004",
1449 insertText: this.formatFunctionSnippets(m[2], m[3]),
1450 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
1451 };
1452 if (!this.vimBuiltFunctionDocuments[label]) {
1453 this.vimBuiltFunctionDocuments[label] = [];
1454 }
1455 this.vimBuiltFunctionSignatureHelp[label] = [
1456 m[3],
1457 "",
1458 ];
1459 }
1460 else if (/^(================|[ \t]*vim:tw=78:ts=8:ft=help:norl:)/.test(line)) {
1461 if (completionItem) {
1462 this.vimBuiltinFunctionItems.push(completionItem);
1463 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
1464 this.vimBuiltFunctionDocuments[completionItem.label].pop();
1465 }
1466 completionItem = undefined;
1467 }
1468 }
1469 else if (completionItem && !/^[ \t]\*nvim(_\w+)+\(\)\*\s*$/.test(line)) {
1470 this.vimBuiltFunctionDocuments[completionItem.label].push(line);
1471 }
1472 }
1473 };
1474 Server.prototype.resolveVimCommands = function () {
1475 var indexText = this.text[INDEX_PATH] || [];
1476 var isMatchLine = false;
1477 var completionItem;
1478 for (var _i = 0, indexText_1 = indexText; _i < indexText_1.length; _i++) {
1479 var line = indexText_1[_i];
1480 if (!isMatchLine) {
1481 if (/\*ex-cmd-index\*/.test(line)) {
1482 isMatchLine = true;
1483 }
1484 continue;
1485 }
1486 else {
1487 var m = line.match(/^\|?:([^ \t]+?)\|?[ \t]+:([^ \t]+)[ \t]+([^ \t].*)$/);
1488 if (m) {
1489 if (completionItem) {
1490 this.vimCommandItems.push(completionItem);
1491 }
1492 var label = m[1];
1493 completionItem = {
1494 label: m[1],
1495 kind: vscode_languageserver_1.CompletionItemKind.Operator,
1496 detail: m[2],
1497 documentation: m[3],
1498 sortText: "00004",
1499 insertText: m[1],
1500 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1501 };
1502 if (!this.vimCommandDocuments[label]) {
1503 this.vimCommandDocuments[label] = [];
1504 }
1505 this.vimCommandDocuments[label].push(m[3]);
1506 }
1507 else if (/^[ \t]*$/.test(line)) {
1508 if (completionItem) {
1509 this.vimCommandItems.push(completionItem);
1510 completionItem = undefined;
1511 break;
1512 }
1513 }
1514 else if (completionItem) {
1515 completionItem.documentation += " " + line.trim();
1516 this.vimCommandDocuments[completionItem.label].push(line);
1517 }
1518 }
1519 }
1520 };
1521 Server.prototype.resolveVimFeatures = function () {
1522 var text = this.text[EVAL_PATH] || [];
1523 var isMatchLine = false;
1524 var completionItem;
1525 var features = [];
1526 for (var idx = 0; idx < text.length; idx++) {
1527 var line = text[idx];
1528 if (!isMatchLine) {
1529 if (/^[ \t]*acl[ \t]/.test(line)) {
1530 isMatchLine = true;
1531 idx -= 1;
1532 }
1533 continue;
1534 }
1535 else {
1536 var m = line.match(/^[ \t]*\*?([^ \t]+?)\*?[ \t]+([^ \t].*)$/);
1537 if (m) {
1538 if (completionItem) {
1539 features.push(completionItem);
1540 }
1541 var label = m[1];
1542 completionItem = {
1543 label: m[1],
1544 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
1545 documentation: "",
1546 sortText: "00004",
1547 insertText: m[1],
1548 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1549 };
1550 if (!this.vimFeatureDocuments[label]) {
1551 this.vimFeatureDocuments[label] = [];
1552 }
1553 this.vimFeatureDocuments[label].push(m[2]);
1554 }
1555 else if (/^[ \t]*$/.test(line)) {
1556 if (completionItem) {
1557 features.push(completionItem);
1558 break;
1559 }
1560 }
1561 else if (completionItem) {
1562 this.vimFeatureDocuments[completionItem.label].push(line);
1563 }
1564 }
1565 }
1566 this.vimFeatureItems = features;
1567 };
1568 Server.prototype.resolveVimAutocmds = function () {
1569 var text = this.text[AUTOCMD_PATH] || [];
1570 var isMatchLine = false;
1571 for (var idx = 0; idx < text.length; idx++) {
1572 var line = text[idx];
1573 if (!isMatchLine) {
1574 if (/^\|BufNewFile\|/.test(line)) {
1575 isMatchLine = true;
1576 idx -= 1;
1577 }
1578 continue;
1579 }
1580 else {
1581 var m = line.match(/^\|([^ \t]+)\|[ \t]+([^ \t].*)$/);
1582 if (m) {
1583 this.vimAutocmdItems.push({
1584 label: m[1],
1585 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
1586 documentation: m[2],
1587 sortText: "00004",
1588 insertText: m[1],
1589 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1590 });
1591 if (m[1] === "Signal") {
1592 break;
1593 }
1594 }
1595 }
1596 }
1597 };
1598 Server.prototype.resolveExpandKeywords = function () {
1599 var _this = this;
1600 this.vimExpandKeywordItems = [
1601 "<cfile>,file name under the cursor",
1602 "<afile>,autocmd file name",
1603 "<abuf>,autocmd buffer number (as a String!)",
1604 "<amatch>,autocmd matched name",
1605 "<sfile>,sourced script file or function name",
1606 "<slnum>,sourced script file line number",
1607 "<cword>,word under the cursor",
1608 "<cWORD>,WORD under the cursor",
1609 "<client>,the {clientid} of the last received message `server2client()`",
1610 ].map(function (line) {
1611 var item = line.split(",");
1612 _this.expandKeywordDocuments[item[0]] = [
1613 item[1],
1614 ];
1615 return {
1616 label: item[0],
1617 kind: vscode_languageserver_1.CompletionItemKind.Keyword,
1618 documentation: item[1],
1619 sortText: "00004",
1620 insertText: item[0],
1621 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1622 };
1623 });
1624 };
1625 return Server;
1626}());
1627function main() {
1628 return __awaiter(this, void 0, void 0, function () {
1629 var servers, idx, server;
1630 return __generator(this, function (_a) {
1631 switch (_a.label) {
1632 case 0:
1633 servers = [];
1634 idx = 2;
1635 _a.label = 1;
1636 case 1:
1637 if (!(idx < process.argv.length)) return [3 /*break*/, 4];
1638 servers.push(new Server({
1639 vimruntime: process.argv[idx],
1640 }));
1641 return [4 /*yield*/, servers[servers.length - 1].build()];
1642 case 2:
1643 _a.sent();
1644 _a.label = 3;
1645 case 3:
1646 idx++;
1647 return [3 /*break*/, 1];
1648 case 4:
1649 server = servers.reduce(function (pre, next) {
1650 // merge functions
1651 next.vimBuiltinFunctionItems.forEach(function (item) {
1652 var label = item.label;
1653 if (!pre.vimBuiltFunctionDocuments[label]) {
1654 pre.vimBuiltinFunctionItems.push(item);
1655 pre.vimBuiltFunctionDocuments[label] = next.vimBuiltFunctionDocuments[label];
1656 }
1657 });
1658 // merge commands
1659 next.vimCommandItems.forEach(function (item) {
1660 var label = item.label;
1661 if (!pre.vimCommandDocuments[label]) {
1662 pre.vimCommandItems.push(item);
1663 pre.vimCommandDocuments[label] = next.vimCommandDocuments[label];
1664 }
1665 });
1666 // merge options
1667 next.vimOptionItems.forEach(function (item) {
1668 var label = item.label;
1669 if (!pre.vimOptionDocuments[label]) {
1670 pre.vimOptionItems.push(item);
1671 pre.vimOptionDocuments[label] = next.vimOptionDocuments[label];
1672 }
1673 });
1674 // merge variables
1675 next.vimPredefinedVariablesItems.forEach(function (item) {
1676 var label = item.label;
1677 if (!pre.vimPredefinedVariableDocuments[label]) {
1678 pre.vimPredefinedVariablesItems.push(item);
1679 pre.vimPredefinedVariableDocuments[label] = next.vimPredefinedVariableDocuments[label];
1680 }
1681 });
1682 // merge features
1683 next.vimFeatureItems.forEach(function (item) {
1684 var label = item.label;
1685 if (!pre.vimFeatureDocuments[label]) {
1686 pre.vimFeatureItems.push(item);
1687 pre.vimFeatureDocuments[label] = next.vimFeatureDocuments[label];
1688 }
1689 });
1690 // merge expand key words
1691 next.vimExpandKeywordItems.forEach(function (item) {
1692 var label = item.label;
1693 if (!pre.expandKeywordDocuments[label]) {
1694 pre.vimExpandKeywordItems.push(item);
1695 pre.expandKeywordDocuments[label] = next.expandKeywordDocuments[label];
1696 }
1697 });
1698 // merge autocmd
1699 next.vimAutocmdItems.forEach(function (item) {
1700 var label = item.label;
1701 if (!pre.vimAutocmdItems.some(function (n) { return n.label === label; })) {
1702 pre.vimAutocmdItems.push(item);
1703 }
1704 });
1705 // merge signature help
1706 pre.vimBuiltFunctionSignatureHelp = __assign(__assign({}, next.vimBuiltFunctionSignatureHelp), pre.vimBuiltFunctionSignatureHelp);
1707 return pre;
1708 });
1709 server.serialize();
1710 return [2 /*return*/];
1711 }
1712 });
1713 });
1714}
1715main();
1716
1717
1718/***/ }),
1719
1720/***/ 73:
1721/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1722
1723"use strict";
1724
1725Object.defineProperty(exports, "__esModule", ({ value: true }));
1726var constant_1 = __webpack_require__(64);
1727var conf;
1728exports.default = {
1729 init: function (config) {
1730 conf = config;
1731 },
1732 changeByKey: function (key, value) {
1733 if (conf) {
1734 conf[key] = value;
1735 }
1736 },
1737 get isNeovim() {
1738 return conf && conf.isNeovim || false;
1739 },
1740 get iskeyword() {
1741 return conf && conf.iskeyword || "";
1742 },
1743 get vimruntime() {
1744 return conf && conf.vimruntime || "";
1745 },
1746 get runtimepath() {
1747 return conf && conf.runtimepath || [];
1748 },
1749 get diagnostic() {
1750 return conf && conf.diagnostic || {
1751 enable: true,
1752 };
1753 },
1754 get snippetSupport() {
1755 return conf && conf.snippetSupport || false;
1756 },
1757 get suggest() {
1758 return conf && conf.suggest || {
1759 fromRuntimepath: false,
1760 fromVimruntime: true,
1761 };
1762 },
1763 get indexes() {
1764 var defaults = {
1765 runtimepath: true,
1766 gap: 100,
1767 count: 1,
1768 projectRootPatterns: constant_1.projectRootPatterns,
1769 };
1770 if (!conf || !conf.indexes) {
1771 return defaults;
1772 }
1773 if (conf.indexes.gap !== undefined) {
1774 defaults.gap = conf.indexes.gap;
1775 }
1776 if (conf.indexes.count !== undefined) {
1777 defaults.count = conf.indexes.count;
1778 }
1779 if (conf.indexes.projectRootPatterns !== undefined
1780 && Array.isArray(conf.indexes.projectRootPatterns)
1781 && conf.indexes.projectRootPatterns.length) {
1782 defaults.projectRootPatterns = conf.indexes.projectRootPatterns;
1783 }
1784 return defaults;
1785 },
1786 get capabilities() {
1787 return conf && conf.capabilities;
1788 }
1789};
1790
1791
1792/***/ }),
1793
1794/***/ 13:
1795/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1796
1797"use strict";
1798
1799/* --------------------------------------------------------------------------------------------
1800 * Copyright (c) Microsoft Corporation. All rights reserved.
1801 * Licensed under the MIT License. See License.txt in the project root for license information.
1802 * ------------------------------------------------------------------------------------------ */
1803/// <reference path="../../typings/thenable.d.ts" />
1804Object.defineProperty(exports, "__esModule", ({ value: true }));
1805exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.Trace = exports.ProgressType = exports.createMessageConnection = exports.NullLogger = exports.ConnectionOptions = exports.ConnectionStrategy = exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = exports.CancellationToken = exports.CancellationTokenSource = exports.Emitter = exports.Event = exports.Disposable = exports.ParameterStructures = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.ErrorCodes = exports.ResponseError = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType0 = exports.RequestType = exports.RAL = void 0;
1806exports.CancellationStrategy = void 0;
1807const messages_1 = __webpack_require__(14);
1808Object.defineProperty(exports, "RequestType", ({ enumerable: true, get: function () { return messages_1.RequestType; } }));
1809Object.defineProperty(exports, "RequestType0", ({ enumerable: true, get: function () { return messages_1.RequestType0; } }));
1810Object.defineProperty(exports, "RequestType1", ({ enumerable: true, get: function () { return messages_1.RequestType1; } }));
1811Object.defineProperty(exports, "RequestType2", ({ enumerable: true, get: function () { return messages_1.RequestType2; } }));
1812Object.defineProperty(exports, "RequestType3", ({ enumerable: true, get: function () { return messages_1.RequestType3; } }));
1813Object.defineProperty(exports, "RequestType4", ({ enumerable: true, get: function () { return messages_1.RequestType4; } }));
1814Object.defineProperty(exports, "RequestType5", ({ enumerable: true, get: function () { return messages_1.RequestType5; } }));
1815Object.defineProperty(exports, "RequestType6", ({ enumerable: true, get: function () { return messages_1.RequestType6; } }));
1816Object.defineProperty(exports, "RequestType7", ({ enumerable: true, get: function () { return messages_1.RequestType7; } }));
1817Object.defineProperty(exports, "RequestType8", ({ enumerable: true, get: function () { return messages_1.RequestType8; } }));
1818Object.defineProperty(exports, "RequestType9", ({ enumerable: true, get: function () { return messages_1.RequestType9; } }));
1819Object.defineProperty(exports, "ResponseError", ({ enumerable: true, get: function () { return messages_1.ResponseError; } }));
1820Object.defineProperty(exports, "ErrorCodes", ({ enumerable: true, get: function () { return messages_1.ErrorCodes; } }));
1821Object.defineProperty(exports, "NotificationType", ({ enumerable: true, get: function () { return messages_1.NotificationType; } }));
1822Object.defineProperty(exports, "NotificationType0", ({ enumerable: true, get: function () { return messages_1.NotificationType0; } }));
1823Object.defineProperty(exports, "NotificationType1", ({ enumerable: true, get: function () { return messages_1.NotificationType1; } }));
1824Object.defineProperty(exports, "NotificationType2", ({ enumerable: true, get: function () { return messages_1.NotificationType2; } }));
1825Object.defineProperty(exports, "NotificationType3", ({ enumerable: true, get: function () { return messages_1.NotificationType3; } }));
1826Object.defineProperty(exports, "NotificationType4", ({ enumerable: true, get: function () { return messages_1.NotificationType4; } }));
1827Object.defineProperty(exports, "NotificationType5", ({ enumerable: true, get: function () { return messages_1.NotificationType5; } }));
1828Object.defineProperty(exports, "NotificationType6", ({ enumerable: true, get: function () { return messages_1.NotificationType6; } }));
1829Object.defineProperty(exports, "NotificationType7", ({ enumerable: true, get: function () { return messages_1.NotificationType7; } }));
1830Object.defineProperty(exports, "NotificationType8", ({ enumerable: true, get: function () { return messages_1.NotificationType8; } }));
1831Object.defineProperty(exports, "NotificationType9", ({ enumerable: true, get: function () { return messages_1.NotificationType9; } }));
1832Object.defineProperty(exports, "ParameterStructures", ({ enumerable: true, get: function () { return messages_1.ParameterStructures; } }));
1833const disposable_1 = __webpack_require__(11);
1834Object.defineProperty(exports, "Disposable", ({ enumerable: true, get: function () { return disposable_1.Disposable; } }));
1835const events_1 = __webpack_require__(16);
1836Object.defineProperty(exports, "Event", ({ enumerable: true, get: function () { return events_1.Event; } }));
1837Object.defineProperty(exports, "Emitter", ({ enumerable: true, get: function () { return events_1.Emitter; } }));
1838const cancellation_1 = __webpack_require__(17);
1839Object.defineProperty(exports, "CancellationTokenSource", ({ enumerable: true, get: function () { return cancellation_1.CancellationTokenSource; } }));
1840Object.defineProperty(exports, "CancellationToken", ({ enumerable: true, get: function () { return cancellation_1.CancellationToken; } }));
1841const messageReader_1 = __webpack_require__(18);
1842Object.defineProperty(exports, "MessageReader", ({ enumerable: true, get: function () { return messageReader_1.MessageReader; } }));
1843Object.defineProperty(exports, "AbstractMessageReader", ({ enumerable: true, get: function () { return messageReader_1.AbstractMessageReader; } }));
1844Object.defineProperty(exports, "ReadableStreamMessageReader", ({ enumerable: true, get: function () { return messageReader_1.ReadableStreamMessageReader; } }));
1845const messageWriter_1 = __webpack_require__(19);
1846Object.defineProperty(exports, "MessageWriter", ({ enumerable: true, get: function () { return messageWriter_1.MessageWriter; } }));
1847Object.defineProperty(exports, "AbstractMessageWriter", ({ enumerable: true, get: function () { return messageWriter_1.AbstractMessageWriter; } }));
1848Object.defineProperty(exports, "WriteableStreamMessageWriter", ({ enumerable: true, get: function () { return messageWriter_1.WriteableStreamMessageWriter; } }));
1849const connection_1 = __webpack_require__(21);
1850Object.defineProperty(exports, "ConnectionStrategy", ({ enumerable: true, get: function () { return connection_1.ConnectionStrategy; } }));
1851Object.defineProperty(exports, "ConnectionOptions", ({ enumerable: true, get: function () { return connection_1.ConnectionOptions; } }));
1852Object.defineProperty(exports, "NullLogger", ({ enumerable: true, get: function () { return connection_1.NullLogger; } }));
1853Object.defineProperty(exports, "createMessageConnection", ({ enumerable: true, get: function () { return connection_1.createMessageConnection; } }));
1854Object.defineProperty(exports, "ProgressType", ({ enumerable: true, get: function () { return connection_1.ProgressType; } }));
1855Object.defineProperty(exports, "Trace", ({ enumerable: true, get: function () { return connection_1.Trace; } }));
1856Object.defineProperty(exports, "TraceFormat", ({ enumerable: true, get: function () { return connection_1.TraceFormat; } }));
1857Object.defineProperty(exports, "SetTraceNotification", ({ enumerable: true, get: function () { return connection_1.SetTraceNotification; } }));
1858Object.defineProperty(exports, "LogTraceNotification", ({ enumerable: true, get: function () { return connection_1.LogTraceNotification; } }));
1859Object.defineProperty(exports, "ConnectionErrors", ({ enumerable: true, get: function () { return connection_1.ConnectionErrors; } }));
1860Object.defineProperty(exports, "ConnectionError", ({ enumerable: true, get: function () { return connection_1.ConnectionError; } }));
1861Object.defineProperty(exports, "CancellationReceiverStrategy", ({ enumerable: true, get: function () { return connection_1.CancellationReceiverStrategy; } }));
1862Object.defineProperty(exports, "CancellationSenderStrategy", ({ enumerable: true, get: function () { return connection_1.CancellationSenderStrategy; } }));
1863Object.defineProperty(exports, "CancellationStrategy", ({ enumerable: true, get: function () { return connection_1.CancellationStrategy; } }));
1864const ral_1 = __webpack_require__(9);
1865exports.RAL = ral_1.default;
1866//# sourceMappingURL=api.js.map
1867
1868/***/ }),
1869
1870/***/ 17:
1871/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1872
1873"use strict";
1874
1875/*---------------------------------------------------------------------------------------------
1876 * Copyright (c) Microsoft Corporation. All rights reserved.
1877 * Licensed under the MIT License. See License.txt in the project root for license information.
1878 *--------------------------------------------------------------------------------------------*/
1879Object.defineProperty(exports, "__esModule", ({ value: true }));
1880exports.CancellationTokenSource = exports.CancellationToken = void 0;
1881const ral_1 = __webpack_require__(9);
1882const Is = __webpack_require__(15);
1883const events_1 = __webpack_require__(16);
1884var CancellationToken;
1885(function (CancellationToken) {
1886 CancellationToken.None = Object.freeze({
1887 isCancellationRequested: false,
1888 onCancellationRequested: events_1.Event.None
1889 });
1890 CancellationToken.Cancelled = Object.freeze({
1891 isCancellationRequested: true,
1892 onCancellationRequested: events_1.Event.None
1893 });
1894 function is(value) {
1895 const candidate = value;
1896 return candidate && (candidate === CancellationToken.None
1897 || candidate === CancellationToken.Cancelled
1898 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
1899 }
1900 CancellationToken.is = is;
1901})(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
1902const shortcutEvent = Object.freeze(function (callback, context) {
1903 const handle = ral_1.default().timer.setTimeout(callback.bind(context), 0);
1904 return { dispose() { ral_1.default().timer.clearTimeout(handle); } };
1905});
1906class MutableToken {
1907 constructor() {
1908 this._isCancelled = false;
1909 }
1910 cancel() {
1911 if (!this._isCancelled) {
1912 this._isCancelled = true;
1913 if (this._emitter) {
1914 this._emitter.fire(undefined);
1915 this.dispose();
1916 }
1917 }
1918 }
1919 get isCancellationRequested() {
1920 return this._isCancelled;
1921 }
1922 get onCancellationRequested() {
1923 if (this._isCancelled) {
1924 return shortcutEvent;
1925 }
1926 if (!this._emitter) {
1927 this._emitter = new events_1.Emitter();
1928 }
1929 return this._emitter.event;
1930 }
1931 dispose() {
1932 if (this._emitter) {
1933 this._emitter.dispose();
1934 this._emitter = undefined;
1935 }
1936 }
1937}
1938class CancellationTokenSource {
1939 get token() {
1940 if (!this._token) {
1941 // be lazy and create the token only when
1942 // actually needed
1943 this._token = new MutableToken();
1944 }
1945 return this._token;
1946 }
1947 cancel() {
1948 if (!this._token) {
1949 // save an object by returning the default
1950 // cancelled token when cancellation happens
1951 // before someone asks for the token
1952 this._token = CancellationToken.Cancelled;
1953 }
1954 else {
1955 this._token.cancel();
1956 }
1957 }
1958 dispose() {
1959 if (!this._token) {
1960 // ensure to initialize with an empty token if we had none
1961 this._token = CancellationToken.None;
1962 }
1963 else if (this._token instanceof MutableToken) {
1964 // actually dispose
1965 this._token.dispose();
1966 }
1967 }
1968}
1969exports.CancellationTokenSource = CancellationTokenSource;
1970//# sourceMappingURL=cancellation.js.map
1971
1972/***/ }),
1973
1974/***/ 21:
1975/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1976
1977"use strict";
1978
1979/* --------------------------------------------------------------------------------------------
1980 * Copyright (c) Microsoft Corporation. All rights reserved.
1981 * Licensed under the MIT License. See License.txt in the project root for license information.
1982 * ------------------------------------------------------------------------------------------ */
1983Object.defineProperty(exports, "__esModule", ({ value: true }));
1984exports.createMessageConnection = exports.ConnectionOptions = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.ConnectionStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.Trace = exports.NullLogger = exports.ProgressType = void 0;
1985const ral_1 = __webpack_require__(9);
1986const Is = __webpack_require__(15);
1987const messages_1 = __webpack_require__(14);
1988const linkedMap_1 = __webpack_require__(22);
1989const events_1 = __webpack_require__(16);
1990const cancellation_1 = __webpack_require__(17);
1991var CancelNotification;
1992(function (CancelNotification) {
1993 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
1994})(CancelNotification || (CancelNotification = {}));
1995var ProgressNotification;
1996(function (ProgressNotification) {
1997 ProgressNotification.type = new messages_1.NotificationType('$/progress');
1998})(ProgressNotification || (ProgressNotification = {}));
1999class ProgressType {
2000 constructor() {
2001 }
2002}
2003exports.ProgressType = ProgressType;
2004var StarRequestHandler;
2005(function (StarRequestHandler) {
2006 function is(value) {
2007 return Is.func(value);
2008 }
2009 StarRequestHandler.is = is;
2010})(StarRequestHandler || (StarRequestHandler = {}));
2011exports.NullLogger = Object.freeze({
2012 error: () => { },
2013 warn: () => { },
2014 info: () => { },
2015 log: () => { }
2016});
2017var Trace;
2018(function (Trace) {
2019 Trace[Trace["Off"] = 0] = "Off";
2020 Trace[Trace["Messages"] = 1] = "Messages";
2021 Trace[Trace["Verbose"] = 2] = "Verbose";
2022})(Trace = exports.Trace || (exports.Trace = {}));
2023(function (Trace) {
2024 function fromString(value) {
2025 if (!Is.string(value)) {
2026 return Trace.Off;
2027 }
2028 value = value.toLowerCase();
2029 switch (value) {
2030 case 'off':
2031 return Trace.Off;
2032 case 'messages':
2033 return Trace.Messages;
2034 case 'verbose':
2035 return Trace.Verbose;
2036 default:
2037 return Trace.Off;
2038 }
2039 }
2040 Trace.fromString = fromString;
2041 function toString(value) {
2042 switch (value) {
2043 case Trace.Off:
2044 return 'off';
2045 case Trace.Messages:
2046 return 'messages';
2047 case Trace.Verbose:
2048 return 'verbose';
2049 default:
2050 return 'off';
2051 }
2052 }
2053 Trace.toString = toString;
2054})(Trace = exports.Trace || (exports.Trace = {}));
2055var TraceFormat;
2056(function (TraceFormat) {
2057 TraceFormat["Text"] = "text";
2058 TraceFormat["JSON"] = "json";
2059})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
2060(function (TraceFormat) {
2061 function fromString(value) {
2062 value = value.toLowerCase();
2063 if (value === 'json') {
2064 return TraceFormat.JSON;
2065 }
2066 else {
2067 return TraceFormat.Text;
2068 }
2069 }
2070 TraceFormat.fromString = fromString;
2071})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
2072var SetTraceNotification;
2073(function (SetTraceNotification) {
2074 SetTraceNotification.type = new messages_1.NotificationType('$/setTrace');
2075})(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
2076var LogTraceNotification;
2077(function (LogTraceNotification) {
2078 LogTraceNotification.type = new messages_1.NotificationType('$/logTrace');
2079})(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
2080var ConnectionErrors;
2081(function (ConnectionErrors) {
2082 /**
2083 * The connection is closed.
2084 */
2085 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
2086 /**
2087 * The connection got disposed.
2088 */
2089 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
2090 /**
2091 * The connection is already in listening mode.
2092 */
2093 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
2094})(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
2095class ConnectionError extends Error {
2096 constructor(code, message) {
2097 super(message);
2098 this.code = code;
2099 Object.setPrototypeOf(this, ConnectionError.prototype);
2100 }
2101}
2102exports.ConnectionError = ConnectionError;
2103var ConnectionStrategy;
2104(function (ConnectionStrategy) {
2105 function is(value) {
2106 const candidate = value;
2107 return candidate && Is.func(candidate.cancelUndispatched);
2108 }
2109 ConnectionStrategy.is = is;
2110})(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
2111var CancellationReceiverStrategy;
2112(function (CancellationReceiverStrategy) {
2113 CancellationReceiverStrategy.Message = Object.freeze({
2114 createCancellationTokenSource(_) {
2115 return new cancellation_1.CancellationTokenSource();
2116 }
2117 });
2118 function is(value) {
2119 const candidate = value;
2120 return candidate && Is.func(candidate.createCancellationTokenSource);
2121 }
2122 CancellationReceiverStrategy.is = is;
2123})(CancellationReceiverStrategy = exports.CancellationReceiverStrategy || (exports.CancellationReceiverStrategy = {}));
2124var CancellationSenderStrategy;
2125(function (CancellationSenderStrategy) {
2126 CancellationSenderStrategy.Message = Object.freeze({
2127 sendCancellation(conn, id) {
2128 conn.sendNotification(CancelNotification.type, { id });
2129 },
2130 cleanup(_) { }
2131 });
2132 function is(value) {
2133 const candidate = value;
2134 return candidate && Is.func(candidate.sendCancellation) && Is.func(candidate.cleanup);
2135 }
2136 CancellationSenderStrategy.is = is;
2137})(CancellationSenderStrategy = exports.CancellationSenderStrategy || (exports.CancellationSenderStrategy = {}));
2138var CancellationStrategy;
2139(function (CancellationStrategy) {
2140 CancellationStrategy.Message = Object.freeze({
2141 receiver: CancellationReceiverStrategy.Message,
2142 sender: CancellationSenderStrategy.Message
2143 });
2144 function is(value) {
2145 const candidate = value;
2146 return candidate && CancellationReceiverStrategy.is(candidate.receiver) && CancellationSenderStrategy.is(candidate.sender);
2147 }
2148 CancellationStrategy.is = is;
2149})(CancellationStrategy = exports.CancellationStrategy || (exports.CancellationStrategy = {}));
2150var ConnectionOptions;
2151(function (ConnectionOptions) {
2152 function is(value) {
2153 const candidate = value;
2154 return candidate && (CancellationStrategy.is(candidate.cancellationStrategy) || ConnectionStrategy.is(candidate.connectionStrategy));
2155 }
2156 ConnectionOptions.is = is;
2157})(ConnectionOptions = exports.ConnectionOptions || (exports.ConnectionOptions = {}));
2158var ConnectionState;
2159(function (ConnectionState) {
2160 ConnectionState[ConnectionState["New"] = 1] = "New";
2161 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
2162 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
2163 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
2164})(ConnectionState || (ConnectionState = {}));
2165function createMessageConnection(messageReader, messageWriter, _logger, options) {
2166 const logger = _logger !== undefined ? _logger : exports.NullLogger;
2167 let sequenceNumber = 0;
2168 let notificationSquenceNumber = 0;
2169 let unknownResponseSquenceNumber = 0;
2170 const version = '2.0';
2171 let starRequestHandler = undefined;
2172 const requestHandlers = Object.create(null);
2173 let starNotificationHandler = undefined;
2174 const notificationHandlers = Object.create(null);
2175 const progressHandlers = new Map();
2176 let timer;
2177 let messageQueue = new linkedMap_1.LinkedMap();
2178 let responsePromises = Object.create(null);
2179 let requestTokens = Object.create(null);
2180 let trace = Trace.Off;
2181 let traceFormat = TraceFormat.Text;
2182 let tracer;
2183 let state = ConnectionState.New;
2184 const errorEmitter = new events_1.Emitter();
2185 const closeEmitter = new events_1.Emitter();
2186 const unhandledNotificationEmitter = new events_1.Emitter();
2187 const unhandledProgressEmitter = new events_1.Emitter();
2188 const disposeEmitter = new events_1.Emitter();
2189 const cancellationStrategy = (options && options.cancellationStrategy) ? options.cancellationStrategy : CancellationStrategy.Message;
2190 function createRequestQueueKey(id) {
2191 if (id === null) {
2192 throw new Error(`Can't send requests with id null since the response can't be correlated.`);
2193 }
2194 return 'req-' + id.toString();
2195 }
2196 function createResponseQueueKey(id) {
2197 if (id === null) {
2198 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
2199 }
2200 else {
2201 return 'res-' + id.toString();
2202 }
2203 }
2204 function createNotificationQueueKey() {
2205 return 'not-' + (++notificationSquenceNumber).toString();
2206 }
2207 function addMessageToQueue(queue, message) {
2208 if (messages_1.isRequestMessage(message)) {
2209 queue.set(createRequestQueueKey(message.id), message);
2210 }
2211 else if (messages_1.isResponseMessage(message)) {
2212 queue.set(createResponseQueueKey(message.id), message);
2213 }
2214 else {
2215 queue.set(createNotificationQueueKey(), message);
2216 }
2217 }
2218 function cancelUndispatched(_message) {
2219 return undefined;
2220 }
2221 function isListening() {
2222 return state === ConnectionState.Listening;
2223 }
2224 function isClosed() {
2225 return state === ConnectionState.Closed;
2226 }
2227 function isDisposed() {
2228 return state === ConnectionState.Disposed;
2229 }
2230 function closeHandler() {
2231 if (state === ConnectionState.New || state === ConnectionState.Listening) {
2232 state = ConnectionState.Closed;
2233 closeEmitter.fire(undefined);
2234 }
2235 // If the connection is disposed don't sent close events.
2236 }
2237 function readErrorHandler(error) {
2238 errorEmitter.fire([error, undefined, undefined]);
2239 }
2240 function writeErrorHandler(data) {
2241 errorEmitter.fire(data);
2242 }
2243 messageReader.onClose(closeHandler);
2244 messageReader.onError(readErrorHandler);
2245 messageWriter.onClose(closeHandler);
2246 messageWriter.onError(writeErrorHandler);
2247 function triggerMessageQueue() {
2248 if (timer || messageQueue.size === 0) {
2249 return;
2250 }
2251 timer = ral_1.default().timer.setImmediate(() => {
2252 timer = undefined;
2253 processMessageQueue();
2254 });
2255 }
2256 function processMessageQueue() {
2257 if (messageQueue.size === 0) {
2258 return;
2259 }
2260 const message = messageQueue.shift();
2261 try {
2262 if (messages_1.isRequestMessage(message)) {
2263 handleRequest(message);
2264 }
2265 else if (messages_1.isNotificationMessage(message)) {
2266 handleNotification(message);
2267 }
2268 else if (messages_1.isResponseMessage(message)) {
2269 handleResponse(message);
2270 }
2271 else {
2272 handleInvalidMessage(message);
2273 }
2274 }
2275 finally {
2276 triggerMessageQueue();
2277 }
2278 }
2279 const callback = (message) => {
2280 try {
2281 // We have received a cancellation message. Check if the message is still in the queue
2282 // and cancel it if allowed to do so.
2283 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
2284 const key = createRequestQueueKey(message.params.id);
2285 const toCancel = messageQueue.get(key);
2286 if (messages_1.isRequestMessage(toCancel)) {
2287 const strategy = options === null || options === void 0 ? void 0 : options.connectionStrategy;
2288 const response = (strategy && strategy.cancelUndispatched) ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
2289 if (response && (response.error !== undefined || response.result !== undefined)) {
2290 messageQueue.delete(key);
2291 response.id = toCancel.id;
2292 traceSendingResponse(response, message.method, Date.now());
2293 messageWriter.write(response);
2294 return;
2295 }
2296 }
2297 }
2298 addMessageToQueue(messageQueue, message);
2299 }
2300 finally {
2301 triggerMessageQueue();
2302 }
2303 };
2304 function handleRequest(requestMessage) {
2305 if (isDisposed()) {
2306 // we return here silently since we fired an event when the
2307 // connection got disposed.
2308 return;
2309 }
2310 function reply(resultOrError, method, startTime) {
2311 const message = {
2312 jsonrpc: version,
2313 id: requestMessage.id
2314 };
2315 if (resultOrError instanceof messages_1.ResponseError) {
2316 message.error = resultOrError.toJson();
2317 }
2318 else {
2319 message.result = resultOrError === undefined ? null : resultOrError;
2320 }
2321 traceSendingResponse(message, method, startTime);
2322 messageWriter.write(message);
2323 }
2324 function replyError(error, method, startTime) {
2325 const message = {
2326 jsonrpc: version,
2327 id: requestMessage.id,
2328 error: error.toJson()
2329 };
2330 traceSendingResponse(message, method, startTime);
2331 messageWriter.write(message);
2332 }
2333 function replySuccess(result, method, startTime) {
2334 // The JSON RPC defines that a response must either have a result or an error
2335 // So we can't treat undefined as a valid response result.
2336 if (result === undefined) {
2337 result = null;
2338 }
2339 const message = {
2340 jsonrpc: version,
2341 id: requestMessage.id,
2342 result: result
2343 };
2344 traceSendingResponse(message, method, startTime);
2345 messageWriter.write(message);
2346 }
2347 traceReceivedRequest(requestMessage);
2348 const element = requestHandlers[requestMessage.method];
2349 let type;
2350 let requestHandler;
2351 if (element) {
2352 type = element.type;
2353 requestHandler = element.handler;
2354 }
2355 const startTime = Date.now();
2356 if (requestHandler || starRequestHandler) {
2357 const tokenKey = String(requestMessage.id);
2358 const cancellationSource = cancellationStrategy.receiver.createCancellationTokenSource(tokenKey);
2359 requestTokens[tokenKey] = cancellationSource;
2360 try {
2361 let handlerResult;
2362 if (requestHandler) {
2363 if (requestMessage.params === undefined) {
2364 if (type !== undefined && type.numberOfParams !== 0) {
2365 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines ${type.numberOfParams} params but recevied none.`), requestMessage.method, startTime);
2366 return;
2367 }
2368 handlerResult = requestHandler(cancellationSource.token);
2369 }
2370 else if (Array.isArray(requestMessage.params)) {
2371 if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byName) {
2372 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by name but received parameters by position`), requestMessage.method, startTime);
2373 return;
2374 }
2375 handlerResult = requestHandler(...requestMessage.params, cancellationSource.token);
2376 }
2377 else {
2378 if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
2379 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by position but received parameters by name`), requestMessage.method, startTime);
2380 return;
2381 }
2382 handlerResult = requestHandler(requestMessage.params, cancellationSource.token);
2383 }
2384 }
2385 else if (starRequestHandler) {
2386 handlerResult = starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
2387 }
2388 const promise = handlerResult;
2389 if (!handlerResult) {
2390 delete requestTokens[tokenKey];
2391 replySuccess(handlerResult, requestMessage.method, startTime);
2392 }
2393 else if (promise.then) {
2394 promise.then((resultOrError) => {
2395 delete requestTokens[tokenKey];
2396 reply(resultOrError, requestMessage.method, startTime);
2397 }, error => {
2398 delete requestTokens[tokenKey];
2399 if (error instanceof messages_1.ResponseError) {
2400 replyError(error, requestMessage.method, startTime);
2401 }
2402 else if (error && Is.string(error.message)) {
2403 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
2404 }
2405 else {
2406 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
2407 }
2408 });
2409 }
2410 else {
2411 delete requestTokens[tokenKey];
2412 reply(handlerResult, requestMessage.method, startTime);
2413 }
2414 }
2415 catch (error) {
2416 delete requestTokens[tokenKey];
2417 if (error instanceof messages_1.ResponseError) {
2418 reply(error, requestMessage.method, startTime);
2419 }
2420 else if (error && Is.string(error.message)) {
2421 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
2422 }
2423 else {
2424 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
2425 }
2426 }
2427 }
2428 else {
2429 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
2430 }
2431 }
2432 function handleResponse(responseMessage) {
2433 if (isDisposed()) {
2434 // See handle request.
2435 return;
2436 }
2437 if (responseMessage.id === null) {
2438 if (responseMessage.error) {
2439 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
2440 }
2441 else {
2442 logger.error(`Received response message without id. No further error information provided.`);
2443 }
2444 }
2445 else {
2446 const key = String(responseMessage.id);
2447 const responsePromise = responsePromises[key];
2448 traceReceivedResponse(responseMessage, responsePromise);
2449 if (responsePromise) {
2450 delete responsePromises[key];
2451 try {
2452 if (responseMessage.error) {
2453 const error = responseMessage.error;
2454 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
2455 }
2456 else if (responseMessage.result !== undefined) {
2457 responsePromise.resolve(responseMessage.result);
2458 }
2459 else {
2460 throw new Error('Should never happen.');
2461 }
2462 }
2463 catch (error) {
2464 if (error.message) {
2465 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
2466 }
2467 else {
2468 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
2469 }
2470 }
2471 }
2472 }
2473 }
2474 function handleNotification(message) {
2475 if (isDisposed()) {
2476 // See handle request.
2477 return;
2478 }
2479 let type = undefined;
2480 let notificationHandler;
2481 if (message.method === CancelNotification.type.method) {
2482 notificationHandler = (params) => {
2483 const id = params.id;
2484 const source = requestTokens[String(id)];
2485 if (source) {
2486 source.cancel();
2487 }
2488 };
2489 }
2490 else {
2491 const element = notificationHandlers[message.method];
2492 if (element) {
2493 notificationHandler = element.handler;
2494 type = element.type;
2495 }
2496 }
2497 if (notificationHandler || starNotificationHandler) {
2498 try {
2499 traceReceivedNotification(message);
2500 if (notificationHandler) {
2501 if (message.params === undefined) {
2502 if (type !== undefined) {
2503 if (type.numberOfParams !== 0 && type.parameterStructures !== messages_1.ParameterStructures.byName) {
2504 logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but recevied none.`);
2505 }
2506 }
2507 notificationHandler();
2508 }
2509 else if (Array.isArray(message.params)) {
2510 if (type !== undefined) {
2511 if (type.parameterStructures === messages_1.ParameterStructures.byName) {
2512 logger.error(`Notification ${message.method} defines parameters by name but received parameters by position`);
2513 }
2514 if (type.numberOfParams !== message.params.length) {
2515 logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but received ${message.params.length} argumennts`);
2516 }
2517 }
2518 notificationHandler(...message.params);
2519 }
2520 else {
2521 if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
2522 logger.error(`Notification ${message.method} defines parameters by position but received parameters by name`);
2523 }
2524 notificationHandler(message.params);
2525 }
2526 }
2527 else if (starNotificationHandler) {
2528 starNotificationHandler(message.method, message.params);
2529 }
2530 }
2531 catch (error) {
2532 if (error.message) {
2533 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
2534 }
2535 else {
2536 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
2537 }
2538 }
2539 }
2540 else {
2541 unhandledNotificationEmitter.fire(message);
2542 }
2543 }
2544 function handleInvalidMessage(message) {
2545 if (!message) {
2546 logger.error('Received empty message.');
2547 return;
2548 }
2549 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
2550 // Test whether we find an id to reject the promise
2551 const responseMessage = message;
2552 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
2553 const key = String(responseMessage.id);
2554 const responseHandler = responsePromises[key];
2555 if (responseHandler) {
2556 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
2557 }
2558 }
2559 }
2560 function traceSendingRequest(message) {
2561 if (trace === Trace.Off || !tracer) {
2562 return;
2563 }
2564 if (traceFormat === TraceFormat.Text) {
2565 let data = undefined;
2566 if (trace === Trace.Verbose && message.params) {
2567 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2568 }
2569 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
2570 }
2571 else {
2572 logLSPMessage('send-request', message);
2573 }
2574 }
2575 function traceSendingNotification(message) {
2576 if (trace === Trace.Off || !tracer) {
2577 return;
2578 }
2579 if (traceFormat === TraceFormat.Text) {
2580 let data = undefined;
2581 if (trace === Trace.Verbose) {
2582 if (message.params) {
2583 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2584 }
2585 else {
2586 data = 'No parameters provided.\n\n';
2587 }
2588 }
2589 tracer.log(`Sending notification '${message.method}'.`, data);
2590 }
2591 else {
2592 logLSPMessage('send-notification', message);
2593 }
2594 }
2595 function traceSendingResponse(message, method, startTime) {
2596 if (trace === Trace.Off || !tracer) {
2597 return;
2598 }
2599 if (traceFormat === TraceFormat.Text) {
2600 let data = undefined;
2601 if (trace === Trace.Verbose) {
2602 if (message.error && message.error.data) {
2603 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
2604 }
2605 else {
2606 if (message.result) {
2607 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
2608 }
2609 else if (message.error === undefined) {
2610 data = 'No result returned.\n\n';
2611 }
2612 }
2613 }
2614 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
2615 }
2616 else {
2617 logLSPMessage('send-response', message);
2618 }
2619 }
2620 function traceReceivedRequest(message) {
2621 if (trace === Trace.Off || !tracer) {
2622 return;
2623 }
2624 if (traceFormat === TraceFormat.Text) {
2625 let data = undefined;
2626 if (trace === Trace.Verbose && message.params) {
2627 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2628 }
2629 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
2630 }
2631 else {
2632 logLSPMessage('receive-request', message);
2633 }
2634 }
2635 function traceReceivedNotification(message) {
2636 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
2637 return;
2638 }
2639 if (traceFormat === TraceFormat.Text) {
2640 let data = undefined;
2641 if (trace === Trace.Verbose) {
2642 if (message.params) {
2643 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2644 }
2645 else {
2646 data = 'No parameters provided.\n\n';
2647 }
2648 }
2649 tracer.log(`Received notification '${message.method}'.`, data);
2650 }
2651 else {
2652 logLSPMessage('receive-notification', message);
2653 }
2654 }
2655 function traceReceivedResponse(message, responsePromise) {
2656 if (trace === Trace.Off || !tracer) {
2657 return;
2658 }
2659 if (traceFormat === TraceFormat.Text) {
2660 let data = undefined;
2661 if (trace === Trace.Verbose) {
2662 if (message.error && message.error.data) {
2663 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
2664 }
2665 else {
2666 if (message.result) {
2667 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
2668 }
2669 else if (message.error === undefined) {
2670 data = 'No result returned.\n\n';
2671 }
2672 }
2673 }
2674 if (responsePromise) {
2675 const error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
2676 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
2677 }
2678 else {
2679 tracer.log(`Received response ${message.id} without active response promise.`, data);
2680 }
2681 }
2682 else {
2683 logLSPMessage('receive-response', message);
2684 }
2685 }
2686 function logLSPMessage(type, message) {
2687 if (!tracer || trace === Trace.Off) {
2688 return;
2689 }
2690 const lspMessage = {
2691 isLSPMessage: true,
2692 type,
2693 message,
2694 timestamp: Date.now()
2695 };
2696 tracer.log(lspMessage);
2697 }
2698 function throwIfClosedOrDisposed() {
2699 if (isClosed()) {
2700 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
2701 }
2702 if (isDisposed()) {
2703 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
2704 }
2705 }
2706 function throwIfListening() {
2707 if (isListening()) {
2708 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
2709 }
2710 }
2711 function throwIfNotListening() {
2712 if (!isListening()) {
2713 throw new Error('Call listen() first.');
2714 }
2715 }
2716 function undefinedToNull(param) {
2717 if (param === undefined) {
2718 return null;
2719 }
2720 else {
2721 return param;
2722 }
2723 }
2724 function nullToUndefined(param) {
2725 if (param === null) {
2726 return undefined;
2727 }
2728 else {
2729 return param;
2730 }
2731 }
2732 function isNamedParam(param) {
2733 return param !== undefined && param !== null && !Array.isArray(param) && typeof param === 'object';
2734 }
2735 function computeSingleParam(parameterStructures, param) {
2736 switch (parameterStructures) {
2737 case messages_1.ParameterStructures.auto:
2738 if (isNamedParam(param)) {
2739 return nullToUndefined(param);
2740 }
2741 else {
2742 return [undefinedToNull(param)];
2743 }
2744 break;
2745 case messages_1.ParameterStructures.byName:
2746 if (!isNamedParam(param)) {
2747 throw new Error(`Recevied parameters by name but param is not an object literal.`);
2748 }
2749 return nullToUndefined(param);
2750 case messages_1.ParameterStructures.byPosition:
2751 return [undefinedToNull(param)];
2752 default:
2753 throw new Error(`Unknown parameter structure ${parameterStructures.toString()}`);
2754 }
2755 }
2756 function computeMessageParams(type, params) {
2757 let result;
2758 const numberOfParams = type.numberOfParams;
2759 switch (numberOfParams) {
2760 case 0:
2761 result = undefined;
2762 break;
2763 case 1:
2764 result = computeSingleParam(type.parameterStructures, params[0]);
2765 break;
2766 default:
2767 result = [];
2768 for (let i = 0; i < params.length && i < numberOfParams; i++) {
2769 result.push(undefinedToNull(params[i]));
2770 }
2771 if (params.length < numberOfParams) {
2772 for (let i = params.length; i < numberOfParams; i++) {
2773 result.push(null);
2774 }
2775 }
2776 break;
2777 }
2778 return result;
2779 }
2780 const connection = {
2781 sendNotification: (type, ...args) => {
2782 throwIfClosedOrDisposed();
2783 let method;
2784 let messageParams;
2785 if (Is.string(type)) {
2786 method = type;
2787 const first = args[0];
2788 let paramStart = 0;
2789 let parameterStructures = messages_1.ParameterStructures.auto;
2790 if (messages_1.ParameterStructures.is(first)) {
2791 paramStart = 1;
2792 parameterStructures = first;
2793 }
2794 let paramEnd = args.length;
2795 const numberOfParams = paramEnd - paramStart;
2796 switch (numberOfParams) {
2797 case 0:
2798 messageParams = undefined;
2799 break;
2800 case 1:
2801 messageParams = computeSingleParam(parameterStructures, args[paramStart]);
2802 break;
2803 default:
2804 if (parameterStructures === messages_1.ParameterStructures.byName) {
2805 throw new Error(`Recevied ${numberOfParams} parameters for 'by Name' notification parameter structure.`);
2806 }
2807 messageParams = args.slice(paramStart, paramEnd).map(value => undefinedToNull(value));
2808 break;
2809 }
2810 }
2811 else {
2812 const params = args;
2813 method = type.method;
2814 messageParams = computeMessageParams(type, params);
2815 }
2816 const notificationMessage = {
2817 jsonrpc: version,
2818 method: method,
2819 params: messageParams
2820 };
2821 traceSendingNotification(notificationMessage);
2822 messageWriter.write(notificationMessage);
2823 },
2824 onNotification: (type, handler) => {
2825 throwIfClosedOrDisposed();
2826 let method;
2827 if (Is.func(type)) {
2828 starNotificationHandler = type;
2829 }
2830 else if (handler) {
2831 if (Is.string(type)) {
2832 method = type;
2833 notificationHandlers[type] = { type: undefined, handler };
2834 }
2835 else {
2836 method = type.method;
2837 notificationHandlers[type.method] = { type, handler };
2838 }
2839 }
2840 return {
2841 dispose: () => {
2842 if (method !== undefined) {
2843 delete notificationHandlers[method];
2844 }
2845 else {
2846 starNotificationHandler = undefined;
2847 }
2848 }
2849 };
2850 },
2851 onProgress: (_type, token, handler) => {
2852 if (progressHandlers.has(token)) {
2853 throw new Error(`Progress handler for token ${token} already registered`);
2854 }
2855 progressHandlers.set(token, handler);
2856 return {
2857 dispose: () => {
2858 progressHandlers.delete(token);
2859 }
2860 };
2861 },
2862 sendProgress: (_type, token, value) => {
2863 connection.sendNotification(ProgressNotification.type, { token, value });
2864 },
2865 onUnhandledProgress: unhandledProgressEmitter.event,
2866 sendRequest: (type, ...args) => {
2867 throwIfClosedOrDisposed();
2868 throwIfNotListening();
2869 let method;
2870 let messageParams;
2871 let token = undefined;
2872 if (Is.string(type)) {
2873 method = type;
2874 const first = args[0];
2875 const last = args[args.length - 1];
2876 let paramStart = 0;
2877 let parameterStructures = messages_1.ParameterStructures.auto;
2878 if (messages_1.ParameterStructures.is(first)) {
2879 paramStart = 1;
2880 parameterStructures = first;
2881 }
2882 let paramEnd = args.length;
2883 if (cancellation_1.CancellationToken.is(last)) {
2884 paramEnd = paramEnd - 1;
2885 token = last;
2886 }
2887 const numberOfParams = paramEnd - paramStart;
2888 switch (numberOfParams) {
2889 case 0:
2890 messageParams = undefined;
2891 break;
2892 case 1:
2893 messageParams = computeSingleParam(parameterStructures, args[paramStart]);
2894 break;
2895 default:
2896 if (parameterStructures === messages_1.ParameterStructures.byName) {
2897 throw new Error(`Recevied ${numberOfParams} parameters for 'by Name' request parameter structure.`);
2898 }
2899 messageParams = args.slice(paramStart, paramEnd).map(value => undefinedToNull(value));
2900 break;
2901 }
2902 }
2903 else {
2904 const params = args;
2905 method = type.method;
2906 messageParams = computeMessageParams(type, params);
2907 const numberOfParams = type.numberOfParams;
2908 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
2909 }
2910 const id = sequenceNumber++;
2911 let disposable;
2912 if (token) {
2913 disposable = token.onCancellationRequested(() => {
2914 cancellationStrategy.sender.sendCancellation(connection, id);
2915 });
2916 }
2917 const result = new Promise((resolve, reject) => {
2918 const requestMessage = {
2919 jsonrpc: version,
2920 id: id,
2921 method: method,
2922 params: messageParams
2923 };
2924 const resolveWithCleanup = (r) => {
2925 resolve(r);
2926 cancellationStrategy.sender.cleanup(id);
2927 disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
2928 };
2929 const rejectWithCleanup = (r) => {
2930 reject(r);
2931 cancellationStrategy.sender.cleanup(id);
2932 disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
2933 };
2934 let responsePromise = { method: method, timerStart: Date.now(), resolve: resolveWithCleanup, reject: rejectWithCleanup };
2935 traceSendingRequest(requestMessage);
2936 try {
2937 messageWriter.write(requestMessage);
2938 }
2939 catch (e) {
2940 // Writing the message failed. So we need to reject the promise.
2941 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
2942 responsePromise = null;
2943 }
2944 if (responsePromise) {
2945 responsePromises[String(id)] = responsePromise;
2946 }
2947 });
2948 return result;
2949 },
2950 onRequest: (type, handler) => {
2951 throwIfClosedOrDisposed();
2952 let method = null;
2953 if (StarRequestHandler.is(type)) {
2954 method = undefined;
2955 starRequestHandler = type;
2956 }
2957 else if (Is.string(type)) {
2958 method = null;
2959 if (handler !== undefined) {
2960 method = type;
2961 requestHandlers[type] = { handler: handler, type: undefined };
2962 }
2963 }
2964 else {
2965 if (handler !== undefined) {
2966 method = type.method;
2967 requestHandlers[type.method] = { type, handler };
2968 }
2969 }
2970 return {
2971 dispose: () => {
2972 if (method === null) {
2973 return;
2974 }
2975 if (method !== undefined) {
2976 delete requestHandlers[method];
2977 }
2978 else {
2979 starRequestHandler = undefined;
2980 }
2981 }
2982 };
2983 },
2984 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
2985 let _sendNotification = false;
2986 let _traceFormat = TraceFormat.Text;
2987 if (sendNotificationOrTraceOptions !== undefined) {
2988 if (Is.boolean(sendNotificationOrTraceOptions)) {
2989 _sendNotification = sendNotificationOrTraceOptions;
2990 }
2991 else {
2992 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
2993 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
2994 }
2995 }
2996 trace = _value;
2997 traceFormat = _traceFormat;
2998 if (trace === Trace.Off) {
2999 tracer = undefined;
3000 }
3001 else {
3002 tracer = _tracer;
3003 }
3004 if (_sendNotification && !isClosed() && !isDisposed()) {
3005 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
3006 }
3007 },
3008 onError: errorEmitter.event,
3009 onClose: closeEmitter.event,
3010 onUnhandledNotification: unhandledNotificationEmitter.event,
3011 onDispose: disposeEmitter.event,
3012 end: () => {
3013 messageWriter.end();
3014 },
3015 dispose: () => {
3016 if (isDisposed()) {
3017 return;
3018 }
3019 state = ConnectionState.Disposed;
3020 disposeEmitter.fire(undefined);
3021 const error = new Error('Connection got disposed.');
3022 Object.keys(responsePromises).forEach((key) => {
3023 responsePromises[key].reject(error);
3024 });
3025 responsePromises = Object.create(null);
3026 requestTokens = Object.create(null);
3027 messageQueue = new linkedMap_1.LinkedMap();
3028 // Test for backwards compatibility
3029 if (Is.func(messageWriter.dispose)) {
3030 messageWriter.dispose();
3031 }
3032 if (Is.func(messageReader.dispose)) {
3033 messageReader.dispose();
3034 }
3035 },
3036 listen: () => {
3037 throwIfClosedOrDisposed();
3038 throwIfListening();
3039 state = ConnectionState.Listening;
3040 messageReader.listen(callback);
3041 },
3042 inspect: () => {
3043 // eslint-disable-next-line no-console
3044 ral_1.default().console.log('inspect');
3045 }
3046 };
3047 connection.onNotification(LogTraceNotification.type, (params) => {
3048 if (trace === Trace.Off || !tracer) {
3049 return;
3050 }
3051 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
3052 });
3053 connection.onNotification(ProgressNotification.type, (params) => {
3054 const handler = progressHandlers.get(params.token);
3055 if (handler) {
3056 handler(params.value);
3057 }
3058 else {
3059 unhandledProgressEmitter.fire(params);
3060 }
3061 });
3062 return connection;
3063}
3064exports.createMessageConnection = createMessageConnection;
3065//# sourceMappingURL=connection.js.map
3066
3067/***/ }),
3068
3069/***/ 11:
3070/***/ ((__unused_webpack_module, exports) => {
3071
3072"use strict";
3073
3074/*---------------------------------------------------------------------------------------------
3075 * Copyright (c) Microsoft Corporation. All rights reserved.
3076 * Licensed under the MIT License. See License.txt in the project root for license information.
3077 *--------------------------------------------------------------------------------------------*/
3078Object.defineProperty(exports, "__esModule", ({ value: true }));
3079exports.Disposable = void 0;
3080var Disposable;
3081(function (Disposable) {
3082 function create(func) {
3083 return {
3084 dispose: func
3085 };
3086 }
3087 Disposable.create = create;
3088})(Disposable = exports.Disposable || (exports.Disposable = {}));
3089//# sourceMappingURL=disposable.js.map
3090
3091/***/ }),
3092
3093/***/ 16:
3094/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3095
3096"use strict";
3097
3098/* --------------------------------------------------------------------------------------------
3099 * Copyright (c) Microsoft Corporation. All rights reserved.
3100 * Licensed under the MIT License. See License.txt in the project root for license information.
3101 * ------------------------------------------------------------------------------------------ */
3102Object.defineProperty(exports, "__esModule", ({ value: true }));
3103exports.Emitter = exports.Event = void 0;
3104const ral_1 = __webpack_require__(9);
3105var Event;
3106(function (Event) {
3107 const _disposable = { dispose() { } };
3108 Event.None = function () { return _disposable; };
3109})(Event = exports.Event || (exports.Event = {}));
3110class CallbackList {
3111 add(callback, context = null, bucket) {
3112 if (!this._callbacks) {
3113 this._callbacks = [];
3114 this._contexts = [];
3115 }
3116 this._callbacks.push(callback);
3117 this._contexts.push(context);
3118 if (Array.isArray(bucket)) {
3119 bucket.push({ dispose: () => this.remove(callback, context) });
3120 }
3121 }
3122 remove(callback, context = null) {
3123 if (!this._callbacks) {
3124 return;
3125 }
3126 let foundCallbackWithDifferentContext = false;
3127 for (let i = 0, len = this._callbacks.length; i < len; i++) {
3128 if (this._callbacks[i] === callback) {
3129 if (this._contexts[i] === context) {
3130 // callback & context match => remove it
3131 this._callbacks.splice(i, 1);
3132 this._contexts.splice(i, 1);
3133 return;
3134 }
3135 else {
3136 foundCallbackWithDifferentContext = true;
3137 }
3138 }
3139 }
3140 if (foundCallbackWithDifferentContext) {
3141 throw new Error('When adding a listener with a context, you should remove it with the same context');
3142 }
3143 }
3144 invoke(...args) {
3145 if (!this._callbacks) {
3146 return [];
3147 }
3148 const ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
3149 for (let i = 0, len = callbacks.length; i < len; i++) {
3150 try {
3151 ret.push(callbacks[i].apply(contexts[i], args));
3152 }
3153 catch (e) {
3154 // eslint-disable-next-line no-console
3155 ral_1.default().console.error(e);
3156 }
3157 }
3158 return ret;
3159 }
3160 isEmpty() {
3161 return !this._callbacks || this._callbacks.length === 0;
3162 }
3163 dispose() {
3164 this._callbacks = undefined;
3165 this._contexts = undefined;
3166 }
3167}
3168class Emitter {
3169 constructor(_options) {
3170 this._options = _options;
3171 }
3172 /**
3173 * For the public to allow to subscribe
3174 * to events from this Emitter
3175 */
3176 get event() {
3177 if (!this._event) {
3178 this._event = (listener, thisArgs, disposables) => {
3179 if (!this._callbacks) {
3180 this._callbacks = new CallbackList();
3181 }
3182 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
3183 this._options.onFirstListenerAdd(this);
3184 }
3185 this._callbacks.add(listener, thisArgs);
3186 const result = {
3187 dispose: () => {
3188 if (!this._callbacks) {
3189 // disposable is disposed after emitter is disposed.
3190 return;
3191 }
3192 this._callbacks.remove(listener, thisArgs);
3193 result.dispose = Emitter._noop;
3194 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
3195 this._options.onLastListenerRemove(this);
3196 }
3197 }
3198 };
3199 if (Array.isArray(disposables)) {
3200 disposables.push(result);
3201 }
3202 return result;
3203 };
3204 }
3205 return this._event;
3206 }
3207 /**
3208 * To be kept private to fire an event to
3209 * subscribers
3210 */
3211 fire(event) {
3212 if (this._callbacks) {
3213 this._callbacks.invoke.call(this._callbacks, event);
3214 }
3215 }
3216 dispose() {
3217 if (this._callbacks) {
3218 this._callbacks.dispose();
3219 this._callbacks = undefined;
3220 }
3221 }
3222}
3223exports.Emitter = Emitter;
3224Emitter._noop = function () { };
3225//# sourceMappingURL=events.js.map
3226
3227/***/ }),
3228
3229/***/ 15:
3230/***/ ((__unused_webpack_module, exports) => {
3231
3232"use strict";
3233
3234/* --------------------------------------------------------------------------------------------
3235 * Copyright (c) Microsoft Corporation. All rights reserved.
3236 * Licensed under the MIT License. See License.txt in the project root for license information.
3237 * ------------------------------------------------------------------------------------------ */
3238Object.defineProperty(exports, "__esModule", ({ value: true }));
3239exports.stringArray = exports.array = exports.func = exports.error = exports.number = exports.string = exports.boolean = void 0;
3240function boolean(value) {
3241 return value === true || value === false;
3242}
3243exports.boolean = boolean;
3244function string(value) {
3245 return typeof value === 'string' || value instanceof String;
3246}
3247exports.string = string;
3248function number(value) {
3249 return typeof value === 'number' || value instanceof Number;
3250}
3251exports.number = number;
3252function error(value) {
3253 return value instanceof Error;
3254}
3255exports.error = error;
3256function func(value) {
3257 return typeof value === 'function';
3258}
3259exports.func = func;
3260function array(value) {
3261 return Array.isArray(value);
3262}
3263exports.array = array;
3264function stringArray(value) {
3265 return array(value) && value.every(elem => string(elem));
3266}
3267exports.stringArray = stringArray;
3268//# sourceMappingURL=is.js.map
3269
3270/***/ }),
3271
3272/***/ 22:
3273/***/ ((__unused_webpack_module, exports) => {
3274
3275"use strict";
3276
3277/*---------------------------------------------------------------------------------------------
3278 * Copyright (c) Microsoft Corporation. All rights reserved.
3279 * Licensed under the MIT License. See License.txt in the project root for license information.
3280 *--------------------------------------------------------------------------------------------*/
3281Object.defineProperty(exports, "__esModule", ({ value: true }));
3282exports.LRUCache = exports.LinkedMap = exports.Touch = void 0;
3283var Touch;
3284(function (Touch) {
3285 Touch.None = 0;
3286 Touch.First = 1;
3287 Touch.AsOld = Touch.First;
3288 Touch.Last = 2;
3289 Touch.AsNew = Touch.Last;
3290})(Touch = exports.Touch || (exports.Touch = {}));
3291class LinkedMap {
3292 constructor() {
3293 this[Symbol.toStringTag] = 'LinkedMap';
3294 this._map = new Map();
3295 this._head = undefined;
3296 this._tail = undefined;
3297 this._size = 0;
3298 this._state = 0;
3299 }
3300 clear() {
3301 this._map.clear();
3302 this._head = undefined;
3303 this._tail = undefined;
3304 this._size = 0;
3305 this._state++;
3306 }
3307 isEmpty() {
3308 return !this._head && !this._tail;
3309 }
3310 get size() {
3311 return this._size;
3312 }
3313 get first() {
3314 var _a;
3315 return (_a = this._head) === null || _a === void 0 ? void 0 : _a.value;
3316 }
3317 get last() {
3318 var _a;
3319 return (_a = this._tail) === null || _a === void 0 ? void 0 : _a.value;
3320 }
3321 has(key) {
3322 return this._map.has(key);
3323 }
3324 get(key, touch = Touch.None) {
3325 const item = this._map.get(key);
3326 if (!item) {
3327 return undefined;
3328 }
3329 if (touch !== Touch.None) {
3330 this.touch(item, touch);
3331 }
3332 return item.value;
3333 }
3334 set(key, value, touch = Touch.None) {
3335 let item = this._map.get(key);
3336 if (item) {
3337 item.value = value;
3338 if (touch !== Touch.None) {
3339 this.touch(item, touch);
3340 }
3341 }
3342 else {
3343 item = { key, value, next: undefined, previous: undefined };
3344 switch (touch) {
3345 case Touch.None:
3346 this.addItemLast(item);
3347 break;
3348 case Touch.First:
3349 this.addItemFirst(item);
3350 break;
3351 case Touch.Last:
3352 this.addItemLast(item);
3353 break;
3354 default:
3355 this.addItemLast(item);
3356 break;
3357 }
3358 this._map.set(key, item);
3359 this._size++;
3360 }
3361 return this;
3362 }
3363 delete(key) {
3364 return !!this.remove(key);
3365 }
3366 remove(key) {
3367 const item = this._map.get(key);
3368 if (!item) {
3369 return undefined;
3370 }
3371 this._map.delete(key);
3372 this.removeItem(item);
3373 this._size--;
3374 return item.value;
3375 }
3376 shift() {
3377 if (!this._head && !this._tail) {
3378 return undefined;
3379 }
3380 if (!this._head || !this._tail) {
3381 throw new Error('Invalid list');
3382 }
3383 const item = this._head;
3384 this._map.delete(item.key);
3385 this.removeItem(item);
3386 this._size--;
3387 return item.value;
3388 }
3389 forEach(callbackfn, thisArg) {
3390 const state = this._state;
3391 let current = this._head;
3392 while (current) {
3393 if (thisArg) {
3394 callbackfn.bind(thisArg)(current.value, current.key, this);
3395 }
3396 else {
3397 callbackfn(current.value, current.key, this);
3398 }
3399 if (this._state !== state) {
3400 throw new Error(`LinkedMap got modified during iteration.`);
3401 }
3402 current = current.next;
3403 }
3404 }
3405 keys() {
3406 const map = this;
3407 const state = this._state;
3408 let current = this._head;
3409 const iterator = {
3410 [Symbol.iterator]() {
3411 return iterator;
3412 },
3413 next() {
3414 if (map._state !== state) {
3415 throw new Error(`LinkedMap got modified during iteration.`);
3416 }
3417 if (current) {
3418 const result = { value: current.key, done: false };
3419 current = current.next;
3420 return result;
3421 }
3422 else {
3423 return { value: undefined, done: true };
3424 }
3425 }
3426 };
3427 return iterator;
3428 }
3429 values() {
3430 const map = this;
3431 const state = this._state;
3432 let current = this._head;
3433 const iterator = {
3434 [Symbol.iterator]() {
3435 return iterator;
3436 },
3437 next() {
3438 if (map._state !== state) {
3439 throw new Error(`LinkedMap got modified during iteration.`);
3440 }
3441 if (current) {
3442 const result = { value: current.value, done: false };
3443 current = current.next;
3444 return result;
3445 }
3446 else {
3447 return { value: undefined, done: true };
3448 }
3449 }
3450 };
3451 return iterator;
3452 }
3453 entries() {
3454 const map = this;
3455 const state = this._state;
3456 let current = this._head;
3457 const iterator = {
3458 [Symbol.iterator]() {
3459 return iterator;
3460 },
3461 next() {
3462 if (map._state !== state) {
3463 throw new Error(`LinkedMap got modified during iteration.`);
3464 }
3465 if (current) {
3466 const result = { value: [current.key, current.value], done: false };
3467 current = current.next;
3468 return result;
3469 }
3470 else {
3471 return { value: undefined, done: true };
3472 }
3473 }
3474 };
3475 return iterator;
3476 }
3477 [Symbol.iterator]() {
3478 return this.entries();
3479 }
3480 trimOld(newSize) {
3481 if (newSize >= this.size) {
3482 return;
3483 }
3484 if (newSize === 0) {
3485 this.clear();
3486 return;
3487 }
3488 let current = this._head;
3489 let currentSize = this.size;
3490 while (current && currentSize > newSize) {
3491 this._map.delete(current.key);
3492 current = current.next;
3493 currentSize--;
3494 }
3495 this._head = current;
3496 this._size = currentSize;
3497 if (current) {
3498 current.previous = undefined;
3499 }
3500 this._state++;
3501 }
3502 addItemFirst(item) {
3503 // First time Insert
3504 if (!this._head && !this._tail) {
3505 this._tail = item;
3506 }
3507 else if (!this._head) {
3508 throw new Error('Invalid list');
3509 }
3510 else {
3511 item.next = this._head;
3512 this._head.previous = item;
3513 }
3514 this._head = item;
3515 this._state++;
3516 }
3517 addItemLast(item) {
3518 // First time Insert
3519 if (!this._head && !this._tail) {
3520 this._head = item;
3521 }
3522 else if (!this._tail) {
3523 throw new Error('Invalid list');
3524 }
3525 else {
3526 item.previous = this._tail;
3527 this._tail.next = item;
3528 }
3529 this._tail = item;
3530 this._state++;
3531 }
3532 removeItem(item) {
3533 if (item === this._head && item === this._tail) {
3534 this._head = undefined;
3535 this._tail = undefined;
3536 }
3537 else if (item === this._head) {
3538 // This can only happend if size === 1 which is handle
3539 // by the case above.
3540 if (!item.next) {
3541 throw new Error('Invalid list');
3542 }
3543 item.next.previous = undefined;
3544 this._head = item.next;
3545 }
3546 else if (item === this._tail) {
3547 // This can only happend if size === 1 which is handle
3548 // by the case above.
3549 if (!item.previous) {
3550 throw new Error('Invalid list');
3551 }
3552 item.previous.next = undefined;
3553 this._tail = item.previous;
3554 }
3555 else {
3556 const next = item.next;
3557 const previous = item.previous;
3558 if (!next || !previous) {
3559 throw new Error('Invalid list');
3560 }
3561 next.previous = previous;
3562 previous.next = next;
3563 }
3564 item.next = undefined;
3565 item.previous = undefined;
3566 this._state++;
3567 }
3568 touch(item, touch) {
3569 if (!this._head || !this._tail) {
3570 throw new Error('Invalid list');
3571 }
3572 if ((touch !== Touch.First && touch !== Touch.Last)) {
3573 return;
3574 }
3575 if (touch === Touch.First) {
3576 if (item === this._head) {
3577 return;
3578 }
3579 const next = item.next;
3580 const previous = item.previous;
3581 // Unlink the item
3582 if (item === this._tail) {
3583 // previous must be defined since item was not head but is tail
3584 // So there are more than on item in the map
3585 previous.next = undefined;
3586 this._tail = previous;
3587 }
3588 else {
3589 // Both next and previous are not undefined since item was neither head nor tail.
3590 next.previous = previous;
3591 previous.next = next;
3592 }
3593 // Insert the node at head
3594 item.previous = undefined;
3595 item.next = this._head;
3596 this._head.previous = item;
3597 this._head = item;
3598 this._state++;
3599 }
3600 else if (touch === Touch.Last) {
3601 if (item === this._tail) {
3602 return;
3603 }
3604 const next = item.next;
3605 const previous = item.previous;
3606 // Unlink the item.
3607 if (item === this._head) {
3608 // next must be defined since item was not tail but is head
3609 // So there are more than on item in the map
3610 next.previous = undefined;
3611 this._head = next;
3612 }
3613 else {
3614 // Both next and previous are not undefined since item was neither head nor tail.
3615 next.previous = previous;
3616 previous.next = next;
3617 }
3618 item.next = undefined;
3619 item.previous = this._tail;
3620 this._tail.next = item;
3621 this._tail = item;
3622 this._state++;
3623 }
3624 }
3625 toJSON() {
3626 const data = [];
3627 this.forEach((value, key) => {
3628 data.push([key, value]);
3629 });
3630 return data;
3631 }
3632 fromJSON(data) {
3633 this.clear();
3634 for (const [key, value] of data) {
3635 this.set(key, value);
3636 }
3637 }
3638}
3639exports.LinkedMap = LinkedMap;
3640class LRUCache extends LinkedMap {
3641 constructor(limit, ratio = 1) {
3642 super();
3643 this._limit = limit;
3644 this._ratio = Math.min(Math.max(0, ratio), 1);
3645 }
3646 get limit() {
3647 return this._limit;
3648 }
3649 set limit(limit) {
3650 this._limit = limit;
3651 this.checkTrim();
3652 }
3653 get ratio() {
3654 return this._ratio;
3655 }
3656 set ratio(ratio) {
3657 this._ratio = Math.min(Math.max(0, ratio), 1);
3658 this.checkTrim();
3659 }
3660 get(key, touch = Touch.AsNew) {
3661 return super.get(key, touch);
3662 }
3663 peek(key) {
3664 return super.get(key, Touch.None);
3665 }
3666 set(key, value) {
3667 super.set(key, value, Touch.Last);
3668 this.checkTrim();
3669 return this;
3670 }
3671 checkTrim() {
3672 if (this.size > this._limit) {
3673 this.trimOld(Math.round(this._limit * this._ratio));
3674 }
3675 }
3676}
3677exports.LRUCache = LRUCache;
3678//# sourceMappingURL=linkedMap.js.map
3679
3680/***/ }),
3681
3682/***/ 12:
3683/***/ ((__unused_webpack_module, exports) => {
3684
3685"use strict";
3686
3687/*---------------------------------------------------------------------------------------------
3688 * Copyright (c) Microsoft Corporation. All rights reserved.
3689 * Licensed under the MIT License. See License.txt in the project root for license information.
3690 *--------------------------------------------------------------------------------------------*/
3691Object.defineProperty(exports, "__esModule", ({ value: true }));
3692exports.AbstractMessageBuffer = void 0;
3693const CR = 13;
3694const LF = 10;
3695const CRLF = '\r\n';
3696class AbstractMessageBuffer {
3697 constructor(encoding = 'utf-8') {
3698 this._encoding = encoding;
3699 this._chunks = [];
3700 this._totalLength = 0;
3701 }
3702 get encoding() {
3703 return this._encoding;
3704 }
3705 append(chunk) {
3706 const toAppend = typeof chunk === 'string' ? this.fromString(chunk, this._encoding) : chunk;
3707 this._chunks.push(toAppend);
3708 this._totalLength += toAppend.byteLength;
3709 }
3710 tryReadHeaders() {
3711 if (this._chunks.length === 0) {
3712 return undefined;
3713 }
3714 let state = 0;
3715 let chunkIndex = 0;
3716 let offset = 0;
3717 let chunkBytesRead = 0;
3718 row: while (chunkIndex < this._chunks.length) {
3719 const chunk = this._chunks[chunkIndex];
3720 offset = 0;
3721 column: while (offset < chunk.length) {
3722 const value = chunk[offset];
3723 switch (value) {
3724 case CR:
3725 switch (state) {
3726 case 0:
3727 state = 1;
3728 break;
3729 case 2:
3730 state = 3;
3731 break;
3732 default:
3733 state = 0;
3734 }
3735 break;
3736 case LF:
3737 switch (state) {
3738 case 1:
3739 state = 2;
3740 break;
3741 case 3:
3742 state = 4;
3743 offset++;
3744 break row;
3745 default:
3746 state = 0;
3747 }
3748 break;
3749 default:
3750 state = 0;
3751 }
3752 offset++;
3753 }
3754 chunkBytesRead += chunk.byteLength;
3755 chunkIndex++;
3756 }
3757 if (state !== 4) {
3758 return undefined;
3759 }
3760 // The buffer contains the two CRLF at the end. So we will
3761 // have two empty lines after the split at the end as well.
3762 const buffer = this._read(chunkBytesRead + offset);
3763 const result = new Map();
3764 const headers = this.toString(buffer, 'ascii').split(CRLF);
3765 if (headers.length < 2) {
3766 return result;
3767 }
3768 for (let i = 0; i < headers.length - 2; i++) {
3769 const header = headers[i];
3770 const index = header.indexOf(':');
3771 if (index === -1) {
3772 throw new Error('Message header must separate key and value using :');
3773 }
3774 const key = header.substr(0, index);
3775 const value = header.substr(index + 1).trim();
3776 result.set(key, value);
3777 }
3778 return result;
3779 }
3780 tryReadBody(length) {
3781 if (this._totalLength < length) {
3782 return undefined;
3783 }
3784 return this._read(length);
3785 }
3786 get numberOfBytes() {
3787 return this._totalLength;
3788 }
3789 _read(byteCount) {
3790 if (byteCount === 0) {
3791 return this.emptyBuffer();
3792 }
3793 if (byteCount > this._totalLength) {
3794 throw new Error(`Cannot read so many bytes!`);
3795 }
3796 if (this._chunks[0].byteLength === byteCount) {
3797 // super fast path, precisely first chunk must be returned
3798 const chunk = this._chunks[0];
3799 this._chunks.shift();
3800 this._totalLength -= byteCount;
3801 return this.asNative(chunk);
3802 }
3803 if (this._chunks[0].byteLength > byteCount) {
3804 // fast path, the reading is entirely within the first chunk
3805 const chunk = this._chunks[0];
3806 const result = this.asNative(chunk, byteCount);
3807 this._chunks[0] = chunk.slice(byteCount);
3808 this._totalLength -= byteCount;
3809 return result;
3810 }
3811 const result = this.allocNative(byteCount);
3812 let resultOffset = 0;
3813 let chunkIndex = 0;
3814 while (byteCount > 0) {
3815 const chunk = this._chunks[chunkIndex];
3816 if (chunk.byteLength > byteCount) {
3817 // this chunk will survive
3818 const chunkPart = chunk.slice(0, byteCount);
3819 result.set(chunkPart, resultOffset);
3820 resultOffset += byteCount;
3821 this._chunks[chunkIndex] = chunk.slice(byteCount);
3822 this._totalLength -= byteCount;
3823 byteCount -= byteCount;
3824 }
3825 else {
3826 // this chunk will be entirely read
3827 result.set(chunk, resultOffset);
3828 resultOffset += chunk.byteLength;
3829 this._chunks.shift();
3830 this._totalLength -= chunk.byteLength;
3831 byteCount -= chunk.byteLength;
3832 }
3833 }
3834 return result;
3835 }
3836}
3837exports.AbstractMessageBuffer = AbstractMessageBuffer;
3838//# sourceMappingURL=messageBuffer.js.map
3839
3840/***/ }),
3841
3842/***/ 18:
3843/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3844
3845"use strict";
3846
3847/* --------------------------------------------------------------------------------------------
3848 * Copyright (c) Microsoft Corporation. All rights reserved.
3849 * Licensed under the MIT License. See License.txt in the project root for license information.
3850 * ------------------------------------------------------------------------------------------ */
3851Object.defineProperty(exports, "__esModule", ({ value: true }));
3852exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = void 0;
3853const ral_1 = __webpack_require__(9);
3854const Is = __webpack_require__(15);
3855const events_1 = __webpack_require__(16);
3856var MessageReader;
3857(function (MessageReader) {
3858 function is(value) {
3859 let candidate = value;
3860 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
3861 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
3862 }
3863 MessageReader.is = is;
3864})(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
3865class AbstractMessageReader {
3866 constructor() {
3867 this.errorEmitter = new events_1.Emitter();
3868 this.closeEmitter = new events_1.Emitter();
3869 this.partialMessageEmitter = new events_1.Emitter();
3870 }
3871 dispose() {
3872 this.errorEmitter.dispose();
3873 this.closeEmitter.dispose();
3874 }
3875 get onError() {
3876 return this.errorEmitter.event;
3877 }
3878 fireError(error) {
3879 this.errorEmitter.fire(this.asError(error));
3880 }
3881 get onClose() {
3882 return this.closeEmitter.event;
3883 }
3884 fireClose() {
3885 this.closeEmitter.fire(undefined);
3886 }
3887 get onPartialMessage() {
3888 return this.partialMessageEmitter.event;
3889 }
3890 firePartialMessage(info) {
3891 this.partialMessageEmitter.fire(info);
3892 }
3893 asError(error) {
3894 if (error instanceof Error) {
3895 return error;
3896 }
3897 else {
3898 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
3899 }
3900 }
3901}
3902exports.AbstractMessageReader = AbstractMessageReader;
3903var ResolvedMessageReaderOptions;
3904(function (ResolvedMessageReaderOptions) {
3905 function fromOptions(options) {
3906 var _a;
3907 let charset;
3908 let result;
3909 let contentDecoder;
3910 const contentDecoders = new Map();
3911 let contentTypeDecoder;
3912 const contentTypeDecoders = new Map();
3913 if (options === undefined || typeof options === 'string') {
3914 charset = options !== null && options !== void 0 ? options : 'utf-8';
3915 }
3916 else {
3917 charset = (_a = options.charset) !== null && _a !== void 0 ? _a : 'utf-8';
3918 if (options.contentDecoder !== undefined) {
3919 contentDecoder = options.contentDecoder;
3920 contentDecoders.set(contentDecoder.name, contentDecoder);
3921 }
3922 if (options.contentDecoders !== undefined) {
3923 for (const decoder of options.contentDecoders) {
3924 contentDecoders.set(decoder.name, decoder);
3925 }
3926 }
3927 if (options.contentTypeDecoder !== undefined) {
3928 contentTypeDecoder = options.contentTypeDecoder;
3929 contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
3930 }
3931 if (options.contentTypeDecoders !== undefined) {
3932 for (const decoder of options.contentTypeDecoders) {
3933 contentTypeDecoders.set(decoder.name, decoder);
3934 }
3935 }
3936 }
3937 if (contentTypeDecoder === undefined) {
3938 contentTypeDecoder = ral_1.default().applicationJson.decoder;
3939 contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
3940 }
3941 return { charset, contentDecoder, contentDecoders, contentTypeDecoder, contentTypeDecoders };
3942 }
3943 ResolvedMessageReaderOptions.fromOptions = fromOptions;
3944})(ResolvedMessageReaderOptions || (ResolvedMessageReaderOptions = {}));
3945class ReadableStreamMessageReader extends AbstractMessageReader {
3946 constructor(readable, options) {
3947 super();
3948 this.readable = readable;
3949 this.options = ResolvedMessageReaderOptions.fromOptions(options);
3950 this.buffer = ral_1.default().messageBuffer.create(this.options.charset);
3951 this._partialMessageTimeout = 10000;
3952 this.nextMessageLength = -1;
3953 this.messageToken = 0;
3954 }
3955 set partialMessageTimeout(timeout) {
3956 this._partialMessageTimeout = timeout;
3957 }
3958 get partialMessageTimeout() {
3959 return this._partialMessageTimeout;
3960 }
3961 listen(callback) {
3962 this.nextMessageLength = -1;
3963 this.messageToken = 0;
3964 this.partialMessageTimer = undefined;
3965 this.callback = callback;
3966 const result = this.readable.onData((data) => {
3967 this.onData(data);
3968 });
3969 this.readable.onError((error) => this.fireError(error));
3970 this.readable.onClose(() => this.fireClose());
3971 return result;
3972 }
3973 onData(data) {
3974 this.buffer.append(data);
3975 while (true) {
3976 if (this.nextMessageLength === -1) {
3977 const headers = this.buffer.tryReadHeaders();
3978 if (!headers) {
3979 return;
3980 }
3981 const contentLength = headers.get('Content-Length');
3982 if (!contentLength) {
3983 throw new Error('Header must provide a Content-Length property.');
3984 }
3985 const length = parseInt(contentLength);
3986 if (isNaN(length)) {
3987 throw new Error('Content-Length value must be a number.');
3988 }
3989 this.nextMessageLength = length;
3990 }
3991 const body = this.buffer.tryReadBody(this.nextMessageLength);
3992 if (body === undefined) {
3993 /** We haven't received the full message yet. */
3994 this.setPartialMessageTimer();
3995 return;
3996 }
3997 this.clearPartialMessageTimer();
3998 this.nextMessageLength = -1;
3999 let p;
4000 if (this.options.contentDecoder !== undefined) {
4001 p = this.options.contentDecoder.decode(body);
4002 }
4003 else {
4004 p = Promise.resolve(body);
4005 }
4006 p.then((value) => {
4007 this.options.contentTypeDecoder.decode(value, this.options).then((msg) => {
4008 this.callback(msg);
4009 }, (error) => {
4010 this.fireError(error);
4011 });
4012 }, (error) => {
4013 this.fireError(error);
4014 });
4015 }
4016 }
4017 clearPartialMessageTimer() {
4018 if (this.partialMessageTimer) {
4019 ral_1.default().timer.clearTimeout(this.partialMessageTimer);
4020 this.partialMessageTimer = undefined;
4021 }
4022 }
4023 setPartialMessageTimer() {
4024 this.clearPartialMessageTimer();
4025 if (this._partialMessageTimeout <= 0) {
4026 return;
4027 }
4028 this.partialMessageTimer = ral_1.default().timer.setTimeout((token, timeout) => {
4029 this.partialMessageTimer = undefined;
4030 if (token === this.messageToken) {
4031 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
4032 this.setPartialMessageTimer();
4033 }
4034 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
4035 }
4036}
4037exports.ReadableStreamMessageReader = ReadableStreamMessageReader;
4038//# sourceMappingURL=messageReader.js.map
4039
4040/***/ }),
4041
4042/***/ 19:
4043/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4044
4045"use strict";
4046
4047/* --------------------------------------------------------------------------------------------
4048 * Copyright (c) Microsoft Corporation. All rights reserved.
4049 * Licensed under the MIT License. See License.txt in the project root for license information.
4050 * ------------------------------------------------------------------------------------------ */
4051Object.defineProperty(exports, "__esModule", ({ value: true }));
4052exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = void 0;
4053const ral_1 = __webpack_require__(9);
4054const Is = __webpack_require__(15);
4055const semaphore_1 = __webpack_require__(20);
4056const events_1 = __webpack_require__(16);
4057const ContentLength = 'Content-Length: ';
4058const CRLF = '\r\n';
4059var MessageWriter;
4060(function (MessageWriter) {
4061 function is(value) {
4062 let candidate = value;
4063 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
4064 Is.func(candidate.onError) && Is.func(candidate.write);
4065 }
4066 MessageWriter.is = is;
4067})(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
4068class AbstractMessageWriter {
4069 constructor() {
4070 this.errorEmitter = new events_1.Emitter();
4071 this.closeEmitter = new events_1.Emitter();
4072 }
4073 dispose() {
4074 this.errorEmitter.dispose();
4075 this.closeEmitter.dispose();
4076 }
4077 get onError() {
4078 return this.errorEmitter.event;
4079 }
4080 fireError(error, message, count) {
4081 this.errorEmitter.fire([this.asError(error), message, count]);
4082 }
4083 get onClose() {
4084 return this.closeEmitter.event;
4085 }
4086 fireClose() {
4087 this.closeEmitter.fire(undefined);
4088 }
4089 asError(error) {
4090 if (error instanceof Error) {
4091 return error;
4092 }
4093 else {
4094 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
4095 }
4096 }
4097}
4098exports.AbstractMessageWriter = AbstractMessageWriter;
4099var ResolvedMessageWriterOptions;
4100(function (ResolvedMessageWriterOptions) {
4101 function fromOptions(options) {
4102 var _a, _b;
4103 if (options === undefined || typeof options === 'string') {
4104 return { charset: options !== null && options !== void 0 ? options : 'utf-8', contentTypeEncoder: ral_1.default().applicationJson.encoder };
4105 }
4106 else {
4107 return { charset: (_a = options.charset) !== null && _a !== void 0 ? _a : 'utf-8', contentEncoder: options.contentEncoder, contentTypeEncoder: (_b = options.contentTypeEncoder) !== null && _b !== void 0 ? _b : ral_1.default().applicationJson.encoder };
4108 }
4109 }
4110 ResolvedMessageWriterOptions.fromOptions = fromOptions;
4111})(ResolvedMessageWriterOptions || (ResolvedMessageWriterOptions = {}));
4112class WriteableStreamMessageWriter extends AbstractMessageWriter {
4113 constructor(writable, options) {
4114 super();
4115 this.writable = writable;
4116 this.options = ResolvedMessageWriterOptions.fromOptions(options);
4117 this.errorCount = 0;
4118 this.writeSemaphore = new semaphore_1.Semaphore(1);
4119 this.writable.onError((error) => this.fireError(error));
4120 this.writable.onClose(() => this.fireClose());
4121 }
4122 async write(msg) {
4123 return this.writeSemaphore.lock(async () => {
4124 const payload = this.options.contentTypeEncoder.encode(msg, this.options).then((buffer) => {
4125 if (this.options.contentEncoder !== undefined) {
4126 return this.options.contentEncoder.encode(buffer);
4127 }
4128 else {
4129 return buffer;
4130 }
4131 });
4132 return payload.then((buffer) => {
4133 const headers = [];
4134 headers.push(ContentLength, buffer.byteLength.toString(), CRLF);
4135 headers.push(CRLF);
4136 return this.doWrite(msg, headers, buffer);
4137 }, (error) => {
4138 this.fireError(error);
4139 throw error;
4140 });
4141 });
4142 }
4143 async doWrite(msg, headers, data) {
4144 try {
4145 await this.writable.write(headers.join(''), 'ascii');
4146 return this.writable.write(data);
4147 }
4148 catch (error) {
4149 this.handleError(error, msg);
4150 return Promise.reject(error);
4151 }
4152 }
4153 handleError(error, msg) {
4154 this.errorCount++;
4155 this.fireError(error, msg, this.errorCount);
4156 }
4157 end() {
4158 this.writable.end();
4159 }
4160}
4161exports.WriteableStreamMessageWriter = WriteableStreamMessageWriter;
4162//# sourceMappingURL=messageWriter.js.map
4163
4164/***/ }),
4165
4166/***/ 14:
4167/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4168
4169"use strict";
4170
4171/* --------------------------------------------------------------------------------------------
4172 * Copyright (c) Microsoft Corporation. All rights reserved.
4173 * Licensed under the MIT License. See License.txt in the project root for license information.
4174 * ------------------------------------------------------------------------------------------ */
4175Object.defineProperty(exports, "__esModule", ({ value: true }));
4176exports.isResponseMessage = exports.isNotificationMessage = exports.isRequestMessage = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
4177const is = __webpack_require__(15);
4178/**
4179 * Predefined error codes.
4180 */
4181var ErrorCodes;
4182(function (ErrorCodes) {
4183 // Defined by JSON RPC
4184 ErrorCodes.ParseError = -32700;
4185 ErrorCodes.InvalidRequest = -32600;
4186 ErrorCodes.MethodNotFound = -32601;
4187 ErrorCodes.InvalidParams = -32602;
4188 ErrorCodes.InternalError = -32603;
4189 /**
4190 * This is the start range of JSON RPC reserved error codes.
4191 * It doesn't denote a real error code. No application error codes should
4192 * be defined between the start and end range. For backwards
4193 * compatibility the `ServerNotInitialized` and the `UnknownErrorCode`
4194 * are left in the range.
4195 *
4196 * @since 3.16.0
4197 */
4198 ErrorCodes.jsonrpcReservedErrorRangeStart = -32099;
4199 /** @deprecated use jsonrpcReservedErrorRangeStart */
4200 ErrorCodes.serverErrorStart = ErrorCodes.jsonrpcReservedErrorRangeStart;
4201 ErrorCodes.MessageWriteError = -32099;
4202 ErrorCodes.MessageReadError = -32098;
4203 ErrorCodes.ServerNotInitialized = -32002;
4204 ErrorCodes.UnknownErrorCode = -32001;
4205 /**
4206 * This is the end range of JSON RPC reserved error codes.
4207 * It doesn't denote a real error code.
4208 *
4209 * @since 3.16.0
4210 */
4211 ErrorCodes.jsonrpcReservedErrorRangeEnd = -32000;
4212 /** @deprecated use jsonrpcReservedErrorRangeEnd */
4213 ErrorCodes.serverErrorEnd = ErrorCodes.jsonrpcReservedErrorRangeEnd;
4214})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
4215/**
4216 * An error object return in a response in case a request
4217 * has failed.
4218 */
4219class ResponseError extends Error {
4220 constructor(code, message, data) {
4221 super(message);
4222 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
4223 this.data = data;
4224 Object.setPrototypeOf(this, ResponseError.prototype);
4225 }
4226 toJson() {
4227 return {
4228 code: this.code,
4229 message: this.message,
4230 data: this.data,
4231 };
4232 }
4233}
4234exports.ResponseError = ResponseError;
4235class ParameterStructures {
4236 constructor(kind) {
4237 this.kind = kind;
4238 }
4239 static is(value) {
4240 return value === ParameterStructures.auto || value === ParameterStructures.byName || value === ParameterStructures.byPosition;
4241 }
4242 toString() {
4243 return this.kind;
4244 }
4245}
4246exports.ParameterStructures = ParameterStructures;
4247/**
4248 * The parameter structure is automatically inferred on the number of parameters
4249 * and the parameter type in case of a single param.
4250 */
4251ParameterStructures.auto = new ParameterStructures('auto');
4252/**
4253 * Forces `byPosition` parameter structure. This is useful if you have a single
4254 * parameter which has a literal type.
4255 */
4256ParameterStructures.byPosition = new ParameterStructures('byPosition');
4257/**
4258 * Forces `byName` parameter structure. This is only useful when having a single
4259 * parameter. The library will report errors if used with a different number of
4260 * parameters.
4261 */
4262ParameterStructures.byName = new ParameterStructures('byName');
4263/**
4264 * An abstract implementation of a MessageType.
4265 */
4266class AbstractMessageSignature {
4267 constructor(method, numberOfParams) {
4268 this.method = method;
4269 this.numberOfParams = numberOfParams;
4270 }
4271 get parameterStructures() {
4272 return ParameterStructures.auto;
4273 }
4274}
4275exports.AbstractMessageSignature = AbstractMessageSignature;
4276/**
4277 * Classes to type request response pairs
4278 */
4279class RequestType0 extends AbstractMessageSignature {
4280 constructor(method) {
4281 super(method, 0);
4282 }
4283}
4284exports.RequestType0 = RequestType0;
4285class RequestType extends AbstractMessageSignature {
4286 constructor(method, _parameterStructures = ParameterStructures.auto) {
4287 super(method, 1);
4288 this._parameterStructures = _parameterStructures;
4289 }
4290 get parameterStructures() {
4291 return this._parameterStructures;
4292 }
4293}
4294exports.RequestType = RequestType;
4295class RequestType1 extends AbstractMessageSignature {
4296 constructor(method, _parameterStructures = ParameterStructures.auto) {
4297 super(method, 1);
4298 this._parameterStructures = _parameterStructures;
4299 }
4300 get parameterStructures() {
4301 return this._parameterStructures;
4302 }
4303}
4304exports.RequestType1 = RequestType1;
4305class RequestType2 extends AbstractMessageSignature {
4306 constructor(method) {
4307 super(method, 2);
4308 }
4309}
4310exports.RequestType2 = RequestType2;
4311class RequestType3 extends AbstractMessageSignature {
4312 constructor(method) {
4313 super(method, 3);
4314 }
4315}
4316exports.RequestType3 = RequestType3;
4317class RequestType4 extends AbstractMessageSignature {
4318 constructor(method) {
4319 super(method, 4);
4320 }
4321}
4322exports.RequestType4 = RequestType4;
4323class RequestType5 extends AbstractMessageSignature {
4324 constructor(method) {
4325 super(method, 5);
4326 }
4327}
4328exports.RequestType5 = RequestType5;
4329class RequestType6 extends AbstractMessageSignature {
4330 constructor(method) {
4331 super(method, 6);
4332 }
4333}
4334exports.RequestType6 = RequestType6;
4335class RequestType7 extends AbstractMessageSignature {
4336 constructor(method) {
4337 super(method, 7);
4338 }
4339}
4340exports.RequestType7 = RequestType7;
4341class RequestType8 extends AbstractMessageSignature {
4342 constructor(method) {
4343 super(method, 8);
4344 }
4345}
4346exports.RequestType8 = RequestType8;
4347class RequestType9 extends AbstractMessageSignature {
4348 constructor(method) {
4349 super(method, 9);
4350 }
4351}
4352exports.RequestType9 = RequestType9;
4353class NotificationType extends AbstractMessageSignature {
4354 constructor(method, _parameterStructures = ParameterStructures.auto) {
4355 super(method, 1);
4356 this._parameterStructures = _parameterStructures;
4357 }
4358 get parameterStructures() {
4359 return this._parameterStructures;
4360 }
4361}
4362exports.NotificationType = NotificationType;
4363class NotificationType0 extends AbstractMessageSignature {
4364 constructor(method) {
4365 super(method, 0);
4366 }
4367}
4368exports.NotificationType0 = NotificationType0;
4369class NotificationType1 extends AbstractMessageSignature {
4370 constructor(method, _parameterStructures = ParameterStructures.auto) {
4371 super(method, 1);
4372 this._parameterStructures = _parameterStructures;
4373 }
4374 get parameterStructures() {
4375 return this._parameterStructures;
4376 }
4377}
4378exports.NotificationType1 = NotificationType1;
4379class NotificationType2 extends AbstractMessageSignature {
4380 constructor(method) {
4381 super(method, 2);
4382 }
4383}
4384exports.NotificationType2 = NotificationType2;
4385class NotificationType3 extends AbstractMessageSignature {
4386 constructor(method) {
4387 super(method, 3);
4388 }
4389}
4390exports.NotificationType3 = NotificationType3;
4391class NotificationType4 extends AbstractMessageSignature {
4392 constructor(method) {
4393 super(method, 4);
4394 }
4395}
4396exports.NotificationType4 = NotificationType4;
4397class NotificationType5 extends AbstractMessageSignature {
4398 constructor(method) {
4399 super(method, 5);
4400 }
4401}
4402exports.NotificationType5 = NotificationType5;
4403class NotificationType6 extends AbstractMessageSignature {
4404 constructor(method) {
4405 super(method, 6);
4406 }
4407}
4408exports.NotificationType6 = NotificationType6;
4409class NotificationType7 extends AbstractMessageSignature {
4410 constructor(method) {
4411 super(method, 7);
4412 }
4413}
4414exports.NotificationType7 = NotificationType7;
4415class NotificationType8 extends AbstractMessageSignature {
4416 constructor(method) {
4417 super(method, 8);
4418 }
4419}
4420exports.NotificationType8 = NotificationType8;
4421class NotificationType9 extends AbstractMessageSignature {
4422 constructor(method) {
4423 super(method, 9);
4424 }
4425}
4426exports.NotificationType9 = NotificationType9;
4427/**
4428 * Tests if the given message is a request message
4429 */
4430function isRequestMessage(message) {
4431 const candidate = message;
4432 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
4433}
4434exports.isRequestMessage = isRequestMessage;
4435/**
4436 * Tests if the given message is a notification message
4437 */
4438function isNotificationMessage(message) {
4439 const candidate = message;
4440 return candidate && is.string(candidate.method) && message.id === void 0;
4441}
4442exports.isNotificationMessage = isNotificationMessage;
4443/**
4444 * Tests if the given message is a response message
4445 */
4446function isResponseMessage(message) {
4447 const candidate = message;
4448 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
4449}
4450exports.isResponseMessage = isResponseMessage;
4451//# sourceMappingURL=messages.js.map
4452
4453/***/ }),
4454
4455/***/ 9:
4456/***/ ((__unused_webpack_module, exports) => {
4457
4458"use strict";
4459
4460/* --------------------------------------------------------------------------------------------
4461 * Copyright (c) Microsoft Corporation. All rights reserved.
4462 * Licensed under the MIT License. See License.txt in the project root for license information.
4463 * ------------------------------------------------------------------------------------------ */
4464Object.defineProperty(exports, "__esModule", ({ value: true }));
4465let _ral;
4466function RAL() {
4467 if (_ral === undefined) {
4468 throw new Error(`No runtime abstraction layer installed`);
4469 }
4470 return _ral;
4471}
4472(function (RAL) {
4473 function install(ral) {
4474 if (ral === undefined) {
4475 throw new Error(`No runtime abstraction layer provided`);
4476 }
4477 _ral = ral;
4478 }
4479 RAL.install = install;
4480})(RAL || (RAL = {}));
4481exports.default = RAL;
4482//# sourceMappingURL=ral.js.map
4483
4484/***/ }),
4485
4486/***/ 20:
4487/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4488
4489"use strict";
4490
4491/* --------------------------------------------------------------------------------------------
4492 * Copyright (c) Microsoft Corporation. All rights reserved.
4493 * Licensed under the MIT License. See License.txt in the project root for license information.
4494 * ------------------------------------------------------------------------------------------ */
4495Object.defineProperty(exports, "__esModule", ({ value: true }));
4496exports.Semaphore = void 0;
4497const ral_1 = __webpack_require__(9);
4498class Semaphore {
4499 constructor(capacity = 1) {
4500 if (capacity <= 0) {
4501 throw new Error('Capacity must be greater than 0');
4502 }
4503 this._capacity = capacity;
4504 this._active = 0;
4505 this._waiting = [];
4506 }
4507 lock(thunk) {
4508 return new Promise((resolve, reject) => {
4509 this._waiting.push({ thunk, resolve, reject });
4510 this.runNext();
4511 });
4512 }
4513 get active() {
4514 return this._active;
4515 }
4516 runNext() {
4517 if (this._waiting.length === 0 || this._active === this._capacity) {
4518 return;
4519 }
4520 ral_1.default().timer.setImmediate(() => this.doRunNext());
4521 }
4522 doRunNext() {
4523 if (this._waiting.length === 0 || this._active === this._capacity) {
4524 return;
4525 }
4526 const next = this._waiting.shift();
4527 this._active++;
4528 if (this._active > this._capacity) {
4529 throw new Error(`To many thunks active`);
4530 }
4531 try {
4532 const result = next.thunk();
4533 if (result instanceof Promise) {
4534 result.then((value) => {
4535 this._active--;
4536 next.resolve(value);
4537 this.runNext();
4538 }, (err) => {
4539 this._active--;
4540 next.reject(err);
4541 this.runNext();
4542 });
4543 }
4544 else {
4545 this._active--;
4546 next.resolve(result);
4547 this.runNext();
4548 }
4549 }
4550 catch (err) {
4551 this._active--;
4552 next.reject(err);
4553 this.runNext();
4554 }
4555 }
4556}
4557exports.Semaphore = Semaphore;
4558//# sourceMappingURL=semaphore.js.map
4559
4560/***/ }),
4561
4562/***/ 7:
4563/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
4564
4565"use strict";
4566
4567var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4568 if (k2 === undefined) k2 = k;
4569 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4570}) : (function(o, m, k, k2) {
4571 if (k2 === undefined) k2 = k;
4572 o[k2] = m[k];
4573}));
4574var __exportStar = (this && this.__exportStar) || function(m, exports) {
4575 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4576};
4577Object.defineProperty(exports, "__esModule", ({ value: true }));
4578exports.createMessageConnection = exports.createServerSocketTransport = exports.createClientSocketTransport = exports.createServerPipeTransport = exports.createClientPipeTransport = exports.generateRandomPipeName = exports.StreamMessageWriter = exports.StreamMessageReader = exports.SocketMessageWriter = exports.SocketMessageReader = exports.IPCMessageWriter = exports.IPCMessageReader = void 0;
4579/* --------------------------------------------------------------------------------------------
4580 * Copyright (c) Microsoft Corporation. All rights reserved.
4581 * Licensed under the MIT License. See License.txt in the project root for license information.
4582 * ----------------------------------------------------------------------------------------- */
4583const ril_1 = __webpack_require__(8);
4584// Install the node runtime abstract.
4585ril_1.default.install();
4586const api_1 = __webpack_require__(13);
4587const path = __webpack_require__(23);
4588const os = __webpack_require__(24);
4589const crypto_1 = __webpack_require__(25);
4590const net_1 = __webpack_require__(26);
4591__exportStar(__webpack_require__(13), exports);
4592class IPCMessageReader extends api_1.AbstractMessageReader {
4593 constructor(process) {
4594 super();
4595 this.process = process;
4596 let eventEmitter = this.process;
4597 eventEmitter.on('error', (error) => this.fireError(error));
4598 eventEmitter.on('close', () => this.fireClose());
4599 }
4600 listen(callback) {
4601 this.process.on('message', callback);
4602 return api_1.Disposable.create(() => this.process.off('message', callback));
4603 }
4604}
4605exports.IPCMessageReader = IPCMessageReader;
4606class IPCMessageWriter extends api_1.AbstractMessageWriter {
4607 constructor(process) {
4608 super();
4609 this.process = process;
4610 this.errorCount = 0;
4611 let eventEmitter = this.process;
4612 eventEmitter.on('error', (error) => this.fireError(error));
4613 eventEmitter.on('close', () => this.fireClose);
4614 }
4615 write(msg) {
4616 try {
4617 if (typeof this.process.send === 'function') {
4618 this.process.send(msg, undefined, undefined, (error) => {
4619 if (error) {
4620 this.errorCount++;
4621 this.handleError(error, msg);
4622 }
4623 else {
4624 this.errorCount = 0;
4625 }
4626 });
4627 }
4628 return Promise.resolve();
4629 }
4630 catch (error) {
4631 this.handleError(error, msg);
4632 return Promise.reject(error);
4633 }
4634 }
4635 handleError(error, msg) {
4636 this.errorCount++;
4637 this.fireError(error, msg, this.errorCount);
4638 }
4639 end() {
4640 }
4641}
4642exports.IPCMessageWriter = IPCMessageWriter;
4643class SocketMessageReader extends api_1.ReadableStreamMessageReader {
4644 constructor(socket, encoding = 'utf-8') {
4645 super(ril_1.default().stream.asReadableStream(socket), encoding);
4646 }
4647}
4648exports.SocketMessageReader = SocketMessageReader;
4649class SocketMessageWriter extends api_1.WriteableStreamMessageWriter {
4650 constructor(socket, options) {
4651 super(ril_1.default().stream.asWritableStream(socket), options);
4652 this.socket = socket;
4653 }
4654 dispose() {
4655 super.dispose();
4656 this.socket.destroy();
4657 }
4658}
4659exports.SocketMessageWriter = SocketMessageWriter;
4660class StreamMessageReader extends api_1.ReadableStreamMessageReader {
4661 constructor(readble, encoding) {
4662 super(ril_1.default().stream.asReadableStream(readble), encoding);
4663 }
4664}
4665exports.StreamMessageReader = StreamMessageReader;
4666class StreamMessageWriter extends api_1.WriteableStreamMessageWriter {
4667 constructor(writable, options) {
4668 super(ril_1.default().stream.asWritableStream(writable), options);
4669 }
4670}
4671exports.StreamMessageWriter = StreamMessageWriter;
4672const XDG_RUNTIME_DIR = process.env['XDG_RUNTIME_DIR'];
4673const safeIpcPathLengths = new Map([
4674 ['linux', 107],
4675 ['darwin', 103]
4676]);
4677function generateRandomPipeName() {
4678 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
4679 if (process.platform === 'win32') {
4680 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
4681 }
4682 let result;
4683 if (XDG_RUNTIME_DIR) {
4684 result = path.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
4685 }
4686 else {
4687 result = path.join(os.tmpdir(), `vscode-${randomSuffix}.sock`);
4688 }
4689 const limit = safeIpcPathLengths.get(process.platform);
4690 if (limit !== undefined && result.length >= limit) {
4691 ril_1.default().console.warn(`WARNING: IPC handle "${result}" is longer than ${limit} characters.`);
4692 }
4693 return result;
4694}
4695exports.generateRandomPipeName = generateRandomPipeName;
4696function createClientPipeTransport(pipeName, encoding = 'utf-8') {
4697 let connectResolve;
4698 const connected = new Promise((resolve, _reject) => {
4699 connectResolve = resolve;
4700 });
4701 return new Promise((resolve, reject) => {
4702 let server = net_1.createServer((socket) => {
4703 server.close();
4704 connectResolve([
4705 new SocketMessageReader(socket, encoding),
4706 new SocketMessageWriter(socket, encoding)
4707 ]);
4708 });
4709 server.on('error', reject);
4710 server.listen(pipeName, () => {
4711 server.removeListener('error', reject);
4712 resolve({
4713 onConnected: () => { return connected; }
4714 });
4715 });
4716 });
4717}
4718exports.createClientPipeTransport = createClientPipeTransport;
4719function createServerPipeTransport(pipeName, encoding = 'utf-8') {
4720 const socket = net_1.createConnection(pipeName);
4721 return [
4722 new SocketMessageReader(socket, encoding),
4723 new SocketMessageWriter(socket, encoding)
4724 ];
4725}
4726exports.createServerPipeTransport = createServerPipeTransport;
4727function createClientSocketTransport(port, encoding = 'utf-8') {
4728 let connectResolve;
4729 const connected = new Promise((resolve, _reject) => {
4730 connectResolve = resolve;
4731 });
4732 return new Promise((resolve, reject) => {
4733 const server = net_1.createServer((socket) => {
4734 server.close();
4735 connectResolve([
4736 new SocketMessageReader(socket, encoding),
4737 new SocketMessageWriter(socket, encoding)
4738 ]);
4739 });
4740 server.on('error', reject);
4741 server.listen(port, '127.0.0.1', () => {
4742 server.removeListener('error', reject);
4743 resolve({
4744 onConnected: () => { return connected; }
4745 });
4746 });
4747 });
4748}
4749exports.createClientSocketTransport = createClientSocketTransport;
4750function createServerSocketTransport(port, encoding = 'utf-8') {
4751 const socket = net_1.createConnection(port, '127.0.0.1');
4752 return [
4753 new SocketMessageReader(socket, encoding),
4754 new SocketMessageWriter(socket, encoding)
4755 ];
4756}
4757exports.createServerSocketTransport = createServerSocketTransport;
4758function isReadableStream(value) {
4759 const candidate = value;
4760 return candidate.read !== undefined && candidate.addListener !== undefined;
4761}
4762function isWritableStream(value) {
4763 const candidate = value;
4764 return candidate.write !== undefined && candidate.addListener !== undefined;
4765}
4766function createMessageConnection(input, output, logger, options) {
4767 if (!logger) {
4768 logger = api_1.NullLogger;
4769 }
4770 const reader = isReadableStream(input) ? new StreamMessageReader(input) : input;
4771 const writer = isWritableStream(output) ? new StreamMessageWriter(output) : output;
4772 if (api_1.ConnectionStrategy.is(options)) {
4773 options = { connectionStrategy: options };
4774 }
4775 return api_1.createMessageConnection(reader, writer, logger, options);
4776}
4777exports.createMessageConnection = createMessageConnection;
4778//# sourceMappingURL=main.js.map
4779
4780/***/ }),
4781
4782/***/ 8:
4783/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4784
4785"use strict";
4786
4787/* --------------------------------------------------------------------------------------------
4788 * Copyright (c) Microsoft Corporation. All rights reserved.
4789 * Licensed under the MIT License. See License.txt in the project root for license information.
4790 * ------------------------------------------------------------------------------------------ */
4791Object.defineProperty(exports, "__esModule", ({ value: true }));
4792const ral_1 = __webpack_require__(9);
4793const util_1 = __webpack_require__(10);
4794const disposable_1 = __webpack_require__(11);
4795const messageBuffer_1 = __webpack_require__(12);
4796class MessageBuffer extends messageBuffer_1.AbstractMessageBuffer {
4797 constructor(encoding = 'utf-8') {
4798 super(encoding);
4799 }
4800 emptyBuffer() {
4801 return MessageBuffer.emptyBuffer;
4802 }
4803 fromString(value, encoding) {
4804 return Buffer.from(value, encoding);
4805 }
4806 toString(value, encoding) {
4807 if (value instanceof Buffer) {
4808 return value.toString(encoding);
4809 }
4810 else {
4811 return new util_1.TextDecoder(encoding).decode(value);
4812 }
4813 }
4814 asNative(buffer, length) {
4815 if (length === undefined) {
4816 return buffer instanceof Buffer ? buffer : Buffer.from(buffer);
4817 }
4818 else {
4819 return buffer instanceof Buffer ? buffer.slice(0, length) : Buffer.from(buffer, 0, length);
4820 }
4821 }
4822 allocNative(length) {
4823 return Buffer.allocUnsafe(length);
4824 }
4825}
4826MessageBuffer.emptyBuffer = Buffer.allocUnsafe(0);
4827class ReadableStreamWrapper {
4828 constructor(stream) {
4829 this.stream = stream;
4830 }
4831 onClose(listener) {
4832 this.stream.on('close', listener);
4833 return disposable_1.Disposable.create(() => this.stream.off('close', listener));
4834 }
4835 onError(listener) {
4836 this.stream.on('error', listener);
4837 return disposable_1.Disposable.create(() => this.stream.off('error', listener));
4838 }
4839 onEnd(listener) {
4840 this.stream.on('end', listener);
4841 return disposable_1.Disposable.create(() => this.stream.off('end', listener));
4842 }
4843 onData(listener) {
4844 this.stream.on('data', listener);
4845 return disposable_1.Disposable.create(() => this.stream.off('data', listener));
4846 }
4847}
4848class WritableStreamWrapper {
4849 constructor(stream) {
4850 this.stream = stream;
4851 }
4852 onClose(listener) {
4853 this.stream.on('close', listener);
4854 return disposable_1.Disposable.create(() => this.stream.off('close', listener));
4855 }
4856 onError(listener) {
4857 this.stream.on('error', listener);
4858 return disposable_1.Disposable.create(() => this.stream.off('error', listener));
4859 }
4860 onEnd(listener) {
4861 this.stream.on('end', listener);
4862 return disposable_1.Disposable.create(() => this.stream.off('end', listener));
4863 }
4864 write(data, encoding) {
4865 return new Promise((resolve, reject) => {
4866 const callback = (error) => {
4867 if (error === undefined || error === null) {
4868 resolve();
4869 }
4870 else {
4871 reject(error);
4872 }
4873 };
4874 if (typeof data === 'string') {
4875 this.stream.write(data, encoding, callback);
4876 }
4877 else {
4878 this.stream.write(data, callback);
4879 }
4880 });
4881 }
4882 end() {
4883 this.stream.end();
4884 }
4885}
4886const _ril = Object.freeze({
4887 messageBuffer: Object.freeze({
4888 create: (encoding) => new MessageBuffer(encoding)
4889 }),
4890 applicationJson: Object.freeze({
4891 encoder: Object.freeze({
4892 name: 'application/json',
4893 encode: (msg, options) => {
4894 try {
4895 return Promise.resolve(Buffer.from(JSON.stringify(msg, undefined, 0), options.charset));
4896 }
4897 catch (err) {
4898 return Promise.reject(err);
4899 }
4900 }
4901 }),
4902 decoder: Object.freeze({
4903 name: 'application/json',
4904 decode: (buffer, options) => {
4905 try {
4906 if (buffer instanceof Buffer) {
4907 return Promise.resolve(JSON.parse(buffer.toString(options.charset)));
4908 }
4909 else {
4910 return Promise.resolve(JSON.parse(new util_1.TextDecoder(options.charset).decode(buffer)));
4911 }
4912 }
4913 catch (err) {
4914 return Promise.reject(err);
4915 }
4916 }
4917 })
4918 }),
4919 stream: Object.freeze({
4920 asReadableStream: (stream) => new ReadableStreamWrapper(stream),
4921 asWritableStream: (stream) => new WritableStreamWrapper(stream)
4922 }),
4923 console: console,
4924 timer: Object.freeze({
4925 setTimeout(callback, ms, ...args) {
4926 return setTimeout(callback, ms, ...args);
4927 },
4928 clearTimeout(handle) {
4929 clearTimeout(handle);
4930 },
4931 setImmediate(callback, ...args) {
4932 return setImmediate(callback, ...args);
4933 },
4934 clearImmediate(handle) {
4935 clearImmediate(handle);
4936 }
4937 })
4938});
4939function RIL() {
4940 return _ril;
4941}
4942(function (RIL) {
4943 function install() {
4944 ral_1.default.install(_ril);
4945 }
4946 RIL.install = install;
4947})(RIL || (RIL = {}));
4948exports.default = RIL;
4949//# sourceMappingURL=ril.js.map
4950
4951/***/ }),
4952
4953/***/ 6:
4954/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4955
4956"use strict";
4957/* --------------------------------------------------------------------------------------------
4958 * Copyright (c) Microsoft Corporation. All rights reserved.
4959 * Licensed under the MIT License. See License.txt in the project root for license information.
4960 * ----------------------------------------------------------------------------------------- */
4961
4962
4963module.exports = __webpack_require__(7);
4964
4965/***/ }),
4966
4967/***/ 27:
4968/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
4969
4970"use strict";
4971
4972/* --------------------------------------------------------------------------------------------
4973 * Copyright (c) Microsoft Corporation. All rights reserved.
4974 * Licensed under the MIT License. See License.txt in the project root for license information.
4975 * ------------------------------------------------------------------------------------------ */
4976var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4977 if (k2 === undefined) k2 = k;
4978 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4979}) : (function(o, m, k, k2) {
4980 if (k2 === undefined) k2 = k;
4981 o[k2] = m[k];
4982}));
4983var __exportStar = (this && this.__exportStar) || function(m, exports) {
4984 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4985};
4986Object.defineProperty(exports, "__esModule", ({ value: true }));
4987exports.LSPErrorCodes = exports.createProtocolConnection = void 0;
4988__exportStar(__webpack_require__(7), exports);
4989__exportStar(__webpack_require__(28), exports);
4990__exportStar(__webpack_require__(29), exports);
4991__exportStar(__webpack_require__(30), exports);
4992var connection_1 = __webpack_require__(47);
4993Object.defineProperty(exports, "createProtocolConnection", ({ enumerable: true, get: function () { return connection_1.createProtocolConnection; } }));
4994var LSPErrorCodes;
4995(function (LSPErrorCodes) {
4996 /**
4997 * This is the start range of LSP reserved error codes.
4998 * It doesn't denote a real error code.
4999 *
5000 * @since 3.16.0
5001 */
5002 LSPErrorCodes.lspReservedErrorRangeStart = -32899;
5003 LSPErrorCodes.ContentModified = -32801;
5004 LSPErrorCodes.RequestCancelled = -32800;
5005 /**
5006 * This is the end range of LSP reserved error codes.
5007 * It doesn't denote a real error code.
5008 *
5009 * @since 3.16.0
5010 */
5011 LSPErrorCodes.lspReservedErrorRangeEnd = -32800;
5012})(LSPErrorCodes = exports.LSPErrorCodes || (exports.LSPErrorCodes = {}));
5013//# sourceMappingURL=api.js.map
5014
5015/***/ }),
5016
5017/***/ 47:
5018/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5019
5020"use strict";
5021
5022/* --------------------------------------------------------------------------------------------
5023 * Copyright (c) Microsoft Corporation. All rights reserved.
5024 * Licensed under the MIT License. See License.txt in the project root for license information.
5025 * ------------------------------------------------------------------------------------------ */
5026Object.defineProperty(exports, "__esModule", ({ value: true }));
5027exports.createProtocolConnection = void 0;
5028const vscode_jsonrpc_1 = __webpack_require__(7);
5029function createProtocolConnection(input, output, logger, options) {
5030 if (vscode_jsonrpc_1.ConnectionStrategy.is(options)) {
5031 options = { connectionStrategy: options };
5032 }
5033 return vscode_jsonrpc_1.createMessageConnection(input, output, logger, options);
5034}
5035exports.createProtocolConnection = createProtocolConnection;
5036//# sourceMappingURL=connection.js.map
5037
5038/***/ }),
5039
5040/***/ 29:
5041/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5042
5043"use strict";
5044
5045/* --------------------------------------------------------------------------------------------
5046 * Copyright (c) Microsoft Corporation. All rights reserved.
5047 * Licensed under the MIT License. See License.txt in the project root for license information.
5048 * ------------------------------------------------------------------------------------------ */
5049Object.defineProperty(exports, "__esModule", ({ value: true }));
5050exports.ProtocolNotificationType = exports.ProtocolNotificationType0 = exports.ProtocolRequestType = exports.ProtocolRequestType0 = exports.RegistrationType = void 0;
5051const vscode_jsonrpc_1 = __webpack_require__(7);
5052class RegistrationType {
5053 constructor(method) {
5054 this.method = method;
5055 }
5056}
5057exports.RegistrationType = RegistrationType;
5058class ProtocolRequestType0 extends vscode_jsonrpc_1.RequestType0 {
5059 constructor(method) {
5060 super(method);
5061 }
5062}
5063exports.ProtocolRequestType0 = ProtocolRequestType0;
5064class ProtocolRequestType extends vscode_jsonrpc_1.RequestType {
5065 constructor(method) {
5066 super(method, vscode_jsonrpc_1.ParameterStructures.byName);
5067 }
5068}
5069exports.ProtocolRequestType = ProtocolRequestType;
5070class ProtocolNotificationType0 extends vscode_jsonrpc_1.NotificationType0 {
5071 constructor(method) {
5072 super(method);
5073 }
5074}
5075exports.ProtocolNotificationType0 = ProtocolNotificationType0;
5076class ProtocolNotificationType extends vscode_jsonrpc_1.NotificationType {
5077 constructor(method) {
5078 super(method, vscode_jsonrpc_1.ParameterStructures.byName);
5079 }
5080}
5081exports.ProtocolNotificationType = ProtocolNotificationType;
5082// let x: ProtocolNotificationType<number, { value: number}>;
5083// let y: ProtocolNotificationType<string, { value: number}>;
5084// x = y;
5085//# sourceMappingURL=messages.js.map
5086
5087/***/ }),
5088
5089/***/ 41:
5090/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5091
5092"use strict";
5093
5094/* --------------------------------------------------------------------------------------------
5095 * Copyright (c) TypeFox and others. All rights reserved.
5096 * Licensed under the MIT License. See License.txt in the project root for license information.
5097 * ------------------------------------------------------------------------------------------ */
5098Object.defineProperty(exports, "__esModule", ({ value: true }));
5099exports.CallHierarchyOutgoingCallsRequest = exports.CallHierarchyIncomingCallsRequest = exports.CallHierarchyPrepareRequest = void 0;
5100const messages_1 = __webpack_require__(29);
5101/**
5102 * A request to result a `CallHierarchyItem` in a document at a given position.
5103 * Can be used as an input to a incoming or outgoing call hierarchy.
5104 *
5105 * @since 3.16.0
5106 */
5107var CallHierarchyPrepareRequest;
5108(function (CallHierarchyPrepareRequest) {
5109 CallHierarchyPrepareRequest.method = 'textDocument/prepareCallHierarchy';
5110 CallHierarchyPrepareRequest.type = new messages_1.ProtocolRequestType(CallHierarchyPrepareRequest.method);
5111})(CallHierarchyPrepareRequest = exports.CallHierarchyPrepareRequest || (exports.CallHierarchyPrepareRequest = {}));
5112/**
5113 * A request to resolve the incoming calls for a given `CallHierarchyItem`.
5114 *
5115 * @since 3.16.0
5116 */
5117var CallHierarchyIncomingCallsRequest;
5118(function (CallHierarchyIncomingCallsRequest) {
5119 CallHierarchyIncomingCallsRequest.method = 'callHierarchy/incomingCalls';
5120 CallHierarchyIncomingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyIncomingCallsRequest.method);
5121})(CallHierarchyIncomingCallsRequest = exports.CallHierarchyIncomingCallsRequest || (exports.CallHierarchyIncomingCallsRequest = {}));
5122/**
5123 * A request to resolve the outgoing calls for a given `CallHierarchyItem`.
5124 *
5125 * @since 3.16.0
5126 */
5127var CallHierarchyOutgoingCallsRequest;
5128(function (CallHierarchyOutgoingCallsRequest) {
5129 CallHierarchyOutgoingCallsRequest.method = 'callHierarchy/outgoingCalls';
5130 CallHierarchyOutgoingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyOutgoingCallsRequest.method);
5131})(CallHierarchyOutgoingCallsRequest = exports.CallHierarchyOutgoingCallsRequest || (exports.CallHierarchyOutgoingCallsRequest = {}));
5132//# sourceMappingURL=protocol.callHierarchy.js.map
5133
5134/***/ }),
5135
5136/***/ 36:
5137/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5138
5139"use strict";
5140
5141/* --------------------------------------------------------------------------------------------
5142 * Copyright (c) Microsoft Corporation. All rights reserved.
5143 * Licensed under the MIT License. See License.txt in the project root for license information.
5144 * ------------------------------------------------------------------------------------------ */
5145Object.defineProperty(exports, "__esModule", ({ value: true }));
5146exports.ColorPresentationRequest = exports.DocumentColorRequest = void 0;
5147const messages_1 = __webpack_require__(29);
5148/**
5149 * A request to list all color symbols found in a given text document. The request's
5150 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
5151 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
5152 * that resolves to such.
5153 */
5154var DocumentColorRequest;
5155(function (DocumentColorRequest) {
5156 DocumentColorRequest.method = 'textDocument/documentColor';
5157 DocumentColorRequest.type = new messages_1.ProtocolRequestType(DocumentColorRequest.method);
5158})(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
5159/**
5160 * A request to list all presentation for a color. The request's
5161 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
5162 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
5163 * that resolves to such.
5164 */
5165var ColorPresentationRequest;
5166(function (ColorPresentationRequest) {
5167 ColorPresentationRequest.type = new messages_1.ProtocolRequestType('textDocument/colorPresentation');
5168})(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
5169//# sourceMappingURL=protocol.colorProvider.js.map
5170
5171/***/ }),
5172
5173/***/ 35:
5174/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5175
5176"use strict";
5177
5178/* --------------------------------------------------------------------------------------------
5179 * Copyright (c) Microsoft Corporation. All rights reserved.
5180 * Licensed under the MIT License. See License.txt in the project root for license information.
5181 * ------------------------------------------------------------------------------------------ */
5182Object.defineProperty(exports, "__esModule", ({ value: true }));
5183exports.ConfigurationRequest = void 0;
5184const messages_1 = __webpack_require__(29);
5185/**
5186 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
5187 * configuration setting.
5188 *
5189 * This pull model replaces the old push model were the client signaled configuration change via an
5190 * event. If the server still needs to react to configuration changes (since the server caches the
5191 * result of `workspace/configuration` requests) the server should register for an empty configuration
5192 * change event and empty the cache if such an event is received.
5193 */
5194var ConfigurationRequest;
5195(function (ConfigurationRequest) {
5196 ConfigurationRequest.type = new messages_1.ProtocolRequestType('workspace/configuration');
5197})(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
5198//# sourceMappingURL=protocol.configuration.js.map
5199
5200/***/ }),
5201
5202/***/ 38:
5203/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5204
5205"use strict";
5206
5207/* --------------------------------------------------------------------------------------------
5208 * Copyright (c) Microsoft Corporation. All rights reserved.
5209 * Licensed under the MIT License. See License.txt in the project root for license information.
5210 * ------------------------------------------------------------------------------------------ */
5211Object.defineProperty(exports, "__esModule", ({ value: true }));
5212exports.DeclarationRequest = void 0;
5213const messages_1 = __webpack_require__(29);
5214// @ts-ignore: to avoid inlining LocatioLink as dynamic import
5215let __noDynamicImport;
5216/**
5217 * A request to resolve the type definition locations of a symbol at a given text
5218 * document position. The request's parameter is of type [TextDocumentPositioParams]
5219 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
5220 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
5221 * to such.
5222 */
5223var DeclarationRequest;
5224(function (DeclarationRequest) {
5225 DeclarationRequest.method = 'textDocument/declaration';
5226 DeclarationRequest.type = new messages_1.ProtocolRequestType(DeclarationRequest.method);
5227})(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
5228//# sourceMappingURL=protocol.declaration.js.map
5229
5230/***/ }),
5231
5232/***/ 45:
5233/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5234
5235"use strict";
5236
5237/* --------------------------------------------------------------------------------------------
5238 * Copyright (c) Microsoft Corporation. All rights reserved.
5239 * Licensed under the MIT License. See License.txt in the project root for license information.
5240 * ------------------------------------------------------------------------------------------ */
5241Object.defineProperty(exports, "__esModule", ({ value: true }));
5242exports.WillDeleteFilesRequest = exports.DidDeleteFilesNotification = exports.DidRenameFilesNotification = exports.WillRenameFilesRequest = exports.DidCreateFilesNotification = exports.WillCreateFilesRequest = exports.FileOperationPatternKind = void 0;
5243const messages_1 = __webpack_require__(29);
5244/**
5245 * A pattern kind describing if a glob pattern matches a file a folder or
5246 * both.
5247 *
5248 * @since 3.16.0
5249 */
5250var FileOperationPatternKind;
5251(function (FileOperationPatternKind) {
5252 /**
5253 * The pattern matches a file only.
5254 */
5255 FileOperationPatternKind.file = 'file';
5256 /**
5257 * The pattern matches a folder only.
5258 */
5259 FileOperationPatternKind.folder = 'folder';
5260})(FileOperationPatternKind = exports.FileOperationPatternKind || (exports.FileOperationPatternKind = {}));
5261/**
5262 * The will create files request is sent from the client to the server before files are actually
5263 * created as long as the creation is triggered from within the client.
5264 *
5265 * @since 3.16.0
5266 */
5267var WillCreateFilesRequest;
5268(function (WillCreateFilesRequest) {
5269 WillCreateFilesRequest.method = 'workspace/willCreateFiles';
5270 WillCreateFilesRequest.type = new messages_1.ProtocolRequestType(WillCreateFilesRequest.method);
5271})(WillCreateFilesRequest = exports.WillCreateFilesRequest || (exports.WillCreateFilesRequest = {}));
5272/**
5273 * The did create files notification is sent from the client to the server when
5274 * files were created from within the client.
5275 *
5276 * @since 3.16.0
5277 */
5278var DidCreateFilesNotification;
5279(function (DidCreateFilesNotification) {
5280 DidCreateFilesNotification.method = 'workspace/didCreateFiles';
5281 DidCreateFilesNotification.type = new messages_1.ProtocolNotificationType(DidCreateFilesNotification.method);
5282})(DidCreateFilesNotification = exports.DidCreateFilesNotification || (exports.DidCreateFilesNotification = {}));
5283/**
5284 * The will rename files request is sent from the client to the server before files are actually
5285 * renamed as long as the rename is triggered from within the client.
5286 *
5287 * @since 3.16.0
5288 */
5289var WillRenameFilesRequest;
5290(function (WillRenameFilesRequest) {
5291 WillRenameFilesRequest.method = 'workspace/willRenameFiles';
5292 WillRenameFilesRequest.type = new messages_1.ProtocolRequestType(WillRenameFilesRequest.method);
5293})(WillRenameFilesRequest = exports.WillRenameFilesRequest || (exports.WillRenameFilesRequest = {}));
5294/**
5295 * The did rename files notification is sent from the client to the server when
5296 * files were renamed from within the client.
5297 *
5298 * @since 3.16.0
5299 */
5300var DidRenameFilesNotification;
5301(function (DidRenameFilesNotification) {
5302 DidRenameFilesNotification.method = 'workspace/didRenameFiles';
5303 DidRenameFilesNotification.type = new messages_1.ProtocolNotificationType(DidRenameFilesNotification.method);
5304})(DidRenameFilesNotification = exports.DidRenameFilesNotification || (exports.DidRenameFilesNotification = {}));
5305/**
5306 * The will delete files request is sent from the client to the server before files are actually
5307 * deleted as long as the deletion is triggered from within the client.
5308 *
5309 * @since 3.16.0
5310 */
5311var DidDeleteFilesNotification;
5312(function (DidDeleteFilesNotification) {
5313 DidDeleteFilesNotification.method = 'workspace/didDeleteFiles';
5314 DidDeleteFilesNotification.type = new messages_1.ProtocolNotificationType(DidDeleteFilesNotification.method);
5315})(DidDeleteFilesNotification = exports.DidDeleteFilesNotification || (exports.DidDeleteFilesNotification = {}));
5316/**
5317 * The did delete files notification is sent from the client to the server when
5318 * files were deleted from within the client.
5319 *
5320 * @since 3.16.0
5321 */
5322var WillDeleteFilesRequest;
5323(function (WillDeleteFilesRequest) {
5324 WillDeleteFilesRequest.method = 'workspace/willDeleteFiles';
5325 WillDeleteFilesRequest.type = new messages_1.ProtocolRequestType(WillDeleteFilesRequest.method);
5326})(WillDeleteFilesRequest = exports.WillDeleteFilesRequest || (exports.WillDeleteFilesRequest = {}));
5327//# sourceMappingURL=protocol.fileOperations.js.map
5328
5329/***/ }),
5330
5331/***/ 37:
5332/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5333
5334"use strict";
5335
5336/*---------------------------------------------------------------------------------------------
5337 * Copyright (c) Microsoft Corporation. All rights reserved.
5338 * Licensed under the MIT License. See License.txt in the project root for license information.
5339 *--------------------------------------------------------------------------------------------*/
5340Object.defineProperty(exports, "__esModule", ({ value: true }));
5341exports.FoldingRangeRequest = exports.FoldingRangeKind = void 0;
5342const messages_1 = __webpack_require__(29);
5343/**
5344 * Enum of known range kinds
5345 */
5346var FoldingRangeKind;
5347(function (FoldingRangeKind) {
5348 /**
5349 * Folding range for a comment
5350 */
5351 FoldingRangeKind["Comment"] = "comment";
5352 /**
5353 * Folding range for a imports or includes
5354 */
5355 FoldingRangeKind["Imports"] = "imports";
5356 /**
5357 * Folding range for a region (e.g. `#region`)
5358 */
5359 FoldingRangeKind["Region"] = "region";
5360})(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
5361/**
5362 * A request to provide folding ranges in a document. The request's
5363 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
5364 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
5365 * that resolves to such.
5366 */
5367var FoldingRangeRequest;
5368(function (FoldingRangeRequest) {
5369 FoldingRangeRequest.method = 'textDocument/foldingRange';
5370 FoldingRangeRequest.type = new messages_1.ProtocolRequestType(FoldingRangeRequest.method);
5371})(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
5372//# sourceMappingURL=protocol.foldingRange.js.map
5373
5374/***/ }),
5375
5376/***/ 32:
5377/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5378
5379"use strict";
5380
5381/* --------------------------------------------------------------------------------------------
5382 * Copyright (c) Microsoft Corporation. All rights reserved.
5383 * Licensed under the MIT License. See License.txt in the project root for license information.
5384 * ------------------------------------------------------------------------------------------ */
5385Object.defineProperty(exports, "__esModule", ({ value: true }));
5386exports.ImplementationRequest = void 0;
5387const messages_1 = __webpack_require__(29);
5388// @ts-ignore: to avoid inlining LocatioLink as dynamic import
5389let __noDynamicImport;
5390/**
5391 * A request to resolve the implementation locations of a symbol at a given text
5392 * document position. The request's parameter is of type [TextDocumentPositioParams]
5393 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
5394 * Thenable that resolves to such.
5395 */
5396var ImplementationRequest;
5397(function (ImplementationRequest) {
5398 ImplementationRequest.method = 'textDocument/implementation';
5399 ImplementationRequest.type = new messages_1.ProtocolRequestType(ImplementationRequest.method);
5400})(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
5401//# sourceMappingURL=protocol.implementation.js.map
5402
5403/***/ }),
5404
5405/***/ 30:
5406/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5407
5408"use strict";
5409
5410/* --------------------------------------------------------------------------------------------
5411 * Copyright (c) Microsoft Corporation. All rights reserved.
5412 * Licensed under the MIT License. See License.txt in the project root for license information.
5413 * ------------------------------------------------------------------------------------------ */
5414Object.defineProperty(exports, "__esModule", ({ value: true }));
5415exports.DocumentLinkRequest = exports.CodeLensRefreshRequest = exports.CodeLensResolveRequest = exports.CodeLensRequest = exports.WorkspaceSymbolRequest = exports.CodeActionResolveRequest = exports.CodeActionRequest = exports.DocumentSymbolRequest = exports.DocumentHighlightRequest = exports.ReferencesRequest = exports.DefinitionRequest = exports.SignatureHelpRequest = exports.SignatureHelpTriggerKind = exports.HoverRequest = exports.CompletionResolveRequest = exports.CompletionRequest = exports.CompletionTriggerKind = exports.PublishDiagnosticsNotification = exports.WatchKind = exports.FileChangeType = exports.DidChangeWatchedFilesNotification = exports.WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentNotification = exports.TextDocumentSaveReason = exports.DidSaveTextDocumentNotification = exports.DidCloseTextDocumentNotification = exports.DidChangeTextDocumentNotification = exports.TextDocumentContentChangeEvent = exports.DidOpenTextDocumentNotification = exports.TextDocumentSyncKind = exports.TelemetryEventNotification = exports.LogMessageNotification = exports.ShowMessageRequest = exports.ShowMessageNotification = exports.MessageType = exports.DidChangeConfigurationNotification = exports.ExitNotification = exports.ShutdownRequest = exports.InitializedNotification = exports.InitializeError = exports.InitializeRequest = exports.WorkDoneProgressOptions = exports.TextDocumentRegistrationOptions = exports.StaticRegistrationOptions = exports.FailureHandlingKind = exports.ResourceOperationKind = exports.UnregistrationRequest = exports.RegistrationRequest = exports.DocumentSelector = exports.DocumentFilter = void 0;
5416exports.MonikerRequest = exports.MonikerKind = exports.UniquenessLevel = exports.WillDeleteFilesRequest = exports.DidDeleteFilesNotification = exports.WillRenameFilesRequest = exports.DidRenameFilesNotification = exports.WillCreateFilesRequest = exports.DidCreateFilesNotification = exports.FileOperationPatternKind = exports.LinkedEditingRangeRequest = exports.ShowDocumentRequest = exports.SemanticTokensRegistrationType = exports.SemanticTokensRefreshRequest = exports.SemanticTokensRangeRequest = exports.SemanticTokensDeltaRequest = exports.SemanticTokensRequest = exports.TokenFormat = exports.SemanticTokens = exports.SemanticTokenModifiers = exports.SemanticTokenTypes = exports.CallHierarchyPrepareRequest = exports.CallHierarchyOutgoingCallsRequest = exports.CallHierarchyIncomingCallsRequest = exports.WorkDoneProgressCancelNotification = exports.WorkDoneProgressCreateRequest = exports.WorkDoneProgress = exports.SelectionRangeRequest = exports.DeclarationRequest = exports.FoldingRangeRequest = exports.ColorPresentationRequest = exports.DocumentColorRequest = exports.ConfigurationRequest = exports.DidChangeWorkspaceFoldersNotification = exports.WorkspaceFoldersRequest = exports.TypeDefinitionRequest = exports.ImplementationRequest = exports.ApplyWorkspaceEditRequest = exports.ExecuteCommandRequest = exports.PrepareRenameRequest = exports.RenameRequest = exports.PrepareSupportDefaultBehavior = exports.DocumentOnTypeFormattingRequest = exports.DocumentRangeFormattingRequest = exports.DocumentFormattingRequest = exports.DocumentLinkResolveRequest = void 0;
5417const Is = __webpack_require__(31);
5418const messages_1 = __webpack_require__(29);
5419const protocol_implementation_1 = __webpack_require__(32);
5420Object.defineProperty(exports, "ImplementationRequest", ({ enumerable: true, get: function () { return protocol_implementation_1.ImplementationRequest; } }));
5421const protocol_typeDefinition_1 = __webpack_require__(33);
5422Object.defineProperty(exports, "TypeDefinitionRequest", ({ enumerable: true, get: function () { return protocol_typeDefinition_1.TypeDefinitionRequest; } }));
5423const protocol_workspaceFolders_1 = __webpack_require__(34);
5424Object.defineProperty(exports, "WorkspaceFoldersRequest", ({ enumerable: true, get: function () { return protocol_workspaceFolders_1.WorkspaceFoldersRequest; } }));
5425Object.defineProperty(exports, "DidChangeWorkspaceFoldersNotification", ({ enumerable: true, get: function () { return protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification; } }));
5426const protocol_configuration_1 = __webpack_require__(35);
5427Object.defineProperty(exports, "ConfigurationRequest", ({ enumerable: true, get: function () { return protocol_configuration_1.ConfigurationRequest; } }));
5428const protocol_colorProvider_1 = __webpack_require__(36);
5429Object.defineProperty(exports, "DocumentColorRequest", ({ enumerable: true, get: function () { return protocol_colorProvider_1.DocumentColorRequest; } }));
5430Object.defineProperty(exports, "ColorPresentationRequest", ({ enumerable: true, get: function () { return protocol_colorProvider_1.ColorPresentationRequest; } }));
5431const protocol_foldingRange_1 = __webpack_require__(37);
5432Object.defineProperty(exports, "FoldingRangeRequest", ({ enumerable: true, get: function () { return protocol_foldingRange_1.FoldingRangeRequest; } }));
5433const protocol_declaration_1 = __webpack_require__(38);
5434Object.defineProperty(exports, "DeclarationRequest", ({ enumerable: true, get: function () { return protocol_declaration_1.DeclarationRequest; } }));
5435const protocol_selectionRange_1 = __webpack_require__(39);
5436Object.defineProperty(exports, "SelectionRangeRequest", ({ enumerable: true, get: function () { return protocol_selectionRange_1.SelectionRangeRequest; } }));
5437const protocol_progress_1 = __webpack_require__(40);
5438Object.defineProperty(exports, "WorkDoneProgress", ({ enumerable: true, get: function () { return protocol_progress_1.WorkDoneProgress; } }));
5439Object.defineProperty(exports, "WorkDoneProgressCreateRequest", ({ enumerable: true, get: function () { return protocol_progress_1.WorkDoneProgressCreateRequest; } }));
5440Object.defineProperty(exports, "WorkDoneProgressCancelNotification", ({ enumerable: true, get: function () { return protocol_progress_1.WorkDoneProgressCancelNotification; } }));
5441const protocol_callHierarchy_1 = __webpack_require__(41);
5442Object.defineProperty(exports, "CallHierarchyIncomingCallsRequest", ({ enumerable: true, get: function () { return protocol_callHierarchy_1.CallHierarchyIncomingCallsRequest; } }));
5443Object.defineProperty(exports, "CallHierarchyOutgoingCallsRequest", ({ enumerable: true, get: function () { return protocol_callHierarchy_1.CallHierarchyOutgoingCallsRequest; } }));
5444Object.defineProperty(exports, "CallHierarchyPrepareRequest", ({ enumerable: true, get: function () { return protocol_callHierarchy_1.CallHierarchyPrepareRequest; } }));
5445const protocol_semanticTokens_1 = __webpack_require__(42);
5446Object.defineProperty(exports, "SemanticTokenTypes", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokenTypes; } }));
5447Object.defineProperty(exports, "SemanticTokenModifiers", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokenModifiers; } }));
5448Object.defineProperty(exports, "SemanticTokens", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokens; } }));
5449Object.defineProperty(exports, "TokenFormat", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.TokenFormat; } }));
5450Object.defineProperty(exports, "SemanticTokensRequest", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokensRequest; } }));
5451Object.defineProperty(exports, "SemanticTokensDeltaRequest", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokensDeltaRequest; } }));
5452Object.defineProperty(exports, "SemanticTokensRangeRequest", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokensRangeRequest; } }));
5453Object.defineProperty(exports, "SemanticTokensRefreshRequest", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokensRefreshRequest; } }));
5454Object.defineProperty(exports, "SemanticTokensRegistrationType", ({ enumerable: true, get: function () { return protocol_semanticTokens_1.SemanticTokensRegistrationType; } }));
5455const protocol_showDocument_1 = __webpack_require__(43);
5456Object.defineProperty(exports, "ShowDocumentRequest", ({ enumerable: true, get: function () { return protocol_showDocument_1.ShowDocumentRequest; } }));
5457const protocol_linkedEditingRange_1 = __webpack_require__(44);
5458Object.defineProperty(exports, "LinkedEditingRangeRequest", ({ enumerable: true, get: function () { return protocol_linkedEditingRange_1.LinkedEditingRangeRequest; } }));
5459const protocol_fileOperations_1 = __webpack_require__(45);
5460Object.defineProperty(exports, "FileOperationPatternKind", ({ enumerable: true, get: function () { return protocol_fileOperations_1.FileOperationPatternKind; } }));
5461Object.defineProperty(exports, "DidCreateFilesNotification", ({ enumerable: true, get: function () { return protocol_fileOperations_1.DidCreateFilesNotification; } }));
5462Object.defineProperty(exports, "WillCreateFilesRequest", ({ enumerable: true, get: function () { return protocol_fileOperations_1.WillCreateFilesRequest; } }));
5463Object.defineProperty(exports, "DidRenameFilesNotification", ({ enumerable: true, get: function () { return protocol_fileOperations_1.DidRenameFilesNotification; } }));
5464Object.defineProperty(exports, "WillRenameFilesRequest", ({ enumerable: true, get: function () { return protocol_fileOperations_1.WillRenameFilesRequest; } }));
5465Object.defineProperty(exports, "DidDeleteFilesNotification", ({ enumerable: true, get: function () { return protocol_fileOperations_1.DidDeleteFilesNotification; } }));
5466Object.defineProperty(exports, "WillDeleteFilesRequest", ({ enumerable: true, get: function () { return protocol_fileOperations_1.WillDeleteFilesRequest; } }));
5467const protocol_moniker_1 = __webpack_require__(46);
5468Object.defineProperty(exports, "UniquenessLevel", ({ enumerable: true, get: function () { return protocol_moniker_1.UniquenessLevel; } }));
5469Object.defineProperty(exports, "MonikerKind", ({ enumerable: true, get: function () { return protocol_moniker_1.MonikerKind; } }));
5470Object.defineProperty(exports, "MonikerRequest", ({ enumerable: true, get: function () { return protocol_moniker_1.MonikerRequest; } }));
5471// @ts-ignore: to avoid inlining LocationLink as dynamic import
5472let __noDynamicImport;
5473/**
5474 * The DocumentFilter namespace provides helper functions to work with
5475 * [DocumentFilter](#DocumentFilter) literals.
5476 */
5477var DocumentFilter;
5478(function (DocumentFilter) {
5479 function is(value) {
5480 const candidate = value;
5481 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
5482 }
5483 DocumentFilter.is = is;
5484})(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
5485/**
5486 * The DocumentSelector namespace provides helper functions to work with
5487 * [DocumentSelector](#DocumentSelector)s.
5488 */
5489var DocumentSelector;
5490(function (DocumentSelector) {
5491 function is(value) {
5492 if (!Array.isArray(value)) {
5493 return false;
5494 }
5495 for (let elem of value) {
5496 if (!Is.string(elem) && !DocumentFilter.is(elem)) {
5497 return false;
5498 }
5499 }
5500 return true;
5501 }
5502 DocumentSelector.is = is;
5503})(DocumentSelector = exports.DocumentSelector || (exports.DocumentSelector = {}));
5504/**
5505 * The `client/registerCapability` request is sent from the server to the client to register a new capability
5506 * handler on the client side.
5507 */
5508var RegistrationRequest;
5509(function (RegistrationRequest) {
5510 RegistrationRequest.type = new messages_1.ProtocolRequestType('client/registerCapability');
5511})(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
5512/**
5513 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
5514 * handler on the client side.
5515 */
5516var UnregistrationRequest;
5517(function (UnregistrationRequest) {
5518 UnregistrationRequest.type = new messages_1.ProtocolRequestType('client/unregisterCapability');
5519})(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
5520var ResourceOperationKind;
5521(function (ResourceOperationKind) {
5522 /**
5523 * Supports creating new files and folders.
5524 */
5525 ResourceOperationKind.Create = 'create';
5526 /**
5527 * Supports renaming existing files and folders.
5528 */
5529 ResourceOperationKind.Rename = 'rename';
5530 /**
5531 * Supports deleting existing files and folders.
5532 */
5533 ResourceOperationKind.Delete = 'delete';
5534})(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
5535var FailureHandlingKind;
5536(function (FailureHandlingKind) {
5537 /**
5538 * Applying the workspace change is simply aborted if one of the changes provided
5539 * fails. All operations executed before the failing operation stay executed.
5540 */
5541 FailureHandlingKind.Abort = 'abort';
5542 /**
5543 * All operations are executed transactional. That means they either all
5544 * succeed or no changes at all are applied to the workspace.
5545 */
5546 FailureHandlingKind.Transactional = 'transactional';
5547 /**
5548 * If the workspace edit contains only textual file changes they are executed transactional.
5549 * If resource changes (create, rename or delete file) are part of the change the failure
5550 * handling strategy is abort.
5551 */
5552 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
5553 /**
5554 * The client tries to undo the operations already executed. But there is no
5555 * guarantee that this is succeeding.
5556 */
5557 FailureHandlingKind.Undo = 'undo';
5558})(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
5559/**
5560 * The StaticRegistrationOptions namespace provides helper functions to work with
5561 * [StaticRegistrationOptions](#StaticRegistrationOptions) literals.
5562 */
5563var StaticRegistrationOptions;
5564(function (StaticRegistrationOptions) {
5565 function hasId(value) {
5566 const candidate = value;
5567 return candidate && Is.string(candidate.id) && candidate.id.length > 0;
5568 }
5569 StaticRegistrationOptions.hasId = hasId;
5570})(StaticRegistrationOptions = exports.StaticRegistrationOptions || (exports.StaticRegistrationOptions = {}));
5571/**
5572 * The TextDocumentRegistrationOptions namespace provides helper functions to work with
5573 * [TextDocumentRegistrationOptions](#TextDocumentRegistrationOptions) literals.
5574 */
5575var TextDocumentRegistrationOptions;
5576(function (TextDocumentRegistrationOptions) {
5577 function is(value) {
5578 const candidate = value;
5579 return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
5580 }
5581 TextDocumentRegistrationOptions.is = is;
5582})(TextDocumentRegistrationOptions = exports.TextDocumentRegistrationOptions || (exports.TextDocumentRegistrationOptions = {}));
5583/**
5584 * The WorkDoneProgressOptions namespace provides helper functions to work with
5585 * [WorkDoneProgressOptions](#WorkDoneProgressOptions) literals.
5586 */
5587var WorkDoneProgressOptions;
5588(function (WorkDoneProgressOptions) {
5589 function is(value) {
5590 const candidate = value;
5591 return Is.objectLiteral(candidate) && (candidate.workDoneProgress === undefined || Is.boolean(candidate.workDoneProgress));
5592 }
5593 WorkDoneProgressOptions.is = is;
5594 function hasWorkDoneProgress(value) {
5595 const candidate = value;
5596 return candidate && Is.boolean(candidate.workDoneProgress);
5597 }
5598 WorkDoneProgressOptions.hasWorkDoneProgress = hasWorkDoneProgress;
5599})(WorkDoneProgressOptions = exports.WorkDoneProgressOptions || (exports.WorkDoneProgressOptions = {}));
5600/**
5601 * The initialize request is sent from the client to the server.
5602 * It is sent once as the request after starting up the server.
5603 * The requests parameter is of type [InitializeParams](#InitializeParams)
5604 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
5605 * resolves to such.
5606 */
5607var InitializeRequest;
5608(function (InitializeRequest) {
5609 InitializeRequest.type = new messages_1.ProtocolRequestType('initialize');
5610})(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
5611/**
5612 * Known error codes for an `InitializeError`;
5613 */
5614var InitializeError;
5615(function (InitializeError) {
5616 /**
5617 * If the protocol version provided by the client can't be handled by the server.
5618 * @deprecated This initialize error got replaced by client capabilities. There is
5619 * no version handshake in version 3.0x
5620 */
5621 InitializeError.unknownProtocolVersion = 1;
5622})(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
5623/**
5624 * The initialized notification is sent from the client to the
5625 * server after the client is fully initialized and the server
5626 * is allowed to send requests from the server to the client.
5627 */
5628var InitializedNotification;
5629(function (InitializedNotification) {
5630 InitializedNotification.type = new messages_1.ProtocolNotificationType('initialized');
5631})(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
5632//---- Shutdown Method ----
5633/**
5634 * A shutdown request is sent from the client to the server.
5635 * It is sent once when the client decides to shutdown the
5636 * server. The only notification that is sent after a shutdown request
5637 * is the exit event.
5638 */
5639var ShutdownRequest;
5640(function (ShutdownRequest) {
5641 ShutdownRequest.type = new messages_1.ProtocolRequestType0('shutdown');
5642})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
5643//---- Exit Notification ----
5644/**
5645 * The exit event is sent from the client to the server to
5646 * ask the server to exit its process.
5647 */
5648var ExitNotification;
5649(function (ExitNotification) {
5650 ExitNotification.type = new messages_1.ProtocolNotificationType0('exit');
5651})(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
5652/**
5653 * The configuration change notification is sent from the client to the server
5654 * when the client's configuration has changed. The notification contains
5655 * the changed configuration as defined by the language client.
5656 */
5657var DidChangeConfigurationNotification;
5658(function (DidChangeConfigurationNotification) {
5659 DidChangeConfigurationNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeConfiguration');
5660})(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
5661//---- Message show and log notifications ----
5662/**
5663 * The message type
5664 */
5665var MessageType;
5666(function (MessageType) {
5667 /**
5668 * An error message.
5669 */
5670 MessageType.Error = 1;
5671 /**
5672 * A warning message.
5673 */
5674 MessageType.Warning = 2;
5675 /**
5676 * An information message.
5677 */
5678 MessageType.Info = 3;
5679 /**
5680 * A log message.
5681 */
5682 MessageType.Log = 4;
5683})(MessageType = exports.MessageType || (exports.MessageType = {}));
5684/**
5685 * The show message notification is sent from a server to a client to ask
5686 * the client to display a particular message in the user interface.
5687 */
5688var ShowMessageNotification;
5689(function (ShowMessageNotification) {
5690 ShowMessageNotification.type = new messages_1.ProtocolNotificationType('window/showMessage');
5691})(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
5692/**
5693 * The show message request is sent from the server to the client to show a message
5694 * and a set of options actions to the user.
5695 */
5696var ShowMessageRequest;
5697(function (ShowMessageRequest) {
5698 ShowMessageRequest.type = new messages_1.ProtocolRequestType('window/showMessageRequest');
5699})(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
5700/**
5701 * The log message notification is sent from the server to the client to ask
5702 * the client to log a particular message.
5703 */
5704var LogMessageNotification;
5705(function (LogMessageNotification) {
5706 LogMessageNotification.type = new messages_1.ProtocolNotificationType('window/logMessage');
5707})(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
5708//---- Telemetry notification
5709/**
5710 * The telemetry event notification is sent from the server to the client to ask
5711 * the client to log telemetry data.
5712 */
5713var TelemetryEventNotification;
5714(function (TelemetryEventNotification) {
5715 TelemetryEventNotification.type = new messages_1.ProtocolNotificationType('telemetry/event');
5716})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
5717/**
5718 * Defines how the host (editor) should sync
5719 * document changes to the language server.
5720 */
5721var TextDocumentSyncKind;
5722(function (TextDocumentSyncKind) {
5723 /**
5724 * Documents should not be synced at all.
5725 */
5726 TextDocumentSyncKind.None = 0;
5727 /**
5728 * Documents are synced by always sending the full content
5729 * of the document.
5730 */
5731 TextDocumentSyncKind.Full = 1;
5732 /**
5733 * Documents are synced by sending the full content on open.
5734 * After that only incremental updates to the document are
5735 * send.
5736 */
5737 TextDocumentSyncKind.Incremental = 2;
5738})(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
5739/**
5740 * The document open notification is sent from the client to the server to signal
5741 * newly opened text documents. The document's truth is now managed by the client
5742 * and the server must not try to read the document's truth using the document's
5743 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
5744 * mean that its content is presented in an editor. An open notification must not
5745 * be sent more than once without a corresponding close notification send before.
5746 * This means open and close notification must be balanced and the max open count
5747 * is one.
5748 */
5749var DidOpenTextDocumentNotification;
5750(function (DidOpenTextDocumentNotification) {
5751 DidOpenTextDocumentNotification.method = 'textDocument/didOpen';
5752 DidOpenTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidOpenTextDocumentNotification.method);
5753})(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
5754var TextDocumentContentChangeEvent;
5755(function (TextDocumentContentChangeEvent) {
5756 /**
5757 * Checks whether the information describes a delta event.
5758 */
5759 function isIncremental(event) {
5760 let candidate = event;
5761 return candidate !== undefined && candidate !== null &&
5762 typeof candidate.text === 'string' && candidate.range !== undefined &&
5763 (candidate.rangeLength === undefined || typeof candidate.rangeLength === 'number');
5764 }
5765 TextDocumentContentChangeEvent.isIncremental = isIncremental;
5766 /**
5767 * Checks whether the information describes a full replacement event.
5768 */
5769 function isFull(event) {
5770 let candidate = event;
5771 return candidate !== undefined && candidate !== null &&
5772 typeof candidate.text === 'string' && candidate.range === undefined && candidate.rangeLength === undefined;
5773 }
5774 TextDocumentContentChangeEvent.isFull = isFull;
5775})(TextDocumentContentChangeEvent = exports.TextDocumentContentChangeEvent || (exports.TextDocumentContentChangeEvent = {}));
5776/**
5777 * The document change notification is sent from the client to the server to signal
5778 * changes to a text document.
5779 */
5780var DidChangeTextDocumentNotification;
5781(function (DidChangeTextDocumentNotification) {
5782 DidChangeTextDocumentNotification.method = 'textDocument/didChange';
5783 DidChangeTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidChangeTextDocumentNotification.method);
5784})(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
5785/**
5786 * The document close notification is sent from the client to the server when
5787 * the document got closed in the client. The document's truth now exists where
5788 * the document's uri points to (e.g. if the document's uri is a file uri the
5789 * truth now exists on disk). As with the open notification the close notification
5790 * is about managing the document's content. Receiving a close notification
5791 * doesn't mean that the document was open in an editor before. A close
5792 * notification requires a previous open notification to be sent.
5793 */
5794var DidCloseTextDocumentNotification;
5795(function (DidCloseTextDocumentNotification) {
5796 DidCloseTextDocumentNotification.method = 'textDocument/didClose';
5797 DidCloseTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidCloseTextDocumentNotification.method);
5798})(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
5799/**
5800 * The document save notification is sent from the client to the server when
5801 * the document got saved in the client.
5802 */
5803var DidSaveTextDocumentNotification;
5804(function (DidSaveTextDocumentNotification) {
5805 DidSaveTextDocumentNotification.method = 'textDocument/didSave';
5806 DidSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidSaveTextDocumentNotification.method);
5807})(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
5808/**
5809 * Represents reasons why a text document is saved.
5810 */
5811var TextDocumentSaveReason;
5812(function (TextDocumentSaveReason) {
5813 /**
5814 * Manually triggered, e.g. by the user pressing save, by starting debugging,
5815 * or by an API call.
5816 */
5817 TextDocumentSaveReason.Manual = 1;
5818 /**
5819 * Automatic after a delay.
5820 */
5821 TextDocumentSaveReason.AfterDelay = 2;
5822 /**
5823 * When the editor lost focus.
5824 */
5825 TextDocumentSaveReason.FocusOut = 3;
5826})(TextDocumentSaveReason = exports.TextDocumentSaveReason || (exports.TextDocumentSaveReason = {}));
5827/**
5828 * A document will save notification is sent from the client to the server before
5829 * the document is actually saved.
5830 */
5831var WillSaveTextDocumentNotification;
5832(function (WillSaveTextDocumentNotification) {
5833 WillSaveTextDocumentNotification.method = 'textDocument/willSave';
5834 WillSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(WillSaveTextDocumentNotification.method);
5835})(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
5836/**
5837 * A document will save request is sent from the client to the server before
5838 * the document is actually saved. The request can return an array of TextEdits
5839 * which will be applied to the text document before it is saved. Please note that
5840 * clients might drop results if computing the text edits took too long or if a
5841 * server constantly fails on this request. This is done to keep the save fast and
5842 * reliable.
5843 */
5844var WillSaveTextDocumentWaitUntilRequest;
5845(function (WillSaveTextDocumentWaitUntilRequest) {
5846 WillSaveTextDocumentWaitUntilRequest.method = 'textDocument/willSaveWaitUntil';
5847 WillSaveTextDocumentWaitUntilRequest.type = new messages_1.ProtocolRequestType(WillSaveTextDocumentWaitUntilRequest.method);
5848})(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
5849/**
5850 * The watched files notification is sent from the client to the server when
5851 * the client detects changes to file watched by the language client.
5852 */
5853var DidChangeWatchedFilesNotification;
5854(function (DidChangeWatchedFilesNotification) {
5855 DidChangeWatchedFilesNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWatchedFiles');
5856})(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
5857/**
5858 * The file event type
5859 */
5860var FileChangeType;
5861(function (FileChangeType) {
5862 /**
5863 * The file got created.
5864 */
5865 FileChangeType.Created = 1;
5866 /**
5867 * The file got changed.
5868 */
5869 FileChangeType.Changed = 2;
5870 /**
5871 * The file got deleted.
5872 */
5873 FileChangeType.Deleted = 3;
5874})(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
5875var WatchKind;
5876(function (WatchKind) {
5877 /**
5878 * Interested in create events.
5879 */
5880 WatchKind.Create = 1;
5881 /**
5882 * Interested in change events
5883 */
5884 WatchKind.Change = 2;
5885 /**
5886 * Interested in delete events
5887 */
5888 WatchKind.Delete = 4;
5889})(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
5890/**
5891 * Diagnostics notification are sent from the server to the client to signal
5892 * results of validation runs.
5893 */
5894var PublishDiagnosticsNotification;
5895(function (PublishDiagnosticsNotification) {
5896 PublishDiagnosticsNotification.type = new messages_1.ProtocolNotificationType('textDocument/publishDiagnostics');
5897})(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
5898/**
5899 * How a completion was triggered
5900 */
5901var CompletionTriggerKind;
5902(function (CompletionTriggerKind) {
5903 /**
5904 * Completion was triggered by typing an identifier (24x7 code
5905 * complete), manual invocation (e.g Ctrl+Space) or via API.
5906 */
5907 CompletionTriggerKind.Invoked = 1;
5908 /**
5909 * Completion was triggered by a trigger character specified by
5910 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
5911 */
5912 CompletionTriggerKind.TriggerCharacter = 2;
5913 /**
5914 * Completion was re-triggered as current completion list is incomplete
5915 */
5916 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
5917})(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
5918/**
5919 * Request to request completion at a given text document position. The request's
5920 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
5921 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
5922 * or a Thenable that resolves to such.
5923 *
5924 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
5925 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
5926 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
5927 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
5928 */
5929var CompletionRequest;
5930(function (CompletionRequest) {
5931 CompletionRequest.method = 'textDocument/completion';
5932 CompletionRequest.type = new messages_1.ProtocolRequestType(CompletionRequest.method);
5933})(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
5934/**
5935 * Request to resolve additional information for a given completion item.The request's
5936 * parameter is of type [CompletionItem](#CompletionItem) the response
5937 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
5938 */
5939var CompletionResolveRequest;
5940(function (CompletionResolveRequest) {
5941 CompletionResolveRequest.method = 'completionItem/resolve';
5942 CompletionResolveRequest.type = new messages_1.ProtocolRequestType(CompletionResolveRequest.method);
5943})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
5944/**
5945 * Request to request hover information at a given text document position. The request's
5946 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
5947 * type [Hover](#Hover) or a Thenable that resolves to such.
5948 */
5949var HoverRequest;
5950(function (HoverRequest) {
5951 HoverRequest.method = 'textDocument/hover';
5952 HoverRequest.type = new messages_1.ProtocolRequestType(HoverRequest.method);
5953})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
5954/**
5955 * How a signature help was triggered.
5956 *
5957 * @since 3.15.0
5958 */
5959var SignatureHelpTriggerKind;
5960(function (SignatureHelpTriggerKind) {
5961 /**
5962 * Signature help was invoked manually by the user or by a command.
5963 */
5964 SignatureHelpTriggerKind.Invoked = 1;
5965 /**
5966 * Signature help was triggered by a trigger character.
5967 */
5968 SignatureHelpTriggerKind.TriggerCharacter = 2;
5969 /**
5970 * Signature help was triggered by the cursor moving or by the document content changing.
5971 */
5972 SignatureHelpTriggerKind.ContentChange = 3;
5973})(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
5974var SignatureHelpRequest;
5975(function (SignatureHelpRequest) {
5976 SignatureHelpRequest.method = 'textDocument/signatureHelp';
5977 SignatureHelpRequest.type = new messages_1.ProtocolRequestType(SignatureHelpRequest.method);
5978})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
5979/**
5980 * A request to resolve the definition location of a symbol at a given text
5981 * document position. The request's parameter is of type [TextDocumentPosition]
5982 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
5983 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
5984 * to such.
5985 */
5986var DefinitionRequest;
5987(function (DefinitionRequest) {
5988 DefinitionRequest.method = 'textDocument/definition';
5989 DefinitionRequest.type = new messages_1.ProtocolRequestType(DefinitionRequest.method);
5990})(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
5991/**
5992 * A request to resolve project-wide references for the symbol denoted
5993 * by the given text document position. The request's parameter is of
5994 * type [ReferenceParams](#ReferenceParams) the response is of type
5995 * [Location[]](#Location) or a Thenable that resolves to such.
5996 */
5997var ReferencesRequest;
5998(function (ReferencesRequest) {
5999 ReferencesRequest.method = 'textDocument/references';
6000 ReferencesRequest.type = new messages_1.ProtocolRequestType(ReferencesRequest.method);
6001})(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
6002/**
6003 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
6004 * text document position. The request's parameter is of type [TextDocumentPosition]
6005 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
6006 * (#DocumentHighlight) or a Thenable that resolves to such.
6007 */
6008var DocumentHighlightRequest;
6009(function (DocumentHighlightRequest) {
6010 DocumentHighlightRequest.method = 'textDocument/documentHighlight';
6011 DocumentHighlightRequest.type = new messages_1.ProtocolRequestType(DocumentHighlightRequest.method);
6012})(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
6013/**
6014 * A request to list all symbols found in a given text document. The request's
6015 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
6016 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
6017 * that resolves to such.
6018 */
6019var DocumentSymbolRequest;
6020(function (DocumentSymbolRequest) {
6021 DocumentSymbolRequest.method = 'textDocument/documentSymbol';
6022 DocumentSymbolRequest.type = new messages_1.ProtocolRequestType(DocumentSymbolRequest.method);
6023})(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
6024/**
6025 * A request to provide commands for the given text document and range.
6026 */
6027var CodeActionRequest;
6028(function (CodeActionRequest) {
6029 CodeActionRequest.method = 'textDocument/codeAction';
6030 CodeActionRequest.type = new messages_1.ProtocolRequestType(CodeActionRequest.method);
6031})(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
6032/**
6033 * Request to resolve additional information for a given code action.The request's
6034 * parameter is of type [CodeAction](#CodeAction) the response
6035 * is of type [CodeAction](#CodeAction) or a Thenable that resolves to such.
6036 */
6037var CodeActionResolveRequest;
6038(function (CodeActionResolveRequest) {
6039 CodeActionResolveRequest.method = 'codeAction/resolve';
6040 CodeActionResolveRequest.type = new messages_1.ProtocolRequestType(CodeActionResolveRequest.method);
6041})(CodeActionResolveRequest = exports.CodeActionResolveRequest || (exports.CodeActionResolveRequest = {}));
6042/**
6043 * A request to list project-wide symbols matching the query string given
6044 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
6045 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
6046 * resolves to such.
6047 */
6048var WorkspaceSymbolRequest;
6049(function (WorkspaceSymbolRequest) {
6050 WorkspaceSymbolRequest.method = 'workspace/symbol';
6051 WorkspaceSymbolRequest.type = new messages_1.ProtocolRequestType(WorkspaceSymbolRequest.method);
6052})(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
6053/**
6054 * A request to provide code lens for the given text document.
6055 */
6056var CodeLensRequest;
6057(function (CodeLensRequest) {
6058 CodeLensRequest.method = 'textDocument/codeLens';
6059 CodeLensRequest.type = new messages_1.ProtocolRequestType(CodeLensRequest.method);
6060})(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
6061/**
6062 * A request to resolve a command for a given code lens.
6063 */
6064var CodeLensResolveRequest;
6065(function (CodeLensResolveRequest) {
6066 CodeLensResolveRequest.method = 'codeLens/resolve';
6067 CodeLensResolveRequest.type = new messages_1.ProtocolRequestType(CodeLensResolveRequest.method);
6068})(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
6069/**
6070 * A request to refresh all code actions
6071 *
6072 * @since 3.16.0
6073 */
6074var CodeLensRefreshRequest;
6075(function (CodeLensRefreshRequest) {
6076 CodeLensRefreshRequest.method = `workspace/codeLens/refresh`;
6077 CodeLensRefreshRequest.type = new messages_1.ProtocolRequestType0(CodeLensRefreshRequest.method);
6078})(CodeLensRefreshRequest = exports.CodeLensRefreshRequest || (exports.CodeLensRefreshRequest = {}));
6079/**
6080 * A request to provide document links
6081 */
6082var DocumentLinkRequest;
6083(function (DocumentLinkRequest) {
6084 DocumentLinkRequest.method = 'textDocument/documentLink';
6085 DocumentLinkRequest.type = new messages_1.ProtocolRequestType(DocumentLinkRequest.method);
6086})(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
6087/**
6088 * Request to resolve additional information for a given document link. The request's
6089 * parameter is of type [DocumentLink](#DocumentLink) the response
6090 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
6091 */
6092var DocumentLinkResolveRequest;
6093(function (DocumentLinkResolveRequest) {
6094 DocumentLinkResolveRequest.method = 'documentLink/resolve';
6095 DocumentLinkResolveRequest.type = new messages_1.ProtocolRequestType(DocumentLinkResolveRequest.method);
6096})(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
6097/**
6098 * A request to to format a whole document.
6099 */
6100var DocumentFormattingRequest;
6101(function (DocumentFormattingRequest) {
6102 DocumentFormattingRequest.method = 'textDocument/formatting';
6103 DocumentFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentFormattingRequest.method);
6104})(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
6105/**
6106 * A request to to format a range in a document.
6107 */
6108var DocumentRangeFormattingRequest;
6109(function (DocumentRangeFormattingRequest) {
6110 DocumentRangeFormattingRequest.method = 'textDocument/rangeFormatting';
6111 DocumentRangeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentRangeFormattingRequest.method);
6112})(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
6113/**
6114 * A request to format a document on type.
6115 */
6116var DocumentOnTypeFormattingRequest;
6117(function (DocumentOnTypeFormattingRequest) {
6118 DocumentOnTypeFormattingRequest.method = 'textDocument/onTypeFormatting';
6119 DocumentOnTypeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentOnTypeFormattingRequest.method);
6120})(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
6121//---- Rename ----------------------------------------------
6122var PrepareSupportDefaultBehavior;
6123(function (PrepareSupportDefaultBehavior) {
6124 /**
6125 * The client's default behavior is to select the identifier
6126 * according the to language's syntax rule.
6127 */
6128 PrepareSupportDefaultBehavior.Identifier = 1;
6129})(PrepareSupportDefaultBehavior = exports.PrepareSupportDefaultBehavior || (exports.PrepareSupportDefaultBehavior = {}));
6130/**
6131 * A request to rename a symbol.
6132 */
6133var RenameRequest;
6134(function (RenameRequest) {
6135 RenameRequest.method = 'textDocument/rename';
6136 RenameRequest.type = new messages_1.ProtocolRequestType(RenameRequest.method);
6137})(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
6138/**
6139 * A request to test and perform the setup necessary for a rename.
6140 *
6141 * @since 3.16 - support for default behavior
6142 */
6143var PrepareRenameRequest;
6144(function (PrepareRenameRequest) {
6145 PrepareRenameRequest.method = 'textDocument/prepareRename';
6146 PrepareRenameRequest.type = new messages_1.ProtocolRequestType(PrepareRenameRequest.method);
6147})(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
6148/**
6149 * A request send from the client to the server to execute a command. The request might return
6150 * a workspace edit which the client will apply to the workspace.
6151 */
6152var ExecuteCommandRequest;
6153(function (ExecuteCommandRequest) {
6154 ExecuteCommandRequest.type = new messages_1.ProtocolRequestType('workspace/executeCommand');
6155})(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
6156/**
6157 * A request sent from the server to the client to modified certain resources.
6158 */
6159var ApplyWorkspaceEditRequest;
6160(function (ApplyWorkspaceEditRequest) {
6161 ApplyWorkspaceEditRequest.type = new messages_1.ProtocolRequestType('workspace/applyEdit');
6162})(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
6163//# sourceMappingURL=protocol.js.map
6164
6165/***/ }),
6166
6167/***/ 44:
6168/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6169
6170"use strict";
6171
6172/*---------------------------------------------------------------------------------------------
6173 * Copyright (c) Microsoft Corporation. All rights reserved.
6174 * Licensed under the MIT License. See License.txt in the project root for license information.
6175 *--------------------------------------------------------------------------------------------*/
6176Object.defineProperty(exports, "__esModule", ({ value: true }));
6177exports.LinkedEditingRangeRequest = void 0;
6178const messages_1 = __webpack_require__(29);
6179/**
6180 * A request to provide ranges that can be edited together.
6181 *
6182 * @since 3.16.0
6183 */
6184var LinkedEditingRangeRequest;
6185(function (LinkedEditingRangeRequest) {
6186 LinkedEditingRangeRequest.method = 'textDocument/linkedEditingRange';
6187 LinkedEditingRangeRequest.type = new messages_1.ProtocolRequestType(LinkedEditingRangeRequest.method);
6188})(LinkedEditingRangeRequest = exports.LinkedEditingRangeRequest || (exports.LinkedEditingRangeRequest = {}));
6189//# sourceMappingURL=protocol.linkedEditingRange.js.map
6190
6191/***/ }),
6192
6193/***/ 46:
6194/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6195
6196"use strict";
6197
6198/* --------------------------------------------------------------------------------------------
6199 * Copyright (c) Microsoft Corporation. All rights reserved.
6200 * Licensed under the MIT License. See License.txt in the project root for license information.
6201 * ------------------------------------------------------------------------------------------ */
6202Object.defineProperty(exports, "__esModule", ({ value: true }));
6203exports.MonikerRequest = exports.MonikerKind = exports.UniquenessLevel = void 0;
6204const messages_1 = __webpack_require__(29);
6205/**
6206 * Moniker uniqueness level to define scope of the moniker.
6207 *
6208 * @since 3.16.0
6209 */
6210var UniquenessLevel;
6211(function (UniquenessLevel) {
6212 /**
6213 * The moniker is only unique inside a document
6214 */
6215 UniquenessLevel["document"] = "document";
6216 /**
6217 * The moniker is unique inside a project for which a dump got created
6218 */
6219 UniquenessLevel["project"] = "project";
6220 /**
6221 * The moniker is unique inside the group to which a project belongs
6222 */
6223 UniquenessLevel["group"] = "group";
6224 /**
6225 * The moniker is unique inside the moniker scheme.
6226 */
6227 UniquenessLevel["scheme"] = "scheme";
6228 /**
6229 * The moniker is globally unique
6230 */
6231 UniquenessLevel["global"] = "global";
6232})(UniquenessLevel = exports.UniquenessLevel || (exports.UniquenessLevel = {}));
6233/**
6234 * The moniker kind.
6235 *
6236 * @since 3.16.0
6237 */
6238var MonikerKind;
6239(function (MonikerKind) {
6240 /**
6241 * The moniker represent a symbol that is imported into a project
6242 */
6243 MonikerKind["import"] = "import";
6244 /**
6245 * The moniker represents a symbol that is exported from a project
6246 */
6247 MonikerKind["export"] = "export";
6248 /**
6249 * The moniker represents a symbol that is local to a project (e.g. a local
6250 * variable of a function, a class not visible outside the project, ...)
6251 */
6252 MonikerKind["local"] = "local";
6253})(MonikerKind = exports.MonikerKind || (exports.MonikerKind = {}));
6254/**
6255 * A request to get the moniker of a symbol at a given text document position.
6256 * The request parameter is of type [TextDocumentPositionParams](#TextDocumentPositionParams).
6257 * The response is of type [Moniker[]](#Moniker[]) or `null`.
6258 */
6259var MonikerRequest;
6260(function (MonikerRequest) {
6261 MonikerRequest.method = 'textDocument/moniker';
6262 MonikerRequest.type = new messages_1.ProtocolRequestType(MonikerRequest.method);
6263})(MonikerRequest = exports.MonikerRequest || (exports.MonikerRequest = {}));
6264//# sourceMappingURL=protocol.moniker.js.map
6265
6266/***/ }),
6267
6268/***/ 40:
6269/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6270
6271"use strict";
6272
6273/* --------------------------------------------------------------------------------------------
6274 * Copyright (c) Microsoft Corporation. All rights reserved.
6275 * Licensed under the MIT License. See License.txt in the project root for license information.
6276 * ------------------------------------------------------------------------------------------ */
6277Object.defineProperty(exports, "__esModule", ({ value: true }));
6278exports.WorkDoneProgressCancelNotification = exports.WorkDoneProgressCreateRequest = exports.WorkDoneProgress = void 0;
6279const vscode_jsonrpc_1 = __webpack_require__(7);
6280const messages_1 = __webpack_require__(29);
6281var WorkDoneProgress;
6282(function (WorkDoneProgress) {
6283 WorkDoneProgress.type = new vscode_jsonrpc_1.ProgressType();
6284 function is(value) {
6285 return value === WorkDoneProgress.type;
6286 }
6287 WorkDoneProgress.is = is;
6288})(WorkDoneProgress = exports.WorkDoneProgress || (exports.WorkDoneProgress = {}));
6289/**
6290 * The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
6291 * reporting from the server.
6292 */
6293var WorkDoneProgressCreateRequest;
6294(function (WorkDoneProgressCreateRequest) {
6295 WorkDoneProgressCreateRequest.type = new messages_1.ProtocolRequestType('window/workDoneProgress/create');
6296})(WorkDoneProgressCreateRequest = exports.WorkDoneProgressCreateRequest || (exports.WorkDoneProgressCreateRequest = {}));
6297/**
6298 * The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
6299 * initiated on the server side.
6300 */
6301var WorkDoneProgressCancelNotification;
6302(function (WorkDoneProgressCancelNotification) {
6303 WorkDoneProgressCancelNotification.type = new messages_1.ProtocolNotificationType('window/workDoneProgress/cancel');
6304})(WorkDoneProgressCancelNotification = exports.WorkDoneProgressCancelNotification || (exports.WorkDoneProgressCancelNotification = {}));
6305//# sourceMappingURL=protocol.progress.js.map
6306
6307/***/ }),
6308
6309/***/ 39:
6310/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6311
6312"use strict";
6313
6314/*---------------------------------------------------------------------------------------------
6315 * Copyright (c) Microsoft Corporation. All rights reserved.
6316 * Licensed under the MIT License. See License.txt in the project root for license information.
6317 *--------------------------------------------------------------------------------------------*/
6318Object.defineProperty(exports, "__esModule", ({ value: true }));
6319exports.SelectionRangeRequest = void 0;
6320const messages_1 = __webpack_require__(29);
6321/**
6322 * A request to provide selection ranges in a document. The request's
6323 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
6324 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
6325 * that resolves to such.
6326 */
6327var SelectionRangeRequest;
6328(function (SelectionRangeRequest) {
6329 SelectionRangeRequest.method = 'textDocument/selectionRange';
6330 SelectionRangeRequest.type = new messages_1.ProtocolRequestType(SelectionRangeRequest.method);
6331})(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
6332//# sourceMappingURL=protocol.selectionRange.js.map
6333
6334/***/ }),
6335
6336/***/ 42:
6337/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6338
6339"use strict";
6340
6341/* --------------------------------------------------------------------------------------------
6342 * Copyright (c) Microsoft Corporation. All rights reserved.
6343 * Licensed under the MIT License. See License.txt in the project root for license information.
6344 * ------------------------------------------------------------------------------------------ */
6345Object.defineProperty(exports, "__esModule", ({ value: true }));
6346exports.SemanticTokensRefreshRequest = exports.SemanticTokensRangeRequest = exports.SemanticTokensDeltaRequest = exports.SemanticTokensRequest = exports.SemanticTokensRegistrationType = exports.TokenFormat = exports.SemanticTokens = exports.SemanticTokenModifiers = exports.SemanticTokenTypes = void 0;
6347const messages_1 = __webpack_require__(29);
6348/**
6349 * A set of predefined token types. This set is not fixed
6350 * an clients can specify additional token types via the
6351 * corresponding client capabilities.
6352 *
6353 * @since 3.16.0
6354 */
6355var SemanticTokenTypes;
6356(function (SemanticTokenTypes) {
6357 SemanticTokenTypes["namespace"] = "namespace";
6358 /**
6359 * Represents a generic type. Acts as a fallback for types which can't be mapped to
6360 * a specific type like class or enum.
6361 */
6362 SemanticTokenTypes["type"] = "type";
6363 SemanticTokenTypes["class"] = "class";
6364 SemanticTokenTypes["enum"] = "enum";
6365 SemanticTokenTypes["interface"] = "interface";
6366 SemanticTokenTypes["struct"] = "struct";
6367 SemanticTokenTypes["typeParameter"] = "typeParameter";
6368 SemanticTokenTypes["parameter"] = "parameter";
6369 SemanticTokenTypes["variable"] = "variable";
6370 SemanticTokenTypes["property"] = "property";
6371 SemanticTokenTypes["enumMember"] = "enumMember";
6372 SemanticTokenTypes["event"] = "event";
6373 SemanticTokenTypes["function"] = "function";
6374 SemanticTokenTypes["method"] = "method";
6375 SemanticTokenTypes["macro"] = "macro";
6376 SemanticTokenTypes["keyword"] = "keyword";
6377 SemanticTokenTypes["modifier"] = "modifier";
6378 SemanticTokenTypes["comment"] = "comment";
6379 SemanticTokenTypes["string"] = "string";
6380 SemanticTokenTypes["number"] = "number";
6381 SemanticTokenTypes["regexp"] = "regexp";
6382 SemanticTokenTypes["operator"] = "operator";
6383})(SemanticTokenTypes = exports.SemanticTokenTypes || (exports.SemanticTokenTypes = {}));
6384/**
6385 * A set of predefined token modifiers. This set is not fixed
6386 * an clients can specify additional token types via the
6387 * corresponding client capabilities.
6388 *
6389 * @since 3.16.0
6390 */
6391var SemanticTokenModifiers;
6392(function (SemanticTokenModifiers) {
6393 SemanticTokenModifiers["declaration"] = "declaration";
6394 SemanticTokenModifiers["definition"] = "definition";
6395 SemanticTokenModifiers["readonly"] = "readonly";
6396 SemanticTokenModifiers["static"] = "static";
6397 SemanticTokenModifiers["deprecated"] = "deprecated";
6398 SemanticTokenModifiers["abstract"] = "abstract";
6399 SemanticTokenModifiers["async"] = "async";
6400 SemanticTokenModifiers["modification"] = "modification";
6401 SemanticTokenModifiers["documentation"] = "documentation";
6402 SemanticTokenModifiers["defaultLibrary"] = "defaultLibrary";
6403})(SemanticTokenModifiers = exports.SemanticTokenModifiers || (exports.SemanticTokenModifiers = {}));
6404/**
6405 * @since 3.16.0
6406 */
6407var SemanticTokens;
6408(function (SemanticTokens) {
6409 function is(value) {
6410 const candidate = value;
6411 return candidate !== undefined && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
6412 Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
6413 }
6414 SemanticTokens.is = is;
6415})(SemanticTokens = exports.SemanticTokens || (exports.SemanticTokens = {}));
6416//------- 'textDocument/semanticTokens' -----
6417var TokenFormat;
6418(function (TokenFormat) {
6419 TokenFormat.Relative = 'relative';
6420})(TokenFormat = exports.TokenFormat || (exports.TokenFormat = {}));
6421var SemanticTokensRegistrationType;
6422(function (SemanticTokensRegistrationType) {
6423 SemanticTokensRegistrationType.method = 'textDocument/semanticTokens';
6424 SemanticTokensRegistrationType.type = new messages_1.RegistrationType(SemanticTokensRegistrationType.method);
6425})(SemanticTokensRegistrationType = exports.SemanticTokensRegistrationType || (exports.SemanticTokensRegistrationType = {}));
6426/**
6427 * @since 3.16.0
6428 */
6429var SemanticTokensRequest;
6430(function (SemanticTokensRequest) {
6431 SemanticTokensRequest.method = 'textDocument/semanticTokens/full';
6432 SemanticTokensRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRequest.method);
6433})(SemanticTokensRequest = exports.SemanticTokensRequest || (exports.SemanticTokensRequest = {}));
6434/**
6435 * @since 3.16.0
6436 */
6437var SemanticTokensDeltaRequest;
6438(function (SemanticTokensDeltaRequest) {
6439 SemanticTokensDeltaRequest.method = 'textDocument/semanticTokens/full/delta';
6440 SemanticTokensDeltaRequest.type = new messages_1.ProtocolRequestType(SemanticTokensDeltaRequest.method);
6441})(SemanticTokensDeltaRequest = exports.SemanticTokensDeltaRequest || (exports.SemanticTokensDeltaRequest = {}));
6442/**
6443 * @since 3.16.0
6444 */
6445var SemanticTokensRangeRequest;
6446(function (SemanticTokensRangeRequest) {
6447 SemanticTokensRangeRequest.method = 'textDocument/semanticTokens/range';
6448 SemanticTokensRangeRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRangeRequest.method);
6449})(SemanticTokensRangeRequest = exports.SemanticTokensRangeRequest || (exports.SemanticTokensRangeRequest = {}));
6450/**
6451 * @since 3.16.0
6452 */
6453var SemanticTokensRefreshRequest;
6454(function (SemanticTokensRefreshRequest) {
6455 SemanticTokensRefreshRequest.method = `workspace/semanticTokens/refresh`;
6456 SemanticTokensRefreshRequest.type = new messages_1.ProtocolRequestType0(SemanticTokensRefreshRequest.method);
6457})(SemanticTokensRefreshRequest = exports.SemanticTokensRefreshRequest || (exports.SemanticTokensRefreshRequest = {}));
6458//# sourceMappingURL=protocol.semanticTokens.js.map
6459
6460/***/ }),
6461
6462/***/ 43:
6463/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6464
6465"use strict";
6466
6467/* --------------------------------------------------------------------------------------------
6468 * Copyright (c) Microsoft Corporation. All rights reserved.
6469 * Licensed under the MIT License. See License.txt in the project root for license information.
6470 * ------------------------------------------------------------------------------------------ */
6471Object.defineProperty(exports, "__esModule", ({ value: true }));
6472exports.ShowDocumentRequest = void 0;
6473const messages_1 = __webpack_require__(29);
6474/**
6475 * A request to show a document. This request might open an
6476 * external program depending on the value of the URI to open.
6477 * For example a request to open `https://code.visualstudio.com/`
6478 * will very likely open the URI in a WEB browser.
6479 *
6480 * @since 3.16.0
6481*/
6482var ShowDocumentRequest;
6483(function (ShowDocumentRequest) {
6484 ShowDocumentRequest.method = 'window/showDocument';
6485 ShowDocumentRequest.type = new messages_1.ProtocolRequestType(ShowDocumentRequest.method);
6486})(ShowDocumentRequest = exports.ShowDocumentRequest || (exports.ShowDocumentRequest = {}));
6487//# sourceMappingURL=protocol.showDocument.js.map
6488
6489/***/ }),
6490
6491/***/ 33:
6492/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6493
6494"use strict";
6495
6496/* --------------------------------------------------------------------------------------------
6497 * Copyright (c) Microsoft Corporation. All rights reserved.
6498 * Licensed under the MIT License. See License.txt in the project root for license information.
6499 * ------------------------------------------------------------------------------------------ */
6500Object.defineProperty(exports, "__esModule", ({ value: true }));
6501exports.TypeDefinitionRequest = void 0;
6502const messages_1 = __webpack_require__(29);
6503// @ts-ignore: to avoid inlining LocatioLink as dynamic import
6504let __noDynamicImport;
6505/**
6506 * A request to resolve the type definition locations of a symbol at a given text
6507 * document position. The request's parameter is of type [TextDocumentPositioParams]
6508 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
6509 * Thenable that resolves to such.
6510 */
6511var TypeDefinitionRequest;
6512(function (TypeDefinitionRequest) {
6513 TypeDefinitionRequest.method = 'textDocument/typeDefinition';
6514 TypeDefinitionRequest.type = new messages_1.ProtocolRequestType(TypeDefinitionRequest.method);
6515})(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
6516//# sourceMappingURL=protocol.typeDefinition.js.map
6517
6518/***/ }),
6519
6520/***/ 34:
6521/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6522
6523"use strict";
6524
6525/* --------------------------------------------------------------------------------------------
6526 * Copyright (c) Microsoft Corporation. All rights reserved.
6527 * Licensed under the MIT License. See License.txt in the project root for license information.
6528 * ------------------------------------------------------------------------------------------ */
6529Object.defineProperty(exports, "__esModule", ({ value: true }));
6530exports.DidChangeWorkspaceFoldersNotification = exports.WorkspaceFoldersRequest = void 0;
6531const messages_1 = __webpack_require__(29);
6532/**
6533 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
6534 */
6535var WorkspaceFoldersRequest;
6536(function (WorkspaceFoldersRequest) {
6537 WorkspaceFoldersRequest.type = new messages_1.ProtocolRequestType0('workspace/workspaceFolders');
6538})(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
6539/**
6540 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
6541 * folder configuration changes.
6542 */
6543var DidChangeWorkspaceFoldersNotification;
6544(function (DidChangeWorkspaceFoldersNotification) {
6545 DidChangeWorkspaceFoldersNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWorkspaceFolders');
6546})(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
6547//# sourceMappingURL=protocol.workspaceFolders.js.map
6548
6549/***/ }),
6550
6551/***/ 31:
6552/***/ ((__unused_webpack_module, exports) => {
6553
6554"use strict";
6555/* --------------------------------------------------------------------------------------------
6556 * Copyright (c) Microsoft Corporation. All rights reserved.
6557 * Licensed under the MIT License. See License.txt in the project root for license information.
6558 * ------------------------------------------------------------------------------------------ */
6559
6560Object.defineProperty(exports, "__esModule", ({ value: true }));
6561exports.objectLiteral = exports.typedArray = exports.stringArray = exports.array = exports.func = exports.error = exports.number = exports.string = exports.boolean = void 0;
6562function boolean(value) {
6563 return value === true || value === false;
6564}
6565exports.boolean = boolean;
6566function string(value) {
6567 return typeof value === 'string' || value instanceof String;
6568}
6569exports.string = string;
6570function number(value) {
6571 return typeof value === 'number' || value instanceof Number;
6572}
6573exports.number = number;
6574function error(value) {
6575 return value instanceof Error;
6576}
6577exports.error = error;
6578function func(value) {
6579 return typeof value === 'function';
6580}
6581exports.func = func;
6582function array(value) {
6583 return Array.isArray(value);
6584}
6585exports.array = array;
6586function stringArray(value) {
6587 return array(value) && value.every(elem => string(elem));
6588}
6589exports.stringArray = stringArray;
6590function typedArray(value, check) {
6591 return Array.isArray(value) && value.every(check);
6592}
6593exports.typedArray = typedArray;
6594function objectLiteral(value) {
6595 // Strictly speaking class instances pass this check as well. Since the LSP
6596 // doesn't use classes we ignore this for now. If we do we need to add something
6597 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
6598 return value !== null && typeof value === 'object';
6599}
6600exports.objectLiteral = objectLiteral;
6601//# sourceMappingURL=is.js.map
6602
6603/***/ }),
6604
6605/***/ 5:
6606/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
6607
6608"use strict";
6609
6610/* --------------------------------------------------------------------------------------------
6611 * Copyright (c) Microsoft Corporation. All rights reserved.
6612 * Licensed under the MIT License. See License.txt in the project root for license information.
6613 * ------------------------------------------------------------------------------------------ */
6614var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6615 if (k2 === undefined) k2 = k;
6616 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6617}) : (function(o, m, k, k2) {
6618 if (k2 === undefined) k2 = k;
6619 o[k2] = m[k];
6620}));
6621var __exportStar = (this && this.__exportStar) || function(m, exports) {
6622 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6623};
6624Object.defineProperty(exports, "__esModule", ({ value: true }));
6625exports.createProtocolConnection = void 0;
6626const node_1 = __webpack_require__(6);
6627__exportStar(__webpack_require__(6), exports);
6628__exportStar(__webpack_require__(27), exports);
6629function createProtocolConnection(input, output, logger, options) {
6630 return node_1.createMessageConnection(input, output, logger, options);
6631}
6632exports.createProtocolConnection = createProtocolConnection;
6633//# sourceMappingURL=main.js.map
6634
6635/***/ }),
6636
6637/***/ 62:
6638/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6639
6640"use strict";
6641/* --------------------------------------------------------------------------------------------
6642 * Copyright (c) Microsoft Corporation. All rights reserved.
6643 * Licensed under the MIT License. See License.txt in the project root for license information.
6644 * ----------------------------------------------------------------------------------------- */
6645
6646
6647module.exports = __webpack_require__(5);
6648
6649/***/ }),
6650
6651/***/ 28:
6652/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6653
6654"use strict";
6655__webpack_require__.r(__webpack_exports__);
6656/* harmony export */ __webpack_require__.d(__webpack_exports__, {
6657/* harmony export */ "integer": () => (/* binding */ integer),
6658/* harmony export */ "uinteger": () => (/* binding */ uinteger),
6659/* harmony export */ "Position": () => (/* binding */ Position),
6660/* harmony export */ "Range": () => (/* binding */ Range),
6661/* harmony export */ "Location": () => (/* binding */ Location),
6662/* harmony export */ "LocationLink": () => (/* binding */ LocationLink),
6663/* harmony export */ "Color": () => (/* binding */ Color),
6664/* harmony export */ "ColorInformation": () => (/* binding */ ColorInformation),
6665/* harmony export */ "ColorPresentation": () => (/* binding */ ColorPresentation),
6666/* harmony export */ "FoldingRangeKind": () => (/* binding */ FoldingRangeKind),
6667/* harmony export */ "FoldingRange": () => (/* binding */ FoldingRange),
6668/* harmony export */ "DiagnosticRelatedInformation": () => (/* binding */ DiagnosticRelatedInformation),
6669/* harmony export */ "DiagnosticSeverity": () => (/* binding */ DiagnosticSeverity),
6670/* harmony export */ "DiagnosticTag": () => (/* binding */ DiagnosticTag),
6671/* harmony export */ "CodeDescription": () => (/* binding */ CodeDescription),
6672/* harmony export */ "Diagnostic": () => (/* binding */ Diagnostic),
6673/* harmony export */ "Command": () => (/* binding */ Command),
6674/* harmony export */ "TextEdit": () => (/* binding */ TextEdit),
6675/* harmony export */ "ChangeAnnotation": () => (/* binding */ ChangeAnnotation),
6676/* harmony export */ "ChangeAnnotationIdentifier": () => (/* binding */ ChangeAnnotationIdentifier),
6677/* harmony export */ "AnnotatedTextEdit": () => (/* binding */ AnnotatedTextEdit),
6678/* harmony export */ "TextDocumentEdit": () => (/* binding */ TextDocumentEdit),
6679/* harmony export */ "CreateFile": () => (/* binding */ CreateFile),
6680/* harmony export */ "RenameFile": () => (/* binding */ RenameFile),
6681/* harmony export */ "DeleteFile": () => (/* binding */ DeleteFile),
6682/* harmony export */ "WorkspaceEdit": () => (/* binding */ WorkspaceEdit),
6683/* harmony export */ "WorkspaceChange": () => (/* binding */ WorkspaceChange),
6684/* harmony export */ "TextDocumentIdentifier": () => (/* binding */ TextDocumentIdentifier),
6685/* harmony export */ "VersionedTextDocumentIdentifier": () => (/* binding */ VersionedTextDocumentIdentifier),
6686/* harmony export */ "OptionalVersionedTextDocumentIdentifier": () => (/* binding */ OptionalVersionedTextDocumentIdentifier),
6687/* harmony export */ "TextDocumentItem": () => (/* binding */ TextDocumentItem),
6688/* harmony export */ "MarkupKind": () => (/* binding */ MarkupKind),
6689/* harmony export */ "MarkupContent": () => (/* binding */ MarkupContent),
6690/* harmony export */ "CompletionItemKind": () => (/* binding */ CompletionItemKind),
6691/* harmony export */ "InsertTextFormat": () => (/* binding */ InsertTextFormat),
6692/* harmony export */ "CompletionItemTag": () => (/* binding */ CompletionItemTag),
6693/* harmony export */ "InsertReplaceEdit": () => (/* binding */ InsertReplaceEdit),
6694/* harmony export */ "InsertTextMode": () => (/* binding */ InsertTextMode),
6695/* harmony export */ "CompletionItem": () => (/* binding */ CompletionItem),
6696/* harmony export */ "CompletionList": () => (/* binding */ CompletionList),
6697/* harmony export */ "MarkedString": () => (/* binding */ MarkedString),
6698/* harmony export */ "Hover": () => (/* binding */ Hover),
6699/* harmony export */ "ParameterInformation": () => (/* binding */ ParameterInformation),
6700/* harmony export */ "SignatureInformation": () => (/* binding */ SignatureInformation),
6701/* harmony export */ "DocumentHighlightKind": () => (/* binding */ DocumentHighlightKind),
6702/* harmony export */ "DocumentHighlight": () => (/* binding */ DocumentHighlight),
6703/* harmony export */ "SymbolKind": () => (/* binding */ SymbolKind),
6704/* harmony export */ "SymbolTag": () => (/* binding */ SymbolTag),
6705/* harmony export */ "SymbolInformation": () => (/* binding */ SymbolInformation),
6706/* harmony export */ "DocumentSymbol": () => (/* binding */ DocumentSymbol),
6707/* harmony export */ "CodeActionKind": () => (/* binding */ CodeActionKind),
6708/* harmony export */ "CodeActionContext": () => (/* binding */ CodeActionContext),
6709/* harmony export */ "CodeAction": () => (/* binding */ CodeAction),
6710/* harmony export */ "CodeLens": () => (/* binding */ CodeLens),
6711/* harmony export */ "FormattingOptions": () => (/* binding */ FormattingOptions),
6712/* harmony export */ "DocumentLink": () => (/* binding */ DocumentLink),
6713/* harmony export */ "SelectionRange": () => (/* binding */ SelectionRange),
6714/* harmony export */ "EOL": () => (/* binding */ EOL),
6715/* harmony export */ "TextDocument": () => (/* binding */ TextDocument)
6716/* harmony export */ });
6717/* --------------------------------------------------------------------------------------------
6718 * Copyright (c) Microsoft Corporation. All rights reserved.
6719 * Licensed under the MIT License. See License.txt in the project root for license information.
6720 * ------------------------------------------------------------------------------------------ */
6721
6722var integer;
6723(function (integer) {
6724 integer.MIN_VALUE = -2147483648;
6725 integer.MAX_VALUE = 2147483647;
6726})(integer || (integer = {}));
6727var uinteger;
6728(function (uinteger) {
6729 uinteger.MIN_VALUE = 0;
6730 uinteger.MAX_VALUE = 2147483647;
6731})(uinteger || (uinteger = {}));
6732/**
6733 * The Position namespace provides helper functions to work with
6734 * [Position](#Position) literals.
6735 */
6736var Position;
6737(function (Position) {
6738 /**
6739 * Creates a new Position literal from the given line and character.
6740 * @param line The position's line.
6741 * @param character The position's character.
6742 */
6743 function create(line, character) {
6744 if (line === Number.MAX_VALUE) {
6745 line = uinteger.MAX_VALUE;
6746 }
6747 if (character === Number.MAX_VALUE) {
6748 character = uinteger.MAX_VALUE;
6749 }
6750 return { line: line, character: character };
6751 }
6752 Position.create = create;
6753 /**
6754 * Checks whether the given literal conforms to the [Position](#Position) interface.
6755 */
6756 function is(value) {
6757 var candidate = value;
6758 return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
6759 }
6760 Position.is = is;
6761})(Position || (Position = {}));
6762/**
6763 * The Range namespace provides helper functions to work with
6764 * [Range](#Range) literals.
6765 */
6766var Range;
6767(function (Range) {
6768 function create(one, two, three, four) {
6769 if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
6770 return { start: Position.create(one, two), end: Position.create(three, four) };
6771 }
6772 else if (Position.is(one) && Position.is(two)) {
6773 return { start: one, end: two };
6774 }
6775 else {
6776 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
6777 }
6778 }
6779 Range.create = create;
6780 /**
6781 * Checks whether the given literal conforms to the [Range](#Range) interface.
6782 */
6783 function is(value) {
6784 var candidate = value;
6785 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
6786 }
6787 Range.is = is;
6788})(Range || (Range = {}));
6789/**
6790 * The Location namespace provides helper functions to work with
6791 * [Location](#Location) literals.
6792 */
6793var Location;
6794(function (Location) {
6795 /**
6796 * Creates a Location literal.
6797 * @param uri The location's uri.
6798 * @param range The location's range.
6799 */
6800 function create(uri, range) {
6801 return { uri: uri, range: range };
6802 }
6803 Location.create = create;
6804 /**
6805 * Checks whether the given literal conforms to the [Location](#Location) interface.
6806 */
6807 function is(value) {
6808 var candidate = value;
6809 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
6810 }
6811 Location.is = is;
6812})(Location || (Location = {}));
6813/**
6814 * The LocationLink namespace provides helper functions to work with
6815 * [LocationLink](#LocationLink) literals.
6816 */
6817var LocationLink;
6818(function (LocationLink) {
6819 /**
6820 * Creates a LocationLink literal.
6821 * @param targetUri The definition's uri.
6822 * @param targetRange The full range of the definition.
6823 * @param targetSelectionRange The span of the symbol definition at the target.
6824 * @param originSelectionRange The span of the symbol being defined in the originating source file.
6825 */
6826 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
6827 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
6828 }
6829 LocationLink.create = create;
6830 /**
6831 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
6832 */
6833 function is(value) {
6834 var candidate = value;
6835 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
6836 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
6837 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
6838 }
6839 LocationLink.is = is;
6840})(LocationLink || (LocationLink = {}));
6841/**
6842 * The Color namespace provides helper functions to work with
6843 * [Color](#Color) literals.
6844 */
6845var Color;
6846(function (Color) {
6847 /**
6848 * Creates a new Color literal.
6849 */
6850 function create(red, green, blue, alpha) {
6851 return {
6852 red: red,
6853 green: green,
6854 blue: blue,
6855 alpha: alpha,
6856 };
6857 }
6858 Color.create = create;
6859 /**
6860 * Checks whether the given literal conforms to the [Color](#Color) interface.
6861 */
6862 function is(value) {
6863 var candidate = value;
6864 return Is.numberRange(candidate.red, 0, 1)
6865 && Is.numberRange(candidate.green, 0, 1)
6866 && Is.numberRange(candidate.blue, 0, 1)
6867 && Is.numberRange(candidate.alpha, 0, 1);
6868 }
6869 Color.is = is;
6870})(Color || (Color = {}));
6871/**
6872 * The ColorInformation namespace provides helper functions to work with
6873 * [ColorInformation](#ColorInformation) literals.
6874 */
6875var ColorInformation;
6876(function (ColorInformation) {
6877 /**
6878 * Creates a new ColorInformation literal.
6879 */
6880 function create(range, color) {
6881 return {
6882 range: range,
6883 color: color,
6884 };
6885 }
6886 ColorInformation.create = create;
6887 /**
6888 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
6889 */
6890 function is(value) {
6891 var candidate = value;
6892 return Range.is(candidate.range) && Color.is(candidate.color);
6893 }
6894 ColorInformation.is = is;
6895})(ColorInformation || (ColorInformation = {}));
6896/**
6897 * The Color namespace provides helper functions to work with
6898 * [ColorPresentation](#ColorPresentation) literals.
6899 */
6900var ColorPresentation;
6901(function (ColorPresentation) {
6902 /**
6903 * Creates a new ColorInformation literal.
6904 */
6905 function create(label, textEdit, additionalTextEdits) {
6906 return {
6907 label: label,
6908 textEdit: textEdit,
6909 additionalTextEdits: additionalTextEdits,
6910 };
6911 }
6912 ColorPresentation.create = create;
6913 /**
6914 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
6915 */
6916 function is(value) {
6917 var candidate = value;
6918 return Is.string(candidate.label)
6919 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
6920 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
6921 }
6922 ColorPresentation.is = is;
6923})(ColorPresentation || (ColorPresentation = {}));
6924/**
6925 * Enum of known range kinds
6926 */
6927var FoldingRangeKind;
6928(function (FoldingRangeKind) {
6929 /**
6930 * Folding range for a comment
6931 */
6932 FoldingRangeKind["Comment"] = "comment";
6933 /**
6934 * Folding range for a imports or includes
6935 */
6936 FoldingRangeKind["Imports"] = "imports";
6937 /**
6938 * Folding range for a region (e.g. `#region`)
6939 */
6940 FoldingRangeKind["Region"] = "region";
6941})(FoldingRangeKind || (FoldingRangeKind = {}));
6942/**
6943 * The folding range namespace provides helper functions to work with
6944 * [FoldingRange](#FoldingRange) literals.
6945 */
6946var FoldingRange;
6947(function (FoldingRange) {
6948 /**
6949 * Creates a new FoldingRange literal.
6950 */
6951 function create(startLine, endLine, startCharacter, endCharacter, kind) {
6952 var result = {
6953 startLine: startLine,
6954 endLine: endLine
6955 };
6956 if (Is.defined(startCharacter)) {
6957 result.startCharacter = startCharacter;
6958 }
6959 if (Is.defined(endCharacter)) {
6960 result.endCharacter = endCharacter;
6961 }
6962 if (Is.defined(kind)) {
6963 result.kind = kind;
6964 }
6965 return result;
6966 }
6967 FoldingRange.create = create;
6968 /**
6969 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
6970 */
6971 function is(value) {
6972 var candidate = value;
6973 return Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine)
6974 && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter))
6975 && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter))
6976 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
6977 }
6978 FoldingRange.is = is;
6979})(FoldingRange || (FoldingRange = {}));
6980/**
6981 * The DiagnosticRelatedInformation namespace provides helper functions to work with
6982 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
6983 */
6984var DiagnosticRelatedInformation;
6985(function (DiagnosticRelatedInformation) {
6986 /**
6987 * Creates a new DiagnosticRelatedInformation literal.
6988 */
6989 function create(location, message) {
6990 return {
6991 location: location,
6992 message: message
6993 };
6994 }
6995 DiagnosticRelatedInformation.create = create;
6996 /**
6997 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
6998 */
6999 function is(value) {
7000 var candidate = value;
7001 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
7002 }
7003 DiagnosticRelatedInformation.is = is;
7004})(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
7005/**
7006 * The diagnostic's severity.
7007 */
7008var DiagnosticSeverity;
7009(function (DiagnosticSeverity) {
7010 /**
7011 * Reports an error.
7012 */
7013 DiagnosticSeverity.Error = 1;
7014 /**
7015 * Reports a warning.
7016 */
7017 DiagnosticSeverity.Warning = 2;
7018 /**
7019 * Reports an information.
7020 */
7021 DiagnosticSeverity.Information = 3;
7022 /**
7023 * Reports a hint.
7024 */
7025 DiagnosticSeverity.Hint = 4;
7026})(DiagnosticSeverity || (DiagnosticSeverity = {}));
7027/**
7028 * The diagnostic tags.
7029 *
7030 * @since 3.15.0
7031 */
7032var DiagnosticTag;
7033(function (DiagnosticTag) {
7034 /**
7035 * Unused or unnecessary code.
7036 *
7037 * Clients are allowed to render diagnostics with this tag faded out instead of having
7038 * an error squiggle.
7039 */
7040 DiagnosticTag.Unnecessary = 1;
7041 /**
7042 * Deprecated or obsolete code.
7043 *
7044 * Clients are allowed to rendered diagnostics with this tag strike through.
7045 */
7046 DiagnosticTag.Deprecated = 2;
7047})(DiagnosticTag || (DiagnosticTag = {}));
7048/**
7049 * The CodeDescription namespace provides functions to deal with descriptions for diagnostic codes.
7050 *
7051 * @since 3.16.0
7052 */
7053var CodeDescription;
7054(function (CodeDescription) {
7055 function is(value) {
7056 var candidate = value;
7057 return candidate !== undefined && candidate !== null && Is.string(candidate.href);
7058 }
7059 CodeDescription.is = is;
7060})(CodeDescription || (CodeDescription = {}));
7061/**
7062 * The Diagnostic namespace provides helper functions to work with
7063 * [Diagnostic](#Diagnostic) literals.
7064 */
7065var Diagnostic;
7066(function (Diagnostic) {
7067 /**
7068 * Creates a new Diagnostic literal.
7069 */
7070 function create(range, message, severity, code, source, relatedInformation) {
7071 var result = { range: range, message: message };
7072 if (Is.defined(severity)) {
7073 result.severity = severity;
7074 }
7075 if (Is.defined(code)) {
7076 result.code = code;
7077 }
7078 if (Is.defined(source)) {
7079 result.source = source;
7080 }
7081 if (Is.defined(relatedInformation)) {
7082 result.relatedInformation = relatedInformation;
7083 }
7084 return result;
7085 }
7086 Diagnostic.create = create;
7087 /**
7088 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
7089 */
7090 function is(value) {
7091 var _a;
7092 var candidate = value;
7093 return Is.defined(candidate)
7094 && Range.is(candidate.range)
7095 && Is.string(candidate.message)
7096 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
7097 && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
7098 && (Is.undefined(candidate.codeDescription) || (Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)))
7099 && (Is.string(candidate.source) || Is.undefined(candidate.source))
7100 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
7101 }
7102 Diagnostic.is = is;
7103})(Diagnostic || (Diagnostic = {}));
7104/**
7105 * The Command namespace provides helper functions to work with
7106 * [Command](#Command) literals.
7107 */
7108var Command;
7109(function (Command) {
7110 /**
7111 * Creates a new Command literal.
7112 */
7113 function create(title, command) {
7114 var args = [];
7115 for (var _i = 2; _i < arguments.length; _i++) {
7116 args[_i - 2] = arguments[_i];
7117 }
7118 var result = { title: title, command: command };
7119 if (Is.defined(args) && args.length > 0) {
7120 result.arguments = args;
7121 }
7122 return result;
7123 }
7124 Command.create = create;
7125 /**
7126 * Checks whether the given literal conforms to the [Command](#Command) interface.
7127 */
7128 function is(value) {
7129 var candidate = value;
7130 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
7131 }
7132 Command.is = is;
7133})(Command || (Command = {}));
7134/**
7135 * The TextEdit namespace provides helper function to create replace,
7136 * insert and delete edits more easily.
7137 */
7138var TextEdit;
7139(function (TextEdit) {
7140 /**
7141 * Creates a replace text edit.
7142 * @param range The range of text to be replaced.
7143 * @param newText The new text.
7144 */
7145 function replace(range, newText) {
7146 return { range: range, newText: newText };
7147 }
7148 TextEdit.replace = replace;
7149 /**
7150 * Creates a insert text edit.
7151 * @param position The position to insert the text at.
7152 * @param newText The text to be inserted.
7153 */
7154 function insert(position, newText) {
7155 return { range: { start: position, end: position }, newText: newText };
7156 }
7157 TextEdit.insert = insert;
7158 /**
7159 * Creates a delete text edit.
7160 * @param range The range of text to be deleted.
7161 */
7162 function del(range) {
7163 return { range: range, newText: '' };
7164 }
7165 TextEdit.del = del;
7166 function is(value) {
7167 var candidate = value;
7168 return Is.objectLiteral(candidate)
7169 && Is.string(candidate.newText)
7170 && Range.is(candidate.range);
7171 }
7172 TextEdit.is = is;
7173})(TextEdit || (TextEdit = {}));
7174var ChangeAnnotation;
7175(function (ChangeAnnotation) {
7176 function create(label, needsConfirmation, description) {
7177 var result = { label: label };
7178 if (needsConfirmation !== undefined) {
7179 result.needsConfirmation = needsConfirmation;
7180 }
7181 if (description !== undefined) {
7182 result.description = description;
7183 }
7184 return result;
7185 }
7186 ChangeAnnotation.create = create;
7187 function is(value) {
7188 var candidate = value;
7189 return candidate !== undefined && Is.objectLiteral(candidate) && Is.string(candidate.label) &&
7190 (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === undefined) &&
7191 (Is.string(candidate.description) || candidate.description === undefined);
7192 }
7193 ChangeAnnotation.is = is;
7194})(ChangeAnnotation || (ChangeAnnotation = {}));
7195var ChangeAnnotationIdentifier;
7196(function (ChangeAnnotationIdentifier) {
7197 function is(value) {
7198 var candidate = value;
7199 return typeof candidate === 'string';
7200 }
7201 ChangeAnnotationIdentifier.is = is;
7202})(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
7203var AnnotatedTextEdit;
7204(function (AnnotatedTextEdit) {
7205 /**
7206 * Creates an annotated replace text edit.
7207 *
7208 * @param range The range of text to be replaced.
7209 * @param newText The new text.
7210 * @param annotation The annotation.
7211 */
7212 function replace(range, newText, annotation) {
7213 return { range: range, newText: newText, annotationId: annotation };
7214 }
7215 AnnotatedTextEdit.replace = replace;
7216 /**
7217 * Creates an annotated insert text edit.
7218 *
7219 * @param position The position to insert the text at.
7220 * @param newText The text to be inserted.
7221 * @param annotation The annotation.
7222 */
7223 function insert(position, newText, annotation) {
7224 return { range: { start: position, end: position }, newText: newText, annotationId: annotation };
7225 }
7226 AnnotatedTextEdit.insert = insert;
7227 /**
7228 * Creates an annotated delete text edit.
7229 *
7230 * @param range The range of text to be deleted.
7231 * @param annotation The annotation.
7232 */
7233 function del(range, annotation) {
7234 return { range: range, newText: '', annotationId: annotation };
7235 }
7236 AnnotatedTextEdit.del = del;
7237 function is(value) {
7238 var candidate = value;
7239 return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
7240 }
7241 AnnotatedTextEdit.is = is;
7242})(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
7243/**
7244 * The TextDocumentEdit namespace provides helper function to create
7245 * an edit that manipulates a text document.
7246 */
7247var TextDocumentEdit;
7248(function (TextDocumentEdit) {
7249 /**
7250 * Creates a new `TextDocumentEdit`
7251 */
7252 function create(textDocument, edits) {
7253 return { textDocument: textDocument, edits: edits };
7254 }
7255 TextDocumentEdit.create = create;
7256 function is(value) {
7257 var candidate = value;
7258 return Is.defined(candidate)
7259 && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument)
7260 && Array.isArray(candidate.edits);
7261 }
7262 TextDocumentEdit.is = is;
7263})(TextDocumentEdit || (TextDocumentEdit = {}));
7264var CreateFile;
7265(function (CreateFile) {
7266 function create(uri, options, annotation) {
7267 var result = {
7268 kind: 'create',
7269 uri: uri
7270 };
7271 if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) {
7272 result.options = options;
7273 }
7274 if (annotation !== undefined) {
7275 result.annotationId = annotation;
7276 }
7277 return result;
7278 }
7279 CreateFile.create = create;
7280 function is(value) {
7281 var candidate = value;
7282 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) && (candidate.options === undefined ||
7283 ((candidate.options.overwrite === undefined || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === undefined || Is.boolean(candidate.options.ignoreIfExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId));
7284 }
7285 CreateFile.is = is;
7286})(CreateFile || (CreateFile = {}));
7287var RenameFile;
7288(function (RenameFile) {
7289 function create(oldUri, newUri, options, annotation) {
7290 var result = {
7291 kind: 'rename',
7292 oldUri: oldUri,
7293 newUri: newUri
7294 };
7295 if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) {
7296 result.options = options;
7297 }
7298 if (annotation !== undefined) {
7299 result.annotationId = annotation;
7300 }
7301 return result;
7302 }
7303 RenameFile.create = create;
7304 function is(value) {
7305 var candidate = value;
7306 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === undefined ||
7307 ((candidate.options.overwrite === undefined || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === undefined || Is.boolean(candidate.options.ignoreIfExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId));
7308 }
7309 RenameFile.is = is;
7310})(RenameFile || (RenameFile = {}));
7311var DeleteFile;
7312(function (DeleteFile) {
7313 function create(uri, options, annotation) {
7314 var result = {
7315 kind: 'delete',
7316 uri: uri
7317 };
7318 if (options !== undefined && (options.recursive !== undefined || options.ignoreIfNotExists !== undefined)) {
7319 result.options = options;
7320 }
7321 if (annotation !== undefined) {
7322 result.annotationId = annotation;
7323 }
7324 return result;
7325 }
7326 DeleteFile.create = create;
7327 function is(value) {
7328 var candidate = value;
7329 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) && (candidate.options === undefined ||
7330 ((candidate.options.recursive === undefined || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === undefined || Is.boolean(candidate.options.ignoreIfNotExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId));
7331 }
7332 DeleteFile.is = is;
7333})(DeleteFile || (DeleteFile = {}));
7334var WorkspaceEdit;
7335(function (WorkspaceEdit) {
7336 function is(value) {
7337 var candidate = value;
7338 return candidate &&
7339 (candidate.changes !== undefined || candidate.documentChanges !== undefined) &&
7340 (candidate.documentChanges === undefined || candidate.documentChanges.every(function (change) {
7341 if (Is.string(change.kind)) {
7342 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
7343 }
7344 else {
7345 return TextDocumentEdit.is(change);
7346 }
7347 }));
7348 }
7349 WorkspaceEdit.is = is;
7350})(WorkspaceEdit || (WorkspaceEdit = {}));
7351var TextEditChangeImpl = /** @class */ (function () {
7352 function TextEditChangeImpl(edits, changeAnnotations) {
7353 this.edits = edits;
7354 this.changeAnnotations = changeAnnotations;
7355 }
7356 TextEditChangeImpl.prototype.insert = function (position, newText, annotation) {
7357 var edit;
7358 var id;
7359 if (annotation === undefined) {
7360 edit = TextEdit.insert(position, newText);
7361 }
7362 else if (ChangeAnnotationIdentifier.is(annotation)) {
7363 id = annotation;
7364 edit = AnnotatedTextEdit.insert(position, newText, annotation);
7365 }
7366 else {
7367 this.assertChangeAnnotations(this.changeAnnotations);
7368 id = this.changeAnnotations.manage(annotation);
7369 edit = AnnotatedTextEdit.insert(position, newText, id);
7370 }
7371 this.edits.push(edit);
7372 if (id !== undefined) {
7373 return id;
7374 }
7375 };
7376 TextEditChangeImpl.prototype.replace = function (range, newText, annotation) {
7377 var edit;
7378 var id;
7379 if (annotation === undefined) {
7380 edit = TextEdit.replace(range, newText);
7381 }
7382 else if (ChangeAnnotationIdentifier.is(annotation)) {
7383 id = annotation;
7384 edit = AnnotatedTextEdit.replace(range, newText, annotation);
7385 }
7386 else {
7387 this.assertChangeAnnotations(this.changeAnnotations);
7388 id = this.changeAnnotations.manage(annotation);
7389 edit = AnnotatedTextEdit.replace(range, newText, id);
7390 }
7391 this.edits.push(edit);
7392 if (id !== undefined) {
7393 return id;
7394 }
7395 };
7396 TextEditChangeImpl.prototype.delete = function (range, annotation) {
7397 var edit;
7398 var id;
7399 if (annotation === undefined) {
7400 edit = TextEdit.del(range);
7401 }
7402 else if (ChangeAnnotationIdentifier.is(annotation)) {
7403 id = annotation;
7404 edit = AnnotatedTextEdit.del(range, annotation);
7405 }
7406 else {
7407 this.assertChangeAnnotations(this.changeAnnotations);
7408 id = this.changeAnnotations.manage(annotation);
7409 edit = AnnotatedTextEdit.del(range, id);
7410 }
7411 this.edits.push(edit);
7412 if (id !== undefined) {
7413 return id;
7414 }
7415 };
7416 TextEditChangeImpl.prototype.add = function (edit) {
7417 this.edits.push(edit);
7418 };
7419 TextEditChangeImpl.prototype.all = function () {
7420 return this.edits;
7421 };
7422 TextEditChangeImpl.prototype.clear = function () {
7423 this.edits.splice(0, this.edits.length);
7424 };
7425 TextEditChangeImpl.prototype.assertChangeAnnotations = function (value) {
7426 if (value === undefined) {
7427 throw new Error("Text edit change is not configured to manage change annotations.");
7428 }
7429 };
7430 return TextEditChangeImpl;
7431}());
7432/**
7433 * A helper class
7434 */
7435var ChangeAnnotations = /** @class */ (function () {
7436 function ChangeAnnotations(annotations) {
7437 this._annotations = annotations === undefined ? Object.create(null) : annotations;
7438 this._counter = 0;
7439 this._size = 0;
7440 }
7441 ChangeAnnotations.prototype.all = function () {
7442 return this._annotations;
7443 };
7444 Object.defineProperty(ChangeAnnotations.prototype, "size", {
7445 get: function () {
7446 return this._size;
7447 },
7448 enumerable: false,
7449 configurable: true
7450 });
7451 ChangeAnnotations.prototype.manage = function (idOrAnnotation, annotation) {
7452 var id;
7453 if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
7454 id = idOrAnnotation;
7455 }
7456 else {
7457 id = this.nextId();
7458 annotation = idOrAnnotation;
7459 }
7460 if (this._annotations[id] !== undefined) {
7461 throw new Error("Id " + id + " is already in use.");
7462 }
7463 if (annotation === undefined) {
7464 throw new Error("No annotation provided for id " + id);
7465 }
7466 this._annotations[id] = annotation;
7467 this._size++;
7468 return id;
7469 };
7470 ChangeAnnotations.prototype.nextId = function () {
7471 this._counter++;
7472 return this._counter.toString();
7473 };
7474 return ChangeAnnotations;
7475}());
7476/**
7477 * A workspace change helps constructing changes to a workspace.
7478 */
7479var WorkspaceChange = /** @class */ (function () {
7480 function WorkspaceChange(workspaceEdit) {
7481 var _this = this;
7482 this._textEditChanges = Object.create(null);
7483 if (workspaceEdit !== undefined) {
7484 this._workspaceEdit = workspaceEdit;
7485 if (workspaceEdit.documentChanges) {
7486 this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
7487 workspaceEdit.changeAnnotations = this._changeAnnotations.all();
7488 workspaceEdit.documentChanges.forEach(function (change) {
7489 if (TextDocumentEdit.is(change)) {
7490 var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
7491 _this._textEditChanges[change.textDocument.uri] = textEditChange;
7492 }
7493 });
7494 }
7495 else if (workspaceEdit.changes) {
7496 Object.keys(workspaceEdit.changes).forEach(function (key) {
7497 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
7498 _this._textEditChanges[key] = textEditChange;
7499 });
7500 }
7501 }
7502 else {
7503 this._workspaceEdit = {};
7504 }
7505 }
7506 Object.defineProperty(WorkspaceChange.prototype, "edit", {
7507 /**
7508 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
7509 * use to be returned from a workspace edit operation like rename.
7510 */
7511 get: function () {
7512 this.initDocumentChanges();
7513 if (this._changeAnnotations !== undefined) {
7514 if (this._changeAnnotations.size === 0) {
7515 this._workspaceEdit.changeAnnotations = undefined;
7516 }
7517 else {
7518 this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
7519 }
7520 }
7521 return this._workspaceEdit;
7522 },
7523 enumerable: false,
7524 configurable: true
7525 });
7526 WorkspaceChange.prototype.getTextEditChange = function (key) {
7527 if (OptionalVersionedTextDocumentIdentifier.is(key)) {
7528 this.initDocumentChanges();
7529 if (this._workspaceEdit.documentChanges === undefined) {
7530 throw new Error('Workspace edit is not configured for document changes.');
7531 }
7532 var textDocument = { uri: key.uri, version: key.version };
7533 var result = this._textEditChanges[textDocument.uri];
7534 if (!result) {
7535 var edits = [];
7536 var textDocumentEdit = {
7537 textDocument: textDocument,
7538 edits: edits
7539 };
7540 this._workspaceEdit.documentChanges.push(textDocumentEdit);
7541 result = new TextEditChangeImpl(edits, this._changeAnnotations);
7542 this._textEditChanges[textDocument.uri] = result;
7543 }
7544 return result;
7545 }
7546 else {
7547 this.initChanges();
7548 if (this._workspaceEdit.changes === undefined) {
7549 throw new Error('Workspace edit is not configured for normal text edit changes.');
7550 }
7551 var result = this._textEditChanges[key];
7552 if (!result) {
7553 var edits = [];
7554 this._workspaceEdit.changes[key] = edits;
7555 result = new TextEditChangeImpl(edits);
7556 this._textEditChanges[key] = result;
7557 }
7558 return result;
7559 }
7560 };
7561 WorkspaceChange.prototype.initDocumentChanges = function () {
7562 if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) {
7563 this._changeAnnotations = new ChangeAnnotations();
7564 this._workspaceEdit.documentChanges = [];
7565 this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
7566 }
7567 };
7568 WorkspaceChange.prototype.initChanges = function () {
7569 if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) {
7570 this._workspaceEdit.changes = Object.create(null);
7571 }
7572 };
7573 WorkspaceChange.prototype.createFile = function (uri, optionsOrAnnotation, options) {
7574 this.initDocumentChanges();
7575 if (this._workspaceEdit.documentChanges === undefined) {
7576 throw new Error('Workspace edit is not configured for document changes.');
7577 }
7578 var annotation;
7579 if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
7580 annotation = optionsOrAnnotation;
7581 }
7582 else {
7583 options = optionsOrAnnotation;
7584 }
7585 var operation;
7586 var id;
7587 if (annotation === undefined) {
7588 operation = CreateFile.create(uri, options);
7589 }
7590 else {
7591 id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
7592 operation = CreateFile.create(uri, options, id);
7593 }
7594 this._workspaceEdit.documentChanges.push(operation);
7595 if (id !== undefined) {
7596 return id;
7597 }
7598 };
7599 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, optionsOrAnnotation, options) {
7600 this.initDocumentChanges();
7601 if (this._workspaceEdit.documentChanges === undefined) {
7602 throw new Error('Workspace edit is not configured for document changes.');
7603 }
7604 var annotation;
7605 if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
7606 annotation = optionsOrAnnotation;
7607 }
7608 else {
7609 options = optionsOrAnnotation;
7610 }
7611 var operation;
7612 var id;
7613 if (annotation === undefined) {
7614 operation = RenameFile.create(oldUri, newUri, options);
7615 }
7616 else {
7617 id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
7618 operation = RenameFile.create(oldUri, newUri, options, id);
7619 }
7620 this._workspaceEdit.documentChanges.push(operation);
7621 if (id !== undefined) {
7622 return id;
7623 }
7624 };
7625 WorkspaceChange.prototype.deleteFile = function (uri, optionsOrAnnotation, options) {
7626 this.initDocumentChanges();
7627 if (this._workspaceEdit.documentChanges === undefined) {
7628 throw new Error('Workspace edit is not configured for document changes.');
7629 }
7630 var annotation;
7631 if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
7632 annotation = optionsOrAnnotation;
7633 }
7634 else {
7635 options = optionsOrAnnotation;
7636 }
7637 var operation;
7638 var id;
7639 if (annotation === undefined) {
7640 operation = DeleteFile.create(uri, options);
7641 }
7642 else {
7643 id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
7644 operation = DeleteFile.create(uri, options, id);
7645 }
7646 this._workspaceEdit.documentChanges.push(operation);
7647 if (id !== undefined) {
7648 return id;
7649 }
7650 };
7651 return WorkspaceChange;
7652}());
7653
7654/**
7655 * The TextDocumentIdentifier namespace provides helper functions to work with
7656 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
7657 */
7658var TextDocumentIdentifier;
7659(function (TextDocumentIdentifier) {
7660 /**
7661 * Creates a new TextDocumentIdentifier literal.
7662 * @param uri The document's uri.
7663 */
7664 function create(uri) {
7665 return { uri: uri };
7666 }
7667 TextDocumentIdentifier.create = create;
7668 /**
7669 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
7670 */
7671 function is(value) {
7672 var candidate = value;
7673 return Is.defined(candidate) && Is.string(candidate.uri);
7674 }
7675 TextDocumentIdentifier.is = is;
7676})(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
7677/**
7678 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
7679 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
7680 */
7681var VersionedTextDocumentIdentifier;
7682(function (VersionedTextDocumentIdentifier) {
7683 /**
7684 * Creates a new VersionedTextDocumentIdentifier literal.
7685 * @param uri The document's uri.
7686 * @param uri The document's text.
7687 */
7688 function create(uri, version) {
7689 return { uri: uri, version: version };
7690 }
7691 VersionedTextDocumentIdentifier.create = create;
7692 /**
7693 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
7694 */
7695 function is(value) {
7696 var candidate = value;
7697 return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
7698 }
7699 VersionedTextDocumentIdentifier.is = is;
7700})(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
7701/**
7702 * The OptionalVersionedTextDocumentIdentifier namespace provides helper functions to work with
7703 * [OptionalVersionedTextDocumentIdentifier](#OptionalVersionedTextDocumentIdentifier) literals.
7704 */
7705var OptionalVersionedTextDocumentIdentifier;
7706(function (OptionalVersionedTextDocumentIdentifier) {
7707 /**
7708 * Creates a new OptionalVersionedTextDocumentIdentifier literal.
7709 * @param uri The document's uri.
7710 * @param uri The document's text.
7711 */
7712 function create(uri, version) {
7713 return { uri: uri, version: version };
7714 }
7715 OptionalVersionedTextDocumentIdentifier.create = create;
7716 /**
7717 * Checks whether the given literal conforms to the [OptionalVersionedTextDocumentIdentifier](#OptionalVersionedTextDocumentIdentifier) interface.
7718 */
7719 function is(value) {
7720 var candidate = value;
7721 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
7722 }
7723 OptionalVersionedTextDocumentIdentifier.is = is;
7724})(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
7725/**
7726 * The TextDocumentItem namespace provides helper functions to work with
7727 * [TextDocumentItem](#TextDocumentItem) literals.
7728 */
7729var TextDocumentItem;
7730(function (TextDocumentItem) {
7731 /**
7732 * Creates a new TextDocumentItem literal.
7733 * @param uri The document's uri.
7734 * @param languageId The document's language identifier.
7735 * @param version The document's version number.
7736 * @param text The document's text.
7737 */
7738 function create(uri, languageId, version, text) {
7739 return { uri: uri, languageId: languageId, version: version, text: text };
7740 }
7741 TextDocumentItem.create = create;
7742 /**
7743 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
7744 */
7745 function is(value) {
7746 var candidate = value;
7747 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
7748 }
7749 TextDocumentItem.is = is;
7750})(TextDocumentItem || (TextDocumentItem = {}));
7751/**
7752 * Describes the content type that a client supports in various
7753 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
7754 *
7755 * Please note that `MarkupKinds` must not start with a `$`. This kinds
7756 * are reserved for internal usage.
7757 */
7758var MarkupKind;
7759(function (MarkupKind) {
7760 /**
7761 * Plain text is supported as a content format
7762 */
7763 MarkupKind.PlainText = 'plaintext';
7764 /**
7765 * Markdown is supported as a content format
7766 */
7767 MarkupKind.Markdown = 'markdown';
7768})(MarkupKind || (MarkupKind = {}));
7769(function (MarkupKind) {
7770 /**
7771 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
7772 */
7773 function is(value) {
7774 var candidate = value;
7775 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
7776 }
7777 MarkupKind.is = is;
7778})(MarkupKind || (MarkupKind = {}));
7779var MarkupContent;
7780(function (MarkupContent) {
7781 /**
7782 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
7783 */
7784 function is(value) {
7785 var candidate = value;
7786 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
7787 }
7788 MarkupContent.is = is;
7789})(MarkupContent || (MarkupContent = {}));
7790/**
7791 * The kind of a completion entry.
7792 */
7793var CompletionItemKind;
7794(function (CompletionItemKind) {
7795 CompletionItemKind.Text = 1;
7796 CompletionItemKind.Method = 2;
7797 CompletionItemKind.Function = 3;
7798 CompletionItemKind.Constructor = 4;
7799 CompletionItemKind.Field = 5;
7800 CompletionItemKind.Variable = 6;
7801 CompletionItemKind.Class = 7;
7802 CompletionItemKind.Interface = 8;
7803 CompletionItemKind.Module = 9;
7804 CompletionItemKind.Property = 10;
7805 CompletionItemKind.Unit = 11;
7806 CompletionItemKind.Value = 12;
7807 CompletionItemKind.Enum = 13;
7808 CompletionItemKind.Keyword = 14;
7809 CompletionItemKind.Snippet = 15;
7810 CompletionItemKind.Color = 16;
7811 CompletionItemKind.File = 17;
7812 CompletionItemKind.Reference = 18;
7813 CompletionItemKind.Folder = 19;
7814 CompletionItemKind.EnumMember = 20;
7815 CompletionItemKind.Constant = 21;
7816 CompletionItemKind.Struct = 22;
7817 CompletionItemKind.Event = 23;
7818 CompletionItemKind.Operator = 24;
7819 CompletionItemKind.TypeParameter = 25;
7820})(CompletionItemKind || (CompletionItemKind = {}));
7821/**
7822 * Defines whether the insert text in a completion item should be interpreted as
7823 * plain text or a snippet.
7824 */
7825var InsertTextFormat;
7826(function (InsertTextFormat) {
7827 /**
7828 * The primary text to be inserted is treated as a plain string.
7829 */
7830 InsertTextFormat.PlainText = 1;
7831 /**
7832 * The primary text to be inserted is treated as a snippet.
7833 *
7834 * A snippet can define tab stops and placeholders with `$1`, `$2`
7835 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
7836 * the end of the snippet. Placeholders with equal identifiers are linked,
7837 * that is typing in one will update others too.
7838 *
7839 * See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax
7840 */
7841 InsertTextFormat.Snippet = 2;
7842})(InsertTextFormat || (InsertTextFormat = {}));
7843/**
7844 * Completion item tags are extra annotations that tweak the rendering of a completion
7845 * item.
7846 *
7847 * @since 3.15.0
7848 */
7849var CompletionItemTag;
7850(function (CompletionItemTag) {
7851 /**
7852 * Render a completion as obsolete, usually using a strike-out.
7853 */
7854 CompletionItemTag.Deprecated = 1;
7855})(CompletionItemTag || (CompletionItemTag = {}));
7856/**
7857 * The InsertReplaceEdit namespace provides functions to deal with insert / replace edits.
7858 *
7859 * @since 3.16.0
7860 */
7861var InsertReplaceEdit;
7862(function (InsertReplaceEdit) {
7863 /**
7864 * Creates a new insert / replace edit
7865 */
7866 function create(newText, insert, replace) {
7867 return { newText: newText, insert: insert, replace: replace };
7868 }
7869 InsertReplaceEdit.create = create;
7870 /**
7871 * Checks whether the given literal conforms to the [InsertReplaceEdit](#InsertReplaceEdit) interface.
7872 */
7873 function is(value) {
7874 var candidate = value;
7875 return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
7876 }
7877 InsertReplaceEdit.is = is;
7878})(InsertReplaceEdit || (InsertReplaceEdit = {}));
7879/**
7880 * How whitespace and indentation is handled during completion
7881 * item insertion.
7882 *
7883 * @since 3.16.0
7884 */
7885var InsertTextMode;
7886(function (InsertTextMode) {
7887 /**
7888 * The insertion or replace strings is taken as it is. If the
7889 * value is multi line the lines below the cursor will be
7890 * inserted using the indentation defined in the string value.
7891 * The client will not apply any kind of adjustments to the
7892 * string.
7893 */
7894 InsertTextMode.asIs = 1;
7895 /**
7896 * The editor adjusts leading whitespace of new lines so that
7897 * they match the indentation up to the cursor of the line for
7898 * which the item is accepted.
7899 *
7900 * Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
7901 * multi line completion item is indented using 2 tabs and all
7902 * following lines inserted will be indented using 2 tabs as well.
7903 */
7904 InsertTextMode.adjustIndentation = 2;
7905})(InsertTextMode || (InsertTextMode = {}));
7906/**
7907 * The CompletionItem namespace provides functions to deal with
7908 * completion items.
7909 */
7910var CompletionItem;
7911(function (CompletionItem) {
7912 /**
7913 * Create a completion item and seed it with a label.
7914 * @param label The completion item's label
7915 */
7916 function create(label) {
7917 return { label: label };
7918 }
7919 CompletionItem.create = create;
7920})(CompletionItem || (CompletionItem = {}));
7921/**
7922 * The CompletionList namespace provides functions to deal with
7923 * completion lists.
7924 */
7925var CompletionList;
7926(function (CompletionList) {
7927 /**
7928 * Creates a new completion list.
7929 *
7930 * @param items The completion items.
7931 * @param isIncomplete The list is not complete.
7932 */
7933 function create(items, isIncomplete) {
7934 return { items: items ? items : [], isIncomplete: !!isIncomplete };
7935 }
7936 CompletionList.create = create;
7937})(CompletionList || (CompletionList = {}));
7938var MarkedString;
7939(function (MarkedString) {
7940 /**
7941 * Creates a marked string from plain text.
7942 *
7943 * @param plainText The plain text.
7944 */
7945 function fromPlainText(plainText) {
7946 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
7947 }
7948 MarkedString.fromPlainText = fromPlainText;
7949 /**
7950 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
7951 */
7952 function is(value) {
7953 var candidate = value;
7954 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
7955 }
7956 MarkedString.is = is;
7957})(MarkedString || (MarkedString = {}));
7958var Hover;
7959(function (Hover) {
7960 /**
7961 * Checks whether the given value conforms to the [Hover](#Hover) interface.
7962 */
7963 function is(value) {
7964 var candidate = value;
7965 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
7966 MarkedString.is(candidate.contents) ||
7967 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === undefined || Range.is(value.range));
7968 }
7969 Hover.is = is;
7970})(Hover || (Hover = {}));
7971/**
7972 * The ParameterInformation namespace provides helper functions to work with
7973 * [ParameterInformation](#ParameterInformation) literals.
7974 */
7975var ParameterInformation;
7976(function (ParameterInformation) {
7977 /**
7978 * Creates a new parameter information literal.
7979 *
7980 * @param label A label string.
7981 * @param documentation A doc string.
7982 */
7983 function create(label, documentation) {
7984 return documentation ? { label: label, documentation: documentation } : { label: label };
7985 }
7986 ParameterInformation.create = create;
7987})(ParameterInformation || (ParameterInformation = {}));
7988/**
7989 * The SignatureInformation namespace provides helper functions to work with
7990 * [SignatureInformation](#SignatureInformation) literals.
7991 */
7992var SignatureInformation;
7993(function (SignatureInformation) {
7994 function create(label, documentation) {
7995 var parameters = [];
7996 for (var _i = 2; _i < arguments.length; _i++) {
7997 parameters[_i - 2] = arguments[_i];
7998 }
7999 var result = { label: label };
8000 if (Is.defined(documentation)) {
8001 result.documentation = documentation;
8002 }
8003 if (Is.defined(parameters)) {
8004 result.parameters = parameters;
8005 }
8006 else {
8007 result.parameters = [];
8008 }
8009 return result;
8010 }
8011 SignatureInformation.create = create;
8012})(SignatureInformation || (SignatureInformation = {}));
8013/**
8014 * A document highlight kind.
8015 */
8016var DocumentHighlightKind;
8017(function (DocumentHighlightKind) {
8018 /**
8019 * A textual occurrence.
8020 */
8021 DocumentHighlightKind.Text = 1;
8022 /**
8023 * Read-access of a symbol, like reading a variable.
8024 */
8025 DocumentHighlightKind.Read = 2;
8026 /**
8027 * Write-access of a symbol, like writing to a variable.
8028 */
8029 DocumentHighlightKind.Write = 3;
8030})(DocumentHighlightKind || (DocumentHighlightKind = {}));
8031/**
8032 * DocumentHighlight namespace to provide helper functions to work with
8033 * [DocumentHighlight](#DocumentHighlight) literals.
8034 */
8035var DocumentHighlight;
8036(function (DocumentHighlight) {
8037 /**
8038 * Create a DocumentHighlight object.
8039 * @param range The range the highlight applies to.
8040 */
8041 function create(range, kind) {
8042 var result = { range: range };
8043 if (Is.number(kind)) {
8044 result.kind = kind;
8045 }
8046 return result;
8047 }
8048 DocumentHighlight.create = create;
8049})(DocumentHighlight || (DocumentHighlight = {}));
8050/**
8051 * A symbol kind.
8052 */
8053var SymbolKind;
8054(function (SymbolKind) {
8055 SymbolKind.File = 1;
8056 SymbolKind.Module = 2;
8057 SymbolKind.Namespace = 3;
8058 SymbolKind.Package = 4;
8059 SymbolKind.Class = 5;
8060 SymbolKind.Method = 6;
8061 SymbolKind.Property = 7;
8062 SymbolKind.Field = 8;
8063 SymbolKind.Constructor = 9;
8064 SymbolKind.Enum = 10;
8065 SymbolKind.Interface = 11;
8066 SymbolKind.Function = 12;
8067 SymbolKind.Variable = 13;
8068 SymbolKind.Constant = 14;
8069 SymbolKind.String = 15;
8070 SymbolKind.Number = 16;
8071 SymbolKind.Boolean = 17;
8072 SymbolKind.Array = 18;
8073 SymbolKind.Object = 19;
8074 SymbolKind.Key = 20;
8075 SymbolKind.Null = 21;
8076 SymbolKind.EnumMember = 22;
8077 SymbolKind.Struct = 23;
8078 SymbolKind.Event = 24;
8079 SymbolKind.Operator = 25;
8080 SymbolKind.TypeParameter = 26;
8081})(SymbolKind || (SymbolKind = {}));
8082/**
8083 * Symbol tags are extra annotations that tweak the rendering of a symbol.
8084 * @since 3.16
8085 */
8086var SymbolTag;
8087(function (SymbolTag) {
8088 /**
8089 * Render a symbol as obsolete, usually using a strike-out.
8090 */
8091 SymbolTag.Deprecated = 1;
8092})(SymbolTag || (SymbolTag = {}));
8093var SymbolInformation;
8094(function (SymbolInformation) {
8095 /**
8096 * Creates a new symbol information literal.
8097 *
8098 * @param name The name of the symbol.
8099 * @param kind The kind of the symbol.
8100 * @param range The range of the location of the symbol.
8101 * @param uri The resource of the location of symbol, defaults to the current document.
8102 * @param containerName The name of the symbol containing the symbol.
8103 */
8104 function create(name, kind, range, uri, containerName) {
8105 var result = {
8106 name: name,
8107 kind: kind,
8108 location: { uri: uri, range: range }
8109 };
8110 if (containerName) {
8111 result.containerName = containerName;
8112 }
8113 return result;
8114 }
8115 SymbolInformation.create = create;
8116})(SymbolInformation || (SymbolInformation = {}));
8117var DocumentSymbol;
8118(function (DocumentSymbol) {
8119 /**
8120 * Creates a new symbol information literal.
8121 *
8122 * @param name The name of the symbol.
8123 * @param detail The detail of the symbol.
8124 * @param kind The kind of the symbol.
8125 * @param range The range of the symbol.
8126 * @param selectionRange The selectionRange of the symbol.
8127 * @param children Children of the symbol.
8128 */
8129 function create(name, detail, kind, range, selectionRange, children) {
8130 var result = {
8131 name: name,
8132 detail: detail,
8133 kind: kind,
8134 range: range,
8135 selectionRange: selectionRange
8136 };
8137 if (children !== undefined) {
8138 result.children = children;
8139 }
8140 return result;
8141 }
8142 DocumentSymbol.create = create;
8143 /**
8144 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
8145 */
8146 function is(value) {
8147 var candidate = value;
8148 return candidate &&
8149 Is.string(candidate.name) && Is.number(candidate.kind) &&
8150 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
8151 (candidate.detail === undefined || Is.string(candidate.detail)) &&
8152 (candidate.deprecated === undefined || Is.boolean(candidate.deprecated)) &&
8153 (candidate.children === undefined || Array.isArray(candidate.children)) &&
8154 (candidate.tags === undefined || Array.isArray(candidate.tags));
8155 }
8156 DocumentSymbol.is = is;
8157})(DocumentSymbol || (DocumentSymbol = {}));
8158/**
8159 * A set of predefined code action kinds
8160 */
8161var CodeActionKind;
8162(function (CodeActionKind) {
8163 /**
8164 * Empty kind.
8165 */
8166 CodeActionKind.Empty = '';
8167 /**
8168 * Base kind for quickfix actions: 'quickfix'
8169 */
8170 CodeActionKind.QuickFix = 'quickfix';
8171 /**
8172 * Base kind for refactoring actions: 'refactor'
8173 */
8174 CodeActionKind.Refactor = 'refactor';
8175 /**
8176 * Base kind for refactoring extraction actions: 'refactor.extract'
8177 *
8178 * Example extract actions:
8179 *
8180 * - Extract method
8181 * - Extract function
8182 * - Extract variable
8183 * - Extract interface from class
8184 * - ...
8185 */
8186 CodeActionKind.RefactorExtract = 'refactor.extract';
8187 /**
8188 * Base kind for refactoring inline actions: 'refactor.inline'
8189 *
8190 * Example inline actions:
8191 *
8192 * - Inline function
8193 * - Inline variable
8194 * - Inline constant
8195 * - ...
8196 */
8197 CodeActionKind.RefactorInline = 'refactor.inline';
8198 /**
8199 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
8200 *
8201 * Example rewrite actions:
8202 *
8203 * - Convert JavaScript function to class
8204 * - Add or remove parameter
8205 * - Encapsulate field
8206 * - Make method static
8207 * - Move method to base class
8208 * - ...
8209 */
8210 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
8211 /**
8212 * Base kind for source actions: `source`
8213 *
8214 * Source code actions apply to the entire file.
8215 */
8216 CodeActionKind.Source = 'source';
8217 /**
8218 * Base kind for an organize imports source action: `source.organizeImports`
8219 */
8220 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
8221 /**
8222 * Base kind for auto-fix source actions: `source.fixAll`.
8223 *
8224 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
8225 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
8226 *
8227 * @since 3.15.0
8228 */
8229 CodeActionKind.SourceFixAll = 'source.fixAll';
8230})(CodeActionKind || (CodeActionKind = {}));
8231/**
8232 * The CodeActionContext namespace provides helper functions to work with
8233 * [CodeActionContext](#CodeActionContext) literals.
8234 */
8235var CodeActionContext;
8236(function (CodeActionContext) {
8237 /**
8238 * Creates a new CodeActionContext literal.
8239 */
8240 function create(diagnostics, only) {
8241 var result = { diagnostics: diagnostics };
8242 if (only !== undefined && only !== null) {
8243 result.only = only;
8244 }
8245 return result;
8246 }
8247 CodeActionContext.create = create;
8248 /**
8249 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
8250 */
8251 function is(value) {
8252 var candidate = value;
8253 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === undefined || Is.typedArray(candidate.only, Is.string));
8254 }
8255 CodeActionContext.is = is;
8256})(CodeActionContext || (CodeActionContext = {}));
8257var CodeAction;
8258(function (CodeAction) {
8259 function create(title, kindOrCommandOrEdit, kind) {
8260 var result = { title: title };
8261 var checkKind = true;
8262 if (typeof kindOrCommandOrEdit === 'string') {
8263 checkKind = false;
8264 result.kind = kindOrCommandOrEdit;
8265 }
8266 else if (Command.is(kindOrCommandOrEdit)) {
8267 result.command = kindOrCommandOrEdit;
8268 }
8269 else {
8270 result.edit = kindOrCommandOrEdit;
8271 }
8272 if (checkKind && kind !== undefined) {
8273 result.kind = kind;
8274 }
8275 return result;
8276 }
8277 CodeAction.create = create;
8278 function is(value) {
8279 var candidate = value;
8280 return candidate && Is.string(candidate.title) &&
8281 (candidate.diagnostics === undefined || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
8282 (candidate.kind === undefined || Is.string(candidate.kind)) &&
8283 (candidate.edit !== undefined || candidate.command !== undefined) &&
8284 (candidate.command === undefined || Command.is(candidate.command)) &&
8285 (candidate.isPreferred === undefined || Is.boolean(candidate.isPreferred)) &&
8286 (candidate.edit === undefined || WorkspaceEdit.is(candidate.edit));
8287 }
8288 CodeAction.is = is;
8289})(CodeAction || (CodeAction = {}));
8290/**
8291 * The CodeLens namespace provides helper functions to work with
8292 * [CodeLens](#CodeLens) literals.
8293 */
8294var CodeLens;
8295(function (CodeLens) {
8296 /**
8297 * Creates a new CodeLens literal.
8298 */
8299 function create(range, data) {
8300 var result = { range: range };
8301 if (Is.defined(data)) {
8302 result.data = data;
8303 }
8304 return result;
8305 }
8306 CodeLens.create = create;
8307 /**
8308 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
8309 */
8310 function is(value) {
8311 var candidate = value;
8312 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
8313 }
8314 CodeLens.is = is;
8315})(CodeLens || (CodeLens = {}));
8316/**
8317 * The FormattingOptions namespace provides helper functions to work with
8318 * [FormattingOptions](#FormattingOptions) literals.
8319 */
8320var FormattingOptions;
8321(function (FormattingOptions) {
8322 /**
8323 * Creates a new FormattingOptions literal.
8324 */
8325 function create(tabSize, insertSpaces) {
8326 return { tabSize: tabSize, insertSpaces: insertSpaces };
8327 }
8328 FormattingOptions.create = create;
8329 /**
8330 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
8331 */
8332 function is(value) {
8333 var candidate = value;
8334 return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
8335 }
8336 FormattingOptions.is = is;
8337})(FormattingOptions || (FormattingOptions = {}));
8338/**
8339 * The DocumentLink namespace provides helper functions to work with
8340 * [DocumentLink](#DocumentLink) literals.
8341 */
8342var DocumentLink;
8343(function (DocumentLink) {
8344 /**
8345 * Creates a new DocumentLink literal.
8346 */
8347 function create(range, target, data) {
8348 return { range: range, target: target, data: data };
8349 }
8350 DocumentLink.create = create;
8351 /**
8352 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
8353 */
8354 function is(value) {
8355 var candidate = value;
8356 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
8357 }
8358 DocumentLink.is = is;
8359})(DocumentLink || (DocumentLink = {}));
8360/**
8361 * The SelectionRange namespace provides helper function to work with
8362 * SelectionRange literals.
8363 */
8364var SelectionRange;
8365(function (SelectionRange) {
8366 /**
8367 * Creates a new SelectionRange
8368 * @param range the range.
8369 * @param parent an optional parent.
8370 */
8371 function create(range, parent) {
8372 return { range: range, parent: parent };
8373 }
8374 SelectionRange.create = create;
8375 function is(value) {
8376 var candidate = value;
8377 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
8378 }
8379 SelectionRange.is = is;
8380})(SelectionRange || (SelectionRange = {}));
8381var EOL = ['\n', '\r\n', '\r'];
8382/**
8383 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
8384 */
8385var TextDocument;
8386(function (TextDocument) {
8387 /**
8388 * Creates a new ITextDocument literal from the given uri and content.
8389 * @param uri The document's uri.
8390 * @param languageId The document's language Id.
8391 * @param content The document's content.
8392 */
8393 function create(uri, languageId, version, content) {
8394 return new FullTextDocument(uri, languageId, version, content);
8395 }
8396 TextDocument.create = create;
8397 /**
8398 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
8399 */
8400 function is(value) {
8401 var candidate = value;
8402 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount)
8403 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
8404 }
8405 TextDocument.is = is;
8406 function applyEdits(document, edits) {
8407 var text = document.getText();
8408 var sortedEdits = mergeSort(edits, function (a, b) {
8409 var diff = a.range.start.line - b.range.start.line;
8410 if (diff === 0) {
8411 return a.range.start.character - b.range.start.character;
8412 }
8413 return diff;
8414 });
8415 var lastModifiedOffset = text.length;
8416 for (var i = sortedEdits.length - 1; i >= 0; i--) {
8417 var e = sortedEdits[i];
8418 var startOffset = document.offsetAt(e.range.start);
8419 var endOffset = document.offsetAt(e.range.end);
8420 if (endOffset <= lastModifiedOffset) {
8421 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
8422 }
8423 else {
8424 throw new Error('Overlapping edit');
8425 }
8426 lastModifiedOffset = startOffset;
8427 }
8428 return text;
8429 }
8430 TextDocument.applyEdits = applyEdits;
8431 function mergeSort(data, compare) {
8432 if (data.length <= 1) {
8433 // sorted
8434 return data;
8435 }
8436 var p = (data.length / 2) | 0;
8437 var left = data.slice(0, p);
8438 var right = data.slice(p);
8439 mergeSort(left, compare);
8440 mergeSort(right, compare);
8441 var leftIdx = 0;
8442 var rightIdx = 0;
8443 var i = 0;
8444 while (leftIdx < left.length && rightIdx < right.length) {
8445 var ret = compare(left[leftIdx], right[rightIdx]);
8446 if (ret <= 0) {
8447 // smaller_equal -> take left to preserve order
8448 data[i++] = left[leftIdx++];
8449 }
8450 else {
8451 // greater -> take right
8452 data[i++] = right[rightIdx++];
8453 }
8454 }
8455 while (leftIdx < left.length) {
8456 data[i++] = left[leftIdx++];
8457 }
8458 while (rightIdx < right.length) {
8459 data[i++] = right[rightIdx++];
8460 }
8461 return data;
8462 }
8463})(TextDocument || (TextDocument = {}));
8464/**
8465 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
8466 */
8467var FullTextDocument = /** @class */ (function () {
8468 function FullTextDocument(uri, languageId, version, content) {
8469 this._uri = uri;
8470 this._languageId = languageId;
8471 this._version = version;
8472 this._content = content;
8473 this._lineOffsets = undefined;
8474 }
8475 Object.defineProperty(FullTextDocument.prototype, "uri", {
8476 get: function () {
8477 return this._uri;
8478 },
8479 enumerable: false,
8480 configurable: true
8481 });
8482 Object.defineProperty(FullTextDocument.prototype, "languageId", {
8483 get: function () {
8484 return this._languageId;
8485 },
8486 enumerable: false,
8487 configurable: true
8488 });
8489 Object.defineProperty(FullTextDocument.prototype, "version", {
8490 get: function () {
8491 return this._version;
8492 },
8493 enumerable: false,
8494 configurable: true
8495 });
8496 FullTextDocument.prototype.getText = function (range) {
8497 if (range) {
8498 var start = this.offsetAt(range.start);
8499 var end = this.offsetAt(range.end);
8500 return this._content.substring(start, end);
8501 }
8502 return this._content;
8503 };
8504 FullTextDocument.prototype.update = function (event, version) {
8505 this._content = event.text;
8506 this._version = version;
8507 this._lineOffsets = undefined;
8508 };
8509 FullTextDocument.prototype.getLineOffsets = function () {
8510 if (this._lineOffsets === undefined) {
8511 var lineOffsets = [];
8512 var text = this._content;
8513 var isLineStart = true;
8514 for (var i = 0; i < text.length; i++) {
8515 if (isLineStart) {
8516 lineOffsets.push(i);
8517 isLineStart = false;
8518 }
8519 var ch = text.charAt(i);
8520 isLineStart = (ch === '\r' || ch === '\n');
8521 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
8522 i++;
8523 }
8524 }
8525 if (isLineStart && text.length > 0) {
8526 lineOffsets.push(text.length);
8527 }
8528 this._lineOffsets = lineOffsets;
8529 }
8530 return this._lineOffsets;
8531 };
8532 FullTextDocument.prototype.positionAt = function (offset) {
8533 offset = Math.max(Math.min(offset, this._content.length), 0);
8534 var lineOffsets = this.getLineOffsets();
8535 var low = 0, high = lineOffsets.length;
8536 if (high === 0) {
8537 return Position.create(0, offset);
8538 }
8539 while (low < high) {
8540 var mid = Math.floor((low + high) / 2);
8541 if (lineOffsets[mid] > offset) {
8542 high = mid;
8543 }
8544 else {
8545 low = mid + 1;
8546 }
8547 }
8548 // low is the least x for which the line offset is larger than the current offset
8549 // or array.length if no line offset is larger than the current offset
8550 var line = low - 1;
8551 return Position.create(line, offset - lineOffsets[line]);
8552 };
8553 FullTextDocument.prototype.offsetAt = function (position) {
8554 var lineOffsets = this.getLineOffsets();
8555 if (position.line >= lineOffsets.length) {
8556 return this._content.length;
8557 }
8558 else if (position.line < 0) {
8559 return 0;
8560 }
8561 var lineOffset = lineOffsets[position.line];
8562 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
8563 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
8564 };
8565 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
8566 get: function () {
8567 return this.getLineOffsets().length;
8568 },
8569 enumerable: false,
8570 configurable: true
8571 });
8572 return FullTextDocument;
8573}());
8574var Is;
8575(function (Is) {
8576 var toString = Object.prototype.toString;
8577 function defined(value) {
8578 return typeof value !== 'undefined';
8579 }
8580 Is.defined = defined;
8581 function undefined(value) {
8582 return typeof value === 'undefined';
8583 }
8584 Is.undefined = undefined;
8585 function boolean(value) {
8586 return value === true || value === false;
8587 }
8588 Is.boolean = boolean;
8589 function string(value) {
8590 return toString.call(value) === '[object String]';
8591 }
8592 Is.string = string;
8593 function number(value) {
8594 return toString.call(value) === '[object Number]';
8595 }
8596 Is.number = number;
8597 function numberRange(value, min, max) {
8598 return toString.call(value) === '[object Number]' && min <= value && value <= max;
8599 }
8600 Is.numberRange = numberRange;
8601 function integer(value) {
8602 return toString.call(value) === '[object Number]' && -2147483648 <= value && value <= 2147483647;
8603 }
8604 Is.integer = integer;
8605 function uinteger(value) {
8606 return toString.call(value) === '[object Number]' && 0 <= value && value <= 2147483647;
8607 }
8608 Is.uinteger = uinteger;
8609 function func(value) {
8610 return toString.call(value) === '[object Function]';
8611 }
8612 Is.func = func;
8613 function objectLiteral(value) {
8614 // Strictly speaking class instances pass this check as well. Since the LSP
8615 // doesn't use classes we ignore this for now. If we do we need to add something
8616 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
8617 return value !== null && typeof value === 'object';
8618 }
8619 Is.objectLiteral = objectLiteral;
8620 function typedArray(value, check) {
8621 return Array.isArray(value) && value.every(check);
8622 }
8623 Is.typedArray = typedArray;
8624})(Is || (Is = {}));
8625
8626
8627/***/ }),
8628
8629/***/ 63:
8630/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
8631
8632"use strict";
8633
8634/* --------------------------------------------------------------------------------------------
8635 * Copyright (c) Microsoft Corporation. All rights reserved.
8636 * Licensed under the MIT License. See License.txt in the project root for license information.
8637 * ------------------------------------------------------------------------------------------ */
8638var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8639 if (k2 === undefined) k2 = k;
8640 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8641}) : (function(o, m, k, k2) {
8642 if (k2 === undefined) k2 = k;
8643 o[k2] = m[k];
8644}));
8645var __exportStar = (this && this.__exportStar) || function(m, exports) {
8646 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
8647};
8648Object.defineProperty(exports, "__esModule", ({ value: true }));
8649exports.ProposedFeatures = exports.SemanticTokensBuilder = void 0;
8650const semanticTokens_1 = __webpack_require__(53);
8651Object.defineProperty(exports, "SemanticTokensBuilder", ({ enumerable: true, get: function () { return semanticTokens_1.SemanticTokensBuilder; } }));
8652__exportStar(__webpack_require__(5), exports);
8653__exportStar(__webpack_require__(4), exports);
8654var ProposedFeatures;
8655(function (ProposedFeatures) {
8656 ProposedFeatures.all = {
8657 __brand: 'features'
8658 };
8659})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
8660//# sourceMappingURL=api.js.map
8661
8662/***/ }),
8663
8664/***/ 52:
8665/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8666
8667"use strict";
8668/* --------------------------------------------------------------------------------------------
8669 * Copyright (c) Microsoft Corporation. All rights reserved.
8670 * Licensed under the MIT License. See License.txt in the project root for license information.
8671 * ------------------------------------------------------------------------------------------ */
8672
8673Object.defineProperty(exports, "__esModule", ({ value: true }));
8674exports.CallHierarchyFeature = void 0;
8675const vscode_languageserver_protocol_1 = __webpack_require__(5);
8676const CallHierarchyFeature = (Base) => {
8677 return class extends Base {
8678 get callHierarchy() {
8679 return {
8680 onPrepare: (handler) => {
8681 this.connection.onRequest(vscode_languageserver_protocol_1.CallHierarchyPrepareRequest.type, (params, cancel) => {
8682 return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
8683 });
8684 },
8685 onIncomingCalls: (handler) => {
8686 const type = vscode_languageserver_protocol_1.CallHierarchyIncomingCallsRequest.type;
8687 this.connection.onRequest(type, (params, cancel) => {
8688 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
8689 });
8690 },
8691 onOutgoingCalls: (handler) => {
8692 const type = vscode_languageserver_protocol_1.CallHierarchyOutgoingCallsRequest.type;
8693 this.connection.onRequest(type, (params, cancel) => {
8694 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
8695 });
8696 }
8697 };
8698 }
8699 };
8700};
8701exports.CallHierarchyFeature = CallHierarchyFeature;
8702//# sourceMappingURL=callHierarchy.js.map
8703
8704/***/ }),
8705
8706/***/ 50:
8707/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8708
8709"use strict";
8710
8711/* --------------------------------------------------------------------------------------------
8712 * Copyright (c) Microsoft Corporation. All rights reserved.
8713 * Licensed under the MIT License. See License.txt in the project root for license information.
8714 * ------------------------------------------------------------------------------------------ */
8715Object.defineProperty(exports, "__esModule", ({ value: true }));
8716exports.ConfigurationFeature = void 0;
8717const vscode_languageserver_protocol_1 = __webpack_require__(5);
8718const Is = __webpack_require__(3);
8719const ConfigurationFeature = (Base) => {
8720 return class extends Base {
8721 getConfiguration(arg) {
8722 if (!arg) {
8723 return this._getConfiguration({});
8724 }
8725 else if (Is.string(arg)) {
8726 return this._getConfiguration({ section: arg });
8727 }
8728 else {
8729 return this._getConfiguration(arg);
8730 }
8731 }
8732 _getConfiguration(arg) {
8733 let params = {
8734 items: Array.isArray(arg) ? arg : [arg]
8735 };
8736 return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {
8737 return Array.isArray(arg) ? result : result[0];
8738 });
8739 }
8740 };
8741};
8742exports.ConfigurationFeature = ConfigurationFeature;
8743//# sourceMappingURL=configuration.js.map
8744
8745/***/ }),
8746
8747/***/ 55:
8748/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8749
8750"use strict";
8751
8752/* --------------------------------------------------------------------------------------------
8753 * Copyright (c) Microsoft Corporation. All rights reserved.
8754 * Licensed under the MIT License. See License.txt in the project root for license information.
8755 * ------------------------------------------------------------------------------------------ */
8756Object.defineProperty(exports, "__esModule", ({ value: true }));
8757exports.FileOperationsFeature = void 0;
8758const vscode_languageserver_protocol_1 = __webpack_require__(5);
8759const FileOperationsFeature = (Base) => {
8760 return class extends Base {
8761 onDidCreateFiles(handler) {
8762 this.connection.onNotification(vscode_languageserver_protocol_1.DidCreateFilesNotification.type, (params) => {
8763 handler(params);
8764 });
8765 }
8766 onDidRenameFiles(handler) {
8767 this.connection.onNotification(vscode_languageserver_protocol_1.DidRenameFilesNotification.type, (params) => {
8768 handler(params);
8769 });
8770 }
8771 onDidDeleteFiles(handler) {
8772 this.connection.onNotification(vscode_languageserver_protocol_1.DidDeleteFilesNotification.type, (params) => {
8773 handler(params);
8774 });
8775 }
8776 onWillCreateFiles(handler) {
8777 return this.connection.onRequest(vscode_languageserver_protocol_1.WillCreateFilesRequest.type, (params, cancel) => {
8778 return handler(params, cancel);
8779 });
8780 }
8781 onWillRenameFiles(handler) {
8782 return this.connection.onRequest(vscode_languageserver_protocol_1.WillRenameFilesRequest.type, (params, cancel) => {
8783 return handler(params, cancel);
8784 });
8785 }
8786 onWillDeleteFiles(handler) {
8787 return this.connection.onRequest(vscode_languageserver_protocol_1.WillDeleteFilesRequest.type, (params, cancel) => {
8788 return handler(params, cancel);
8789 });
8790 }
8791 };
8792};
8793exports.FileOperationsFeature = FileOperationsFeature;
8794//# sourceMappingURL=fileOperations.js.map
8795
8796/***/ }),
8797
8798/***/ 56:
8799/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8800
8801"use strict";
8802
8803/* --------------------------------------------------------------------------------------------
8804 * Copyright (c) Microsoft Corporation. All rights reserved.
8805 * Licensed under the MIT License. See License.txt in the project root for license information.
8806 * ------------------------------------------------------------------------------------------ */
8807Object.defineProperty(exports, "__esModule", ({ value: true }));
8808exports.LinkedEditingRangeFeature = void 0;
8809const vscode_languageserver_protocol_1 = __webpack_require__(5);
8810const LinkedEditingRangeFeature = (Base) => {
8811 return class extends Base {
8812 onLinkedEditingRange(handler) {
8813 this.connection.onRequest(vscode_languageserver_protocol_1.LinkedEditingRangeRequest.type, (params, cancel) => {
8814 return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
8815 });
8816 }
8817 };
8818};
8819exports.LinkedEditingRangeFeature = LinkedEditingRangeFeature;
8820//# sourceMappingURL=linkedEditingRange.js.map
8821
8822/***/ }),
8823
8824/***/ 57:
8825/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8826
8827"use strict";
8828/* --------------------------------------------------------------------------------------------
8829 * Copyright (c) Microsoft Corporation. All rights reserved.
8830 * Licensed under the MIT License. See License.txt in the project root for license information.
8831 * ------------------------------------------------------------------------------------------ */
8832
8833Object.defineProperty(exports, "__esModule", ({ value: true }));
8834exports.MonikerFeature = void 0;
8835const vscode_languageserver_protocol_1 = __webpack_require__(5);
8836const MonikerFeature = (Base) => {
8837 return class extends Base {
8838 get moniker() {
8839 return {
8840 on: (handler) => {
8841 const type = vscode_languageserver_protocol_1.MonikerRequest.type;
8842 this.connection.onRequest(type, (params, cancel) => {
8843 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
8844 });
8845 },
8846 };
8847 }
8848 };
8849};
8850exports.MonikerFeature = MonikerFeature;
8851//# sourceMappingURL=moniker.js.map
8852
8853/***/ }),
8854
8855/***/ 49:
8856/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8857
8858"use strict";
8859
8860/* --------------------------------------------------------------------------------------------
8861 * Copyright (c) Microsoft Corporation. All rights reserved.
8862 * Licensed under the MIT License. See License.txt in the project root for license information.
8863 * ------------------------------------------------------------------------------------------ */
8864Object.defineProperty(exports, "__esModule", ({ value: true }));
8865exports.attachPartialResult = exports.ProgressFeature = exports.attachWorkDone = void 0;
8866const vscode_languageserver_protocol_1 = __webpack_require__(5);
8867const uuid_1 = __webpack_require__(48);
8868class WorkDoneProgressReporterImpl {
8869 constructor(_connection, _token) {
8870 this._connection = _connection;
8871 this._token = _token;
8872 WorkDoneProgressReporterImpl.Instances.set(this._token, this);
8873 }
8874 begin(title, percentage, message, cancellable) {
8875 let param = {
8876 kind: 'begin',
8877 title,
8878 percentage,
8879 message,
8880 cancellable
8881 };
8882 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
8883 }
8884 report(arg0, arg1) {
8885 let param = {
8886 kind: 'report'
8887 };
8888 if (typeof arg0 === 'number') {
8889 param.percentage = arg0;
8890 if (arg1 !== undefined) {
8891 param.message = arg1;
8892 }
8893 }
8894 else {
8895 param.message = arg0;
8896 }
8897 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
8898 }
8899 done() {
8900 WorkDoneProgressReporterImpl.Instances.delete(this._token);
8901 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, { kind: 'end' });
8902 }
8903}
8904WorkDoneProgressReporterImpl.Instances = new Map();
8905class WorkDoneProgressServerReporterImpl extends WorkDoneProgressReporterImpl {
8906 constructor(connection, token) {
8907 super(connection, token);
8908 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
8909 }
8910 get token() {
8911 return this._source.token;
8912 }
8913 done() {
8914 this._source.dispose();
8915 super.done();
8916 }
8917 cancel() {
8918 this._source.cancel();
8919 }
8920}
8921class NullProgressReporter {
8922 constructor() {
8923 }
8924 begin() {
8925 }
8926 report() {
8927 }
8928 done() {
8929 }
8930}
8931class NullProgressServerReporter extends NullProgressReporter {
8932 constructor() {
8933 super();
8934 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
8935 }
8936 get token() {
8937 return this._source.token;
8938 }
8939 done() {
8940 this._source.dispose();
8941 }
8942 cancel() {
8943 this._source.cancel();
8944 }
8945}
8946function attachWorkDone(connection, params) {
8947 if (params === undefined || params.workDoneToken === undefined) {
8948 return new NullProgressReporter();
8949 }
8950 const token = params.workDoneToken;
8951 delete params.workDoneToken;
8952 return new WorkDoneProgressReporterImpl(connection, token);
8953}
8954exports.attachWorkDone = attachWorkDone;
8955const ProgressFeature = (Base) => {
8956 return class extends Base {
8957 constructor() {
8958 super();
8959 this._progressSupported = false;
8960 }
8961 initialize(capabilities) {
8962 var _a;
8963 if (((_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.window) === null || _a === void 0 ? void 0 : _a.workDoneProgress) === true) {
8964 this._progressSupported = true;
8965 this.connection.onNotification(vscode_languageserver_protocol_1.WorkDoneProgressCancelNotification.type, (params) => {
8966 let progress = WorkDoneProgressReporterImpl.Instances.get(params.token);
8967 if (progress instanceof WorkDoneProgressServerReporterImpl || progress instanceof NullProgressServerReporter) {
8968 progress.cancel();
8969 }
8970 });
8971 }
8972 }
8973 attachWorkDoneProgress(token) {
8974 if (token === undefined) {
8975 return new NullProgressReporter();
8976 }
8977 else {
8978 return new WorkDoneProgressReporterImpl(this.connection, token);
8979 }
8980 }
8981 createWorkDoneProgress() {
8982 if (this._progressSupported) {
8983 const token = uuid_1.generateUuid();
8984 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkDoneProgressCreateRequest.type, { token }).then(() => {
8985 const result = new WorkDoneProgressServerReporterImpl(this.connection, token);
8986 return result;
8987 });
8988 }
8989 else {
8990 return Promise.resolve(new NullProgressServerReporter());
8991 }
8992 }
8993 };
8994};
8995exports.ProgressFeature = ProgressFeature;
8996var ResultProgress;
8997(function (ResultProgress) {
8998 ResultProgress.type = new vscode_languageserver_protocol_1.ProgressType();
8999})(ResultProgress || (ResultProgress = {}));
9000class ResultProgressReporterImpl {
9001 constructor(_connection, _token) {
9002 this._connection = _connection;
9003 this._token = _token;
9004 }
9005 report(data) {
9006 this._connection.sendProgress(ResultProgress.type, this._token, data);
9007 }
9008}
9009function attachPartialResult(connection, params) {
9010 if (params === undefined || params.partialResultToken === undefined) {
9011 return undefined;
9012 }
9013 const token = params.partialResultToken;
9014 delete params.partialResultToken;
9015 return new ResultProgressReporterImpl(connection, token);
9016}
9017exports.attachPartialResult = attachPartialResult;
9018//# sourceMappingURL=progress.js.map
9019
9020/***/ }),
9021
9022/***/ 53:
9023/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9024
9025"use strict";
9026
9027/* --------------------------------------------------------------------------------------------
9028 * Copyright (c) Microsoft Corporation. All rights reserved.
9029 * Licensed under the MIT License. See License.txt in the project root for license information.
9030 * ------------------------------------------------------------------------------------------ */
9031Object.defineProperty(exports, "__esModule", ({ value: true }));
9032exports.SemanticTokensBuilder = exports.SemanticTokensFeature = void 0;
9033const vscode_languageserver_protocol_1 = __webpack_require__(5);
9034const SemanticTokensFeature = (Base) => {
9035 return class extends Base {
9036 get semanticTokens() {
9037 return {
9038 on: (handler) => {
9039 const type = vscode_languageserver_protocol_1.SemanticTokensRequest.type;
9040 this.connection.onRequest(type, (params, cancel) => {
9041 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
9042 });
9043 },
9044 onDelta: (handler) => {
9045 const type = vscode_languageserver_protocol_1.SemanticTokensDeltaRequest.type;
9046 this.connection.onRequest(type, (params, cancel) => {
9047 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
9048 });
9049 },
9050 onRange: (handler) => {
9051 const type = vscode_languageserver_protocol_1.SemanticTokensRangeRequest.type;
9052 this.connection.onRequest(type, (params, cancel) => {
9053 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
9054 });
9055 }
9056 };
9057 }
9058 };
9059};
9060exports.SemanticTokensFeature = SemanticTokensFeature;
9061class SemanticTokensBuilder {
9062 constructor() {
9063 this._prevData = undefined;
9064 this.initialize();
9065 }
9066 initialize() {
9067 this._id = Date.now();
9068 this._prevLine = 0;
9069 this._prevChar = 0;
9070 this._data = [];
9071 this._dataLen = 0;
9072 }
9073 push(line, char, length, tokenType, tokenModifiers) {
9074 let pushLine = line;
9075 let pushChar = char;
9076 if (this._dataLen > 0) {
9077 pushLine -= this._prevLine;
9078 if (pushLine === 0) {
9079 pushChar -= this._prevChar;
9080 }
9081 }
9082 this._data[this._dataLen++] = pushLine;
9083 this._data[this._dataLen++] = pushChar;
9084 this._data[this._dataLen++] = length;
9085 this._data[this._dataLen++] = tokenType;
9086 this._data[this._dataLen++] = tokenModifiers;
9087 this._prevLine = line;
9088 this._prevChar = char;
9089 }
9090 get id() {
9091 return this._id.toString();
9092 }
9093 previousResult(id) {
9094 if (this.id === id) {
9095 this._prevData = this._data;
9096 }
9097 this.initialize();
9098 }
9099 build() {
9100 this._prevData = undefined;
9101 return {
9102 resultId: this.id,
9103 data: this._data
9104 };
9105 }
9106 canBuildEdits() {
9107 return this._prevData !== undefined;
9108 }
9109 buildEdits() {
9110 if (this._prevData !== undefined) {
9111 const prevDataLength = this._prevData.length;
9112 const dataLength = this._data.length;
9113 let startIndex = 0;
9114 while (startIndex < dataLength && startIndex < prevDataLength && this._prevData[startIndex] === this._data[startIndex]) {
9115 startIndex++;
9116 }
9117 if (startIndex < dataLength && startIndex < prevDataLength) {
9118 // Find end index
9119 let endIndex = 0;
9120 while (endIndex < dataLength && endIndex < prevDataLength && this._prevData[prevDataLength - 1 - endIndex] === this._data[dataLength - 1 - endIndex]) {
9121 endIndex++;
9122 }
9123 const newData = this._data.slice(startIndex, dataLength - endIndex);
9124 const result = {
9125 resultId: this.id,
9126 edits: [
9127 { start: startIndex, deleteCount: prevDataLength - endIndex - startIndex, data: newData }
9128 ]
9129 };
9130 return result;
9131 }
9132 else if (startIndex < dataLength) {
9133 return { resultId: this.id, edits: [
9134 { start: startIndex, deleteCount: 0, data: this._data.slice(startIndex) }
9135 ] };
9136 }
9137 else if (startIndex < prevDataLength) {
9138 return { resultId: this.id, edits: [
9139 { start: startIndex, deleteCount: prevDataLength - startIndex }
9140 ] };
9141 }
9142 else {
9143 return { resultId: this.id, edits: [] };
9144 }
9145 }
9146 else {
9147 return this.build();
9148 }
9149 }
9150}
9151exports.SemanticTokensBuilder = SemanticTokensBuilder;
9152//# sourceMappingURL=semanticTokens.js.map
9153
9154/***/ }),
9155
9156/***/ 4:
9157/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9158
9159"use strict";
9160
9161/* --------------------------------------------------------------------------------------------
9162 * Copyright (c) Microsoft Corporation. All rights reserved.
9163 * Licensed under the MIT License. See License.txt in the project root for license information.
9164 * ------------------------------------------------------------------------------------------ */
9165Object.defineProperty(exports, "__esModule", ({ value: true }));
9166exports.createConnection = exports.combineFeatures = exports.combineLanguagesFeatures = exports.combineWorkspaceFeatures = exports.combineWindowFeatures = exports.combineClientFeatures = exports.combineTracerFeatures = exports.combineTelemetryFeatures = exports.combineConsoleFeatures = exports._LanguagesImpl = exports.BulkUnregistration = exports.BulkRegistration = exports.ErrorMessageTracker = exports.TextDocuments = void 0;
9167const vscode_languageserver_protocol_1 = __webpack_require__(5);
9168const Is = __webpack_require__(3);
9169const UUID = __webpack_require__(48);
9170const progress_1 = __webpack_require__(49);
9171const configuration_1 = __webpack_require__(50);
9172const workspaceFolders_1 = __webpack_require__(51);
9173const callHierarchy_1 = __webpack_require__(52);
9174const semanticTokens_1 = __webpack_require__(53);
9175const showDocument_1 = __webpack_require__(54);
9176const fileOperations_1 = __webpack_require__(55);
9177const linkedEditingRange_1 = __webpack_require__(56);
9178const moniker_1 = __webpack_require__(57);
9179function null2Undefined(value) {
9180 if (value === null) {
9181 return undefined;
9182 }
9183 return value;
9184}
9185/**
9186 * A manager for simple text documents
9187 */
9188class TextDocuments {
9189 /**
9190 * Create a new text document manager.
9191 */
9192 constructor(configuration) {
9193 this._documents = Object.create(null);
9194 this._configuration = configuration;
9195 this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
9196 this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
9197 this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
9198 this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
9199 this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
9200 }
9201 /**
9202 * An event that fires when a text document managed by this manager
9203 * has been opened or the content changes.
9204 */
9205 get onDidChangeContent() {
9206 return this._onDidChangeContent.event;
9207 }
9208 /**
9209 * An event that fires when a text document managed by this manager
9210 * has been opened.
9211 */
9212 get onDidOpen() {
9213 return this._onDidOpen.event;
9214 }
9215 /**
9216 * An event that fires when a text document managed by this manager
9217 * will be saved.
9218 */
9219 get onWillSave() {
9220 return this._onWillSave.event;
9221 }
9222 /**
9223 * Sets a handler that will be called if a participant wants to provide
9224 * edits during a text document save.
9225 */
9226 onWillSaveWaitUntil(handler) {
9227 this._willSaveWaitUntil = handler;
9228 }
9229 /**
9230 * An event that fires when a text document managed by this manager
9231 * has been saved.
9232 */
9233 get onDidSave() {
9234 return this._onDidSave.event;
9235 }
9236 /**
9237 * An event that fires when a text document managed by this manager
9238 * has been closed.
9239 */
9240 get onDidClose() {
9241 return this._onDidClose.event;
9242 }
9243 /**
9244 * Returns the document for the given URI. Returns undefined if
9245 * the document is not managed by this instance.
9246 *
9247 * @param uri The text document's URI to retrieve.
9248 * @return the text document or `undefined`.
9249 */
9250 get(uri) {
9251 return this._documents[uri];
9252 }
9253 /**
9254 * Returns all text documents managed by this instance.
9255 *
9256 * @return all text documents.
9257 */
9258 all() {
9259 return Object.keys(this._documents).map(key => this._documents[key]);
9260 }
9261 /**
9262 * Returns the URIs of all text documents managed by this instance.
9263 *
9264 * @return the URI's of all text documents.
9265 */
9266 keys() {
9267 return Object.keys(this._documents);
9268 }
9269 /**
9270 * Listens for `low level` notification on the given connection to
9271 * update the text documents managed by this instance.
9272 *
9273 * Please note that the connection only provides handlers not an event model. Therefore
9274 * listening on a connection will overwrite the following handlers on a connection:
9275 * `onDidOpenTextDocument`, `onDidChangeTextDocument`, `onDidCloseTextDocument`,
9276 * `onWillSaveTextDocument`, `onWillSaveTextDocumentWaitUntil` and `onDidSaveTextDocument`.
9277 *
9278 * Use the corresponding events on the TextDocuments instance instead.
9279 *
9280 * @param connection The connection to listen on.
9281 */
9282 listen(connection) {
9283 connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
9284 connection.onDidOpenTextDocument((event) => {
9285 let td = event.textDocument;
9286 let document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
9287 this._documents[td.uri] = document;
9288 let toFire = Object.freeze({ document });
9289 this._onDidOpen.fire(toFire);
9290 this._onDidChangeContent.fire(toFire);
9291 });
9292 connection.onDidChangeTextDocument((event) => {
9293 let td = event.textDocument;
9294 let changes = event.contentChanges;
9295 if (changes.length === 0) {
9296 return;
9297 }
9298 let document = this._documents[td.uri];
9299 const { version } = td;
9300 if (version === null || version === undefined) {
9301 throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
9302 }
9303 document = this._configuration.update(document, changes, version);
9304 this._documents[td.uri] = document;
9305 this._onDidChangeContent.fire(Object.freeze({ document }));
9306 });
9307 connection.onDidCloseTextDocument((event) => {
9308 let document = this._documents[event.textDocument.uri];
9309 if (document) {
9310 delete this._documents[event.textDocument.uri];
9311 this._onDidClose.fire(Object.freeze({ document }));
9312 }
9313 });
9314 connection.onWillSaveTextDocument((event) => {
9315 let document = this._documents[event.textDocument.uri];
9316 if (document) {
9317 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
9318 }
9319 });
9320 connection.onWillSaveTextDocumentWaitUntil((event, token) => {
9321 let document = this._documents[event.textDocument.uri];
9322 if (document && this._willSaveWaitUntil) {
9323 return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);
9324 }
9325 else {
9326 return [];
9327 }
9328 });
9329 connection.onDidSaveTextDocument((event) => {
9330 let document = this._documents[event.textDocument.uri];
9331 if (document) {
9332 this._onDidSave.fire(Object.freeze({ document }));
9333 }
9334 });
9335 }
9336}
9337exports.TextDocuments = TextDocuments;
9338/**
9339 * Helps tracking error message. Equal occurrences of the same
9340 * message are only stored once. This class is for example
9341 * useful if text documents are validated in a loop and equal
9342 * error message should be folded into one.
9343 */
9344class ErrorMessageTracker {
9345 constructor() {
9346 this._messages = Object.create(null);
9347 }
9348 /**
9349 * Add a message to the tracker.
9350 *
9351 * @param message The message to add.
9352 */
9353 add(message) {
9354 let count = this._messages[message];
9355 if (!count) {
9356 count = 0;
9357 }
9358 count++;
9359 this._messages[message] = count;
9360 }
9361 /**
9362 * Send all tracked messages to the connection's window.
9363 *
9364 * @param connection The connection established between client and server.
9365 */
9366 sendErrors(connection) {
9367 Object.keys(this._messages).forEach(message => {
9368 connection.window.showErrorMessage(message);
9369 });
9370 }
9371}
9372exports.ErrorMessageTracker = ErrorMessageTracker;
9373class RemoteConsoleImpl {
9374 constructor() {
9375 }
9376 rawAttach(connection) {
9377 this._rawConnection = connection;
9378 }
9379 attach(connection) {
9380 this._connection = connection;
9381 }
9382 get connection() {
9383 if (!this._connection) {
9384 throw new Error('Remote is not attached to a connection yet.');
9385 }
9386 return this._connection;
9387 }
9388 fillServerCapabilities(_capabilities) {
9389 }
9390 initialize(_capabilities) {
9391 }
9392 error(message) {
9393 this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
9394 }
9395 warn(message) {
9396 this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
9397 }
9398 info(message) {
9399 this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
9400 }
9401 log(message) {
9402 this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
9403 }
9404 send(type, message) {
9405 if (this._rawConnection) {
9406 this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });
9407 }
9408 }
9409}
9410class _RemoteWindowImpl {
9411 constructor() {
9412 }
9413 attach(connection) {
9414 this._connection = connection;
9415 }
9416 get connection() {
9417 if (!this._connection) {
9418 throw new Error('Remote is not attached to a connection yet.');
9419 }
9420 return this._connection;
9421 }
9422 initialize(_capabilities) {
9423 }
9424 fillServerCapabilities(_capabilities) {
9425 }
9426 showErrorMessage(message, ...actions) {
9427 let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };
9428 return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
9429 }
9430 showWarningMessage(message, ...actions) {
9431 let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };
9432 return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
9433 }
9434 showInformationMessage(message, ...actions) {
9435 let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };
9436 return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
9437 }
9438}
9439const RemoteWindowImpl = showDocument_1.ShowDocumentFeature(progress_1.ProgressFeature(_RemoteWindowImpl));
9440var BulkRegistration;
9441(function (BulkRegistration) {
9442 /**
9443 * Creates a new bulk registration.
9444 * @return an empty bulk registration.
9445 */
9446 function create() {
9447 return new BulkRegistrationImpl();
9448 }
9449 BulkRegistration.create = create;
9450})(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));
9451class BulkRegistrationImpl {
9452 constructor() {
9453 this._registrations = [];
9454 this._registered = new Set();
9455 }
9456 add(type, registerOptions) {
9457 const method = Is.string(type) ? type : type.method;
9458 if (this._registered.has(method)) {
9459 throw new Error(`${method} is already added to this registration`);
9460 }
9461 const id = UUID.generateUuid();
9462 this._registrations.push({
9463 id: id,
9464 method: method,
9465 registerOptions: registerOptions || {}
9466 });
9467 this._registered.add(method);
9468 }
9469 asRegistrationParams() {
9470 return {
9471 registrations: this._registrations
9472 };
9473 }
9474}
9475var BulkUnregistration;
9476(function (BulkUnregistration) {
9477 function create() {
9478 return new BulkUnregistrationImpl(undefined, []);
9479 }
9480 BulkUnregistration.create = create;
9481})(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));
9482class BulkUnregistrationImpl {
9483 constructor(_connection, unregistrations) {
9484 this._connection = _connection;
9485 this._unregistrations = new Map();
9486 unregistrations.forEach(unregistration => {
9487 this._unregistrations.set(unregistration.method, unregistration);
9488 });
9489 }
9490 get isAttached() {
9491 return !!this._connection;
9492 }
9493 attach(connection) {
9494 this._connection = connection;
9495 }
9496 add(unregistration) {
9497 this._unregistrations.set(unregistration.method, unregistration);
9498 }
9499 dispose() {
9500 let unregistrations = [];
9501 for (let unregistration of this._unregistrations.values()) {
9502 unregistrations.push(unregistration);
9503 }
9504 let params = {
9505 unregisterations: unregistrations
9506 };
9507 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
9508 this._connection.console.info(`Bulk unregistration failed.`);
9509 });
9510 }
9511 disposeSingle(arg) {
9512 const method = Is.string(arg) ? arg : arg.method;
9513 const unregistration = this._unregistrations.get(method);
9514 if (!unregistration) {
9515 return false;
9516 }
9517 let params = {
9518 unregisterations: [unregistration]
9519 };
9520 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
9521 this._unregistrations.delete(method);
9522 }, (_error) => {
9523 this._connection.console.info(`Un-registering request handler for ${unregistration.id} failed.`);
9524 });
9525 return true;
9526 }
9527}
9528class RemoteClientImpl {
9529 attach(connection) {
9530 this._connection = connection;
9531 }
9532 get connection() {
9533 if (!this._connection) {
9534 throw new Error('Remote is not attached to a connection yet.');
9535 }
9536 return this._connection;
9537 }
9538 initialize(_capabilities) {
9539 }
9540 fillServerCapabilities(_capabilities) {
9541 }
9542 register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
9543 if (typeOrRegistrations instanceof BulkRegistrationImpl) {
9544 return this.registerMany(typeOrRegistrations);
9545 }
9546 else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
9547 return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
9548 }
9549 else {
9550 return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
9551 }
9552 }
9553 registerSingle1(unregistration, type, registerOptions) {
9554 const method = Is.string(type) ? type : type.method;
9555 const id = UUID.generateUuid();
9556 let params = {
9557 registrations: [{ id, method, registerOptions: registerOptions || {} }]
9558 };
9559 if (!unregistration.isAttached) {
9560 unregistration.attach(this.connection);
9561 }
9562 return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
9563 unregistration.add({ id: id, method: method });
9564 return unregistration;
9565 }, (_error) => {
9566 this.connection.console.info(`Registering request handler for ${method} failed.`);
9567 return Promise.reject(_error);
9568 });
9569 }
9570 registerSingle2(type, registerOptions) {
9571 const method = Is.string(type) ? type : type.method;
9572 const id = UUID.generateUuid();
9573 let params = {
9574 registrations: [{ id, method, registerOptions: registerOptions || {} }]
9575 };
9576 return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
9577 return vscode_languageserver_protocol_1.Disposable.create(() => {
9578 this.unregisterSingle(id, method);
9579 });
9580 }, (_error) => {
9581 this.connection.console.info(`Registering request handler for ${method} failed.`);
9582 return Promise.reject(_error);
9583 });
9584 }
9585 unregisterSingle(id, method) {
9586 let params = {
9587 unregisterations: [{ id, method }]
9588 };
9589 return this.connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
9590 this.connection.console.info(`Un-registering request handler for ${id} failed.`);
9591 });
9592 }
9593 registerMany(registrations) {
9594 let params = registrations.asRegistrationParams();
9595 return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
9596 return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
9597 }, (_error) => {
9598 this.connection.console.info(`Bulk registration failed.`);
9599 return Promise.reject(_error);
9600 });
9601 }
9602}
9603class _RemoteWorkspaceImpl {
9604 constructor() {
9605 }
9606 attach(connection) {
9607 this._connection = connection;
9608 }
9609 get connection() {
9610 if (!this._connection) {
9611 throw new Error('Remote is not attached to a connection yet.');
9612 }
9613 return this._connection;
9614 }
9615 initialize(_capabilities) {
9616 }
9617 fillServerCapabilities(_capabilities) {
9618 }
9619 applyEdit(paramOrEdit) {
9620 function isApplyWorkspaceEditParams(value) {
9621 return value && !!value.edit;
9622 }
9623 let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
9624 return this.connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
9625 }
9626}
9627const RemoteWorkspaceImpl = fileOperations_1.FileOperationsFeature(workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl)));
9628class TracerImpl {
9629 constructor() {
9630 this._trace = vscode_languageserver_protocol_1.Trace.Off;
9631 }
9632 attach(connection) {
9633 this._connection = connection;
9634 }
9635 get connection() {
9636 if (!this._connection) {
9637 throw new Error('Remote is not attached to a connection yet.');
9638 }
9639 return this._connection;
9640 }
9641 initialize(_capabilities) {
9642 }
9643 fillServerCapabilities(_capabilities) {
9644 }
9645 set trace(value) {
9646 this._trace = value;
9647 }
9648 log(message, verbose) {
9649 if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
9650 return;
9651 }
9652 this.connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
9653 message: message,
9654 verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
9655 });
9656 }
9657}
9658class TelemetryImpl {
9659 constructor() {
9660 }
9661 attach(connection) {
9662 this._connection = connection;
9663 }
9664 get connection() {
9665 if (!this._connection) {
9666 throw new Error('Remote is not attached to a connection yet.');
9667 }
9668 return this._connection;
9669 }
9670 initialize(_capabilities) {
9671 }
9672 fillServerCapabilities(_capabilities) {
9673 }
9674 logEvent(data) {
9675 this.connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
9676 }
9677}
9678class _LanguagesImpl {
9679 constructor() {
9680 }
9681 attach(connection) {
9682 this._connection = connection;
9683 }
9684 get connection() {
9685 if (!this._connection) {
9686 throw new Error('Remote is not attached to a connection yet.');
9687 }
9688 return this._connection;
9689 }
9690 initialize(_capabilities) {
9691 }
9692 fillServerCapabilities(_capabilities) {
9693 }
9694 attachWorkDoneProgress(params) {
9695 return progress_1.attachWorkDone(this.connection, params);
9696 }
9697 attachPartialResultProgress(_type, params) {
9698 return progress_1.attachPartialResult(this.connection, params);
9699 }
9700}
9701exports._LanguagesImpl = _LanguagesImpl;
9702const LanguagesImpl = moniker_1.MonikerFeature(linkedEditingRange_1.LinkedEditingRangeFeature(semanticTokens_1.SemanticTokensFeature(callHierarchy_1.CallHierarchyFeature(_LanguagesImpl))));
9703function combineConsoleFeatures(one, two) {
9704 return function (Base) {
9705 return two(one(Base));
9706 };
9707}
9708exports.combineConsoleFeatures = combineConsoleFeatures;
9709function combineTelemetryFeatures(one, two) {
9710 return function (Base) {
9711 return two(one(Base));
9712 };
9713}
9714exports.combineTelemetryFeatures = combineTelemetryFeatures;
9715function combineTracerFeatures(one, two) {
9716 return function (Base) {
9717 return two(one(Base));
9718 };
9719}
9720exports.combineTracerFeatures = combineTracerFeatures;
9721function combineClientFeatures(one, two) {
9722 return function (Base) {
9723 return two(one(Base));
9724 };
9725}
9726exports.combineClientFeatures = combineClientFeatures;
9727function combineWindowFeatures(one, two) {
9728 return function (Base) {
9729 return two(one(Base));
9730 };
9731}
9732exports.combineWindowFeatures = combineWindowFeatures;
9733function combineWorkspaceFeatures(one, two) {
9734 return function (Base) {
9735 return two(one(Base));
9736 };
9737}
9738exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
9739function combineLanguagesFeatures(one, two) {
9740 return function (Base) {
9741 return two(one(Base));
9742 };
9743}
9744exports.combineLanguagesFeatures = combineLanguagesFeatures;
9745function combineFeatures(one, two) {
9746 function combine(one, two, func) {
9747 if (one && two) {
9748 return func(one, two);
9749 }
9750 else if (one) {
9751 return one;
9752 }
9753 else {
9754 return two;
9755 }
9756 }
9757 let result = {
9758 __brand: 'features',
9759 console: combine(one.console, two.console, combineConsoleFeatures),
9760 tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
9761 telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
9762 client: combine(one.client, two.client, combineClientFeatures),
9763 window: combine(one.window, two.window, combineWindowFeatures),
9764 workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)
9765 };
9766 return result;
9767}
9768exports.combineFeatures = combineFeatures;
9769function createConnection(connectionFactory, watchDog, factories) {
9770 const logger = (factories && factories.console ? new (factories.console(RemoteConsoleImpl))() : new RemoteConsoleImpl());
9771 const connection = connectionFactory(logger);
9772 logger.rawAttach(connection);
9773 const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());
9774 const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());
9775 const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());
9776 const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());
9777 const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());
9778 const languages = (factories && factories.languages ? new (factories.languages(LanguagesImpl))() : new LanguagesImpl());
9779 const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages];
9780 function asPromise(value) {
9781 if (value instanceof Promise) {
9782 return value;
9783 }
9784 else if (Is.thenable(value)) {
9785 return new Promise((resolve, reject) => {
9786 value.then((resolved) => resolve(resolved), (error) => reject(error));
9787 });
9788 }
9789 else {
9790 return Promise.resolve(value);
9791 }
9792 }
9793 let shutdownHandler = undefined;
9794 let initializeHandler = undefined;
9795 let exitHandler = undefined;
9796 let protocolConnection = {
9797 listen: () => connection.listen(),
9798 sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
9799 onRequest: (type, handler) => connection.onRequest(type, handler),
9800 sendNotification: (type, param) => {
9801 const method = Is.string(type) ? type : type.method;
9802 if (arguments.length === 1) {
9803 connection.sendNotification(method);
9804 }
9805 else {
9806 connection.sendNotification(method, param);
9807 }
9808 },
9809 onNotification: (type, handler) => connection.onNotification(type, handler),
9810 onProgress: connection.onProgress,
9811 sendProgress: connection.sendProgress,
9812 onInitialize: (handler) => initializeHandler = handler,
9813 onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
9814 onShutdown: (handler) => shutdownHandler = handler,
9815 onExit: (handler) => exitHandler = handler,
9816 get console() { return logger; },
9817 get telemetry() { return telemetry; },
9818 get tracer() { return tracer; },
9819 get client() { return client; },
9820 get window() { return remoteWindow; },
9821 get workspace() { return workspace; },
9822 get languages() { return languages; },
9823 onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
9824 onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
9825 __textDocumentSync: undefined,
9826 onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
9827 onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
9828 onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
9829 onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
9830 onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
9831 onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
9832 sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
9833 onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, (params, cancel) => {
9834 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
9835 }),
9836 onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
9837 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9838 }),
9839 onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
9840 onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
9841 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
9842 }),
9843 onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
9844 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9845 }),
9846 onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
9847 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9848 }),
9849 onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
9850 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9851 }),
9852 onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
9853 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9854 }),
9855 onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
9856 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9857 }),
9858 onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
9859 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9860 }),
9861 onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
9862 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9863 }),
9864 onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
9865 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9866 }),
9867 onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
9868 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9869 }),
9870 onCodeActionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionResolveRequest.type, (params, cancel) => {
9871 return handler(params, cancel);
9872 }),
9873 onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
9874 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9875 }),
9876 onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, (params, cancel) => {
9877 return handler(params, cancel);
9878 }),
9879 onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
9880 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
9881 }),
9882 onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
9883 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
9884 }),
9885 onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, (params, cancel) => {
9886 return handler(params, cancel);
9887 }),
9888 onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, (params, cancel) => {
9889 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
9890 }),
9891 onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, (params, cancel) => {
9892 return handler(params, cancel);
9893 }),
9894 onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, (params, cancel) => {
9895 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9896 }),
9897 onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, (params, cancel) => {
9898 return handler(params, cancel);
9899 }),
9900 onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
9901 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9902 }),
9903 onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
9904 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9905 }),
9906 onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
9907 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9908 }),
9909 onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
9910 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
9911 }),
9912 onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
9913 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
9914 }),
9915 dispose: () => connection.dispose()
9916 };
9917 for (let remote of allRemotes) {
9918 remote.attach(protocolConnection);
9919 }
9920 connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
9921 watchDog.initialize(params);
9922 if (Is.string(params.trace)) {
9923 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
9924 }
9925 for (let remote of allRemotes) {
9926 remote.initialize(params.capabilities);
9927 }
9928 if (initializeHandler) {
9929 let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token, progress_1.attachWorkDone(connection, params), undefined);
9930 return asPromise(result).then((value) => {
9931 if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
9932 return value;
9933 }
9934 let result = value;
9935 if (!result) {
9936 result = { capabilities: {} };
9937 }
9938 let capabilities = result.capabilities;
9939 if (!capabilities) {
9940 capabilities = {};
9941 result.capabilities = capabilities;
9942 }
9943 if (capabilities.textDocumentSync === undefined || capabilities.textDocumentSync === null) {
9944 capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
9945 }
9946 else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
9947 capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
9948 }
9949 for (let remote of allRemotes) {
9950 remote.fillServerCapabilities(capabilities);
9951 }
9952 return result;
9953 });
9954 }
9955 else {
9956 let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };
9957 for (let remote of allRemotes) {
9958 remote.fillServerCapabilities(result.capabilities);
9959 }
9960 return result;
9961 }
9962 });
9963 connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
9964 watchDog.shutdownReceived = true;
9965 if (shutdownHandler) {
9966 return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
9967 }
9968 else {
9969 return undefined;
9970 }
9971 });
9972 connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
9973 try {
9974 if (exitHandler) {
9975 exitHandler();
9976 }
9977 }
9978 finally {
9979 if (watchDog.shutdownReceived) {
9980 watchDog.exit(0);
9981 }
9982 else {
9983 watchDog.exit(1);
9984 }
9985 }
9986 });
9987 connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
9988 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
9989 });
9990 return protocolConnection;
9991}
9992exports.createConnection = createConnection;
9993//# sourceMappingURL=server.js.map
9994
9995/***/ }),
9996
9997/***/ 54:
9998/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9999
10000"use strict";
10001
10002/* --------------------------------------------------------------------------------------------
10003 * Copyright (c) Microsoft Corporation. All rights reserved.
10004 * Licensed under the MIT License. See License.txt in the project root for license information.
10005 * ------------------------------------------------------------------------------------------ */
10006Object.defineProperty(exports, "__esModule", ({ value: true }));
10007exports.ShowDocumentFeature = void 0;
10008const vscode_languageserver_protocol_1 = __webpack_require__(5);
10009const ShowDocumentFeature = (Base) => {
10010 return class extends Base {
10011 showDocument(params) {
10012 return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowDocumentRequest.type, params);
10013 }
10014 };
10015};
10016exports.ShowDocumentFeature = ShowDocumentFeature;
10017//# sourceMappingURL=showDocument.js.map
10018
10019/***/ }),
10020
10021/***/ 3:
10022/***/ ((__unused_webpack_module, exports) => {
10023
10024"use strict";
10025
10026/* --------------------------------------------------------------------------------------------
10027 * Copyright (c) Microsoft Corporation. All rights reserved.
10028 * Licensed under the MIT License. See License.txt in the project root for license information.
10029 * ------------------------------------------------------------------------------------------ */
10030Object.defineProperty(exports, "__esModule", ({ value: true }));
10031exports.thenable = exports.typedArray = exports.stringArray = exports.array = exports.func = exports.error = exports.number = exports.string = exports.boolean = void 0;
10032function boolean(value) {
10033 return value === true || value === false;
10034}
10035exports.boolean = boolean;
10036function string(value) {
10037 return typeof value === 'string' || value instanceof String;
10038}
10039exports.string = string;
10040function number(value) {
10041 return typeof value === 'number' || value instanceof Number;
10042}
10043exports.number = number;
10044function error(value) {
10045 return value instanceof Error;
10046}
10047exports.error = error;
10048function func(value) {
10049 return typeof value === 'function';
10050}
10051exports.func = func;
10052function array(value) {
10053 return Array.isArray(value);
10054}
10055exports.array = array;
10056function stringArray(value) {
10057 return array(value) && value.every(elem => string(elem));
10058}
10059exports.stringArray = stringArray;
10060function typedArray(value, check) {
10061 return Array.isArray(value) && value.every(check);
10062}
10063exports.typedArray = typedArray;
10064function thenable(value) {
10065 return value && func(value.then);
10066}
10067exports.thenable = thenable;
10068//# sourceMappingURL=is.js.map
10069
10070/***/ }),
10071
10072/***/ 48:
10073/***/ ((__unused_webpack_module, exports) => {
10074
10075"use strict";
10076
10077/*---------------------------------------------------------------------------------------------
10078 * Copyright (c) Microsoft Corporation. All rights reserved.
10079 * Licensed under the MIT License. See License.txt in the project root for license information.
10080 *--------------------------------------------------------------------------------------------*/
10081Object.defineProperty(exports, "__esModule", ({ value: true }));
10082exports.generateUuid = exports.parse = exports.isUUID = exports.v4 = exports.empty = void 0;
10083class ValueUUID {
10084 constructor(_value) {
10085 this._value = _value;
10086 // empty
10087 }
10088 asHex() {
10089 return this._value;
10090 }
10091 equals(other) {
10092 return this.asHex() === other.asHex();
10093 }
10094}
10095class V4UUID extends ValueUUID {
10096 constructor() {
10097 super([
10098 V4UUID._randomHex(),
10099 V4UUID._randomHex(),
10100 V4UUID._randomHex(),
10101 V4UUID._randomHex(),
10102 V4UUID._randomHex(),
10103 V4UUID._randomHex(),
10104 V4UUID._randomHex(),
10105 V4UUID._randomHex(),
10106 '-',
10107 V4UUID._randomHex(),
10108 V4UUID._randomHex(),
10109 V4UUID._randomHex(),
10110 V4UUID._randomHex(),
10111 '-',
10112 '4',
10113 V4UUID._randomHex(),
10114 V4UUID._randomHex(),
10115 V4UUID._randomHex(),
10116 '-',
10117 V4UUID._oneOf(V4UUID._timeHighBits),
10118 V4UUID._randomHex(),
10119 V4UUID._randomHex(),
10120 V4UUID._randomHex(),
10121 '-',
10122 V4UUID._randomHex(),
10123 V4UUID._randomHex(),
10124 V4UUID._randomHex(),
10125 V4UUID._randomHex(),
10126 V4UUID._randomHex(),
10127 V4UUID._randomHex(),
10128 V4UUID._randomHex(),
10129 V4UUID._randomHex(),
10130 V4UUID._randomHex(),
10131 V4UUID._randomHex(),
10132 V4UUID._randomHex(),
10133 V4UUID._randomHex(),
10134 ].join(''));
10135 }
10136 static _oneOf(array) {
10137 return array[Math.floor(array.length * Math.random())];
10138 }
10139 static _randomHex() {
10140 return V4UUID._oneOf(V4UUID._chars);
10141 }
10142}
10143V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
10144V4UUID._timeHighBits = ['8', '9', 'a', 'b'];
10145/**
10146 * An empty UUID that contains only zeros.
10147 */
10148exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');
10149function v4() {
10150 return new V4UUID();
10151}
10152exports.v4 = v4;
10153const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10154function isUUID(value) {
10155 return _UUIDPattern.test(value);
10156}
10157exports.isUUID = isUUID;
10158/**
10159 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
10160 * @param value A uuid string.
10161 */
10162function parse(value) {
10163 if (!isUUID(value)) {
10164 throw new Error('invalid uuid');
10165 }
10166 return new ValueUUID(value);
10167}
10168exports.parse = parse;
10169function generateUuid() {
10170 return v4().asHex();
10171}
10172exports.generateUuid = generateUuid;
10173//# sourceMappingURL=uuid.js.map
10174
10175/***/ }),
10176
10177/***/ 51:
10178/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
10179
10180"use strict";
10181/* --------------------------------------------------------------------------------------------
10182 * Copyright (c) Microsoft Corporation. All rights reserved.
10183 * Licensed under the MIT License. See License.txt in the project root for license information.
10184 * ------------------------------------------------------------------------------------------ */
10185
10186Object.defineProperty(exports, "__esModule", ({ value: true }));
10187exports.WorkspaceFoldersFeature = void 0;
10188const vscode_languageserver_protocol_1 = __webpack_require__(5);
10189const WorkspaceFoldersFeature = (Base) => {
10190 return class extends Base {
10191 initialize(capabilities) {
10192 let workspaceCapabilities = capabilities.workspace;
10193 if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {
10194 this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();
10195 this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {
10196 this._onDidChangeWorkspaceFolders.fire(params.event);
10197 });
10198 }
10199 }
10200 getWorkspaceFolders() {
10201 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
10202 }
10203 get onDidChangeWorkspaceFolders() {
10204 if (!this._onDidChangeWorkspaceFolders) {
10205 throw new Error('Client doesn\'t support sending workspace folder change events.');
10206 }
10207 if (!this._unregistration) {
10208 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
10209 }
10210 return this._onDidChangeWorkspaceFolders.event;
10211 }
10212 };
10213};
10214exports.WorkspaceFoldersFeature = WorkspaceFoldersFeature;
10215//# sourceMappingURL=workspaceFolders.js.map
10216
10217/***/ }),
10218
10219/***/ 58:
10220/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
10221
10222"use strict";
10223
10224/* --------------------------------------------------------------------------------------------
10225 * Copyright (c) Microsoft Corporation. All rights reserved.
10226 * Licensed under the MIT License. See License.txt in the project root for license information.
10227 * ------------------------------------------------------------------------------------------ */
10228Object.defineProperty(exports, "__esModule", ({ value: true }));
10229exports.resolveModulePath = exports.FileSystem = exports.resolveGlobalYarnPath = exports.resolveGlobalNodePath = exports.resolve = exports.uriToFilePath = void 0;
10230const url = __webpack_require__(59);
10231const path = __webpack_require__(23);
10232const fs = __webpack_require__(60);
10233const child_process_1 = __webpack_require__(61);
10234/**
10235 * @deprecated Use the `vscode-uri` npm module which provides a more
10236 * complete implementation of handling VS Code URIs.
10237 */
10238function uriToFilePath(uri) {
10239 let parsed = url.parse(uri);
10240 if (parsed.protocol !== 'file:' || !parsed.path) {
10241 return undefined;
10242 }
10243 let segments = parsed.path.split('/');
10244 for (var i = 0, len = segments.length; i < len; i++) {
10245 segments[i] = decodeURIComponent(segments[i]);
10246 }
10247 if (process.platform === 'win32' && segments.length > 1) {
10248 let first = segments[0];
10249 let second = segments[1];
10250 // Do we have a drive letter and we started with a / which is the
10251 // case if the first segement is empty (see split above)
10252 if (first.length === 0 && second.length > 1 && second[1] === ':') {
10253 // Remove first slash
10254 segments.shift();
10255 }
10256 }
10257 return path.normalize(segments.join('/'));
10258}
10259exports.uriToFilePath = uriToFilePath;
10260function isWindows() {
10261 return process.platform === 'win32';
10262}
10263function resolve(moduleName, nodePath, cwd, tracer) {
10264 const nodePathKey = 'NODE_PATH';
10265 const app = [
10266 'var p = process;',
10267 'p.on(\'message\',function(m){',
10268 'if(m.c===\'e\'){',
10269 'p.exit(0);',
10270 '}',
10271 'else if(m.c===\'rs\'){',
10272 'try{',
10273 'var r=require.resolve(m.a);',
10274 'p.send({c:\'r\',s:true,r:r});',
10275 '}',
10276 'catch(err){',
10277 'p.send({c:\'r\',s:false});',
10278 '}',
10279 '}',
10280 '});'
10281 ].join('');
10282 return new Promise((resolve, reject) => {
10283 let env = process.env;
10284 let newEnv = Object.create(null);
10285 Object.keys(env).forEach(key => newEnv[key] = env[key]);
10286 if (nodePath && fs.existsSync(nodePath) /* see issue 545 */) {
10287 if (newEnv[nodePathKey]) {
10288 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
10289 }
10290 else {
10291 newEnv[nodePathKey] = nodePath;
10292 }
10293 if (tracer) {
10294 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
10295 }
10296 }
10297 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
10298 try {
10299 let cp = child_process_1.fork('', [], {
10300 cwd: cwd,
10301 env: newEnv,
10302 execArgv: ['-e', app]
10303 });
10304 if (cp.pid === void 0) {
10305 reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
10306 return;
10307 }
10308 cp.on('error', (error) => {
10309 reject(error);
10310 });
10311 cp.on('message', (message) => {
10312 if (message.c === 'r') {
10313 cp.send({ c: 'e' });
10314 if (message.s) {
10315 resolve(message.r);
10316 }
10317 else {
10318 reject(new Error(`Failed to resolve module: ${moduleName}`));
10319 }
10320 }
10321 });
10322 let message = {
10323 c: 'rs',
10324 a: moduleName
10325 };
10326 cp.send(message);
10327 }
10328 catch (error) {
10329 reject(error);
10330 }
10331 });
10332}
10333exports.resolve = resolve;
10334/**
10335 * Resolve the global npm package path.
10336 * @deprecated Since this depends on the used package manager and their version the best is that servers
10337 * implement this themselves since they know best what kind of package managers to support.
10338 * @param tracer the tracer to use
10339 */
10340function resolveGlobalNodePath(tracer) {
10341 let npmCommand = 'npm';
10342 const env = Object.create(null);
10343 Object.keys(process.env).forEach(key => env[key] = process.env[key]);
10344 env['NO_UPDATE_NOTIFIER'] = 'true';
10345 const options = {
10346 encoding: 'utf8',
10347 env
10348 };
10349 if (isWindows()) {
10350 npmCommand = 'npm.cmd';
10351 options.shell = true;
10352 }
10353 let handler = () => { };
10354 try {
10355 process.on('SIGPIPE', handler);
10356 let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;
10357 if (!stdout) {
10358 if (tracer) {
10359 tracer(`'npm config get prefix' didn't return a value.`);
10360 }
10361 return undefined;
10362 }
10363 let prefix = stdout.trim();
10364 if (tracer) {
10365 tracer(`'npm config get prefix' value is: ${prefix}`);
10366 }
10367 if (prefix.length > 0) {
10368 if (isWindows()) {
10369 return path.join(prefix, 'node_modules');
10370 }
10371 else {
10372 return path.join(prefix, 'lib', 'node_modules');
10373 }
10374 }
10375 return undefined;
10376 }
10377 catch (err) {
10378 return undefined;
10379 }
10380 finally {
10381 process.removeListener('SIGPIPE', handler);
10382 }
10383}
10384exports.resolveGlobalNodePath = resolveGlobalNodePath;
10385/*
10386 * Resolve the global yarn pakage path.
10387 * @deprecated Since this depends on the used package manager and their version the best is that servers
10388 * implement this themselves since they know best what kind of package managers to support.
10389 * @param tracer the tracer to use
10390 */
10391function resolveGlobalYarnPath(tracer) {
10392 let yarnCommand = 'yarn';
10393 let options = {
10394 encoding: 'utf8'
10395 };
10396 if (isWindows()) {
10397 yarnCommand = 'yarn.cmd';
10398 options.shell = true;
10399 }
10400 let handler = () => { };
10401 try {
10402 process.on('SIGPIPE', handler);
10403 let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);
10404 let stdout = results.stdout;
10405 if (!stdout) {
10406 if (tracer) {
10407 tracer(`'yarn global dir' didn't return a value.`);
10408 if (results.stderr) {
10409 tracer(results.stderr);
10410 }
10411 }
10412 return undefined;
10413 }
10414 let lines = stdout.trim().split(/\r?\n/);
10415 for (let line of lines) {
10416 try {
10417 let yarn = JSON.parse(line);
10418 if (yarn.type === 'log') {
10419 return path.join(yarn.data, 'node_modules');
10420 }
10421 }
10422 catch (e) {
10423 // Do nothing. Ignore the line
10424 }
10425 }
10426 return undefined;
10427 }
10428 catch (err) {
10429 return undefined;
10430 }
10431 finally {
10432 process.removeListener('SIGPIPE', handler);
10433 }
10434}
10435exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
10436var FileSystem;
10437(function (FileSystem) {
10438 let _isCaseSensitive = undefined;
10439 function isCaseSensitive() {
10440 if (_isCaseSensitive !== void 0) {
10441 return _isCaseSensitive;
10442 }
10443 if (process.platform === 'win32') {
10444 _isCaseSensitive = false;
10445 }
10446 else {
10447 // convert current file name to upper case / lower case and check if file exists
10448 // (guards against cases when name is already all uppercase or lowercase)
10449 _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
10450 }
10451 return _isCaseSensitive;
10452 }
10453 FileSystem.isCaseSensitive = isCaseSensitive;
10454 function isParent(parent, child) {
10455 if (isCaseSensitive()) {
10456 return path.normalize(child).indexOf(path.normalize(parent)) === 0;
10457 }
10458 else {
10459 return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) === 0;
10460 }
10461 }
10462 FileSystem.isParent = isParent;
10463})(FileSystem = exports.FileSystem || (exports.FileSystem = {}));
10464function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
10465 if (nodePath) {
10466 if (!path.isAbsolute(nodePath)) {
10467 nodePath = path.join(workspaceRoot, nodePath);
10468 }
10469 return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
10470 if (FileSystem.isParent(nodePath, value)) {
10471 return value;
10472 }
10473 else {
10474 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
10475 }
10476 }).then(undefined, (_error) => {
10477 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
10478 });
10479 }
10480 else {
10481 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
10482 }
10483}
10484exports.resolveModulePath = resolveModulePath;
10485//# sourceMappingURL=files.js.map
10486
10487/***/ }),
10488
10489/***/ 2:
10490/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
10491
10492"use strict";
10493
10494/* --------------------------------------------------------------------------------------------
10495 * Copyright (c) Microsoft Corporation. All rights reserved.
10496 * Licensed under the MIT License. See License.txt in the project root for license information.
10497 * ------------------------------------------------------------------------------------------ */
10498/// <reference path="../../typings/thenable.d.ts" />
10499var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10500 if (k2 === undefined) k2 = k;
10501 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
10502}) : (function(o, m, k, k2) {
10503 if (k2 === undefined) k2 = k;
10504 o[k2] = m[k];
10505}));
10506var __exportStar = (this && this.__exportStar) || function(m, exports) {
10507 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
10508};
10509Object.defineProperty(exports, "__esModule", ({ value: true }));
10510exports.createConnection = exports.Files = void 0;
10511const Is = __webpack_require__(3);
10512const server_1 = __webpack_require__(4);
10513const fm = __webpack_require__(58);
10514const node_1 = __webpack_require__(62);
10515__exportStar(__webpack_require__(62), exports);
10516__exportStar(__webpack_require__(63), exports);
10517var Files;
10518(function (Files) {
10519 Files.uriToFilePath = fm.uriToFilePath;
10520 Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
10521 Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
10522 Files.resolve = fm.resolve;
10523 Files.resolveModulePath = fm.resolveModulePath;
10524})(Files = exports.Files || (exports.Files = {}));
10525let _protocolConnection;
10526function endProtocolConnection() {
10527 if (_protocolConnection === undefined) {
10528 return;
10529 }
10530 try {
10531 _protocolConnection.end();
10532 }
10533 catch (_err) {
10534 // Ignore. The client process could have already
10535 // did and we can't send an end into the connection.
10536 }
10537}
10538let _shutdownReceived = false;
10539let exitTimer = undefined;
10540function setupExitTimer() {
10541 const argName = '--clientProcessId';
10542 function runTimer(value) {
10543 try {
10544 let processId = parseInt(value);
10545 if (!isNaN(processId)) {
10546 exitTimer = setInterval(() => {
10547 try {
10548 process.kill(processId, 0);
10549 }
10550 catch (ex) {
10551 // Parent process doesn't exist anymore. Exit the server.
10552 endProtocolConnection();
10553 process.exit(_shutdownReceived ? 0 : 1);
10554 }
10555 }, 3000);
10556 }
10557 }
10558 catch (e) {
10559 // Ignore errors;
10560 }
10561 }
10562 for (let i = 2; i < process.argv.length; i++) {
10563 let arg = process.argv[i];
10564 if (arg === argName && i + 1 < process.argv.length) {
10565 runTimer(process.argv[i + 1]);
10566 return;
10567 }
10568 else {
10569 let args = arg.split('=');
10570 if (args[0] === argName) {
10571 runTimer(args[1]);
10572 }
10573 }
10574 }
10575}
10576setupExitTimer();
10577const watchDog = {
10578 initialize: (params) => {
10579 const processId = params.processId;
10580 if (Is.number(processId) && exitTimer === undefined) {
10581 // We received a parent process id. Set up a timer to periodically check
10582 // if the parent is still alive.
10583 setInterval(() => {
10584 try {
10585 process.kill(processId, 0);
10586 }
10587 catch (ex) {
10588 // Parent process doesn't exist anymore. Exit the server.
10589 process.exit(_shutdownReceived ? 0 : 1);
10590 }
10591 }, 3000);
10592 }
10593 },
10594 get shutdownReceived() {
10595 return _shutdownReceived;
10596 },
10597 set shutdownReceived(value) {
10598 _shutdownReceived = value;
10599 },
10600 exit: (code) => {
10601 endProtocolConnection();
10602 process.exit(code);
10603 }
10604};
10605function createConnection(arg1, arg2, arg3, arg4) {
10606 let factories;
10607 let input;
10608 let output;
10609 let options;
10610 if (arg1 !== void 0 && arg1.__brand === 'features') {
10611 factories = arg1;
10612 arg1 = arg2;
10613 arg2 = arg3;
10614 arg3 = arg4;
10615 }
10616 if (node_1.ConnectionStrategy.is(arg1) || node_1.ConnectionOptions.is(arg1)) {
10617 options = arg1;
10618 }
10619 else {
10620 input = arg1;
10621 output = arg2;
10622 options = arg3;
10623 }
10624 return _createConnection(input, output, options, factories);
10625}
10626exports.createConnection = createConnection;
10627function _createConnection(input, output, options, factories) {
10628 if (!input && !output && process.argv.length > 2) {
10629 let port = void 0;
10630 let pipeName = void 0;
10631 let argv = process.argv.slice(2);
10632 for (let i = 0; i < argv.length; i++) {
10633 let arg = argv[i];
10634 if (arg === '--node-ipc') {
10635 input = new node_1.IPCMessageReader(process);
10636 output = new node_1.IPCMessageWriter(process);
10637 break;
10638 }
10639 else if (arg === '--stdio') {
10640 input = process.stdin;
10641 output = process.stdout;
10642 break;
10643 }
10644 else if (arg === '--socket') {
10645 port = parseInt(argv[i + 1]);
10646 break;
10647 }
10648 else if (arg === '--pipe') {
10649 pipeName = argv[i + 1];
10650 break;
10651 }
10652 else {
10653 var args = arg.split('=');
10654 if (args[0] === '--socket') {
10655 port = parseInt(args[1]);
10656 break;
10657 }
10658 else if (args[0] === '--pipe') {
10659 pipeName = args[1];
10660 break;
10661 }
10662 }
10663 }
10664 if (port) {
10665 let transport = node_1.createServerSocketTransport(port);
10666 input = transport[0];
10667 output = transport[1];
10668 }
10669 else if (pipeName) {
10670 let transport = node_1.createServerPipeTransport(pipeName);
10671 input = transport[0];
10672 output = transport[1];
10673 }
10674 }
10675 var commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
10676 if (!input) {
10677 throw new Error('Connection input stream is not set. ' + commandLineMessage);
10678 }
10679 if (!output) {
10680 throw new Error('Connection output stream is not set. ' + commandLineMessage);
10681 }
10682 // Backwards compatibility
10683 if (Is.func(input.read) && Is.func(input.on)) {
10684 let inputStream = input;
10685 inputStream.on('end', () => {
10686 endProtocolConnection();
10687 process.exit(_shutdownReceived ? 0 : 1);
10688 });
10689 inputStream.on('close', () => {
10690 endProtocolConnection();
10691 process.exit(_shutdownReceived ? 0 : 1);
10692 });
10693 }
10694 const connectionFactory = (logger) => {
10695 const result = node_1.createProtocolConnection(input, output, logger, options);
10696 return result;
10697 };
10698 return server_1.createConnection(connectionFactory, watchDog, factories);
10699}
10700//# sourceMappingURL=main.js.map
10701
10702/***/ }),
10703
10704/***/ 71:
10705/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10706
10707/* module decorator */ module = __webpack_require__.nmd(module);
10708//!/usr/bin/env nodejs
10709// usage: nodejs vimlparser.js [--neovim] foo.vim
10710
10711var fs = __webpack_require__(60);
10712var util = __webpack_require__(10);
10713
10714function main() {
10715 var neovim = false;
10716 var fpath = ''
10717 var args = process.argv;
10718 if (args.length == 4) {
10719 if (args[2] == '--neovim') {
10720 neovim = true;
10721 }
10722 fpath = args[3];
10723 } else if (args.length == 3) {
10724 neovim = false;
10725 fpath = args[2]
10726 }
10727 var r = new StringReader(viml_readfile(fpath));
10728 var p = new VimLParser(neovim);
10729 var c = new Compiler();
10730 try {
10731 var lines = c.compile(p.parse(r));
10732 for (var i in lines) {
10733 process.stdout.write(lines[i] + "\n");
10734 }
10735 } catch (e) {
10736 process.stdout.write(e + '\n');
10737 }
10738}
10739
10740var pat_vim2js = {
10741 "[0-9a-zA-Z]" : "[0-9a-zA-Z]",
10742 "[@*!=><&~#]" : "[@*!=><&~#]",
10743 "\\<ARGOPT\\>" : "\\bARGOPT\\b",
10744 "\\<BANG\\>" : "\\bBANG\\b",
10745 "\\<EDITCMD\\>" : "\\bEDITCMD\\b",
10746 "\\<NOTRLCOM\\>" : "\\bNOTRLCOM\\b",
10747 "\\<TRLBAR\\>" : "\\bTRLBAR\\b",
10748 "\\<USECTRLV\\>" : "\\bUSECTRLV\\b",
10749 "\\<USERCMD\\>" : "\\bUSERCMD\\b",
10750 "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>" : "\\b(XFILE|FILES|FILE1)\\b",
10751 "\\S" : "\\S",
10752 "\\a" : "[A-Za-z]",
10753 "\\d" : "\\d",
10754 "\\h" : "[A-Za-z_]",
10755 "\\s" : "\\s",
10756 "\\v^d%[elete][lp]$" : "^d(elete|elet|ele|el|e)[lp]$",
10757 "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])" : "^s(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])",
10758 "\\w" : "[0-9A-Za-z_]",
10759 "\\w\\|[:#]" : "[0-9A-Za-z_]|[:#]",
10760 "\\x" : "[0-9A-Fa-f]",
10761 "^++" : "^\+\+",
10762 "^++bad=\\(keep\\|drop\\|.\\)\\>" : "^\\+\\+bad=(keep|drop|.)\\b",
10763 "^++bad=drop" : "^\\+\\+bad=drop",
10764 "^++bad=keep" : "^\\+\\+bad=keep",
10765 "^++bin\\>" : "^\\+\\+bin\\b",
10766 "^++edit\\>" : "^\\+\\+edit\\b",
10767 "^++enc=\\S" : "^\\+\\+enc=\\S",
10768 "^++encoding=\\S" : "^\\+\\+encoding=\\S",
10769 "^++ff=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+ff=(dos|unix|mac)\\b",
10770 "^++fileformat=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+fileformat=(dos|unix|mac)\\b",
10771 "^++nobin\\>" : "^\\+\\+nobin\\b",
10772 "^[A-Z]" : "^[A-Z]",
10773 "^\\$\\w\\+" : "^\\$[0-9A-Za-z_]+",
10774 "^\\(!\\|global\\|vglobal\\)$" : "^(!|global|vglobal)$",
10775 "^\\(WHILE\\|FOR\\)$" : "^(WHILE|FOR)$",
10776 "^\\(vimgrep\\|vimgrepadd\\|lvimgrep\\|lvimgrepadd\\)$" : "^(vimgrep|vimgrepadd|lvimgrep|lvimgrepadd)$",
10777 "^\\d" : "^\\d",
10778 "^\\h" : "^[A-Za-z_]",
10779 "^\\s" : "^\\s",
10780 "^\\s*\\\\" : "^\\s*\\\\",
10781 "^[ \\t]$" : "^[ \\t]$",
10782 "^[A-Za-z]$" : "^[A-Za-z]$",
10783 "^[0-9A-Za-z]$" : "^[0-9A-Za-z]$",
10784 "^[0-9]$" : "^[0-9]$",
10785 "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$",
10786 "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$",
10787 "^[A-Za-z_]$" : "^[A-Za-z_]$",
10788 "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$",
10789 "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$",
10790 "^[A-Z]$" : "^[A-Z]$",
10791 "^[a-z]$" : "^[a-z]$",
10792 "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$",
10793 "^[0-7]$" : "^[0-7]$",
10794 "^[0-9A-Fa-f][0-9A-Fa-f]$" : "^[0-9A-Fa-f][0-9A-Fa-f]$",
10795 "^\\.[0-9A-Fa-f]$" : "^\\.[0-9A-Fa-f]$",
10796 "^[0-9A-Fa-f][^0-9A-Fa-f]$" : "^[0-9A-Fa-f][^0-9A-Fa-f]$",
10797}
10798
10799function viml_add(lst, item) {
10800 lst.push(item);
10801}
10802
10803function viml_call(func, args) {
10804 return func.apply(null, args);
10805}
10806
10807function viml_char2nr(c) {
10808 return c.charCodeAt(0);
10809}
10810
10811function viml_empty(obj) {
10812 return obj.length == 0;
10813}
10814
10815function viml_equalci(a, b) {
10816 return a.toLowerCase() == b.toLowerCase();
10817}
10818
10819function viml_eqreg(s, reg) {
10820 var mx = new RegExp(pat_vim2js[reg]);
10821 return mx.exec(s) != null;
10822}
10823
10824function viml_eqregh(s, reg) {
10825 var mx = new RegExp(pat_vim2js[reg]);
10826 return mx.exec(s) != null;
10827}
10828
10829function viml_eqregq(s, reg) {
10830 var mx = new RegExp(pat_vim2js[reg], "i");
10831 return mx.exec(s) != null;
10832}
10833
10834function viml_escape(s, chars) {
10835 var r = '';
10836 for (var i = 0; i < s.length; ++i) {
10837 if (chars.indexOf(s.charAt(i)) != -1) {
10838 r = r + "\\" + s.charAt(i);
10839 } else {
10840 r = r + s.charAt(i);
10841 }
10842 }
10843 return r;
10844}
10845
10846function viml_extend(obj, item) {
10847 obj.push.apply(obj, item);
10848}
10849
10850function viml_insert(lst, item) {
10851 var idx = arguments.length >= 3 ? arguments[2] : 0;
10852 lst.splice(0, 0, item);
10853}
10854
10855function viml_join(lst, sep) {
10856 return lst.join(sep);
10857}
10858
10859function viml_keys(obj) {
10860 return Object.keys(obj);
10861}
10862
10863function viml_len(obj) {
10864 if (typeof obj === 'string') {
10865 var len = 0;
10866 for (var i = 0; i < obj.length; i++) {
10867 var c = obj.charCodeAt(i);
10868 len += c < 128 ? 1 : ((c > 127) && (c < 2048)) ? 2 : 3;
10869 }
10870 return len;
10871 }
10872 return obj.length;
10873}
10874
10875function viml_printf() {
10876 var a000 = Array.prototype.slice.call(arguments, 0);
10877 if (a000.length == 1) {
10878 return a000[0];
10879 } else {
10880 return util.format.apply(null, a000);
10881 }
10882}
10883
10884function viml_range(start) {
10885 var end = arguments.length >= 2 ? arguments[1] : null;
10886 if (end == null) {
10887 var x = [];
10888 for (var i = 0; i < start; ++i) {
10889 x.push(i);
10890 }
10891 return x;
10892 } else {
10893 var x = []
10894 for (var i = start; i <= end; ++i) {
10895 x.push(i);
10896 }
10897 return x;
10898 }
10899}
10900
10901function viml_readfile(path) {
10902 // FIXME: newline?
10903 return fs.readFileSync(path, 'utf-8').split(/\r\n|\r|\n/);
10904}
10905
10906function viml_remove(lst, idx) {
10907 lst.splice(idx, 1);
10908}
10909
10910function viml_split(s, sep) {
10911 if (sep == "\\zs") {
10912 return s.split("");
10913 }
10914 throw "NotImplemented";
10915}
10916
10917function viml_str2nr(s) {
10918 var base = arguments.length >= 2 ? arguments[1] : 10;
10919 return parseInt(s, base);
10920}
10921
10922function viml_string(obj) {
10923 return obj.toString();
10924}
10925
10926function viml_has_key(obj, key) {
10927 return obj[key] !== undefined;
10928}
10929
10930function viml_stridx(a, b) {
10931 return a.indexOf(b);
10932}
10933
10934var NIL = [];
10935var TRUE = 1;
10936var FALSE = 0;
10937var NODE_TOPLEVEL = 1;
10938var NODE_COMMENT = 2;
10939var NODE_EXCMD = 3;
10940var NODE_FUNCTION = 4;
10941var NODE_ENDFUNCTION = 5;
10942var NODE_DELFUNCTION = 6;
10943var NODE_RETURN = 7;
10944var NODE_EXCALL = 8;
10945var NODE_LET = 9;
10946var NODE_UNLET = 10;
10947var NODE_LOCKVAR = 11;
10948var NODE_UNLOCKVAR = 12;
10949var NODE_IF = 13;
10950var NODE_ELSEIF = 14;
10951var NODE_ELSE = 15;
10952var NODE_ENDIF = 16;
10953var NODE_WHILE = 17;
10954var NODE_ENDWHILE = 18;
10955var NODE_FOR = 19;
10956var NODE_ENDFOR = 20;
10957var NODE_CONTINUE = 21;
10958var NODE_BREAK = 22;
10959var NODE_TRY = 23;
10960var NODE_CATCH = 24;
10961var NODE_FINALLY = 25;
10962var NODE_ENDTRY = 26;
10963var NODE_THROW = 27;
10964var NODE_ECHO = 28;
10965var NODE_ECHON = 29;
10966var NODE_ECHOHL = 30;
10967var NODE_ECHOMSG = 31;
10968var NODE_ECHOERR = 32;
10969var NODE_EXECUTE = 33;
10970var NODE_TERNARY = 34;
10971var NODE_OR = 35;
10972var NODE_AND = 36;
10973var NODE_EQUAL = 37;
10974var NODE_EQUALCI = 38;
10975var NODE_EQUALCS = 39;
10976var NODE_NEQUAL = 40;
10977var NODE_NEQUALCI = 41;
10978var NODE_NEQUALCS = 42;
10979var NODE_GREATER = 43;
10980var NODE_GREATERCI = 44;
10981var NODE_GREATERCS = 45;
10982var NODE_GEQUAL = 46;
10983var NODE_GEQUALCI = 47;
10984var NODE_GEQUALCS = 48;
10985var NODE_SMALLER = 49;
10986var NODE_SMALLERCI = 50;
10987var NODE_SMALLERCS = 51;
10988var NODE_SEQUAL = 52;
10989var NODE_SEQUALCI = 53;
10990var NODE_SEQUALCS = 54;
10991var NODE_MATCH = 55;
10992var NODE_MATCHCI = 56;
10993var NODE_MATCHCS = 57;
10994var NODE_NOMATCH = 58;
10995var NODE_NOMATCHCI = 59;
10996var NODE_NOMATCHCS = 60;
10997var NODE_IS = 61;
10998var NODE_ISCI = 62;
10999var NODE_ISCS = 63;
11000var NODE_ISNOT = 64;
11001var NODE_ISNOTCI = 65;
11002var NODE_ISNOTCS = 66;
11003var NODE_ADD = 67;
11004var NODE_SUBTRACT = 68;
11005var NODE_CONCAT = 69;
11006var NODE_MULTIPLY = 70;
11007var NODE_DIVIDE = 71;
11008var NODE_REMAINDER = 72;
11009var NODE_NOT = 73;
11010var NODE_MINUS = 74;
11011var NODE_PLUS = 75;
11012var NODE_SUBSCRIPT = 76;
11013var NODE_SLICE = 77;
11014var NODE_CALL = 78;
11015var NODE_DOT = 79;
11016var NODE_NUMBER = 80;
11017var NODE_STRING = 81;
11018var NODE_LIST = 82;
11019var NODE_DICT = 83;
11020var NODE_OPTION = 85;
11021var NODE_IDENTIFIER = 86;
11022var NODE_CURLYNAME = 87;
11023var NODE_ENV = 88;
11024var NODE_REG = 89;
11025var NODE_CURLYNAMEPART = 90;
11026var NODE_CURLYNAMEEXPR = 91;
11027var NODE_LAMBDA = 92;
11028var NODE_BLOB = 93;
11029var NODE_CONST = 94;
11030var NODE_EVAL = 95;
11031var NODE_HEREDOC = 96;
11032var NODE_METHOD = 97;
11033var TOKEN_EOF = 1;
11034var TOKEN_EOL = 2;
11035var TOKEN_SPACE = 3;
11036var TOKEN_OROR = 4;
11037var TOKEN_ANDAND = 5;
11038var TOKEN_EQEQ = 6;
11039var TOKEN_EQEQCI = 7;
11040var TOKEN_EQEQCS = 8;
11041var TOKEN_NEQ = 9;
11042var TOKEN_NEQCI = 10;
11043var TOKEN_NEQCS = 11;
11044var TOKEN_GT = 12;
11045var TOKEN_GTCI = 13;
11046var TOKEN_GTCS = 14;
11047var TOKEN_GTEQ = 15;
11048var TOKEN_GTEQCI = 16;
11049var TOKEN_GTEQCS = 17;
11050var TOKEN_LT = 18;
11051var TOKEN_LTCI = 19;
11052var TOKEN_LTCS = 20;
11053var TOKEN_LTEQ = 21;
11054var TOKEN_LTEQCI = 22;
11055var TOKEN_LTEQCS = 23;
11056var TOKEN_MATCH = 24;
11057var TOKEN_MATCHCI = 25;
11058var TOKEN_MATCHCS = 26;
11059var TOKEN_NOMATCH = 27;
11060var TOKEN_NOMATCHCI = 28;
11061var TOKEN_NOMATCHCS = 29;
11062var TOKEN_IS = 30;
11063var TOKEN_ISCI = 31;
11064var TOKEN_ISCS = 32;
11065var TOKEN_ISNOT = 33;
11066var TOKEN_ISNOTCI = 34;
11067var TOKEN_ISNOTCS = 35;
11068var TOKEN_PLUS = 36;
11069var TOKEN_MINUS = 37;
11070var TOKEN_DOT = 38;
11071var TOKEN_STAR = 39;
11072var TOKEN_SLASH = 40;
11073var TOKEN_PERCENT = 41;
11074var TOKEN_NOT = 42;
11075var TOKEN_QUESTION = 43;
11076var TOKEN_COLON = 44;
11077var TOKEN_POPEN = 45;
11078var TOKEN_PCLOSE = 46;
11079var TOKEN_SQOPEN = 47;
11080var TOKEN_SQCLOSE = 48;
11081var TOKEN_COPEN = 49;
11082var TOKEN_CCLOSE = 50;
11083var TOKEN_COMMA = 51;
11084var TOKEN_NUMBER = 52;
11085var TOKEN_SQUOTE = 53;
11086var TOKEN_DQUOTE = 54;
11087var TOKEN_OPTION = 55;
11088var TOKEN_IDENTIFIER = 56;
11089var TOKEN_ENV = 57;
11090var TOKEN_REG = 58;
11091var TOKEN_EQ = 59;
11092var TOKEN_OR = 60;
11093var TOKEN_SEMICOLON = 61;
11094var TOKEN_BACKTICK = 62;
11095var TOKEN_DOTDOTDOT = 63;
11096var TOKEN_SHARP = 64;
11097var TOKEN_ARROW = 65;
11098var TOKEN_BLOB = 66;
11099var TOKEN_LITCOPEN = 67;
11100var TOKEN_DOTDOT = 68;
11101var TOKEN_HEREDOC = 69;
11102var MAX_FUNC_ARGS = 20;
11103function isalpha(c) {
11104 return viml_eqregh(c, "^[A-Za-z]$");
11105}
11106
11107function isalnum(c) {
11108 return viml_eqregh(c, "^[0-9A-Za-z]$");
11109}
11110
11111function isdigit(c) {
11112 return viml_eqregh(c, "^[0-9]$");
11113}
11114
11115function isodigit(c) {
11116 return viml_eqregh(c, "^[0-7]$");
11117}
11118
11119function isxdigit(c) {
11120 return viml_eqregh(c, "^[0-9A-Fa-f]$");
11121}
11122
11123function iswordc(c) {
11124 return viml_eqregh(c, "^[0-9A-Za-z_]$");
11125}
11126
11127function iswordc1(c) {
11128 return viml_eqregh(c, "^[A-Za-z_]$");
11129}
11130
11131function iswhite(c) {
11132 return viml_eqregh(c, "^[ \\t]$");
11133}
11134
11135function isnamec(c) {
11136 return viml_eqregh(c, "^[0-9A-Za-z_:#]$");
11137}
11138
11139function isnamec1(c) {
11140 return viml_eqregh(c, "^[A-Za-z_]$");
11141}
11142
11143function isargname(s) {
11144 return viml_eqregh(s, "^[A-Za-z_][0-9A-Za-z_]*$");
11145}
11146
11147function isvarname(s) {
11148 return viml_eqregh(s, "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$");
11149}
11150
11151// FIXME:
11152function isidc(c) {
11153 return viml_eqregh(c, "^[0-9A-Za-z_]$");
11154}
11155
11156function isupper(c) {
11157 return viml_eqregh(c, "^[A-Z]$");
11158}
11159
11160function islower(c) {
11161 return viml_eqregh(c, "^[a-z]$");
11162}
11163
11164function ExArg() {
11165 var ea = {};
11166 ea.forceit = FALSE;
11167 ea.addr_count = 0;
11168 ea.line1 = 0;
11169 ea.line2 = 0;
11170 ea.flags = 0;
11171 ea.do_ecmd_cmd = "";
11172 ea.do_ecmd_lnum = 0;
11173 ea.append = 0;
11174 ea.usefilter = FALSE;
11175 ea.amount = 0;
11176 ea.regname = 0;
11177 ea.force_bin = 0;
11178 ea.read_edit = 0;
11179 ea.force_ff = 0;
11180 ea.force_enc = 0;
11181 ea.bad_char = 0;
11182 ea.linepos = {};
11183 ea.cmdpos = [];
11184 ea.argpos = [];
11185 ea.cmd = {};
11186 ea.modifiers = [];
11187 ea.range = [];
11188 ea.argopt = {};
11189 ea.argcmd = {};
11190 return ea;
11191}
11192
11193// struct node {
11194// int type
11195// pos pos
11196// node left
11197// node right
11198// node cond
11199// node rest
11200// node[] list
11201// node[] rlist
11202// node[] default_args
11203// node[] body
11204// string op
11205// string str
11206// int depth
11207// variant value
11208// }
11209// TOPLEVEL .body
11210// COMMENT .str
11211// EXCMD .ea .str
11212// FUNCTION .ea .body .left .rlist .default_args .attr .endfunction
11213// ENDFUNCTION .ea
11214// DELFUNCTION .ea .left
11215// RETURN .ea .left
11216// EXCALL .ea .left
11217// LET .ea .op .left .list .rest .right
11218// CONST .ea .op .left .list .rest .right
11219// UNLET .ea .list
11220// LOCKVAR .ea .depth .list
11221// UNLOCKVAR .ea .depth .list
11222// IF .ea .body .cond .elseif .else .endif
11223// ELSEIF .ea .body .cond
11224// ELSE .ea .body
11225// ENDIF .ea
11226// WHILE .ea .body .cond .endwhile
11227// ENDWHILE .ea
11228// FOR .ea .body .left .list .rest .right .endfor
11229// ENDFOR .ea
11230// CONTINUE .ea
11231// BREAK .ea
11232// TRY .ea .body .catch .finally .endtry
11233// CATCH .ea .body .pattern
11234// FINALLY .ea .body
11235// ENDTRY .ea
11236// THROW .ea .left
11237// EVAL .ea .left
11238// ECHO .ea .list
11239// ECHON .ea .list
11240// ECHOHL .ea .str
11241// ECHOMSG .ea .list
11242// ECHOERR .ea .list
11243// EXECUTE .ea .list
11244// TERNARY .cond .left .right
11245// OR .left .right
11246// AND .left .right
11247// EQUAL .left .right
11248// EQUALCI .left .right
11249// EQUALCS .left .right
11250// NEQUAL .left .right
11251// NEQUALCI .left .right
11252// NEQUALCS .left .right
11253// GREATER .left .right
11254// GREATERCI .left .right
11255// GREATERCS .left .right
11256// GEQUAL .left .right
11257// GEQUALCI .left .right
11258// GEQUALCS .left .right
11259// SMALLER .left .right
11260// SMALLERCI .left .right
11261// SMALLERCS .left .right
11262// SEQUAL .left .right
11263// SEQUALCI .left .right
11264// SEQUALCS .left .right
11265// MATCH .left .right
11266// MATCHCI .left .right
11267// MATCHCS .left .right
11268// NOMATCH .left .right
11269// NOMATCHCI .left .right
11270// NOMATCHCS .left .right
11271// IS .left .right
11272// ISCI .left .right
11273// ISCS .left .right
11274// ISNOT .left .right
11275// ISNOTCI .left .right
11276// ISNOTCS .left .right
11277// ADD .left .right
11278// SUBTRACT .left .right
11279// CONCAT .left .right
11280// MULTIPLY .left .right
11281// DIVIDE .left .right
11282// REMAINDER .left .right
11283// NOT .left
11284// MINUS .left
11285// PLUS .left
11286// SUBSCRIPT .left .right
11287// SLICE .left .rlist
11288// METHOD .left .right
11289// CALL .left .rlist
11290// DOT .left .right
11291// NUMBER .value
11292// STRING .value
11293// LIST .value
11294// DICT .value
11295// BLOB .value
11296// NESTING .left
11297// OPTION .value
11298// IDENTIFIER .value
11299// CURLYNAME .value
11300// ENV .value
11301// REG .value
11302// CURLYNAMEPART .value
11303// CURLYNAMEEXPR .value
11304// LAMBDA .rlist .left
11305// HEREDOC .rlist .op .body
11306function Node(type) {
11307 return {"type":type};
11308}
11309
11310function Err(msg, pos) {
11311 return viml_printf("vimlparser: %s: line %d col %d", msg, pos.lnum, pos.col);
11312}
11313
11314function VimLParser() { this.__init__.apply(this, arguments); }
11315VimLParser.prototype.__init__ = function() {
11316 var a000 = Array.prototype.slice.call(arguments, 0);
11317 if (viml_len(a000) > 0) {
11318 this.neovim = a000[0];
11319 }
11320 else {
11321 this.neovim = 0;
11322 }
11323 this.find_command_cache = {};
11324}
11325
11326VimLParser.prototype.push_context = function(node) {
11327 viml_insert(this.context, node);
11328}
11329
11330VimLParser.prototype.pop_context = function() {
11331 viml_remove(this.context, 0);
11332}
11333
11334VimLParser.prototype.find_context = function(type) {
11335 var i = 0;
11336 var __c3 = this.context;
11337 for (var __i3 = 0; __i3 < __c3.length; ++__i3) {
11338 var node = __c3[__i3];
11339 if (node.type == type) {
11340 return i;
11341 }
11342 i += 1;
11343 }
11344 return -1;
11345}
11346
11347VimLParser.prototype.add_node = function(node) {
11348 viml_add(this.context[0].body, node);
11349}
11350
11351VimLParser.prototype.check_missing_endfunction = function(ends, pos) {
11352 if (this.context[0].type == NODE_FUNCTION) {
11353 throw Err(viml_printf("E126: Missing :endfunction: %s", ends), pos);
11354 }
11355}
11356
11357VimLParser.prototype.check_missing_endif = function(ends, pos) {
11358 if (this.context[0].type == NODE_IF || this.context[0].type == NODE_ELSEIF || this.context[0].type == NODE_ELSE) {
11359 throw Err(viml_printf("E171: Missing :endif: %s", ends), pos);
11360 }
11361}
11362
11363VimLParser.prototype.check_missing_endtry = function(ends, pos) {
11364 if (this.context[0].type == NODE_TRY || this.context[0].type == NODE_CATCH || this.context[0].type == NODE_FINALLY) {
11365 throw Err(viml_printf("E600: Missing :endtry: %s", ends), pos);
11366 }
11367}
11368
11369VimLParser.prototype.check_missing_endwhile = function(ends, pos) {
11370 if (this.context[0].type == NODE_WHILE) {
11371 throw Err(viml_printf("E170: Missing :endwhile: %s", ends), pos);
11372 }
11373}
11374
11375VimLParser.prototype.check_missing_endfor = function(ends, pos) {
11376 if (this.context[0].type == NODE_FOR) {
11377 throw Err(viml_printf("E170: Missing :endfor: %s", ends), pos);
11378 }
11379}
11380
11381VimLParser.prototype.parse = function(reader) {
11382 this.reader = reader;
11383 this.context = [];
11384 var toplevel = Node(NODE_TOPLEVEL);
11385 toplevel.pos = this.reader.getpos();
11386 toplevel.body = [];
11387 this.push_context(toplevel);
11388 while (this.reader.peek() != "<EOF>") {
11389 this.parse_one_cmd();
11390 }
11391 this.check_missing_endfunction("TOPLEVEL", this.reader.getpos());
11392 this.check_missing_endif("TOPLEVEL", this.reader.getpos());
11393 this.check_missing_endtry("TOPLEVEL", this.reader.getpos());
11394 this.check_missing_endwhile("TOPLEVEL", this.reader.getpos());
11395 this.check_missing_endfor("TOPLEVEL", this.reader.getpos());
11396 this.pop_context();
11397 return toplevel;
11398}
11399
11400VimLParser.prototype.parse_one_cmd = function() {
11401 this.ea = ExArg();
11402 if (this.reader.peekn(2) == "#!") {
11403 this.parse_hashbang();
11404 this.reader.get();
11405 return;
11406 }
11407 this.reader.skip_white_and_colon();
11408 if (this.reader.peekn(1) == "") {
11409 this.reader.get();
11410 return;
11411 }
11412 if (this.reader.peekn(1) == "\"") {
11413 this.parse_comment();
11414 this.reader.get();
11415 return;
11416 }
11417 this.ea.linepos = this.reader.getpos();
11418 this.parse_command_modifiers();
11419 this.parse_range();
11420 this.parse_command();
11421 this.parse_trail();
11422}
11423
11424// FIXME:
11425VimLParser.prototype.parse_command_modifiers = function() {
11426 var modifiers = [];
11427 while (TRUE) {
11428 var pos = this.reader.tell();
11429 var d = "";
11430 if (isdigit(this.reader.peekn(1))) {
11431 var d = this.reader.read_digit();
11432 this.reader.skip_white();
11433 }
11434 var k = this.reader.read_alpha();
11435 var c = this.reader.peekn(1);
11436 this.reader.skip_white();
11437 if (viml_stridx("aboveleft", k) == 0 && viml_len(k) >= 3) {
11438 // abo\%[veleft]
11439 viml_add(modifiers, {"name":"aboveleft"});
11440 }
11441 else if (viml_stridx("belowright", k) == 0 && viml_len(k) >= 3) {
11442 // bel\%[owright]
11443 viml_add(modifiers, {"name":"belowright"});
11444 }
11445 else if (viml_stridx("browse", k) == 0 && viml_len(k) >= 3) {
11446 // bro\%[wse]
11447 viml_add(modifiers, {"name":"browse"});
11448 }
11449 else if (viml_stridx("botright", k) == 0 && viml_len(k) >= 2) {
11450 // bo\%[tright]
11451 viml_add(modifiers, {"name":"botright"});
11452 }
11453 else if (viml_stridx("confirm", k) == 0 && viml_len(k) >= 4) {
11454 // conf\%[irm]
11455 viml_add(modifiers, {"name":"confirm"});
11456 }
11457 else if (viml_stridx("keepmarks", k) == 0 && viml_len(k) >= 3) {
11458 // kee\%[pmarks]
11459 viml_add(modifiers, {"name":"keepmarks"});
11460 }
11461 else if (viml_stridx("keepalt", k) == 0 && viml_len(k) >= 5) {
11462 // keepa\%[lt]
11463 viml_add(modifiers, {"name":"keepalt"});
11464 }
11465 else if (viml_stridx("keepjumps", k) == 0 && viml_len(k) >= 5) {
11466 // keepj\%[umps]
11467 viml_add(modifiers, {"name":"keepjumps"});
11468 }
11469 else if (viml_stridx("keeppatterns", k) == 0 && viml_len(k) >= 5) {
11470 // keepp\%[atterns]
11471 viml_add(modifiers, {"name":"keeppatterns"});
11472 }
11473 else if (viml_stridx("hide", k) == 0 && viml_len(k) >= 3) {
11474 // hid\%[e]
11475 if (this.ends_excmds(c)) {
11476 break;
11477 }
11478 viml_add(modifiers, {"name":"hide"});
11479 }
11480 else if (viml_stridx("lockmarks", k) == 0 && viml_len(k) >= 3) {
11481 // loc\%[kmarks]
11482 viml_add(modifiers, {"name":"lockmarks"});
11483 }
11484 else if (viml_stridx("leftabove", k) == 0 && viml_len(k) >= 5) {
11485 // lefta\%[bove]
11486 viml_add(modifiers, {"name":"leftabove"});
11487 }
11488 else if (viml_stridx("noautocmd", k) == 0 && viml_len(k) >= 3) {
11489 // noa\%[utocmd]
11490 viml_add(modifiers, {"name":"noautocmd"});
11491 }
11492 else if (viml_stridx("noswapfile", k) == 0 && viml_len(k) >= 3) {
11493 // :nos\%[wapfile]
11494 viml_add(modifiers, {"name":"noswapfile"});
11495 }
11496 else if (viml_stridx("rightbelow", k) == 0 && viml_len(k) >= 6) {
11497 // rightb\%[elow]
11498 viml_add(modifiers, {"name":"rightbelow"});
11499 }
11500 else if (viml_stridx("sandbox", k) == 0 && viml_len(k) >= 3) {
11501 // san\%[dbox]
11502 viml_add(modifiers, {"name":"sandbox"});
11503 }
11504 else if (viml_stridx("silent", k) == 0 && viml_len(k) >= 3) {
11505 // sil\%[ent]
11506 if (c == "!") {
11507 this.reader.get();
11508 viml_add(modifiers, {"name":"silent", "bang":1});
11509 }
11510 else {
11511 viml_add(modifiers, {"name":"silent", "bang":0});
11512 }
11513 }
11514 else if (k == "tab") {
11515 // tab
11516 if (d != "") {
11517 viml_add(modifiers, {"name":"tab", "count":viml_str2nr(d, 10)});
11518 }
11519 else {
11520 viml_add(modifiers, {"name":"tab"});
11521 }
11522 }
11523 else if (viml_stridx("topleft", k) == 0 && viml_len(k) >= 2) {
11524 // to\%[pleft]
11525 viml_add(modifiers, {"name":"topleft"});
11526 }
11527 else if (viml_stridx("unsilent", k) == 0 && viml_len(k) >= 3) {
11528 // uns\%[ilent]
11529 viml_add(modifiers, {"name":"unsilent"});
11530 }
11531 else if (viml_stridx("vertical", k) == 0 && viml_len(k) >= 4) {
11532 // vert\%[ical]
11533 viml_add(modifiers, {"name":"vertical"});
11534 }
11535 else if (viml_stridx("verbose", k) == 0 && viml_len(k) >= 4) {
11536 // verb\%[ose]
11537 if (d != "") {
11538 viml_add(modifiers, {"name":"verbose", "count":viml_str2nr(d, 10)});
11539 }
11540 else {
11541 viml_add(modifiers, {"name":"verbose", "count":1});
11542 }
11543 }
11544 else {
11545 this.reader.seek_set(pos);
11546 break;
11547 }
11548 }
11549 this.ea.modifiers = modifiers;
11550}
11551
11552// FIXME:
11553VimLParser.prototype.parse_range = function() {
11554 var tokens = [];
11555 while (TRUE) {
11556 while (TRUE) {
11557 this.reader.skip_white();
11558 var c = this.reader.peekn(1);
11559 if (c == "") {
11560 break;
11561 }
11562 if (c == ".") {
11563 viml_add(tokens, this.reader.getn(1));
11564 }
11565 else if (c == "$") {
11566 viml_add(tokens, this.reader.getn(1));
11567 }
11568 else if (c == "'") {
11569 this.reader.getn(1);
11570 var m = this.reader.getn(1);
11571 if (m == "") {
11572 break;
11573 }
11574 viml_add(tokens, "'" + m);
11575 }
11576 else if (c == "/") {
11577 this.reader.getn(1);
11578 var __tmp = this.parse_pattern(c);
11579 var pattern = __tmp[0];
11580 var _ = __tmp[1];
11581 viml_add(tokens, pattern);
11582 }
11583 else if (c == "?") {
11584 this.reader.getn(1);
11585 var __tmp = this.parse_pattern(c);
11586 var pattern = __tmp[0];
11587 var _ = __tmp[1];
11588 viml_add(tokens, pattern);
11589 }
11590 else if (c == "\\") {
11591 var m = this.reader.p(1);
11592 if (m == "&" || m == "?" || m == "/") {
11593 this.reader.seek_cur(2);
11594 viml_add(tokens, "\\" + m);
11595 }
11596 else {
11597 throw Err("E10: \\\\ should be followed by /, ? or &", this.reader.getpos());
11598 }
11599 }
11600 else if (isdigit(c)) {
11601 viml_add(tokens, this.reader.read_digit());
11602 }
11603 while (TRUE) {
11604 this.reader.skip_white();
11605 if (this.reader.peekn(1) == "") {
11606 break;
11607 }
11608 var n = this.reader.read_integer();
11609 if (n == "") {
11610 break;
11611 }
11612 viml_add(tokens, n);
11613 }
11614 if (this.reader.p(0) != "/" && this.reader.p(0) != "?") {
11615 break;
11616 }
11617 }
11618 if (this.reader.peekn(1) == "%") {
11619 viml_add(tokens, this.reader.getn(1));
11620 }
11621 else if (this.reader.peekn(1) == "*") {
11622 // && &cpoptions !~ '\*'
11623 viml_add(tokens, this.reader.getn(1));
11624 }
11625 if (this.reader.peekn(1) == ";") {
11626 viml_add(tokens, this.reader.getn(1));
11627 continue;
11628 }
11629 else if (this.reader.peekn(1) == ",") {
11630 viml_add(tokens, this.reader.getn(1));
11631 continue;
11632 }
11633 break;
11634 }
11635 this.ea.range = tokens;
11636}
11637
11638// FIXME:
11639VimLParser.prototype.parse_pattern = function(delimiter) {
11640 var pattern = "";
11641 var endc = "";
11642 var inbracket = 0;
11643 while (TRUE) {
11644 var c = this.reader.getn(1);
11645 if (c == "") {
11646 break;
11647 }
11648 if (c == delimiter && inbracket == 0) {
11649 var endc = c;
11650 break;
11651 }
11652 pattern += c;
11653 if (c == "\\") {
11654 var c = this.reader.peekn(1);
11655 if (c == "") {
11656 throw Err("E682: Invalid search pattern or delimiter", this.reader.getpos());
11657 }
11658 this.reader.getn(1);
11659 pattern += c;
11660 }
11661 else if (c == "[") {
11662 inbracket += 1;
11663 }
11664 else if (c == "]") {
11665 inbracket -= 1;
11666 }
11667 }
11668 return [pattern, endc];
11669}
11670
11671VimLParser.prototype.parse_command = function() {
11672 this.reader.skip_white_and_colon();
11673 this.ea.cmdpos = this.reader.getpos();
11674 if (this.reader.peekn(1) == "" || this.reader.peekn(1) == "\"") {
11675 if (!viml_empty(this.ea.modifiers) || !viml_empty(this.ea.range)) {
11676 this.parse_cmd_modifier_range();
11677 }
11678 return;
11679 }
11680 this.ea.cmd = this.find_command();
11681 if (this.ea.cmd === NIL) {
11682 this.reader.setpos(this.ea.cmdpos);
11683 throw Err(viml_printf("E492: Not an editor command: %s", this.reader.peekline()), this.ea.cmdpos);
11684 }
11685 if (this.reader.peekn(1) == "!" && this.ea.cmd.name != "substitute" && this.ea.cmd.name != "smagic" && this.ea.cmd.name != "snomagic") {
11686 this.reader.getn(1);
11687 this.ea.forceit = TRUE;
11688 }
11689 else {
11690 this.ea.forceit = FALSE;
11691 }
11692 if (!viml_eqregh(this.ea.cmd.flags, "\\<BANG\\>") && this.ea.forceit && !viml_eqregh(this.ea.cmd.flags, "\\<USERCMD\\>")) {
11693 throw Err("E477: No ! allowed", this.ea.cmdpos);
11694 }
11695 if (this.ea.cmd.name != "!") {
11696 this.reader.skip_white();
11697 }
11698 this.ea.argpos = this.reader.getpos();
11699 if (viml_eqregh(this.ea.cmd.flags, "\\<ARGOPT\\>")) {
11700 this.parse_argopt();
11701 }
11702 if (this.ea.cmd.name == "write" || this.ea.cmd.name == "update") {
11703 if (this.reader.p(0) == ">") {
11704 if (this.reader.p(1) != ">") {
11705 throw Err("E494: Use w or w>>", this.ea.cmdpos);
11706 }
11707 this.reader.seek_cur(2);
11708 this.reader.skip_white();
11709 this.ea.append = 1;
11710 }
11711 else if (this.reader.peekn(1) == "!" && this.ea.cmd.name == "write") {
11712 this.reader.getn(1);
11713 this.ea.usefilter = TRUE;
11714 }
11715 }
11716 if (this.ea.cmd.name == "read") {
11717 if (this.ea.forceit) {
11718 this.ea.usefilter = TRUE;
11719 this.ea.forceit = FALSE;
11720 }
11721 else if (this.reader.peekn(1) == "!") {
11722 this.reader.getn(1);
11723 this.ea.usefilter = TRUE;
11724 }
11725 }
11726 if (this.ea.cmd.name == "<" || this.ea.cmd.name == ">") {
11727 this.ea.amount = 1;
11728 while (this.reader.peekn(1) == this.ea.cmd.name) {
11729 this.reader.getn(1);
11730 this.ea.amount += 1;
11731 }
11732 this.reader.skip_white();
11733 }
11734 if (viml_eqregh(this.ea.cmd.flags, "\\<EDITCMD\\>") && !this.ea.usefilter) {
11735 this.parse_argcmd();
11736 }
11737 this._parse_command(this.ea.cmd.parser);
11738}
11739
11740// TODO: self[a:parser]
11741VimLParser.prototype._parse_command = function(parser) {
11742 if (parser == "parse_cmd_append") {
11743 this.parse_cmd_append();
11744 }
11745 else if (parser == "parse_cmd_break") {
11746 this.parse_cmd_break();
11747 }
11748 else if (parser == "parse_cmd_call") {
11749 this.parse_cmd_call();
11750 }
11751 else if (parser == "parse_cmd_catch") {
11752 this.parse_cmd_catch();
11753 }
11754 else if (parser == "parse_cmd_common") {
11755 this.parse_cmd_common();
11756 }
11757 else if (parser == "parse_cmd_continue") {
11758 this.parse_cmd_continue();
11759 }
11760 else if (parser == "parse_cmd_delfunction") {
11761 this.parse_cmd_delfunction();
11762 }
11763 else if (parser == "parse_cmd_echo") {
11764 this.parse_cmd_echo();
11765 }
11766 else if (parser == "parse_cmd_echoerr") {
11767 this.parse_cmd_echoerr();
11768 }
11769 else if (parser == "parse_cmd_echohl") {
11770 this.parse_cmd_echohl();
11771 }
11772 else if (parser == "parse_cmd_echomsg") {
11773 this.parse_cmd_echomsg();
11774 }
11775 else if (parser == "parse_cmd_echon") {
11776 this.parse_cmd_echon();
11777 }
11778 else if (parser == "parse_cmd_else") {
11779 this.parse_cmd_else();
11780 }
11781 else if (parser == "parse_cmd_elseif") {
11782 this.parse_cmd_elseif();
11783 }
11784 else if (parser == "parse_cmd_endfor") {
11785 this.parse_cmd_endfor();
11786 }
11787 else if (parser == "parse_cmd_endfunction") {
11788 this.parse_cmd_endfunction();
11789 }
11790 else if (parser == "parse_cmd_endif") {
11791 this.parse_cmd_endif();
11792 }
11793 else if (parser == "parse_cmd_endtry") {
11794 this.parse_cmd_endtry();
11795 }
11796 else if (parser == "parse_cmd_endwhile") {
11797 this.parse_cmd_endwhile();
11798 }
11799 else if (parser == "parse_cmd_execute") {
11800 this.parse_cmd_execute();
11801 }
11802 else if (parser == "parse_cmd_finally") {
11803 this.parse_cmd_finally();
11804 }
11805 else if (parser == "parse_cmd_finish") {
11806 this.parse_cmd_finish();
11807 }
11808 else if (parser == "parse_cmd_for") {
11809 this.parse_cmd_for();
11810 }
11811 else if (parser == "parse_cmd_function") {
11812 this.parse_cmd_function();
11813 }
11814 else if (parser == "parse_cmd_if") {
11815 this.parse_cmd_if();
11816 }
11817 else if (parser == "parse_cmd_insert") {
11818 this.parse_cmd_insert();
11819 }
11820 else if (parser == "parse_cmd_let") {
11821 this.parse_cmd_let();
11822 }
11823 else if (parser == "parse_cmd_const") {
11824 this.parse_cmd_const();
11825 }
11826 else if (parser == "parse_cmd_loadkeymap") {
11827 this.parse_cmd_loadkeymap();
11828 }
11829 else if (parser == "parse_cmd_lockvar") {
11830 this.parse_cmd_lockvar();
11831 }
11832 else if (parser == "parse_cmd_lua") {
11833 this.parse_cmd_lua();
11834 }
11835 else if (parser == "parse_cmd_modifier_range") {
11836 this.parse_cmd_modifier_range();
11837 }
11838 else if (parser == "parse_cmd_mzscheme") {
11839 this.parse_cmd_mzscheme();
11840 }
11841 else if (parser == "parse_cmd_perl") {
11842 this.parse_cmd_perl();
11843 }
11844 else if (parser == "parse_cmd_python") {
11845 this.parse_cmd_python();
11846 }
11847 else if (parser == "parse_cmd_python3") {
11848 this.parse_cmd_python3();
11849 }
11850 else if (parser == "parse_cmd_return") {
11851 this.parse_cmd_return();
11852 }
11853 else if (parser == "parse_cmd_ruby") {
11854 this.parse_cmd_ruby();
11855 }
11856 else if (parser == "parse_cmd_tcl") {
11857 this.parse_cmd_tcl();
11858 }
11859 else if (parser == "parse_cmd_throw") {
11860 this.parse_cmd_throw();
11861 }
11862 else if (parser == "parse_cmd_eval") {
11863 this.parse_cmd_eval();
11864 }
11865 else if (parser == "parse_cmd_try") {
11866 this.parse_cmd_try();
11867 }
11868 else if (parser == "parse_cmd_unlet") {
11869 this.parse_cmd_unlet();
11870 }
11871 else if (parser == "parse_cmd_unlockvar") {
11872 this.parse_cmd_unlockvar();
11873 }
11874 else if (parser == "parse_cmd_usercmd") {
11875 this.parse_cmd_usercmd();
11876 }
11877 else if (parser == "parse_cmd_while") {
11878 this.parse_cmd_while();
11879 }
11880 else if (parser == "parse_wincmd") {
11881 this.parse_wincmd();
11882 }
11883 else if (parser == "parse_cmd_syntax") {
11884 this.parse_cmd_syntax();
11885 }
11886 else {
11887 throw viml_printf("unknown parser: %s", viml_string(parser));
11888 }
11889}
11890
11891VimLParser.prototype.find_command = function() {
11892 var c = this.reader.peekn(1);
11893 var name = "";
11894 if (c == "k") {
11895 this.reader.getn(1);
11896 var name = "k";
11897 }
11898 else if (c == "s" && viml_eqregh(this.reader.peekn(5), "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])")) {
11899 this.reader.getn(1);
11900 var name = "substitute";
11901 }
11902 else if (viml_eqregh(c, "[@*!=><&~#]")) {
11903 this.reader.getn(1);
11904 var name = c;
11905 }
11906 else if (this.reader.peekn(2) == "py") {
11907 var name = this.reader.read_alnum();
11908 }
11909 else {
11910 var pos = this.reader.tell();
11911 var name = this.reader.read_alpha();
11912 if (name != "del" && viml_eqregh(name, "\\v^d%[elete][lp]$")) {
11913 this.reader.seek_set(pos);
11914 var name = this.reader.getn(viml_len(name) - 1);
11915 }
11916 }
11917 if (name == "") {
11918 return NIL;
11919 }
11920 if (viml_has_key(this.find_command_cache, name)) {
11921 return this.find_command_cache[name];
11922 }
11923 var cmd = NIL;
11924 var __c4 = this.builtin_commands;
11925 for (var __i4 = 0; __i4 < __c4.length; ++__i4) {
11926 var x = __c4[__i4];
11927 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
11928 delete cmd;
11929 var cmd = x;
11930 break;
11931 }
11932 }
11933 if (this.neovim) {
11934 var __c5 = this.neovim_additional_commands;
11935 for (var __i5 = 0; __i5 < __c5.length; ++__i5) {
11936 var x = __c5[__i5];
11937 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
11938 delete cmd;
11939 var cmd = x;
11940 break;
11941 }
11942 }
11943 var __c6 = this.neovim_removed_commands;
11944 for (var __i6 = 0; __i6 < __c6.length; ++__i6) {
11945 var x = __c6[__i6];
11946 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
11947 delete cmd;
11948 var cmd = NIL;
11949 break;
11950 }
11951 }
11952 }
11953 // FIXME: user defined command
11954 if ((cmd === NIL || cmd.name == "Print") && viml_eqregh(name, "^[A-Z]")) {
11955 name += this.reader.read_alnum();
11956 delete cmd;
11957 var cmd = {"name":name, "flags":"USERCMD", "parser":"parse_cmd_usercmd"};
11958 }
11959 this.find_command_cache[name] = cmd;
11960 return cmd;
11961}
11962
11963// TODO:
11964VimLParser.prototype.parse_hashbang = function() {
11965 this.reader.getn(-1);
11966}
11967
11968// TODO:
11969// ++opt=val
11970VimLParser.prototype.parse_argopt = function() {
11971 while (this.reader.p(0) == "+" && this.reader.p(1) == "+") {
11972 var s = this.reader.peekn(20);
11973 if (viml_eqregh(s, "^++bin\\>")) {
11974 this.reader.getn(5);
11975 this.ea.force_bin = 1;
11976 }
11977 else if (viml_eqregh(s, "^++nobin\\>")) {
11978 this.reader.getn(7);
11979 this.ea.force_bin = 2;
11980 }
11981 else if (viml_eqregh(s, "^++edit\\>")) {
11982 this.reader.getn(6);
11983 this.ea.read_edit = 1;
11984 }
11985 else if (viml_eqregh(s, "^++ff=\\(dos\\|unix\\|mac\\)\\>")) {
11986 this.reader.getn(5);
11987 this.ea.force_ff = this.reader.read_alpha();
11988 }
11989 else if (viml_eqregh(s, "^++fileformat=\\(dos\\|unix\\|mac\\)\\>")) {
11990 this.reader.getn(13);
11991 this.ea.force_ff = this.reader.read_alpha();
11992 }
11993 else if (viml_eqregh(s, "^++enc=\\S")) {
11994 this.reader.getn(6);
11995 this.ea.force_enc = this.reader.read_nonwhite();
11996 }
11997 else if (viml_eqregh(s, "^++encoding=\\S")) {
11998 this.reader.getn(11);
11999 this.ea.force_enc = this.reader.read_nonwhite();
12000 }
12001 else if (viml_eqregh(s, "^++bad=\\(keep\\|drop\\|.\\)\\>")) {
12002 this.reader.getn(6);
12003 if (viml_eqregh(s, "^++bad=keep")) {
12004 this.ea.bad_char = this.reader.getn(4);
12005 }
12006 else if (viml_eqregh(s, "^++bad=drop")) {
12007 this.ea.bad_char = this.reader.getn(4);
12008 }
12009 else {
12010 this.ea.bad_char = this.reader.getn(1);
12011 }
12012 }
12013 else if (viml_eqregh(s, "^++")) {
12014 throw Err("E474: Invalid Argument", this.reader.getpos());
12015 }
12016 else {
12017 break;
12018 }
12019 this.reader.skip_white();
12020 }
12021}
12022
12023// TODO:
12024// +command
12025VimLParser.prototype.parse_argcmd = function() {
12026 if (this.reader.peekn(1) == "+") {
12027 this.reader.getn(1);
12028 if (this.reader.peekn(1) == " ") {
12029 this.ea.do_ecmd_cmd = "$";
12030 }
12031 else {
12032 this.ea.do_ecmd_cmd = this.read_cmdarg();
12033 }
12034 }
12035}
12036
12037VimLParser.prototype.read_cmdarg = function() {
12038 var r = "";
12039 while (TRUE) {
12040 var c = this.reader.peekn(1);
12041 if (c == "" || iswhite(c)) {
12042 break;
12043 }
12044 this.reader.getn(1);
12045 if (c == "\\") {
12046 var c = this.reader.getn(1);
12047 }
12048 r += c;
12049 }
12050 return r;
12051}
12052
12053VimLParser.prototype.parse_comment = function() {
12054 var npos = this.reader.getpos();
12055 var c = this.reader.get();
12056 if (c != "\"") {
12057 throw Err(viml_printf("unexpected character: %s", c), npos);
12058 }
12059 var node = Node(NODE_COMMENT);
12060 node.pos = npos;
12061 node.str = this.reader.getn(-1);
12062 this.add_node(node);
12063}
12064
12065VimLParser.prototype.parse_trail = function() {
12066 this.reader.skip_white();
12067 var c = this.reader.peek();
12068 if (c == "<EOF>") {
12069 // pass
12070 }
12071 else if (c == "<EOL>") {
12072 this.reader.get();
12073 }
12074 else if (c == "|") {
12075 this.reader.get();
12076 }
12077 else if (c == "\"") {
12078 this.parse_comment();
12079 this.reader.get();
12080 }
12081 else {
12082 throw Err(viml_printf("E488: Trailing characters: %s", c), this.reader.getpos());
12083 }
12084}
12085
12086// modifier or range only command line
12087VimLParser.prototype.parse_cmd_modifier_range = function() {
12088 var node = Node(NODE_EXCMD);
12089 node.pos = this.ea.cmdpos;
12090 node.ea = this.ea;
12091 node.str = this.reader.getstr(this.ea.linepos, this.reader.getpos());
12092 this.add_node(node);
12093}
12094
12095// TODO:
12096VimLParser.prototype.parse_cmd_common = function() {
12097 var end = this.reader.getpos();
12098 if (viml_eqregh(this.ea.cmd.flags, "\\<TRLBAR\\>") && !this.ea.usefilter) {
12099 var end = this.separate_nextcmd();
12100 }
12101 else if (this.ea.cmd.name == "!" || this.ea.cmd.name == "global" || this.ea.cmd.name == "vglobal" || this.ea.usefilter) {
12102 while (TRUE) {
12103 var end = this.reader.getpos();
12104 if (this.reader.getn(1) == "") {
12105 break;
12106 }
12107 }
12108 }
12109 else {
12110 while (TRUE) {
12111 var end = this.reader.getpos();
12112 if (this.reader.getn(1) == "") {
12113 break;
12114 }
12115 }
12116 }
12117 var node = Node(NODE_EXCMD);
12118 node.pos = this.ea.cmdpos;
12119 node.ea = this.ea;
12120 node.str = this.reader.getstr(this.ea.linepos, end);
12121 this.add_node(node);
12122}
12123
12124VimLParser.prototype.separate_nextcmd = function() {
12125 if (this.ea.cmd.name == "vimgrep" || this.ea.cmd.name == "vimgrepadd" || this.ea.cmd.name == "lvimgrep" || this.ea.cmd.name == "lvimgrepadd") {
12126 this.skip_vimgrep_pat();
12127 }
12128 var pc = "";
12129 var end = this.reader.getpos();
12130 var nospend = end;
12131 while (TRUE) {
12132 var end = this.reader.getpos();
12133 if (!iswhite(pc)) {
12134 var nospend = end;
12135 }
12136 var c = this.reader.peek();
12137 if (c == "<EOF>" || c == "<EOL>") {
12138 break;
12139 }
12140 else if (c == "\x16") {
12141 // <C-V>
12142 this.reader.get();
12143 var end = this.reader.getpos();
12144 var nospend = this.reader.getpos();
12145 var c = this.reader.peek();
12146 if (c == "<EOF>" || c == "<EOL>") {
12147 break;
12148 }
12149 this.reader.get();
12150 }
12151 else if (this.reader.peekn(2) == "`=" && viml_eqregh(this.ea.cmd.flags, "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>")) {
12152 this.reader.getn(2);
12153 this.parse_expr();
12154 var c = this.reader.peekn(1);
12155 if (c != "`") {
12156 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
12157 }
12158 this.reader.getn(1);
12159 }
12160 else if (c == "|" || c == "\n" || c == "\"" && !viml_eqregh(this.ea.cmd.flags, "\\<NOTRLCOM\\>") && (this.ea.cmd.name != "@" && this.ea.cmd.name != "*" || this.reader.getpos() != this.ea.argpos) && (this.ea.cmd.name != "redir" || this.reader.getpos().i != this.ea.argpos.i + 1 || pc != "@")) {
12161 var has_cpo_bar = FALSE;
12162 // &cpoptions =~ 'b'
12163 if ((!has_cpo_bar || !viml_eqregh(this.ea.cmd.flags, "\\<USECTRLV\\>")) && pc == "\\") {
12164 this.reader.get();
12165 }
12166 else {
12167 break;
12168 }
12169 }
12170 else {
12171 this.reader.get();
12172 }
12173 var pc = c;
12174 }
12175 if (!viml_eqregh(this.ea.cmd.flags, "\\<NOTRLCOM\\>")) {
12176 var end = nospend;
12177 }
12178 return end;
12179}
12180
12181// FIXME
12182VimLParser.prototype.skip_vimgrep_pat = function() {
12183 if (this.reader.peekn(1) == "") {
12184 // pass
12185 }
12186 else if (isidc(this.reader.peekn(1))) {
12187 // :vimgrep pattern fname
12188 this.reader.read_nonwhite();
12189 }
12190 else {
12191 // :vimgrep /pattern/[g][j] fname
12192 var c = this.reader.getn(1);
12193 var __tmp = this.parse_pattern(c);
12194 var _ = __tmp[0];
12195 var endc = __tmp[1];
12196 if (c != endc) {
12197 return;
12198 }
12199 while (this.reader.p(0) == "g" || this.reader.p(0) == "j") {
12200 this.reader.getn(1);
12201 }
12202 }
12203}
12204
12205VimLParser.prototype.parse_cmd_append = function() {
12206 this.reader.setpos(this.ea.linepos);
12207 var cmdline = this.reader.readline();
12208 var lines = [cmdline];
12209 var m = ".";
12210 while (TRUE) {
12211 if (this.reader.peek() == "<EOF>") {
12212 break;
12213 }
12214 var line = this.reader.getn(-1);
12215 viml_add(lines, line);
12216 if (line == m) {
12217 break;
12218 }
12219 this.reader.get();
12220 }
12221 var node = Node(NODE_EXCMD);
12222 node.pos = this.ea.cmdpos;
12223 node.ea = this.ea;
12224 node.str = viml_join(lines, "\n");
12225 this.add_node(node);
12226}
12227
12228VimLParser.prototype.parse_cmd_insert = function() {
12229 this.parse_cmd_append();
12230}
12231
12232VimLParser.prototype.parse_cmd_loadkeymap = function() {
12233 this.reader.setpos(this.ea.linepos);
12234 var cmdline = this.reader.readline();
12235 var lines = [cmdline];
12236 while (TRUE) {
12237 if (this.reader.peek() == "<EOF>") {
12238 break;
12239 }
12240 var line = this.reader.readline();
12241 viml_add(lines, line);
12242 }
12243 var node = Node(NODE_EXCMD);
12244 node.pos = this.ea.cmdpos;
12245 node.ea = this.ea;
12246 node.str = viml_join(lines, "\n");
12247 this.add_node(node);
12248}
12249
12250VimLParser.prototype.parse_cmd_lua = function() {
12251 var lines = [];
12252 this.reader.skip_white();
12253 if (this.reader.peekn(2) == "<<") {
12254 this.reader.getn(2);
12255 this.reader.skip_white();
12256 var m = this.reader.readline();
12257 if (m == "") {
12258 var m = ".";
12259 }
12260 this.reader.setpos(this.ea.linepos);
12261 var cmdline = this.reader.getn(-1);
12262 var lines = [cmdline];
12263 this.reader.get();
12264 while (TRUE) {
12265 if (this.reader.peek() == "<EOF>") {
12266 break;
12267 }
12268 var line = this.reader.getn(-1);
12269 viml_add(lines, line);
12270 if (line == m) {
12271 break;
12272 }
12273 this.reader.get();
12274 }
12275 }
12276 else {
12277 this.reader.setpos(this.ea.linepos);
12278 var cmdline = this.reader.getn(-1);
12279 var lines = [cmdline];
12280 }
12281 var node = Node(NODE_EXCMD);
12282 node.pos = this.ea.cmdpos;
12283 node.ea = this.ea;
12284 node.str = viml_join(lines, "\n");
12285 this.add_node(node);
12286}
12287
12288VimLParser.prototype.parse_cmd_mzscheme = function() {
12289 this.parse_cmd_lua();
12290}
12291
12292VimLParser.prototype.parse_cmd_perl = function() {
12293 this.parse_cmd_lua();
12294}
12295
12296VimLParser.prototype.parse_cmd_python = function() {
12297 this.parse_cmd_lua();
12298}
12299
12300VimLParser.prototype.parse_cmd_python3 = function() {
12301 this.parse_cmd_lua();
12302}
12303
12304VimLParser.prototype.parse_cmd_ruby = function() {
12305 this.parse_cmd_lua();
12306}
12307
12308VimLParser.prototype.parse_cmd_tcl = function() {
12309 this.parse_cmd_lua();
12310}
12311
12312VimLParser.prototype.parse_cmd_finish = function() {
12313 this.parse_cmd_common();
12314 if (this.context[0].type == NODE_TOPLEVEL) {
12315 this.reader.seek_end(0);
12316 }
12317}
12318
12319// FIXME
12320VimLParser.prototype.parse_cmd_usercmd = function() {
12321 this.parse_cmd_common();
12322}
12323
12324VimLParser.prototype.parse_cmd_function = function() {
12325 var pos = this.reader.tell();
12326 this.reader.skip_white();
12327 // :function
12328 if (this.ends_excmds(this.reader.peek())) {
12329 this.reader.seek_set(pos);
12330 this.parse_cmd_common();
12331 return;
12332 }
12333 // :function /pattern
12334 if (this.reader.peekn(1) == "/") {
12335 this.reader.seek_set(pos);
12336 this.parse_cmd_common();
12337 return;
12338 }
12339 var left = this.parse_lvalue_func();
12340 this.reader.skip_white();
12341 if (left.type == NODE_IDENTIFIER) {
12342 var s = left.value;
12343 var ss = viml_split(s, "\\zs");
12344 if (ss[0] != "<" && ss[0] != "_" && !isupper(ss[0]) && viml_stridx(s, ":") == -1 && viml_stridx(s, "#") == -1) {
12345 throw Err(viml_printf("E128: Function name must start with a capital or contain a colon: %s", s), left.pos);
12346 }
12347 }
12348 // :function {name}
12349 if (this.reader.peekn(1) != "(") {
12350 this.reader.seek_set(pos);
12351 this.parse_cmd_common();
12352 return;
12353 }
12354 // :function[!] {name}([arguments]) [range] [abort] [dict] [closure]
12355 var node = Node(NODE_FUNCTION);
12356 node.pos = this.ea.cmdpos;
12357 node.body = [];
12358 node.ea = this.ea;
12359 node.left = left;
12360 node.rlist = [];
12361 node.default_args = [];
12362 node.attr = {"range":0, "abort":0, "dict":0, "closure":0};
12363 node.endfunction = NIL;
12364 this.reader.getn(1);
12365 var tokenizer = new ExprTokenizer(this.reader);
12366 if (tokenizer.peek().type == TOKEN_PCLOSE) {
12367 tokenizer.get();
12368 }
12369 else {
12370 var named = {};
12371 while (TRUE) {
12372 var varnode = Node(NODE_IDENTIFIER);
12373 var token = tokenizer.get();
12374 if (token.type == TOKEN_IDENTIFIER) {
12375 if (!isargname(token.value) || token.value == "firstline" || token.value == "lastline") {
12376 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
12377 }
12378 else if (viml_has_key(named, token.value)) {
12379 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
12380 }
12381 named[token.value] = 1;
12382 varnode.pos = token.pos;
12383 varnode.value = token.value;
12384 viml_add(node.rlist, varnode);
12385 if (tokenizer.peek().type == TOKEN_EQ) {
12386 tokenizer.get();
12387 viml_add(node.default_args, this.parse_expr());
12388 }
12389 else if (viml_len(node.default_args) > 0) {
12390 throw Err("E989: Non-default argument follows default argument", varnode.pos);
12391 }
12392 // XXX: Vim doesn't skip white space before comma. F(a ,b) => E475
12393 if (iswhite(this.reader.p(0)) && tokenizer.peek().type == TOKEN_COMMA) {
12394 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
12395 }
12396 var token = tokenizer.get();
12397 if (token.type == TOKEN_COMMA) {
12398 // XXX: Vim allows last comma. F(a, b, ) => OK
12399 if (tokenizer.peek().type == TOKEN_PCLOSE) {
12400 tokenizer.get();
12401 break;
12402 }
12403 }
12404 else if (token.type == TOKEN_PCLOSE) {
12405 break;
12406 }
12407 else {
12408 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12409 }
12410 }
12411 else if (token.type == TOKEN_DOTDOTDOT) {
12412 varnode.pos = token.pos;
12413 varnode.value = token.value;
12414 viml_add(node.rlist, varnode);
12415 var token = tokenizer.get();
12416 if (token.type == TOKEN_PCLOSE) {
12417 break;
12418 }
12419 else {
12420 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12421 }
12422 }
12423 else {
12424 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12425 }
12426 }
12427 }
12428 while (TRUE) {
12429 this.reader.skip_white();
12430 var epos = this.reader.getpos();
12431 var key = this.reader.read_alpha();
12432 if (key == "") {
12433 break;
12434 }
12435 else if (key == "range") {
12436 node.attr.range = TRUE;
12437 }
12438 else if (key == "abort") {
12439 node.attr.abort = TRUE;
12440 }
12441 else if (key == "dict") {
12442 node.attr.dict = TRUE;
12443 }
12444 else if (key == "closure") {
12445 node.attr.closure = TRUE;
12446 }
12447 else {
12448 throw Err(viml_printf("unexpected token: %s", key), epos);
12449 }
12450 }
12451 this.add_node(node);
12452 this.push_context(node);
12453}
12454
12455VimLParser.prototype.parse_cmd_endfunction = function() {
12456 this.check_missing_endif("ENDFUNCTION", this.ea.cmdpos);
12457 this.check_missing_endtry("ENDFUNCTION", this.ea.cmdpos);
12458 this.check_missing_endwhile("ENDFUNCTION", this.ea.cmdpos);
12459 this.check_missing_endfor("ENDFUNCTION", this.ea.cmdpos);
12460 if (this.context[0].type != NODE_FUNCTION) {
12461 throw Err("E193: :endfunction not inside a function", this.ea.cmdpos);
12462 }
12463 this.reader.getn(-1);
12464 var node = Node(NODE_ENDFUNCTION);
12465 node.pos = this.ea.cmdpos;
12466 node.ea = this.ea;
12467 this.context[0].endfunction = node;
12468 this.pop_context();
12469}
12470
12471VimLParser.prototype.parse_cmd_delfunction = function() {
12472 var node = Node(NODE_DELFUNCTION);
12473 node.pos = this.ea.cmdpos;
12474 node.ea = this.ea;
12475 node.left = this.parse_lvalue_func();
12476 this.add_node(node);
12477}
12478
12479VimLParser.prototype.parse_cmd_return = function() {
12480 if (this.find_context(NODE_FUNCTION) == -1) {
12481 throw Err("E133: :return not inside a function", this.ea.cmdpos);
12482 }
12483 var node = Node(NODE_RETURN);
12484 node.pos = this.ea.cmdpos;
12485 node.ea = this.ea;
12486 node.left = NIL;
12487 this.reader.skip_white();
12488 var c = this.reader.peek();
12489 if (c == "\"" || !this.ends_excmds(c)) {
12490 node.left = this.parse_expr();
12491 }
12492 this.add_node(node);
12493}
12494
12495VimLParser.prototype.parse_cmd_call = function() {
12496 var node = Node(NODE_EXCALL);
12497 node.pos = this.ea.cmdpos;
12498 node.ea = this.ea;
12499 this.reader.skip_white();
12500 var c = this.reader.peek();
12501 if (this.ends_excmds(c)) {
12502 throw Err("E471: Argument required", this.reader.getpos());
12503 }
12504 node.left = this.parse_expr();
12505 if (node.left.type != NODE_CALL) {
12506 throw Err("Not a function call", node.left.pos);
12507 }
12508 this.add_node(node);
12509}
12510
12511VimLParser.prototype.parse_heredoc = function() {
12512 var node = Node(NODE_HEREDOC);
12513 node.pos = this.ea.cmdpos;
12514 node.op = "";
12515 node.rlist = [];
12516 node.body = [];
12517 while (TRUE) {
12518 this.reader.skip_white();
12519 var key = this.reader.read_word();
12520 if (key == "") {
12521 break;
12522 }
12523 if (!islower(key[0])) {
12524 node.op = key;
12525 break;
12526 }
12527 else {
12528 viml_add(node.rlist, key);
12529 }
12530 }
12531 if (node.op == "") {
12532 throw Err("E172: Missing marker", this.reader.getpos());
12533 }
12534 this.parse_trail();
12535 while (TRUE) {
12536 if (this.reader.peek() == "<EOF>") {
12537 break;
12538 }
12539 var line = this.reader.getn(-1);
12540 if (line == node.op) {
12541 return node;
12542 }
12543 viml_add(node.body, line);
12544 this.reader.get();
12545 }
12546 throw Err(viml_printf("E990: Missing end marker '%s'", node.op), this.reader.getpos());
12547}
12548
12549VimLParser.prototype.parse_cmd_let = function() {
12550 var pos = this.reader.tell();
12551 this.reader.skip_white();
12552 // :let
12553 if (this.ends_excmds(this.reader.peek())) {
12554 this.reader.seek_set(pos);
12555 this.parse_cmd_common();
12556 return;
12557 }
12558 var lhs = this.parse_letlhs();
12559 this.reader.skip_white();
12560 var s1 = this.reader.peekn(1);
12561 var s2 = this.reader.peekn(2);
12562 // TODO check scriptversion?
12563 if (s2 == "..") {
12564 var s2 = this.reader.peekn(3);
12565 }
12566 else if (s2 == "=<") {
12567 var s2 = this.reader.peekn(3);
12568 }
12569 // :let {var-name} ..
12570 if (this.ends_excmds(s1) || s2 != "+=" && s2 != "-=" && s2 != ".=" && s2 != "..=" && s2 != "*=" && s2 != "/=" && s2 != "%=" && s2 != "=<<" && s1 != "=") {
12571 this.reader.seek_set(pos);
12572 this.parse_cmd_common();
12573 return;
12574 }
12575 // :let left op right
12576 var node = Node(NODE_LET);
12577 node.pos = this.ea.cmdpos;
12578 node.ea = this.ea;
12579 node.op = "";
12580 node.left = lhs.left;
12581 node.list = lhs.list;
12582 node.rest = lhs.rest;
12583 node.right = NIL;
12584 if (s2 == "+=" || s2 == "-=" || s2 == ".=" || s2 == "..=" || s2 == "*=" || s2 == "/=" || s2 == "%=") {
12585 this.reader.getn(viml_len(s2));
12586 node.op = s2;
12587 }
12588 else if (s2 == "=<<") {
12589 this.reader.getn(viml_len(s2));
12590 this.reader.skip_white();
12591 node.op = s2;
12592 node.right = this.parse_heredoc();
12593 this.add_node(node);
12594 return;
12595 }
12596 else if (s1 == "=") {
12597 this.reader.getn(1);
12598 node.op = s1;
12599 }
12600 else {
12601 throw "NOT REACHED";
12602 }
12603 node.right = this.parse_expr();
12604 this.add_node(node);
12605}
12606
12607VimLParser.prototype.parse_cmd_const = function() {
12608 var pos = this.reader.tell();
12609 this.reader.skip_white();
12610 // :const
12611 if (this.ends_excmds(this.reader.peek())) {
12612 this.reader.seek_set(pos);
12613 this.parse_cmd_common();
12614 return;
12615 }
12616 var lhs = this.parse_constlhs();
12617 this.reader.skip_white();
12618 var s1 = this.reader.peekn(1);
12619 // :const {var-name}
12620 if (this.ends_excmds(s1) || s1 != "=") {
12621 this.reader.seek_set(pos);
12622 this.parse_cmd_common();
12623 return;
12624 }
12625 // :const left op right
12626 var node = Node(NODE_CONST);
12627 node.pos = this.ea.cmdpos;
12628 node.ea = this.ea;
12629 this.reader.getn(1);
12630 node.op = s1;
12631 node.left = lhs.left;
12632 node.list = lhs.list;
12633 node.rest = lhs.rest;
12634 node.right = this.parse_expr();
12635 this.add_node(node);
12636}
12637
12638VimLParser.prototype.parse_cmd_unlet = function() {
12639 var node = Node(NODE_UNLET);
12640 node.pos = this.ea.cmdpos;
12641 node.ea = this.ea;
12642 node.list = this.parse_lvaluelist();
12643 this.add_node(node);
12644}
12645
12646VimLParser.prototype.parse_cmd_lockvar = function() {
12647 var node = Node(NODE_LOCKVAR);
12648 node.pos = this.ea.cmdpos;
12649 node.ea = this.ea;
12650 node.depth = NIL;
12651 node.list = [];
12652 this.reader.skip_white();
12653 if (isdigit(this.reader.peekn(1))) {
12654 node.depth = viml_str2nr(this.reader.read_digit(), 10);
12655 }
12656 node.list = this.parse_lvaluelist();
12657 this.add_node(node);
12658}
12659
12660VimLParser.prototype.parse_cmd_unlockvar = function() {
12661 var node = Node(NODE_UNLOCKVAR);
12662 node.pos = this.ea.cmdpos;
12663 node.ea = this.ea;
12664 node.depth = NIL;
12665 node.list = [];
12666 this.reader.skip_white();
12667 if (isdigit(this.reader.peekn(1))) {
12668 node.depth = viml_str2nr(this.reader.read_digit(), 10);
12669 }
12670 node.list = this.parse_lvaluelist();
12671 this.add_node(node);
12672}
12673
12674VimLParser.prototype.parse_cmd_if = function() {
12675 var node = Node(NODE_IF);
12676 node.pos = this.ea.cmdpos;
12677 node.body = [];
12678 node.ea = this.ea;
12679 node.cond = this.parse_expr();
12680 node.elseif = [];
12681 node._else = NIL;
12682 node.endif = NIL;
12683 this.add_node(node);
12684 this.push_context(node);
12685}
12686
12687VimLParser.prototype.parse_cmd_elseif = function() {
12688 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
12689 throw Err("E582: :elseif without :if", this.ea.cmdpos);
12690 }
12691 if (this.context[0].type != NODE_IF) {
12692 this.pop_context();
12693 }
12694 var node = Node(NODE_ELSEIF);
12695 node.pos = this.ea.cmdpos;
12696 node.body = [];
12697 node.ea = this.ea;
12698 node.cond = this.parse_expr();
12699 viml_add(this.context[0].elseif, node);
12700 this.push_context(node);
12701}
12702
12703VimLParser.prototype.parse_cmd_else = function() {
12704 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
12705 throw Err("E581: :else without :if", this.ea.cmdpos);
12706 }
12707 if (this.context[0].type != NODE_IF) {
12708 this.pop_context();
12709 }
12710 var node = Node(NODE_ELSE);
12711 node.pos = this.ea.cmdpos;
12712 node.body = [];
12713 node.ea = this.ea;
12714 this.context[0]._else = node;
12715 this.push_context(node);
12716}
12717
12718VimLParser.prototype.parse_cmd_endif = function() {
12719 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF && this.context[0].type != NODE_ELSE) {
12720 throw Err("E580: :endif without :if", this.ea.cmdpos);
12721 }
12722 if (this.context[0].type != NODE_IF) {
12723 this.pop_context();
12724 }
12725 var node = Node(NODE_ENDIF);
12726 node.pos = this.ea.cmdpos;
12727 node.ea = this.ea;
12728 this.context[0].endif = node;
12729 this.pop_context();
12730}
12731
12732VimLParser.prototype.parse_cmd_while = function() {
12733 var node = Node(NODE_WHILE);
12734 node.pos = this.ea.cmdpos;
12735 node.body = [];
12736 node.ea = this.ea;
12737 node.cond = this.parse_expr();
12738 node.endwhile = NIL;
12739 this.add_node(node);
12740 this.push_context(node);
12741}
12742
12743VimLParser.prototype.parse_cmd_endwhile = function() {
12744 if (this.context[0].type != NODE_WHILE) {
12745 throw Err("E588: :endwhile without :while", this.ea.cmdpos);
12746 }
12747 var node = Node(NODE_ENDWHILE);
12748 node.pos = this.ea.cmdpos;
12749 node.ea = this.ea;
12750 this.context[0].endwhile = node;
12751 this.pop_context();
12752}
12753
12754VimLParser.prototype.parse_cmd_for = function() {
12755 var node = Node(NODE_FOR);
12756 node.pos = this.ea.cmdpos;
12757 node.body = [];
12758 node.ea = this.ea;
12759 node.left = NIL;
12760 node.right = NIL;
12761 node.endfor = NIL;
12762 var lhs = this.parse_letlhs();
12763 node.left = lhs.left;
12764 node.list = lhs.list;
12765 node.rest = lhs.rest;
12766 this.reader.skip_white();
12767 var epos = this.reader.getpos();
12768 if (this.reader.read_alpha() != "in") {
12769 throw Err("Missing \"in\" after :for", epos);
12770 }
12771 node.right = this.parse_expr();
12772 this.add_node(node);
12773 this.push_context(node);
12774}
12775
12776VimLParser.prototype.parse_cmd_endfor = function() {
12777 if (this.context[0].type != NODE_FOR) {
12778 throw Err("E588: :endfor without :for", this.ea.cmdpos);
12779 }
12780 var node = Node(NODE_ENDFOR);
12781 node.pos = this.ea.cmdpos;
12782 node.ea = this.ea;
12783 this.context[0].endfor = node;
12784 this.pop_context();
12785}
12786
12787VimLParser.prototype.parse_cmd_continue = function() {
12788 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
12789 throw Err("E586: :continue without :while or :for", this.ea.cmdpos);
12790 }
12791 var node = Node(NODE_CONTINUE);
12792 node.pos = this.ea.cmdpos;
12793 node.ea = this.ea;
12794 this.add_node(node);
12795}
12796
12797VimLParser.prototype.parse_cmd_break = function() {
12798 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
12799 throw Err("E587: :break without :while or :for", this.ea.cmdpos);
12800 }
12801 var node = Node(NODE_BREAK);
12802 node.pos = this.ea.cmdpos;
12803 node.ea = this.ea;
12804 this.add_node(node);
12805}
12806
12807VimLParser.prototype.parse_cmd_try = function() {
12808 var node = Node(NODE_TRY);
12809 node.pos = this.ea.cmdpos;
12810 node.body = [];
12811 node.ea = this.ea;
12812 node.catch = [];
12813 node._finally = NIL;
12814 node.endtry = NIL;
12815 this.add_node(node);
12816 this.push_context(node);
12817}
12818
12819VimLParser.prototype.parse_cmd_catch = function() {
12820 if (this.context[0].type == NODE_FINALLY) {
12821 throw Err("E604: :catch after :finally", this.ea.cmdpos);
12822 }
12823 else if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
12824 throw Err("E603: :catch without :try", this.ea.cmdpos);
12825 }
12826 if (this.context[0].type != NODE_TRY) {
12827 this.pop_context();
12828 }
12829 var node = Node(NODE_CATCH);
12830 node.pos = this.ea.cmdpos;
12831 node.body = [];
12832 node.ea = this.ea;
12833 node.pattern = NIL;
12834 this.reader.skip_white();
12835 if (!this.ends_excmds(this.reader.peek())) {
12836 var __tmp = this.parse_pattern(this.reader.get());
12837 node.pattern = __tmp[0];
12838 var _ = __tmp[1];
12839 }
12840 viml_add(this.context[0].catch, node);
12841 this.push_context(node);
12842}
12843
12844VimLParser.prototype.parse_cmd_finally = function() {
12845 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
12846 throw Err("E606: :finally without :try", this.ea.cmdpos);
12847 }
12848 if (this.context[0].type != NODE_TRY) {
12849 this.pop_context();
12850 }
12851 var node = Node(NODE_FINALLY);
12852 node.pos = this.ea.cmdpos;
12853 node.body = [];
12854 node.ea = this.ea;
12855 this.context[0]._finally = node;
12856 this.push_context(node);
12857}
12858
12859VimLParser.prototype.parse_cmd_endtry = function() {
12860 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH && this.context[0].type != NODE_FINALLY) {
12861 throw Err("E602: :endtry without :try", this.ea.cmdpos);
12862 }
12863 if (this.context[0].type != NODE_TRY) {
12864 this.pop_context();
12865 }
12866 var node = Node(NODE_ENDTRY);
12867 node.pos = this.ea.cmdpos;
12868 node.ea = this.ea;
12869 this.context[0].endtry = node;
12870 this.pop_context();
12871}
12872
12873VimLParser.prototype.parse_cmd_throw = function() {
12874 var node = Node(NODE_THROW);
12875 node.pos = this.ea.cmdpos;
12876 node.ea = this.ea;
12877 node.left = this.parse_expr();
12878 this.add_node(node);
12879}
12880
12881VimLParser.prototype.parse_cmd_eval = function() {
12882 var node = Node(NODE_EVAL);
12883 node.pos = this.ea.cmdpos;
12884 node.ea = this.ea;
12885 node.left = this.parse_expr();
12886 this.add_node(node);
12887}
12888
12889VimLParser.prototype.parse_cmd_echo = function() {
12890 var node = Node(NODE_ECHO);
12891 node.pos = this.ea.cmdpos;
12892 node.ea = this.ea;
12893 node.list = this.parse_exprlist();
12894 this.add_node(node);
12895}
12896
12897VimLParser.prototype.parse_cmd_echon = function() {
12898 var node = Node(NODE_ECHON);
12899 node.pos = this.ea.cmdpos;
12900 node.ea = this.ea;
12901 node.list = this.parse_exprlist();
12902 this.add_node(node);
12903}
12904
12905VimLParser.prototype.parse_cmd_echohl = function() {
12906 var node = Node(NODE_ECHOHL);
12907 node.pos = this.ea.cmdpos;
12908 node.ea = this.ea;
12909 node.str = "";
12910 while (!this.ends_excmds(this.reader.peek())) {
12911 node.str += this.reader.get();
12912 }
12913 this.add_node(node);
12914}
12915
12916VimLParser.prototype.parse_cmd_echomsg = function() {
12917 var node = Node(NODE_ECHOMSG);
12918 node.pos = this.ea.cmdpos;
12919 node.ea = this.ea;
12920 node.list = this.parse_exprlist();
12921 this.add_node(node);
12922}
12923
12924VimLParser.prototype.parse_cmd_echoerr = function() {
12925 var node = Node(NODE_ECHOERR);
12926 node.pos = this.ea.cmdpos;
12927 node.ea = this.ea;
12928 node.list = this.parse_exprlist();
12929 this.add_node(node);
12930}
12931
12932VimLParser.prototype.parse_cmd_execute = function() {
12933 var node = Node(NODE_EXECUTE);
12934 node.pos = this.ea.cmdpos;
12935 node.ea = this.ea;
12936 node.list = this.parse_exprlist();
12937 this.add_node(node);
12938}
12939
12940VimLParser.prototype.parse_expr = function() {
12941 return new ExprParser(this.reader).parse();
12942}
12943
12944VimLParser.prototype.parse_exprlist = function() {
12945 var list = [];
12946 while (TRUE) {
12947 this.reader.skip_white();
12948 var c = this.reader.peek();
12949 if (c != "\"" && this.ends_excmds(c)) {
12950 break;
12951 }
12952 var node = this.parse_expr();
12953 viml_add(list, node);
12954 }
12955 return list;
12956}
12957
12958VimLParser.prototype.parse_lvalue_func = function() {
12959 var p = new LvalueParser(this.reader);
12960 var node = p.parse();
12961 if (node.type == NODE_IDENTIFIER || node.type == NODE_CURLYNAME || node.type == NODE_SUBSCRIPT || node.type == NODE_DOT || node.type == NODE_OPTION || node.type == NODE_ENV || node.type == NODE_REG) {
12962 return node;
12963 }
12964 throw Err("Invalid Expression", node.pos);
12965}
12966
12967// FIXME:
12968VimLParser.prototype.parse_lvalue = function() {
12969 var p = new LvalueParser(this.reader);
12970 var node = p.parse();
12971 if (node.type == NODE_IDENTIFIER) {
12972 if (!isvarname(node.value)) {
12973 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
12974 }
12975 }
12976 if (node.type == NODE_IDENTIFIER || node.type == NODE_CURLYNAME || node.type == NODE_SUBSCRIPT || node.type == NODE_SLICE || node.type == NODE_DOT || node.type == NODE_OPTION || node.type == NODE_ENV || node.type == NODE_REG) {
12977 return node;
12978 }
12979 throw Err("Invalid Expression", node.pos);
12980}
12981
12982// TODO: merge with s:VimLParser.parse_lvalue()
12983VimLParser.prototype.parse_constlvalue = function() {
12984 var p = new LvalueParser(this.reader);
12985 var node = p.parse();
12986 if (node.type == NODE_IDENTIFIER) {
12987 if (!isvarname(node.value)) {
12988 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
12989 }
12990 }
12991 if (node.type == NODE_IDENTIFIER || node.type == NODE_CURLYNAME) {
12992 return node;
12993 }
12994 else if (node.type == NODE_SUBSCRIPT || node.type == NODE_SLICE || node.type == NODE_DOT) {
12995 throw Err("E996: Cannot lock a list or dict", node.pos);
12996 }
12997 else if (node.type == NODE_OPTION) {
12998 throw Err("E996: Cannot lock an option", node.pos);
12999 }
13000 else if (node.type == NODE_ENV) {
13001 throw Err("E996: Cannot lock an environment variable", node.pos);
13002 }
13003 else if (node.type == NODE_REG) {
13004 throw Err("E996: Cannot lock a register", node.pos);
13005 }
13006 throw Err("Invalid Expression", node.pos);
13007}
13008
13009VimLParser.prototype.parse_lvaluelist = function() {
13010 var list = [];
13011 var node = this.parse_expr();
13012 viml_add(list, node);
13013 while (TRUE) {
13014 this.reader.skip_white();
13015 if (this.ends_excmds(this.reader.peek())) {
13016 break;
13017 }
13018 var node = this.parse_lvalue();
13019 viml_add(list, node);
13020 }
13021 return list;
13022}
13023
13024// FIXME:
13025VimLParser.prototype.parse_letlhs = function() {
13026 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
13027 var tokenizer = new ExprTokenizer(this.reader);
13028 if (tokenizer.peek().type == TOKEN_SQOPEN) {
13029 tokenizer.get();
13030 lhs.list = [];
13031 while (TRUE) {
13032 var node = this.parse_lvalue();
13033 viml_add(lhs.list, node);
13034 var token = tokenizer.get();
13035 if (token.type == TOKEN_SQCLOSE) {
13036 break;
13037 }
13038 else if (token.type == TOKEN_COMMA) {
13039 continue;
13040 }
13041 else if (token.type == TOKEN_SEMICOLON) {
13042 var node = this.parse_lvalue();
13043 lhs.rest = node;
13044 var token = tokenizer.get();
13045 if (token.type == TOKEN_SQCLOSE) {
13046 break;
13047 }
13048 else {
13049 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
13050 }
13051 }
13052 else {
13053 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
13054 }
13055 }
13056 }
13057 else {
13058 lhs.left = this.parse_lvalue();
13059 }
13060 return lhs;
13061}
13062
13063// TODO: merge with s:VimLParser.parse_letlhs() ?
13064VimLParser.prototype.parse_constlhs = function() {
13065 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
13066 var tokenizer = new ExprTokenizer(this.reader);
13067 if (tokenizer.peek().type == TOKEN_SQOPEN) {
13068 tokenizer.get();
13069 lhs.list = [];
13070 while (TRUE) {
13071 var node = this.parse_lvalue();
13072 viml_add(lhs.list, node);
13073 var token = tokenizer.get();
13074 if (token.type == TOKEN_SQCLOSE) {
13075 break;
13076 }
13077 else if (token.type == TOKEN_COMMA) {
13078 continue;
13079 }
13080 else if (token.type == TOKEN_SEMICOLON) {
13081 var node = this.parse_lvalue();
13082 lhs.rest = node;
13083 var token = tokenizer.get();
13084 if (token.type == TOKEN_SQCLOSE) {
13085 break;
13086 }
13087 else {
13088 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
13089 }
13090 }
13091 else {
13092 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
13093 }
13094 }
13095 }
13096 else {
13097 lhs.left = this.parse_constlvalue();
13098 }
13099 return lhs;
13100}
13101
13102VimLParser.prototype.ends_excmds = function(c) {
13103 return c == "" || c == "|" || c == "\"" || c == "<EOF>" || c == "<EOL>";
13104}
13105
13106// FIXME: validate argument
13107VimLParser.prototype.parse_wincmd = function() {
13108 var c = this.reader.getn(1);
13109 if (c == "") {
13110 throw Err("E471: Argument required", this.reader.getpos());
13111 }
13112 else if (c == "g" || c == "\x07") {
13113 // <C-G>
13114 var c2 = this.reader.getn(1);
13115 if (c2 == "" || iswhite(c2)) {
13116 throw Err("E474: Invalid Argument", this.reader.getpos());
13117 }
13118 }
13119 var end = this.reader.getpos();
13120 this.reader.skip_white();
13121 if (!this.ends_excmds(this.reader.peek())) {
13122 throw Err("E474: Invalid Argument", this.reader.getpos());
13123 }
13124 var node = Node(NODE_EXCMD);
13125 node.pos = this.ea.cmdpos;
13126 node.ea = this.ea;
13127 node.str = this.reader.getstr(this.ea.linepos, end);
13128 this.add_node(node);
13129}
13130
13131// FIXME: validate argument
13132VimLParser.prototype.parse_cmd_syntax = function() {
13133 var end = this.reader.getpos();
13134 while (TRUE) {
13135 var end = this.reader.getpos();
13136 var c = this.reader.peek();
13137 if (c == "/" || c == "'" || c == "\"") {
13138 this.reader.getn(1);
13139 this.parse_pattern(c);
13140 }
13141 else if (c == "=") {
13142 this.reader.getn(1);
13143 this.parse_pattern(" ");
13144 }
13145 else if (this.ends_excmds(c)) {
13146 break;
13147 }
13148 this.reader.getn(1);
13149 }
13150 var node = Node(NODE_EXCMD);
13151 node.pos = this.ea.cmdpos;
13152 node.ea = this.ea;
13153 node.str = this.reader.getstr(this.ea.linepos, end);
13154 this.add_node(node);
13155}
13156
13157VimLParser.prototype.neovim_additional_commands = [{"name":"rshada", "minlen":3, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"wshada", "minlen":3, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}];
13158VimLParser.prototype.neovim_removed_commands = [{"name":"Print", "minlen":1, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"fixdel", "minlen":3, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"helpfind", "minlen":5, "flags":"EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"open", "minlen":1, "flags":"RANGE|BANG|EXTRA", "parser":"parse_cmd_common"}, {"name":"shell", "minlen":2, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tearoff", "minlen":2, "flags":"NEEDARG|EXTRA|TRLBAR|NOTRLCOM|CMDWIN", "parser":"parse_cmd_common"}, {"name":"gvim", "minlen":2, "flags":"BANG|FILES|EDITCMD|ARGOPT|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}];
13159// To find new builtin_commands, run the below script.
13160// $ scripts/update_builtin_commands.sh /path/to/vim/src/ex_cmds.h
13161VimLParser.prototype.builtin_commands = [{"name":"append", "minlen":1, "flags":"BANG|RANGE|ZEROR|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_append"}, {"name":"abbreviate", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"abclear", "minlen":3, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"aboveleft", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"all", "minlen":2, "flags":"BANG|RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"amenu", "minlen":2, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"anoremenu", "minlen":2, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"args", "minlen":2, "flags":"BANG|FILES|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"argadd", "minlen":4, "flags":"BANG|NEEDARG|RANGE|NOTADR|ZEROR|FILES|TRLBAR", "parser":"parse_cmd_common"}, {"name":"argdelete", "minlen":4, "flags":"BANG|RANGE|NOTADR|FILES|TRLBAR", "parser":"parse_cmd_common"}, {"name":"argedit", "minlen":4, "flags":"BANG|NEEDARG|RANGE|NOTADR|FILE1|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"argdo", "minlen":5, "flags":"BANG|NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"argglobal", "minlen":4, "flags":"BANG|FILES|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"arglocal", "minlen":4, "flags":"BANG|FILES|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"argument", "minlen":4, "flags":"BANG|RANGE|NOTADR|COUNT|EXTRA|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"ascii", "minlen":2, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"autocmd", "minlen":2, "flags":"BANG|EXTRA|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"augroup", "minlen":3, "flags":"BANG|WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"aunmenu", "minlen":3, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"buffer", "minlen":1, "flags":"BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"bNext", "minlen":2, "flags":"BANG|RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"ball", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"badd", "minlen":3, "flags":"NEEDARG|FILE1|EDITCMD|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"bdelete", "minlen":2, "flags":"BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"behave", "minlen":2, "flags":"NEEDARG|WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"belowright", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"bfirst", "minlen":2, "flags":"BANG|RANGE|NOTADR|TRLBAR", "parser":"parse_cmd_common"}, {"name":"blast", "minlen":2, "flags":"BANG|RANGE|NOTADR|TRLBAR", "parser":"parse_cmd_common"}, {"name":"bmodified", "minlen":2, "flags":"BANG|RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"bnext", "minlen":2, "flags":"BANG|RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"botright", "minlen":2, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"bprevious", "minlen":2, "flags":"BANG|RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"brewind", "minlen":2, "flags":"BANG|RANGE|NOTADR|TRLBAR", "parser":"parse_cmd_common"}, {"name":"break", "minlen":4, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_break"}, {"name":"breakadd", "minlen":6, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"breakdel", "minlen":6, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"breaklist", "minlen":6, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"browse", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM|CMDWIN", "parser":"parse_cmd_common"}, {"name":"bufdo", "minlen":5, "flags":"BANG|NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"buffers", "minlen":7, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"bunload", "minlen":3, "flags":"BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"bwipeout", "minlen":2, "flags":"BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"change", "minlen":1, "flags":"BANG|WHOLEFOLD|RANGE|COUNT|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"cNext", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cNfile", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cabbrev", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cabclear", "minlen":4, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"caddbuffer", "minlen":3, "flags":"RANGE|NOTADR|WORD1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"caddexpr", "minlen":5, "flags":"NEEDARG|WORD1|NOTRLCOM|TRLBAR", "parser":"parse_cmd_common"}, {"name":"caddfile", "minlen":5, "flags":"TRLBAR|FILE1", "parser":"parse_cmd_common"}, {"name":"call", "minlen":3, "flags":"RANGE|NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_call"}, {"name":"catch", "minlen":3, "flags":"EXTRA|SBOXOK|CMDWIN", "parser":"parse_cmd_catch"}, {"name":"cbuffer", "minlen":2, "flags":"BANG|RANGE|NOTADR|WORD1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"cc", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cclose", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"cd", "minlen":2, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"center", "minlen":2, "flags":"TRLBAR|RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"cexpr", "minlen":3, "flags":"NEEDARG|WORD1|NOTRLCOM|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cfile", "minlen":2, "flags":"TRLBAR|FILE1|BANG", "parser":"parse_cmd_common"}, {"name":"cfirst", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cgetbuffer", "minlen":5, "flags":"RANGE|NOTADR|WORD1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"cgetexpr", "minlen":5, "flags":"NEEDARG|WORD1|NOTRLCOM|TRLBAR", "parser":"parse_cmd_common"}, {"name":"cgetfile", "minlen":2, "flags":"TRLBAR|FILE1", "parser":"parse_cmd_common"}, {"name":"changes", "minlen":7, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"chdir", "minlen":3, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"checkpath", "minlen":3, "flags":"TRLBAR|BANG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"checktime", "minlen":6, "flags":"RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"clist", "minlen":2, "flags":"BANG|EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"clast", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"close", "minlen":3, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cmapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cmenu", "minlen":3, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cnext", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cnewer", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"cnfile", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cnoremap", "minlen":3, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cnoreabbrev", "minlen":6, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cnoremenu", "minlen":7, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"copy", "minlen":2, "flags":"RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"colder", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"colorscheme", "minlen":4, "flags":"WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"command", "minlen":3, "flags":"EXTRA|BANG|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"comclear", "minlen":4, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"compiler", "minlen":4, "flags":"BANG|TRLBAR|WORD1|CMDWIN", "parser":"parse_cmd_common"}, {"name":"continue", "minlen":3, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_continue"}, {"name":"confirm", "minlen":4, "flags":"NEEDARG|EXTRA|NOTRLCOM|CMDWIN", "parser":"parse_cmd_common"}, {"name":"copen", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"cprevious", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cpfile", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cquit", "minlen":2, "flags":"TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"crewind", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"cscope", "minlen":2, "flags":"EXTRA|NOTRLCOM|XFILE", "parser":"parse_cmd_common"}, {"name":"cstag", "minlen":3, "flags":"BANG|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"cunmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cunabbrev", "minlen":4, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cunmenu", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"cwindow", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"delete", "minlen":1, "flags":"RANGE|WHOLEFOLD|REGSTR|COUNT|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"delmarks", "minlen":4, "flags":"BANG|EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"debug", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"debuggreedy", "minlen":6, "flags":"RANGE|NOTADR|ZEROR|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"delcommand", "minlen":4, "flags":"NEEDARG|WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"delfunction", "minlen":4, "flags":"BANG|NEEDARG|WORD1|CMDWIN", "parser":"parse_cmd_delfunction"}, {"name":"diffupdate", "minlen":3, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"diffget", "minlen":5, "flags":"RANGE|EXTRA|TRLBAR|MODIFY", "parser":"parse_cmd_common"}, {"name":"diffoff", "minlen":5, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"diffpatch", "minlen":5, "flags":"EXTRA|FILE1|TRLBAR|MODIFY", "parser":"parse_cmd_common"}, {"name":"diffput", "minlen":6, "flags":"RANGE|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"diffsplit", "minlen":5, "flags":"EXTRA|FILE1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"diffthis", "minlen":5, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"digraphs", "minlen":3, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"display", "minlen":2, "flags":"EXTRA|NOTRLCOM|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"djump", "minlen":2, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA", "parser":"parse_cmd_common"}, {"name":"dlist", "minlen":2, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"doautocmd", "minlen":2, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"doautoall", "minlen":7, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"drop", "minlen":2, "flags":"FILES|EDITCMD|NEEDARG|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"dsearch", "minlen":2, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"dsplit", "minlen":3, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA", "parser":"parse_cmd_common"}, {"name":"edit", "minlen":1, "flags":"BANG|FILE1|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"earlier", "minlen":2, "flags":"TRLBAR|EXTRA|NOSPC|CMDWIN", "parser":"parse_cmd_common"}, {"name":"echo", "minlen":2, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_echo"}, {"name":"echoerr", "minlen":5, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_echoerr"}, {"name":"echohl", "minlen":5, "flags":"EXTRA|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_echohl"}, {"name":"echomsg", "minlen":5, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_echomsg"}, {"name":"echon", "minlen":5, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_echon"}, {"name":"else", "minlen":2, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_else"}, {"name":"elseif", "minlen":5, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_elseif"}, {"name":"emenu", "minlen":2, "flags":"NEEDARG|EXTRA|TRLBAR|NOTRLCOM|RANGE|NOTADR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"endif", "minlen":2, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_endif"}, {"name":"endfor", "minlen":5, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_endfor"}, {"name":"endfunction", "minlen":4, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_endfunction"}, {"name":"endtry", "minlen":4, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_endtry"}, {"name":"endwhile", "minlen":4, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_endwhile"}, {"name":"enew", "minlen":3, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"eval", "minlen":2, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_eval"}, {"name":"ex", "minlen":2, "flags":"BANG|FILE1|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"execute", "minlen":3, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_execute"}, {"name":"exit", "minlen":3, "flags":"RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"exusage", "minlen":3, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"file", "minlen":1, "flags":"RANGE|NOTADR|ZEROR|BANG|FILE1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"files", "minlen":5, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"filetype", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"find", "minlen":3, "flags":"RANGE|NOTADR|BANG|FILE1|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"finally", "minlen":4, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_finally"}, {"name":"finish", "minlen":4, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_finish"}, {"name":"first", "minlen":3, "flags":"EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"fixdel", "minlen":3, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"fold", "minlen":2, "flags":"RANGE|WHOLEFOLD|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"foldclose", "minlen":5, "flags":"RANGE|BANG|WHOLEFOLD|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"folddoopen", "minlen":5, "flags":"RANGE|DFLALL|NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"folddoclosed", "minlen":7, "flags":"RANGE|DFLALL|NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"foldopen", "minlen":5, "flags":"RANGE|BANG|WHOLEFOLD|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"for", "minlen":3, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_for"}, {"name":"function", "minlen":2, "flags":"EXTRA|BANG|CMDWIN", "parser":"parse_cmd_function"}, {"name":"global", "minlen":1, "flags":"RANGE|WHOLEFOLD|BANG|EXTRA|DFLALL|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"goto", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"grep", "minlen":2, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"grepadd", "minlen":5, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"gui", "minlen":2, "flags":"BANG|FILES|EDITCMD|ARGOPT|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"gvim", "minlen":2, "flags":"BANG|FILES|EDITCMD|ARGOPT|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"hardcopy", "minlen":2, "flags":"RANGE|COUNT|EXTRA|TRLBAR|DFLALL|BANG", "parser":"parse_cmd_common"}, {"name":"help", "minlen":1, "flags":"BANG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"helpfind", "minlen":5, "flags":"EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"helpgrep", "minlen":5, "flags":"EXTRA|NOTRLCOM|NEEDARG", "parser":"parse_cmd_common"}, {"name":"helptags", "minlen":5, "flags":"NEEDARG|FILES|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"highlight", "minlen":2, "flags":"BANG|EXTRA|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"hide", "minlen":3, "flags":"BANG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"history", "minlen":3, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"insert", "minlen":1, "flags":"BANG|RANGE|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_insert"}, {"name":"iabbrev", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"iabclear", "minlen":4, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"if", "minlen":2, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_if"}, {"name":"ijump", "minlen":2, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA", "parser":"parse_cmd_common"}, {"name":"ilist", "minlen":2, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"imap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"imapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"imenu", "minlen":3, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"inoremap", "minlen":3, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"inoreabbrev", "minlen":6, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"inoremenu", "minlen":7, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"intro", "minlen":3, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"isearch", "minlen":2, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"isplit", "minlen":3, "flags":"BANG|RANGE|DFLALL|WHOLEFOLD|EXTRA", "parser":"parse_cmd_common"}, {"name":"iunmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"iunabbrev", "minlen":4, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"iunmenu", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"join", "minlen":1, "flags":"BANG|RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"jumps", "minlen":2, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"k", "minlen":1, "flags":"RANGE|WORD1|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"keepalt", "minlen":5, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"keepmarks", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"keepjumps", "minlen":5, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"keeppatterns", "minlen":5, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"lNext", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"lNfile", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"list", "minlen":1, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"laddexpr", "minlen":3, "flags":"NEEDARG|WORD1|NOTRLCOM|TRLBAR", "parser":"parse_cmd_common"}, {"name":"laddbuffer", "minlen":5, "flags":"RANGE|NOTADR|WORD1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"laddfile", "minlen":5, "flags":"TRLBAR|FILE1", "parser":"parse_cmd_common"}, {"name":"last", "minlen":2, "flags":"EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"language", "minlen":3, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"later", "minlen":3, "flags":"TRLBAR|EXTRA|NOSPC|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lbuffer", "minlen":2, "flags":"BANG|RANGE|NOTADR|WORD1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lcd", "minlen":2, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lchdir", "minlen":3, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lclose", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lcscope", "minlen":3, "flags":"EXTRA|NOTRLCOM|XFILE", "parser":"parse_cmd_common"}, {"name":"left", "minlen":2, "flags":"TRLBAR|RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"leftabove", "minlen":5, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"let", "minlen":3, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_let"}, {"name":"const", "minlen":4, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_const"}, {"name":"lexpr", "minlen":3, "flags":"NEEDARG|WORD1|NOTRLCOM|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"lfile", "minlen":2, "flags":"TRLBAR|FILE1|BANG", "parser":"parse_cmd_common"}, {"name":"lfirst", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"lgetbuffer", "minlen":5, "flags":"RANGE|NOTADR|WORD1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lgetexpr", "minlen":5, "flags":"NEEDARG|WORD1|NOTRLCOM|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lgetfile", "minlen":2, "flags":"TRLBAR|FILE1", "parser":"parse_cmd_common"}, {"name":"lgrep", "minlen":3, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"lgrepadd", "minlen":6, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"lhelpgrep", "minlen":2, "flags":"EXTRA|NOTRLCOM|NEEDARG", "parser":"parse_cmd_common"}, {"name":"ll", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"llast", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"list", "minlen":3, "flags":"BANG|EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lmake", "minlen":4, "flags":"BANG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"lmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lmapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lnext", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"lnewer", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lnfile", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"lnoremap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"loadkeymap", "minlen":5, "flags":"CMDWIN", "parser":"parse_cmd_loadkeymap"}, {"name":"loadview", "minlen":2, "flags":"FILE1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lockmarks", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"lockvar", "minlen":5, "flags":"BANG|EXTRA|NEEDARG|SBOXOK|CMDWIN", "parser":"parse_cmd_lockvar"}, {"name":"lolder", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lopen", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"lprevious", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"lpfile", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"lrewind", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR|BANG", "parser":"parse_cmd_common"}, {"name":"ls", "minlen":2, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"ltag", "minlen":2, "flags":"NOTADR|TRLBAR|BANG|WORD1", "parser":"parse_cmd_common"}, {"name":"lunmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lua", "minlen":3, "flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_lua"}, {"name":"luado", "minlen":4, "flags":"RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"luafile", "minlen":4, "flags":"RANGE|FILE1|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"lvimgrep", "minlen":2, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"lvimgrepadd", "minlen":9, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"lwindow", "minlen":2, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"move", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"mark", "minlen":2, "flags":"RANGE|WORD1|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"make", "minlen":3, "flags":"BANG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"map", "minlen":3, "flags":"BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"mapclear", "minlen":4, "flags":"EXTRA|BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"marks", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"match", "minlen":3, "flags":"RANGE|NOTADR|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"menu", "minlen":2, "flags":"RANGE|NOTADR|ZEROR|BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"menutranslate", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"messages", "minlen":3, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"mkexrc", "minlen":2, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"mksession", "minlen":3, "flags":"BANG|FILE1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"mkspell", "minlen":4, "flags":"BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"mkvimrc", "minlen":3, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"mkview", "minlen":5, "flags":"BANG|FILE1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"mode", "minlen":3, "flags":"WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"mzscheme", "minlen":2, "flags":"RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN|SBOXOK", "parser":"parse_cmd_mzscheme"}, {"name":"mzfile", "minlen":3, "flags":"RANGE|FILE1|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nbclose", "minlen":3, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nbkey", "minlen":2, "flags":"EXTRA|NOTADR|NEEDARG", "parser":"parse_cmd_common"}, {"name":"nbstart", "minlen":3, "flags":"WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"next", "minlen":1, "flags":"RANGE|NOTADR|BANG|FILES|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"new", "minlen":3, "flags":"BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"nmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nmapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nmenu", "minlen":3, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nnoremap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nnoremenu", "minlen":7, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"noautocmd", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"noremap", "minlen":2, "flags":"BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nohlsearch", "minlen":3, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"noreabbrev", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"noremenu", "minlen":6, "flags":"RANGE|NOTADR|ZEROR|BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"normal", "minlen":4, "flags":"RANGE|BANG|EXTRA|NEEDARG|NOTRLCOM|USECTRLV|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"number", "minlen":2, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nunmap", "minlen":3, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"nunmenu", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"oldfiles", "minlen":2, "flags":"BANG|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"open", "minlen":1, "flags":"RANGE|BANG|EXTRA", "parser":"parse_cmd_common"}, {"name":"omap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"omapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"omenu", "minlen":3, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"only", "minlen":2, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"onoremap", "minlen":3, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"onoremenu", "minlen":7, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"options", "minlen":3, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"ounmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"ounmenu", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"ownsyntax", "minlen":2, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"pclose", "minlen":2, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"pedit", "minlen":3, "flags":"BANG|FILE1|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"perl", "minlen":2, "flags":"RANGE|EXTRA|DFLALL|NEEDARG|SBOXOK|CMDWIN", "parser":"parse_cmd_perl"}, {"name":"print", "minlen":1, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN|SBOXOK", "parser":"parse_cmd_common"}, {"name":"profdel", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"profile", "minlen":4, "flags":"BANG|EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"promptfind", "minlen":3, "flags":"EXTRA|NOTRLCOM|CMDWIN", "parser":"parse_cmd_common"}, {"name":"promptrepl", "minlen":7, "flags":"EXTRA|NOTRLCOM|CMDWIN", "parser":"parse_cmd_common"}, {"name":"perldo", "minlen":5, "flags":"RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"pop", "minlen":2, "flags":"RANGE|NOTADR|BANG|COUNT|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"popup", "minlen":4, "flags":"NEEDARG|EXTRA|BANG|TRLBAR|NOTRLCOM|CMDWIN", "parser":"parse_cmd_common"}, {"name":"ppop", "minlen":2, "flags":"RANGE|NOTADR|BANG|COUNT|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"preserve", "minlen":3, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"previous", "minlen":4, "flags":"EXTRA|RANGE|NOTADR|COUNT|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"psearch", "minlen":2, "flags":"BANG|RANGE|WHOLEFOLD|DFLALL|EXTRA", "parser":"parse_cmd_common"}, {"name":"ptag", "minlen":2, "flags":"RANGE|NOTADR|BANG|WORD1|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"ptNext", "minlen":3, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"ptfirst", "minlen":3, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"ptjump", "minlen":3, "flags":"BANG|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"ptlast", "minlen":3, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"ptnext", "minlen":3, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"ptprevious", "minlen":3, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"ptrewind", "minlen":3, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"ptselect", "minlen":3, "flags":"BANG|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"put", "minlen":2, "flags":"RANGE|WHOLEFOLD|BANG|REGSTR|TRLBAR|ZEROR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"pwd", "minlen":2, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"py3", "minlen":3, "flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_python3"}, {"name":"python3", "minlen":7, "flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_python3"}, {"name":"py3file", "minlen":4, "flags":"RANGE|FILE1|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"python", "minlen":2, "flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_python"}, {"name":"pyfile", "minlen":3, "flags":"RANGE|FILE1|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"pydo", "minlen":3, "flags":"RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"py3do", "minlen":4, "flags":"RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"quit", "minlen":1, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"quitall", "minlen":5, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"qall", "minlen":2, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"read", "minlen":1, "flags":"BANG|RANGE|WHOLEFOLD|FILE1|ARGOPT|TRLBAR|ZEROR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"recover", "minlen":3, "flags":"BANG|FILE1|TRLBAR", "parser":"parse_cmd_common"}, {"name":"redo", "minlen":3, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"redir", "minlen":4, "flags":"BANG|FILES|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"redraw", "minlen":4, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"redrawstatus", "minlen":7, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"registers", "minlen":3, "flags":"EXTRA|NOTRLCOM|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"resize", "minlen":3, "flags":"RANGE|NOTADR|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"retab", "minlen":3, "flags":"TRLBAR|RANGE|WHOLEFOLD|DFLALL|BANG|WORD1|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"return", "minlen":4, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_return"}, {"name":"rewind", "minlen":3, "flags":"EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"right", "minlen":2, "flags":"TRLBAR|RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"rightbelow", "minlen":6, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"ruby", "minlen":3, "flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_ruby"}, {"name":"rubydo", "minlen":5, "flags":"RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"rubyfile", "minlen":5, "flags":"RANGE|FILE1|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"rundo", "minlen":4, "flags":"NEEDARG|FILE1", "parser":"parse_cmd_common"}, {"name":"runtime", "minlen":2, "flags":"BANG|NEEDARG|FILES|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"rviminfo", "minlen":2, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"substitute", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"sNext", "minlen":2, "flags":"EXTRA|RANGE|NOTADR|COUNT|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sandbox", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"sargument", "minlen":2, "flags":"BANG|RANGE|NOTADR|COUNT|EXTRA|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sall", "minlen":3, "flags":"BANG|RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"saveas", "minlen":3, "flags":"BANG|DFLALL|FILE1|ARGOPT|CMDWIN|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sbuffer", "minlen":2, "flags":"BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sbNext", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sball", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sbfirst", "minlen":3, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"sblast", "minlen":3, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"sbmodified", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sbnext", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sbprevious", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sbrewind", "minlen":3, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"scriptnames", "minlen":3, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"scriptencoding", "minlen":7, "flags":"WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"scscope", "minlen":3, "flags":"EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"set", "minlen":2, "flags":"TRLBAR|EXTRA|CMDWIN|SBOXOK", "parser":"parse_cmd_common"}, {"name":"setfiletype", "minlen":4, "flags":"TRLBAR|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"setglobal", "minlen":4, "flags":"TRLBAR|EXTRA|CMDWIN|SBOXOK", "parser":"parse_cmd_common"}, {"name":"setlocal", "minlen":4, "flags":"TRLBAR|EXTRA|CMDWIN|SBOXOK", "parser":"parse_cmd_common"}, {"name":"sfind", "minlen":2, "flags":"BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sfirst", "minlen":4, "flags":"EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"shell", "minlen":2, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"simalt", "minlen":3, "flags":"NEEDARG|WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"sign", "minlen":3, "flags":"NEEDARG|RANGE|NOTADR|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"silent", "minlen":3, "flags":"NEEDARG|EXTRA|BANG|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"sleep", "minlen":2, "flags":"RANGE|NOTADR|COUNT|EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"slast", "minlen":3, "flags":"EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"smagic", "minlen":2, "flags":"RANGE|WHOLEFOLD|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"smap", "minlen":4, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"smapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"smenu", "minlen":3, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"snext", "minlen":2, "flags":"RANGE|NOTADR|BANG|FILES|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sniff", "minlen":3, "flags":"EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"snomagic", "minlen":3, "flags":"RANGE|WHOLEFOLD|EXTRA|CMDWIN", "parser":"parse_cmd_common"}, {"name":"snoremap", "minlen":4, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"snoremenu", "minlen":7, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"sort", "minlen":3, "flags":"RANGE|DFLALL|WHOLEFOLD|BANG|EXTRA|NOTRLCOM|MODIFY", "parser":"parse_cmd_common"}, {"name":"source", "minlen":2, "flags":"BANG|FILE1|TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"spelldump", "minlen":6, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"spellgood", "minlen":3, "flags":"BANG|RANGE|NOTADR|NEEDARG|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"spellinfo", "minlen":6, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"spellrepall", "minlen":6, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"spellundo", "minlen":6, "flags":"BANG|RANGE|NOTADR|NEEDARG|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"spellwrong", "minlen":6, "flags":"BANG|RANGE|NOTADR|NEEDARG|EXTRA|TRLBAR", "parser":"parse_cmd_common"}, {"name":"split", "minlen":2, "flags":"BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sprevious", "minlen":3, "flags":"EXTRA|RANGE|NOTADR|COUNT|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"srewind", "minlen":3, "flags":"EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"stop", "minlen":2, "flags":"TRLBAR|BANG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"stag", "minlen":3, "flags":"RANGE|NOTADR|BANG|WORD1|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"startinsert", "minlen":4, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"startgreplace", "minlen":6, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"startreplace", "minlen":6, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"stopinsert", "minlen":5, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"stjump", "minlen":3, "flags":"BANG|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"stselect", "minlen":3, "flags":"BANG|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"sunhide", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"sunmap", "minlen":4, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"sunmenu", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"suspend", "minlen":3, "flags":"TRLBAR|BANG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"sview", "minlen":2, "flags":"BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"swapname", "minlen":2, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"syntax", "minlen":2, "flags":"EXTRA|NOTRLCOM|CMDWIN", "parser":"parse_cmd_syntax"}, {"name":"syntime", "minlen":5, "flags":"NEEDARG|WORD1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"syncbind", "minlen":4, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"t", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"tNext", "minlen":2, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"tabNext", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabclose", "minlen":4, "flags":"RANGE|NOTADR|COUNT|BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tabdo", "minlen":4, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"tabedit", "minlen":4, "flags":"BANG|FILE1|RANGE|NOTADR|ZEROR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabfind", "minlen":4, "flags":"BANG|FILE1|RANGE|NOTADR|ZEROR|EDITCMD|ARGOPT|NEEDARG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabfirst", "minlen":6, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"tablast", "minlen":4, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabmove", "minlen":4, "flags":"RANGE|NOTADR|ZEROR|EXTRA|NOSPC|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabnew", "minlen":6, "flags":"BANG|FILE1|RANGE|NOTADR|ZEROR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabnext", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabonly", "minlen":4, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tabprevious", "minlen":4, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabrewind", "minlen":4, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"tabs", "minlen":4, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tab", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"tag", "minlen":2, "flags":"RANGE|NOTADR|BANG|WORD1|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"tags", "minlen":4, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tcl", "minlen":2, "flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_tcl"}, {"name":"tcldo", "minlen":4, "flags":"RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tclfile", "minlen":4, "flags":"RANGE|FILE1|NEEDARG|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tearoff", "minlen":2, "flags":"NEEDARG|EXTRA|TRLBAR|NOTRLCOM|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tfirst", "minlen":2, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"throw", "minlen":2, "flags":"EXTRA|NEEDARG|SBOXOK|CMDWIN", "parser":"parse_cmd_throw"}, {"name":"tjump", "minlen":2, "flags":"BANG|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"tlast", "minlen":2, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"tmenu", "minlen":2, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"tnext", "minlen":2, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"topleft", "minlen":2, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"tprevious", "minlen":2, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"trewind", "minlen":2, "flags":"RANGE|NOTADR|BANG|TRLBAR|ZEROR", "parser":"parse_cmd_common"}, {"name":"try", "minlen":3, "flags":"TRLBAR|SBOXOK|CMDWIN", "parser":"parse_cmd_try"}, {"name":"tselect", "minlen":2, "flags":"BANG|TRLBAR|WORD1", "parser":"parse_cmd_common"}, {"name":"tunmenu", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"undo", "minlen":1, "flags":"RANGE|NOTADR|COUNT|ZEROR|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"undojoin", "minlen":5, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"undolist", "minlen":5, "flags":"TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"unabbreviate", "minlen":3, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"unhide", "minlen":3, "flags":"RANGE|NOTADR|COUNT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"unlet", "minlen":3, "flags":"BANG|EXTRA|NEEDARG|SBOXOK|CMDWIN", "parser":"parse_cmd_unlet"}, {"name":"unlockvar", "minlen":4, "flags":"BANG|EXTRA|NEEDARG|SBOXOK|CMDWIN", "parser":"parse_cmd_unlockvar"}, {"name":"unmap", "minlen":3, "flags":"BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"unmenu", "minlen":4, "flags":"BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"unsilent", "minlen":3, "flags":"NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"update", "minlen":2, "flags":"RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR", "parser":"parse_cmd_common"}, {"name":"vglobal", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|DFLALL|CMDWIN", "parser":"parse_cmd_common"}, {"name":"version", "minlen":2, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"verbose", "minlen":4, "flags":"NEEDARG|RANGE|NOTADR|EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_common"}, {"name":"vertical", "minlen":4, "flags":"NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"vimgrep", "minlen":3, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"vimgrepadd", "minlen":8, "flags":"RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE", "parser":"parse_cmd_common"}, {"name":"visual", "minlen":2, "flags":"BANG|FILE1|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"viusage", "minlen":3, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"view", "minlen":3, "flags":"BANG|FILE1|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"vmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"vmapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"vmenu", "minlen":3, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"vnew", "minlen":3, "flags":"BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"vnoremap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"vnoremenu", "minlen":7, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"vsplit", "minlen":2, "flags":"BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"vunmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"vunmenu", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"windo", "minlen":5, "flags":"BANG|NEEDARG|EXTRA|NOTRLCOM", "parser":"parse_cmd_common"}, {"name":"write", "minlen":1, "flags":"RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"wNext", "minlen":2, "flags":"RANGE|WHOLEFOLD|NOTADR|BANG|FILE1|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"wall", "minlen":2, "flags":"BANG|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"while", "minlen":2, "flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "parser":"parse_cmd_while"}, {"name":"winsize", "minlen":2, "flags":"EXTRA|NEEDARG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"wincmd", "minlen":4, "flags":"NEEDARG|WORD1|RANGE|NOTADR", "parser":"parse_wincmd"}, {"name":"winpos", "minlen":4, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"wnext", "minlen":2, "flags":"RANGE|NOTADR|BANG|FILE1|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"wprevious", "minlen":2, "flags":"RANGE|NOTADR|BANG|FILE1|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"wq", "minlen":2, "flags":"RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR", "parser":"parse_cmd_common"}, {"name":"wqall", "minlen":3, "flags":"BANG|FILE1|ARGOPT|DFLALL|TRLBAR", "parser":"parse_cmd_common"}, {"name":"wsverb", "minlen":2, "flags":"EXTRA|NOTADR|NEEDARG", "parser":"parse_cmd_common"}, {"name":"wundo", "minlen":2, "flags":"BANG|NEEDARG|FILE1", "parser":"parse_cmd_common"}, {"name":"wviminfo", "minlen":2, "flags":"BANG|FILE1|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xit", "minlen":1, "flags":"RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xall", "minlen":2, "flags":"BANG|TRLBAR", "parser":"parse_cmd_common"}, {"name":"xmapclear", "minlen":5, "flags":"EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xmenu", "minlen":3, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xnoremap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xnoremenu", "minlen":7, "flags":"RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xunmap", "minlen":2, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"xunmenu", "minlen":5, "flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "parser":"parse_cmd_common"}, {"name":"yank", "minlen":1, "flags":"RANGE|WHOLEFOLD|REGSTR|COUNT|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"z", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|EXFLAGS|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"!", "minlen":1, "flags":"RANGE|WHOLEFOLD|BANG|FILES|CMDWIN", "parser":"parse_cmd_common"}, {"name":"#", "minlen":1, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"&", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"*", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"<", "minlen":1, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"=", "minlen":1, "flags":"RANGE|TRLBAR|DFLALL|EXFLAGS|CMDWIN", "parser":"parse_cmd_common"}, {"name":">", "minlen":1, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"name":"@", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"Next", "minlen":1, "flags":"EXTRA|RANGE|NOTADR|COUNT|BANG|EDITCMD|ARGOPT|TRLBAR", "parser":"parse_cmd_common"}, {"name":"Print", "minlen":1, "flags":"RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN", "parser":"parse_cmd_common"}, {"name":"X", "minlen":1, "flags":"TRLBAR", "parser":"parse_cmd_common"}, {"name":"~", "minlen":1, "flags":"RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY", "parser":"parse_cmd_common"}, {"flags":"TRLBAR", "minlen":3, "name":"cbottom", "parser":"parse_cmd_common"}, {"flags":"BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL", "minlen":3, "name":"cdo", "parser":"parse_cmd_common"}, {"flags":"BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL", "minlen":3, "name":"cfdo", "parser":"parse_cmd_common"}, {"flags":"TRLBAR", "minlen":3, "name":"chistory", "parser":"parse_cmd_common"}, {"flags":"TRLBAR|CMDWIN", "minlen":3, "name":"clearjumps", "parser":"parse_cmd_common"}, {"flags":"BANG|NEEDARG|EXTRA|NOTRLCOM", "minlen":4, "name":"filter", "parser":"parse_cmd_common"}, {"flags":"RANGE|NOTADR|COUNT|TRLBAR", "minlen":5, "name":"helpclose", "parser":"parse_cmd_common"}, {"flags":"TRLBAR", "minlen":3, "name":"lbottom", "parser":"parse_cmd_common"}, {"flags":"BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL", "minlen":2, "name":"ldo", "parser":"parse_cmd_common"}, {"flags":"BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL", "minlen":3, "name":"lfdo", "parser":"parse_cmd_common"}, {"flags":"TRLBAR", "minlen":3, "name":"lhistory", "parser":"parse_cmd_common"}, {"flags":"BANG|EXTRA|TRLBAR|CMDWIN", "minlen":3, "name":"llist", "parser":"parse_cmd_common"}, {"flags":"NEEDARG|EXTRA|NOTRLCOM", "minlen":3, "name":"noswapfile", "parser":"parse_cmd_common"}, {"flags":"BANG|FILE1|NEEDARG|TRLBAR|SBOXOK|CMDWIN", "minlen":2, "name":"packadd", "parser":"parse_cmd_common"}, {"flags":"BANG|TRLBAR|SBOXOK|CMDWIN", "minlen":5, "name":"packloadall", "parser":"parse_cmd_common"}, {"flags":"TRLBAR|CMDWIN|SBOXOK", "minlen":3, "name":"smile", "parser":"parse_cmd_common"}, {"flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "minlen":3, "name":"pyx", "parser":"parse_cmd_common"}, {"flags":"RANGE|DFLALL|EXTRA|NEEDARG|CMDWIN", "minlen":4, "name":"pyxdo", "parser":"parse_cmd_common"}, {"flags":"RANGE|EXTRA|NEEDARG|CMDWIN", "minlen":7, "name":"pythonx", "parser":"parse_cmd_common"}, {"flags":"RANGE|FILE1|NEEDARG|CMDWIN", "minlen":4, "name":"pyxfile", "parser":"parse_cmd_common"}, {"flags":"RANGE|BANG|FILES|CMDWIN", "minlen":3, "name":"terminal", "parser":"parse_cmd_common"}, {"flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "minlen":3, "name":"tmap", "parser":"parse_cmd_common"}, {"flags":"EXTRA|TRLBAR|CMDWIN", "minlen":5, "name":"tmapclear", "parser":"parse_cmd_common"}, {"flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "minlen":3, "name":"tnoremap", "parser":"parse_cmd_common"}, {"flags":"EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN", "minlen":5, "name":"tunmap", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":4, "name":"cabove", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":3, "name":"cafter", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":3, "name":"cbefore", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":4, "name":"cbelow", "parser":"parse_cmd_common"}, {"flags":"EXTRA|NOTRLCOM|SBOXOK|CMDWIN", "minlen":4, "name":"const", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":3, "name":"labove", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":3, "name":"lafter", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":3, "name":"lbefore", "parser":"parse_cmd_common"}, {"flags":"RANGE|COUNT|TRLBAR", "minlen":4, "name":"lbelow", "parser":"parse_cmd_common"}, {"flags":"TRLBAR|CMDWIN", "minlen":7, "name":"redrawtabline", "parser":"parse_cmd_common"}, {"flags":"WORD1|TRLBAR|CMDWIN", "minlen":7, "name":"scriptversion", "parser":"parse_cmd_common"}, {"flags":"BANG|FILE1|TRLBAR|CMDWIN", "minlen":2, "name":"tcd", "parser":"parse_cmd_common"}, {"flags":"BANG|FILE1|TRLBAR|CMDWIN", "minlen":3, "name":"tchdir", "parser":"parse_cmd_common"}, {"flags":"RANGE|ZEROR|EXTRA|TRLBAR|NOTRLCOM|CTRLV|CMDWIN", "minlen":3, "name":"tlmenu", "parser":"parse_cmd_common"}, {"flags":"RANGE|ZEROR|EXTRA|TRLBAR|NOTRLCOM|CTRLV|CMDWIN", "minlen":3, "name":"tlnoremenu", "parser":"parse_cmd_common"}, {"flags":"RANGE|ZEROR|EXTRA|TRLBAR|NOTRLCOM|CTRLV|CMDWIN", "minlen":3, "name":"tlunmenu", "parser":"parse_cmd_common"}, {"flags":"EXTRA|TRLBAR|CMDWIN", "minlen":2, "name":"xrestore", "parser":"parse_cmd_common"}, {"flags":"EXTRA|BANG|SBOXOK|CMDWIN", "minlen":3, "name":"def", "parser":"parse_cmd_common"}, {"flags":"EXTRA|NEEDARG|TRLBAR|CMDWIN", "minlen":4, "name":"disassemble", "parser":"parse_cmd_common"}, {"flags":"TRLBAR|CMDWIN", "minlen":4, "name":"enddef", "parser":"parse_cmd_common"}, {"flags":"EXTRA|NOTRLCOM", "minlen":3, "name":"export", "parser":"parse_cmd_common"}, {"flags":"EXTRA|NOTRLCOM", "minlen":3, "name":"import", "parser":"parse_cmd_common"}, {"flags":"BANG|RANGE|NEEDARG|EXTRA|TRLBAR", "minlen":7, "name":"spellrare", "parser":"parse_cmd_common"}, {"flags":"", "minlen":4, "name":"vim9script", "parser":"parse_cmd_common"}];
13162// To find new builtin_functions, run the below script.
13163// $ scripts/update_builtin_functions.sh /path/to/vim/src/evalfunc.c
13164VimLParser.prototype.builtin_functions = [{"name":"abs", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"acos", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"add", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"and", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"append", "min_argc":2, "max_argc":2, "argtype":"FEARG_LAST"}, {"name":"appendbufline", "min_argc":3, "max_argc":3, "argtype":"FEARG_LAST"}, {"name":"argc", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"argidx", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"arglistid", "min_argc":0, "max_argc":2, "argtype":"0"}, {"name":"argv", "min_argc":0, "max_argc":2, "argtype":"0"}, {"name":"asin", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"assert_beeps", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"assert_equal", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"assert_equalfile", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"assert_exception", "min_argc":1, "max_argc":2, "argtype":"0"}, {"name":"assert_fails", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"assert_false", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"assert_inrange", "min_argc":3, "max_argc":4, "argtype":"FEARG_3"}, {"name":"assert_match", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"assert_notequal", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"assert_notmatch", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"assert_report", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"assert_true", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"atan", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"atan2", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"balloon_gettext", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"balloon_show", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"balloon_split", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"browse", "min_argc":4, "max_argc":4, "argtype":"0"}, {"name":"browsedir", "min_argc":2, "max_argc":2, "argtype":"0"}, {"name":"bufadd", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"bufexists", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"buffer_exists", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"buffer_name", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"buffer_number", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"buflisted", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"bufload", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"bufloaded", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"bufname", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"bufnr", "min_argc":0, "max_argc":2, "argtype":"FEARG_1"}, {"name":"bufwinid", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"bufwinnr", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"byte2line", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"byteidx", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"byteidxcomp", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"call", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"ceil", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"ch_canread", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"ch_close", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"ch_close_in", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"ch_evalexpr", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"ch_evalraw", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"ch_getbufnr", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_getjob", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"ch_info", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"ch_log", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_logfile", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_open", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_read", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_readblob", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_readraw", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_sendexpr", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"ch_sendraw", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"ch_setoptions", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"ch_status", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"changenr", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"char2nr", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"chdir", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"cindent", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"clearmatches", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"col", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"complete", "min_argc":2, "max_argc":2, "argtype":"FEARG_2"}, {"name":"complete_add", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"complete_check", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"complete_info", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"confirm", "min_argc":1, "max_argc":4, "argtype":"FEARG_1"}, {"name":"copy", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"cos", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"cosh", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"count", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"cscope_connection", "min_argc":0, "max_argc":3, "argtype":"0"}, {"name":"cursor", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"debugbreak", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"deepcopy", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"delete", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"deletebufline", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"did_filetype", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"diff_filler", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"diff_hlID", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"echoraw", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"empty", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"environ", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"escape", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"eval", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"eventhandler", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"executable", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"execute", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"exepath", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"exists", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"exp", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"expand", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"expandcmd", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"extend", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"feedkeys", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"file_readable", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"filereadable", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"filewritable", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"filter", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"finddir", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"findfile", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"float2nr", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"floor", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"fmod", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"fnameescape", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"fnamemodify", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"foldclosed", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"foldclosedend", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"foldlevel", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"foldtext", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"foldtextresult", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"foreground", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"funcref", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"function", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"garbagecollect", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"get", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"getbufinfo", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"getbufline", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"getbufvar", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"getchangelist", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getchar", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"getcharmod", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getcharsearch", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getcmdline", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getcmdpos", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getcmdtype", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getcmdwintype", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getcompletion", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"getcurpos", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getcwd", "min_argc":0, "max_argc":2, "argtype":"FEARG_1"}, {"name":"getenv", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getfontname", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"getfperm", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getfsize", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getftime", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getftype", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getimstatus", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getjumplist", "min_argc":0, "max_argc":2, "argtype":"FEARG_1"}, {"name":"getline", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"getloclist", "min_argc":1, "max_argc":2, "argtype":"0"}, {"name":"getmatches", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"getmousepos", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getpid", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getpos", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getqflist", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"getreg", "min_argc":0, "max_argc":3, "argtype":"FEARG_1"}, {"name":"getregtype", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"gettabinfo", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"gettabvar", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"gettabwinvar", "min_argc":3, "max_argc":4, "argtype":"FEARG_1"}, {"name":"gettagstack", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getwininfo", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getwinpos", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"getwinposx", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getwinposy", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"getwinvar", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"glob", "min_argc":1, "max_argc":4, "argtype":"FEARG_1"}, {"name":"glob2regpat", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"globpath", "min_argc":2, "max_argc":5, "argtype":"FEARG_2"}, {"name":"has", "min_argc":1, "max_argc":1, "argtype":"0"}, {"name":"has_key", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"haslocaldir", "min_argc":0, "max_argc":2, "argtype":"FEARG_1"}, {"name":"hasmapto", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"highlightID", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"highlight_exists", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"histadd", "min_argc":2, "max_argc":2, "argtype":"FEARG_2"}, {"name":"histdel", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"histget", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"histnr", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"hlID", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"hlexists", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"hostname", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"iconv", "min_argc":3, "max_argc":3, "argtype":"FEARG_1"}, {"name":"indent", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"index", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"input", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"inputdialog", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"inputlist", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"inputrestore", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"inputsave", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"inputsecret", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"insert", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"interrupt", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"invert", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"isdirectory", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"isinf", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"islocked", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"isnan", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"items", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"job_getchannel", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"job_info", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"job_setoptions", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"job_start", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"job_status", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"job_stop", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"join", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"js_decode", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"js_encode", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"json_decode", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"json_encode", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"keys", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"last_buffer_nr", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"len", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"libcall", "min_argc":3, "max_argc":3, "argtype":"FEARG_3"}, {"name":"libcallnr", "min_argc":3, "max_argc":3, "argtype":"FEARG_3"}, {"name":"line", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"line2byte", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"lispindent", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"list2str", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"listener_add", "min_argc":1, "max_argc":2, "argtype":"FEARG_2"}, {"name":"listener_flush", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"listener_remove", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"localtime", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"log", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"log10", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"luaeval", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"map", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"maparg", "min_argc":1, "max_argc":4, "argtype":"FEARG_1"}, {"name":"mapcheck", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"match", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"matchadd", "min_argc":2, "max_argc":5, "argtype":"FEARG_1"}, {"name":"matchaddpos", "min_argc":2, "max_argc":5, "argtype":"FEARG_1"}, {"name":"matcharg", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"matchdelete", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"matchend", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"matchlist", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"matchstr", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"matchstrpos", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"max", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"min", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"mkdir", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"mode", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"mzeval", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"nextnonblank", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"nr2char", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"or", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"pathshorten", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"perleval", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"popup_atcursor", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_beval", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_clear", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"popup_close", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_create", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_dialog", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_filter_menu", "min_argc":2, "max_argc":2, "argtype":"0"}, {"name":"popup_filter_yesno", "min_argc":2, "max_argc":2, "argtype":"0"}, {"name":"popup_findinfo", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"popup_findpreview", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"popup_getoptions", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"popup_getpos", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"popup_hide", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"popup_locate", "min_argc":2, "max_argc":2, "argtype":"0"}, {"name":"popup_menu", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_move", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_notification", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_setoptions", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_settext", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"popup_show", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"pow", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prevnonblank", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"printf", "min_argc":1, "max_argc":19, "argtype":"FEARG_2"}, {"name":"prompt_setcallback", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prompt_setinterrupt", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prompt_setprompt", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prop_add", "min_argc":3, "max_argc":3, "argtype":"FEARG_1"}, {"name":"prop_clear", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"prop_find", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prop_list", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prop_remove", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"prop_type_add", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prop_type_change", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prop_type_delete", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prop_type_get", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"prop_type_list", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"pum_getpos", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"pumvisible", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"py3eval", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"pyeval", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"pyxeval", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"rand", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"range", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"readdir", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"readfile", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"reg_executing", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"reg_recording", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"reltime", "min_argc":0, "max_argc":2, "argtype":"FEARG_1"}, {"name":"reltimefloat", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"reltimestr", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"remote_expr", "min_argc":2, "max_argc":4, "argtype":"FEARG_1"}, {"name":"remote_foreground", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"remote_peek", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"remote_read", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"remote_send", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"remote_startserver", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"remove", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"rename", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"repeat", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"resolve", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"reverse", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"round", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"rubyeval", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"screenattr", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"screenchar", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"screenchars", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"screencol", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"screenpos", "min_argc":3, "max_argc":3, "argtype":"FEARG_1"}, {"name":"screenrow", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"screenstring", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"search", "min_argc":1, "max_argc":4, "argtype":"FEARG_1"}, {"name":"searchdecl", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"searchpair", "min_argc":3, "max_argc":7, "argtype":"0"}, {"name":"searchpairpos", "min_argc":3, "max_argc":7, "argtype":"0"}, {"name":"searchpos", "min_argc":1, "max_argc":4, "argtype":"FEARG_1"}, {"name":"server2client", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"serverlist", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"setbufline", "min_argc":3, "max_argc":3, "argtype":"FEARG_3"}, {"name":"setbufvar", "min_argc":3, "max_argc":3, "argtype":"FEARG_3"}, {"name":"setcharsearch", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"setcmdpos", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"setenv", "min_argc":2, "max_argc":2, "argtype":"FEARG_2"}, {"name":"setfperm", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"setline", "min_argc":2, "max_argc":2, "argtype":"FEARG_2"}, {"name":"setloclist", "min_argc":2, "max_argc":4, "argtype":"FEARG_2"}, {"name":"setmatches", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"setpos", "min_argc":2, "max_argc":2, "argtype":"FEARG_2"}, {"name":"setqflist", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"setreg", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"settabvar", "min_argc":3, "max_argc":3, "argtype":"FEARG_3"}, {"name":"settabwinvar", "min_argc":4, "max_argc":4, "argtype":"FEARG_4"}, {"name":"settagstack", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"setwinvar", "min_argc":3, "max_argc":3, "argtype":"FEARG_3"}, {"name":"sha256", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"shellescape", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"shiftwidth", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"sign_define", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"sign_getdefined", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"sign_getplaced", "min_argc":0, "max_argc":2, "argtype":"FEARG_1"}, {"name":"sign_jump", "min_argc":3, "max_argc":3, "argtype":"FEARG_1"}, {"name":"sign_place", "min_argc":4, "max_argc":5, "argtype":"FEARG_1"}, {"name":"sign_placelist", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"sign_undefine", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"sign_unplace", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"sign_unplacelist", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"simplify", "min_argc":1, "max_argc":1, "argtype":"0"}, {"name":"sin", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"sinh", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"sort", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"sound_clear", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"sound_playevent", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"sound_playfile", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"sound_stop", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"soundfold", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"spellbadword", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"spellsuggest", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"split", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"sqrt", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"srand", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"state", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"str2float", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"str2list", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"str2nr", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"strcharpart", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"strchars", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"strdisplaywidth", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"strftime", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"strgetchar", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"stridx", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"string", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"strlen", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"strpart", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"strptime", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"strridx", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"strtrans", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"strwidth", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"submatch", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"substitute", "min_argc":4, "max_argc":4, "argtype":"FEARG_1"}, {"name":"swapinfo", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"swapname", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"synID", "min_argc":3, "max_argc":3, "argtype":"0"}, {"name":"synIDattr", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"synIDtrans", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"synconcealed", "min_argc":2, "max_argc":2, "argtype":"0"}, {"name":"synstack", "min_argc":2, "max_argc":2, "argtype":"0"}, {"name":"system", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"systemlist", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"tabpagebuflist", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"tabpagenr", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"tabpagewinnr", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"tagfiles", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"taglist", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"tan", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"tanh", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"tempname", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"term_dumpdiff", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"term_dumpload", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_dumpwrite", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"term_getaltscreen", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_getansicolors", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_getattr", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_getcursor", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_getjob", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_getline", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_getscrolled", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_getsize", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_getstatus", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_gettitle", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"term_gettty", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_list", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"term_scrape", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_sendkeys", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_setansicolors", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_setapi", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_setkill", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_setrestore", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_setsize", "min_argc":3, "max_argc":3, "argtype":"FEARG_1"}, {"name":"term_start", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"term_wait", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"test_alloc_fail", "min_argc":3, "max_argc":3, "argtype":"FEARG_1"}, {"name":"test_autochdir", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_feedinput", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"test_garbagecollect_now", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_garbagecollect_soon", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_getvalue", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"test_ignore_error", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"test_null_blob", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_null_channel", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_null_dict", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_null_job", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_null_list", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_null_partial", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_null_string", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_option_not_set", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"test_override", "min_argc":2, "max_argc":2, "argtype":"FEARG_2"}, {"name":"test_refcount", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"test_scrollbar", "min_argc":3, "max_argc":3, "argtype":"FEARG_2"}, {"name":"test_setmouse", "min_argc":2, "max_argc":2, "argtype":"0"}, {"name":"test_settime", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"test_srand_seed", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"test_unknown", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"test_void", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"timer_info", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"timer_pause", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}, {"name":"timer_start", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"timer_stop", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"timer_stopall", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"tolower", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"toupper", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"tr", "min_argc":3, "max_argc":3, "argtype":"FEARG_1"}, {"name":"trim", "min_argc":1, "max_argc":2, "argtype":"FEARG_1"}, {"name":"trunc", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"type", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"undofile", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"undotree", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"uniq", "min_argc":1, "max_argc":3, "argtype":"FEARG_1"}, {"name":"values", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"virtcol", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"visualmode", "min_argc":0, "max_argc":1, "argtype":"0"}, {"name":"wildmenumode", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"win_execute", "min_argc":2, "max_argc":3, "argtype":"FEARG_2"}, {"name":"win_findbuf", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"win_getid", "min_argc":0, "max_argc":2, "argtype":"FEARG_1"}, {"name":"win_gettype", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"win_gotoid", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"win_id2tabwin", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"win_id2win", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"win_screenpos", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"win_splitmove", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"winbufnr", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"wincol", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"windowsversion", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"winheight", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"winlayout", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"winline", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"winnr", "min_argc":0, "max_argc":1, "argtype":"FEARG_1"}, {"name":"winrestcmd", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"winrestview", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"winsaveview", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"winwidth", "min_argc":1, "max_argc":1, "argtype":"FEARG_1"}, {"name":"wordcount", "min_argc":0, "max_argc":0, "argtype":"0"}, {"name":"writefile", "min_argc":2, "max_argc":3, "argtype":"FEARG_1"}, {"name":"xor", "min_argc":2, "max_argc":2, "argtype":"FEARG_1"}];
13165function ExprTokenizer() { this.__init__.apply(this, arguments); }
13166ExprTokenizer.prototype.__init__ = function(reader) {
13167 this.reader = reader;
13168 this.cache = {};
13169}
13170
13171ExprTokenizer.prototype.token = function(type, value, pos) {
13172 return {"type":type, "value":value, "pos":pos};
13173}
13174
13175ExprTokenizer.prototype.peek = function() {
13176 var pos = this.reader.tell();
13177 var r = this.get();
13178 this.reader.seek_set(pos);
13179 return r;
13180}
13181
13182ExprTokenizer.prototype.get = function() {
13183 // FIXME: remove dirty hack
13184 if (viml_has_key(this.cache, this.reader.tell())) {
13185 var x = this.cache[this.reader.tell()];
13186 this.reader.seek_set(x[0]);
13187 return x[1];
13188 }
13189 var pos = this.reader.tell();
13190 this.reader.skip_white();
13191 var r = this.get2();
13192 this.cache[pos] = [this.reader.tell(), r];
13193 return r;
13194}
13195
13196ExprTokenizer.prototype.get2 = function() {
13197 var r = this.reader;
13198 var pos = r.getpos();
13199 var c = r.peek();
13200 if (c == "<EOF>") {
13201 return this.token(TOKEN_EOF, c, pos);
13202 }
13203 else if (c == "<EOL>") {
13204 r.seek_cur(1);
13205 return this.token(TOKEN_EOL, c, pos);
13206 }
13207 else if (iswhite(c)) {
13208 var s = r.read_white();
13209 return this.token(TOKEN_SPACE, s, pos);
13210 }
13211 else if (c == "0" && (r.p(1) == "X" || r.p(1) == "x") && isxdigit(r.p(2))) {
13212 var s = r.getn(3);
13213 s += r.read_xdigit();
13214 return this.token(TOKEN_NUMBER, s, pos);
13215 }
13216 else if (c == "0" && (r.p(1) == "B" || r.p(1) == "b") && (r.p(2) == "0" || r.p(2) == "1")) {
13217 var s = r.getn(3);
13218 s += r.read_bdigit();
13219 return this.token(TOKEN_NUMBER, s, pos);
13220 }
13221 else if (c == "0" && (r.p(1) == "Z" || r.p(1) == "z") && r.p(2) != ".") {
13222 var s = r.getn(2);
13223 s += r.read_blob();
13224 return this.token(TOKEN_BLOB, s, pos);
13225 }
13226 else if (isdigit(c)) {
13227 var s = r.read_digit();
13228 if (r.p(0) == "." && isdigit(r.p(1))) {
13229 s += r.getn(1);
13230 s += r.read_digit();
13231 if ((r.p(0) == "E" || r.p(0) == "e") && (isdigit(r.p(1)) || (r.p(1) == "-" || r.p(1) == "+") && isdigit(r.p(2)))) {
13232 s += r.getn(2);
13233 s += r.read_digit();
13234 }
13235 }
13236 return this.token(TOKEN_NUMBER, s, pos);
13237 }
13238 else if (c == "i" && r.p(1) == "s" && !isidc(r.p(2))) {
13239 if (r.p(2) == "?") {
13240 r.seek_cur(3);
13241 return this.token(TOKEN_ISCI, "is?", pos);
13242 }
13243 else if (r.p(2) == "#") {
13244 r.seek_cur(3);
13245 return this.token(TOKEN_ISCS, "is#", pos);
13246 }
13247 else {
13248 r.seek_cur(2);
13249 return this.token(TOKEN_IS, "is", pos);
13250 }
13251 }
13252 else if (c == "i" && r.p(1) == "s" && r.p(2) == "n" && r.p(3) == "o" && r.p(4) == "t" && !isidc(r.p(5))) {
13253 if (r.p(5) == "?") {
13254 r.seek_cur(6);
13255 return this.token(TOKEN_ISNOTCI, "isnot?", pos);
13256 }
13257 else if (r.p(5) == "#") {
13258 r.seek_cur(6);
13259 return this.token(TOKEN_ISNOTCS, "isnot#", pos);
13260 }
13261 else {
13262 r.seek_cur(5);
13263 return this.token(TOKEN_ISNOT, "isnot", pos);
13264 }
13265 }
13266 else if (isnamec1(c)) {
13267 var s = r.read_name();
13268 return this.token(TOKEN_IDENTIFIER, s, pos);
13269 }
13270 else if (c == "|" && r.p(1) == "|") {
13271 r.seek_cur(2);
13272 return this.token(TOKEN_OROR, "||", pos);
13273 }
13274 else if (c == "&" && r.p(1) == "&") {
13275 r.seek_cur(2);
13276 return this.token(TOKEN_ANDAND, "&&", pos);
13277 }
13278 else if (c == "=" && r.p(1) == "=") {
13279 if (r.p(2) == "?") {
13280 r.seek_cur(3);
13281 return this.token(TOKEN_EQEQCI, "==?", pos);
13282 }
13283 else if (r.p(2) == "#") {
13284 r.seek_cur(3);
13285 return this.token(TOKEN_EQEQCS, "==#", pos);
13286 }
13287 else {
13288 r.seek_cur(2);
13289 return this.token(TOKEN_EQEQ, "==", pos);
13290 }
13291 }
13292 else if (c == "!" && r.p(1) == "=") {
13293 if (r.p(2) == "?") {
13294 r.seek_cur(3);
13295 return this.token(TOKEN_NEQCI, "!=?", pos);
13296 }
13297 else if (r.p(2) == "#") {
13298 r.seek_cur(3);
13299 return this.token(TOKEN_NEQCS, "!=#", pos);
13300 }
13301 else {
13302 r.seek_cur(2);
13303 return this.token(TOKEN_NEQ, "!=", pos);
13304 }
13305 }
13306 else if (c == ">" && r.p(1) == "=") {
13307 if (r.p(2) == "?") {
13308 r.seek_cur(3);
13309 return this.token(TOKEN_GTEQCI, ">=?", pos);
13310 }
13311 else if (r.p(2) == "#") {
13312 r.seek_cur(3);
13313 return this.token(TOKEN_GTEQCS, ">=#", pos);
13314 }
13315 else {
13316 r.seek_cur(2);
13317 return this.token(TOKEN_GTEQ, ">=", pos);
13318 }
13319 }
13320 else if (c == "<" && r.p(1) == "=") {
13321 if (r.p(2) == "?") {
13322 r.seek_cur(3);
13323 return this.token(TOKEN_LTEQCI, "<=?", pos);
13324 }
13325 else if (r.p(2) == "#") {
13326 r.seek_cur(3);
13327 return this.token(TOKEN_LTEQCS, "<=#", pos);
13328 }
13329 else {
13330 r.seek_cur(2);
13331 return this.token(TOKEN_LTEQ, "<=", pos);
13332 }
13333 }
13334 else if (c == "=" && r.p(1) == "~") {
13335 if (r.p(2) == "?") {
13336 r.seek_cur(3);
13337 return this.token(TOKEN_MATCHCI, "=~?", pos);
13338 }
13339 else if (r.p(2) == "#") {
13340 r.seek_cur(3);
13341 return this.token(TOKEN_MATCHCS, "=~#", pos);
13342 }
13343 else {
13344 r.seek_cur(2);
13345 return this.token(TOKEN_MATCH, "=~", pos);
13346 }
13347 }
13348 else if (c == "!" && r.p(1) == "~") {
13349 if (r.p(2) == "?") {
13350 r.seek_cur(3);
13351 return this.token(TOKEN_NOMATCHCI, "!~?", pos);
13352 }
13353 else if (r.p(2) == "#") {
13354 r.seek_cur(3);
13355 return this.token(TOKEN_NOMATCHCS, "!~#", pos);
13356 }
13357 else {
13358 r.seek_cur(2);
13359 return this.token(TOKEN_NOMATCH, "!~", pos);
13360 }
13361 }
13362 else if (c == ">") {
13363 if (r.p(1) == "?") {
13364 r.seek_cur(2);
13365 return this.token(TOKEN_GTCI, ">?", pos);
13366 }
13367 else if (r.p(1) == "#") {
13368 r.seek_cur(2);
13369 return this.token(TOKEN_GTCS, ">#", pos);
13370 }
13371 else {
13372 r.seek_cur(1);
13373 return this.token(TOKEN_GT, ">", pos);
13374 }
13375 }
13376 else if (c == "<") {
13377 if (r.p(1) == "?") {
13378 r.seek_cur(2);
13379 return this.token(TOKEN_LTCI, "<?", pos);
13380 }
13381 else if (r.p(1) == "#") {
13382 r.seek_cur(2);
13383 return this.token(TOKEN_LTCS, "<#", pos);
13384 }
13385 else {
13386 r.seek_cur(1);
13387 return this.token(TOKEN_LT, "<", pos);
13388 }
13389 }
13390 else if (c == "+") {
13391 r.seek_cur(1);
13392 return this.token(TOKEN_PLUS, "+", pos);
13393 }
13394 else if (c == "-") {
13395 if (r.p(1) == ">") {
13396 r.seek_cur(2);
13397 return this.token(TOKEN_ARROW, "->", pos);
13398 }
13399 else {
13400 r.seek_cur(1);
13401 return this.token(TOKEN_MINUS, "-", pos);
13402 }
13403 }
13404 else if (c == ".") {
13405 if (r.p(1) == "." && r.p(2) == ".") {
13406 r.seek_cur(3);
13407 return this.token(TOKEN_DOTDOTDOT, "...", pos);
13408 }
13409 else if (r.p(1) == ".") {
13410 r.seek_cur(2);
13411 return this.token(TOKEN_DOTDOT, "..", pos);
13412 // TODO check scriptversion?
13413 }
13414 else {
13415 r.seek_cur(1);
13416 return this.token(TOKEN_DOT, ".", pos);
13417 // TODO check scriptversion?
13418 }
13419 }
13420 else if (c == "*") {
13421 r.seek_cur(1);
13422 return this.token(TOKEN_STAR, "*", pos);
13423 }
13424 else if (c == "/") {
13425 r.seek_cur(1);
13426 return this.token(TOKEN_SLASH, "/", pos);
13427 }
13428 else if (c == "%") {
13429 r.seek_cur(1);
13430 return this.token(TOKEN_PERCENT, "%", pos);
13431 }
13432 else if (c == "!") {
13433 r.seek_cur(1);
13434 return this.token(TOKEN_NOT, "!", pos);
13435 }
13436 else if (c == "?") {
13437 r.seek_cur(1);
13438 return this.token(TOKEN_QUESTION, "?", pos);
13439 }
13440 else if (c == ":") {
13441 r.seek_cur(1);
13442 return this.token(TOKEN_COLON, ":", pos);
13443 }
13444 else if (c == "#") {
13445 if (r.p(1) == "{") {
13446 r.seek_cur(2);
13447 return this.token(TOKEN_LITCOPEN, "#{", pos);
13448 }
13449 else {
13450 r.seek_cur(1);
13451 return this.token(TOKEN_SHARP, "#", pos);
13452 }
13453 }
13454 else if (c == "(") {
13455 r.seek_cur(1);
13456 return this.token(TOKEN_POPEN, "(", pos);
13457 }
13458 else if (c == ")") {
13459 r.seek_cur(1);
13460 return this.token(TOKEN_PCLOSE, ")", pos);
13461 }
13462 else if (c == "[") {
13463 r.seek_cur(1);
13464 return this.token(TOKEN_SQOPEN, "[", pos);
13465 }
13466 else if (c == "]") {
13467 r.seek_cur(1);
13468 return this.token(TOKEN_SQCLOSE, "]", pos);
13469 }
13470 else if (c == "{") {
13471 r.seek_cur(1);
13472 return this.token(TOKEN_COPEN, "{", pos);
13473 }
13474 else if (c == "}") {
13475 r.seek_cur(1);
13476 return this.token(TOKEN_CCLOSE, "}", pos);
13477 }
13478 else if (c == ",") {
13479 r.seek_cur(1);
13480 return this.token(TOKEN_COMMA, ",", pos);
13481 }
13482 else if (c == "'") {
13483 r.seek_cur(1);
13484 return this.token(TOKEN_SQUOTE, "'", pos);
13485 }
13486 else if (c == "\"") {
13487 r.seek_cur(1);
13488 return this.token(TOKEN_DQUOTE, "\"", pos);
13489 }
13490 else if (c == "$") {
13491 var s = r.getn(1);
13492 s += r.read_word();
13493 return this.token(TOKEN_ENV, s, pos);
13494 }
13495 else if (c == "@") {
13496 // @<EOL> is treated as @"
13497 return this.token(TOKEN_REG, r.getn(2), pos);
13498 }
13499 else if (c == "&") {
13500 var s = "";
13501 if ((r.p(1) == "g" || r.p(1) == "l") && r.p(2) == ":") {
13502 var s = r.getn(3) + r.read_word();
13503 }
13504 else {
13505 var s = r.getn(1) + r.read_word();
13506 }
13507 return this.token(TOKEN_OPTION, s, pos);
13508 }
13509 else if (c == "=") {
13510 r.seek_cur(1);
13511 return this.token(TOKEN_EQ, "=", pos);
13512 }
13513 else if (c == "|") {
13514 r.seek_cur(1);
13515 return this.token(TOKEN_OR, "|", pos);
13516 }
13517 else if (c == ";") {
13518 r.seek_cur(1);
13519 return this.token(TOKEN_SEMICOLON, ";", pos);
13520 }
13521 else if (c == "`") {
13522 r.seek_cur(1);
13523 return this.token(TOKEN_BACKTICK, "`", pos);
13524 }
13525 else {
13526 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
13527 }
13528}
13529
13530ExprTokenizer.prototype.get_sstring = function() {
13531 this.reader.skip_white();
13532 var c = this.reader.p(0);
13533 if (c != "'") {
13534 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
13535 }
13536 this.reader.seek_cur(1);
13537 var s = "";
13538 while (TRUE) {
13539 var c = this.reader.p(0);
13540 if (c == "<EOF>" || c == "<EOL>") {
13541 throw Err("unexpected EOL", this.reader.getpos());
13542 }
13543 else if (c == "'") {
13544 this.reader.seek_cur(1);
13545 if (this.reader.p(0) == "'") {
13546 this.reader.seek_cur(1);
13547 s += "''";
13548 }
13549 else {
13550 break;
13551 }
13552 }
13553 else {
13554 this.reader.seek_cur(1);
13555 s += c;
13556 }
13557 }
13558 return s;
13559}
13560
13561ExprTokenizer.prototype.get_dstring = function() {
13562 this.reader.skip_white();
13563 var c = this.reader.p(0);
13564 if (c != "\"") {
13565 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
13566 }
13567 this.reader.seek_cur(1);
13568 var s = "";
13569 while (TRUE) {
13570 var c = this.reader.p(0);
13571 if (c == "<EOF>" || c == "<EOL>") {
13572 throw Err("unexpectd EOL", this.reader.getpos());
13573 }
13574 else if (c == "\"") {
13575 this.reader.seek_cur(1);
13576 break;
13577 }
13578 else if (c == "\\") {
13579 this.reader.seek_cur(1);
13580 s += c;
13581 var c = this.reader.p(0);
13582 if (c == "<EOF>" || c == "<EOL>") {
13583 throw Err("ExprTokenizer: unexpected EOL", this.reader.getpos());
13584 }
13585 this.reader.seek_cur(1);
13586 s += c;
13587 }
13588 else {
13589 this.reader.seek_cur(1);
13590 s += c;
13591 }
13592 }
13593 return s;
13594}
13595
13596ExprTokenizer.prototype.parse_dict_literal_key = function() {
13597 this.reader.skip_white();
13598 var c = this.reader.peek();
13599 if (!isalnum(c) && c != "_" && c != "-") {
13600 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
13601 }
13602 var node = Node(NODE_STRING);
13603 var s = c;
13604 this.reader.seek_cur(1);
13605 node.pos = this.reader.getpos();
13606 while (TRUE) {
13607 var c = this.reader.p(0);
13608 if (c == "<EOF>" || c == "<EOL>") {
13609 throw Err("unexpectd EOL", this.reader.getpos());
13610 }
13611 if (!isalnum(c) && c != "_" && c != "-") {
13612 break;
13613 }
13614 this.reader.seek_cur(1);
13615 s += c;
13616 }
13617 node.value = "'" + s + "'";
13618 return node;
13619}
13620
13621function ExprParser() { this.__init__.apply(this, arguments); }
13622ExprParser.prototype.__init__ = function(reader) {
13623 this.reader = reader;
13624 this.tokenizer = new ExprTokenizer(reader);
13625}
13626
13627ExprParser.prototype.parse = function() {
13628 return this.parse_expr1();
13629}
13630
13631// expr1: expr2 ? expr1 : expr1
13632ExprParser.prototype.parse_expr1 = function() {
13633 var left = this.parse_expr2();
13634 var pos = this.reader.tell();
13635 var token = this.tokenizer.get();
13636 if (token.type == TOKEN_QUESTION) {
13637 var node = Node(NODE_TERNARY);
13638 node.pos = token.pos;
13639 node.cond = left;
13640 node.left = this.parse_expr1();
13641 var token = this.tokenizer.get();
13642 if (token.type != TOKEN_COLON) {
13643 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
13644 }
13645 node.right = this.parse_expr1();
13646 var left = node;
13647 }
13648 else {
13649 this.reader.seek_set(pos);
13650 }
13651 return left;
13652}
13653
13654// expr2: expr3 || expr3 ..
13655ExprParser.prototype.parse_expr2 = function() {
13656 var left = this.parse_expr3();
13657 while (TRUE) {
13658 var pos = this.reader.tell();
13659 var token = this.tokenizer.get();
13660 if (token.type == TOKEN_OROR) {
13661 var node = Node(NODE_OR);
13662 node.pos = token.pos;
13663 node.left = left;
13664 node.right = this.parse_expr3();
13665 var left = node;
13666 }
13667 else {
13668 this.reader.seek_set(pos);
13669 break;
13670 }
13671 }
13672 return left;
13673}
13674
13675// expr3: expr4 && expr4
13676ExprParser.prototype.parse_expr3 = function() {
13677 var left = this.parse_expr4();
13678 while (TRUE) {
13679 var pos = this.reader.tell();
13680 var token = this.tokenizer.get();
13681 if (token.type == TOKEN_ANDAND) {
13682 var node = Node(NODE_AND);
13683 node.pos = token.pos;
13684 node.left = left;
13685 node.right = this.parse_expr4();
13686 var left = node;
13687 }
13688 else {
13689 this.reader.seek_set(pos);
13690 break;
13691 }
13692 }
13693 return left;
13694}
13695
13696// expr4: expr5 == expr5
13697// expr5 != expr5
13698// expr5 > expr5
13699// expr5 >= expr5
13700// expr5 < expr5
13701// expr5 <= expr5
13702// expr5 =~ expr5
13703// expr5 !~ expr5
13704//
13705// expr5 ==? expr5
13706// expr5 ==# expr5
13707// etc.
13708//
13709// expr5 is expr5
13710// expr5 isnot expr5
13711ExprParser.prototype.parse_expr4 = function() {
13712 var left = this.parse_expr5();
13713 var pos = this.reader.tell();
13714 var token = this.tokenizer.get();
13715 if (token.type == TOKEN_EQEQ) {
13716 var node = Node(NODE_EQUAL);
13717 node.pos = token.pos;
13718 node.left = left;
13719 node.right = this.parse_expr5();
13720 var left = node;
13721 }
13722 else if (token.type == TOKEN_EQEQCI) {
13723 var node = Node(NODE_EQUALCI);
13724 node.pos = token.pos;
13725 node.left = left;
13726 node.right = this.parse_expr5();
13727 var left = node;
13728 }
13729 else if (token.type == TOKEN_EQEQCS) {
13730 var node = Node(NODE_EQUALCS);
13731 node.pos = token.pos;
13732 node.left = left;
13733 node.right = this.parse_expr5();
13734 var left = node;
13735 }
13736 else if (token.type == TOKEN_NEQ) {
13737 var node = Node(NODE_NEQUAL);
13738 node.pos = token.pos;
13739 node.left = left;
13740 node.right = this.parse_expr5();
13741 var left = node;
13742 }
13743 else if (token.type == TOKEN_NEQCI) {
13744 var node = Node(NODE_NEQUALCI);
13745 node.pos = token.pos;
13746 node.left = left;
13747 node.right = this.parse_expr5();
13748 var left = node;
13749 }
13750 else if (token.type == TOKEN_NEQCS) {
13751 var node = Node(NODE_NEQUALCS);
13752 node.pos = token.pos;
13753 node.left = left;
13754 node.right = this.parse_expr5();
13755 var left = node;
13756 }
13757 else if (token.type == TOKEN_GT) {
13758 var node = Node(NODE_GREATER);
13759 node.pos = token.pos;
13760 node.left = left;
13761 node.right = this.parse_expr5();
13762 var left = node;
13763 }
13764 else if (token.type == TOKEN_GTCI) {
13765 var node = Node(NODE_GREATERCI);
13766 node.pos = token.pos;
13767 node.left = left;
13768 node.right = this.parse_expr5();
13769 var left = node;
13770 }
13771 else if (token.type == TOKEN_GTCS) {
13772 var node = Node(NODE_GREATERCS);
13773 node.pos = token.pos;
13774 node.left = left;
13775 node.right = this.parse_expr5();
13776 var left = node;
13777 }
13778 else if (token.type == TOKEN_GTEQ) {
13779 var node = Node(NODE_GEQUAL);
13780 node.pos = token.pos;
13781 node.left = left;
13782 node.right = this.parse_expr5();
13783 var left = node;
13784 }
13785 else if (token.type == TOKEN_GTEQCI) {
13786 var node = Node(NODE_GEQUALCI);
13787 node.pos = token.pos;
13788 node.left = left;
13789 node.right = this.parse_expr5();
13790 var left = node;
13791 }
13792 else if (token.type == TOKEN_GTEQCS) {
13793 var node = Node(NODE_GEQUALCS);
13794 node.pos = token.pos;
13795 node.left = left;
13796 node.right = this.parse_expr5();
13797 var left = node;
13798 }
13799 else if (token.type == TOKEN_LT) {
13800 var node = Node(NODE_SMALLER);
13801 node.pos = token.pos;
13802 node.left = left;
13803 node.right = this.parse_expr5();
13804 var left = node;
13805 }
13806 else if (token.type == TOKEN_LTCI) {
13807 var node = Node(NODE_SMALLERCI);
13808 node.pos = token.pos;
13809 node.left = left;
13810 node.right = this.parse_expr5();
13811 var left = node;
13812 }
13813 else if (token.type == TOKEN_LTCS) {
13814 var node = Node(NODE_SMALLERCS);
13815 node.pos = token.pos;
13816 node.left = left;
13817 node.right = this.parse_expr5();
13818 var left = node;
13819 }
13820 else if (token.type == TOKEN_LTEQ) {
13821 var node = Node(NODE_SEQUAL);
13822 node.pos = token.pos;
13823 node.left = left;
13824 node.right = this.parse_expr5();
13825 var left = node;
13826 }
13827 else if (token.type == TOKEN_LTEQCI) {
13828 var node = Node(NODE_SEQUALCI);
13829 node.pos = token.pos;
13830 node.left = left;
13831 node.right = this.parse_expr5();
13832 var left = node;
13833 }
13834 else if (token.type == TOKEN_LTEQCS) {
13835 var node = Node(NODE_SEQUALCS);
13836 node.pos = token.pos;
13837 node.left = left;
13838 node.right = this.parse_expr5();
13839 var left = node;
13840 }
13841 else if (token.type == TOKEN_MATCH) {
13842 var node = Node(NODE_MATCH);
13843 node.pos = token.pos;
13844 node.left = left;
13845 node.right = this.parse_expr5();
13846 var left = node;
13847 }
13848 else if (token.type == TOKEN_MATCHCI) {
13849 var node = Node(NODE_MATCHCI);
13850 node.pos = token.pos;
13851 node.left = left;
13852 node.right = this.parse_expr5();
13853 var left = node;
13854 }
13855 else if (token.type == TOKEN_MATCHCS) {
13856 var node = Node(NODE_MATCHCS);
13857 node.pos = token.pos;
13858 node.left = left;
13859 node.right = this.parse_expr5();
13860 var left = node;
13861 }
13862 else if (token.type == TOKEN_NOMATCH) {
13863 var node = Node(NODE_NOMATCH);
13864 node.pos = token.pos;
13865 node.left = left;
13866 node.right = this.parse_expr5();
13867 var left = node;
13868 }
13869 else if (token.type == TOKEN_NOMATCHCI) {
13870 var node = Node(NODE_NOMATCHCI);
13871 node.pos = token.pos;
13872 node.left = left;
13873 node.right = this.parse_expr5();
13874 var left = node;
13875 }
13876 else if (token.type == TOKEN_NOMATCHCS) {
13877 var node = Node(NODE_NOMATCHCS);
13878 node.pos = token.pos;
13879 node.left = left;
13880 node.right = this.parse_expr5();
13881 var left = node;
13882 }
13883 else if (token.type == TOKEN_IS) {
13884 var node = Node(NODE_IS);
13885 node.pos = token.pos;
13886 node.left = left;
13887 node.right = this.parse_expr5();
13888 var left = node;
13889 }
13890 else if (token.type == TOKEN_ISCI) {
13891 var node = Node(NODE_ISCI);
13892 node.pos = token.pos;
13893 node.left = left;
13894 node.right = this.parse_expr5();
13895 var left = node;
13896 }
13897 else if (token.type == TOKEN_ISCS) {
13898 var node = Node(NODE_ISCS);
13899 node.pos = token.pos;
13900 node.left = left;
13901 node.right = this.parse_expr5();
13902 var left = node;
13903 }
13904 else if (token.type == TOKEN_ISNOT) {
13905 var node = Node(NODE_ISNOT);
13906 node.pos = token.pos;
13907 node.left = left;
13908 node.right = this.parse_expr5();
13909 var left = node;
13910 }
13911 else if (token.type == TOKEN_ISNOTCI) {
13912 var node = Node(NODE_ISNOTCI);
13913 node.pos = token.pos;
13914 node.left = left;
13915 node.right = this.parse_expr5();
13916 var left = node;
13917 }
13918 else if (token.type == TOKEN_ISNOTCS) {
13919 var node = Node(NODE_ISNOTCS);
13920 node.pos = token.pos;
13921 node.left = left;
13922 node.right = this.parse_expr5();
13923 var left = node;
13924 }
13925 else {
13926 this.reader.seek_set(pos);
13927 }
13928 return left;
13929}
13930
13931// expr5: expr6 + expr6 ..
13932// expr6 - expr6 ..
13933// expr6 . expr6 ..
13934// expr6 .. expr6 ..
13935ExprParser.prototype.parse_expr5 = function() {
13936 var left = this.parse_expr6();
13937 while (TRUE) {
13938 var pos = this.reader.tell();
13939 var token = this.tokenizer.get();
13940 if (token.type == TOKEN_PLUS) {
13941 var node = Node(NODE_ADD);
13942 node.pos = token.pos;
13943 node.left = left;
13944 node.right = this.parse_expr6();
13945 var left = node;
13946 }
13947 else if (token.type == TOKEN_MINUS) {
13948 var node = Node(NODE_SUBTRACT);
13949 node.pos = token.pos;
13950 node.left = left;
13951 node.right = this.parse_expr6();
13952 var left = node;
13953 }
13954 else if (token.type == TOKEN_DOTDOT) {
13955 // TODO check scriptversion?
13956 var node = Node(NODE_CONCAT);
13957 node.pos = token.pos;
13958 node.left = left;
13959 node.right = this.parse_expr6();
13960 var left = node;
13961 }
13962 else if (token.type == TOKEN_DOT) {
13963 // TODO check scriptversion?
13964 var node = Node(NODE_CONCAT);
13965 node.pos = token.pos;
13966 node.left = left;
13967 node.right = this.parse_expr6();
13968 var left = node;
13969 }
13970 else {
13971 this.reader.seek_set(pos);
13972 break;
13973 }
13974 }
13975 return left;
13976}
13977
13978// expr6: expr7 * expr7 ..
13979// expr7 / expr7 ..
13980// expr7 % expr7 ..
13981ExprParser.prototype.parse_expr6 = function() {
13982 var left = this.parse_expr7();
13983 while (TRUE) {
13984 var pos = this.reader.tell();
13985 var token = this.tokenizer.get();
13986 if (token.type == TOKEN_STAR) {
13987 var node = Node(NODE_MULTIPLY);
13988 node.pos = token.pos;
13989 node.left = left;
13990 node.right = this.parse_expr7();
13991 var left = node;
13992 }
13993 else if (token.type == TOKEN_SLASH) {
13994 var node = Node(NODE_DIVIDE);
13995 node.pos = token.pos;
13996 node.left = left;
13997 node.right = this.parse_expr7();
13998 var left = node;
13999 }
14000 else if (token.type == TOKEN_PERCENT) {
14001 var node = Node(NODE_REMAINDER);
14002 node.pos = token.pos;
14003 node.left = left;
14004 node.right = this.parse_expr7();
14005 var left = node;
14006 }
14007 else {
14008 this.reader.seek_set(pos);
14009 break;
14010 }
14011 }
14012 return left;
14013}
14014
14015// expr7: ! expr7
14016// - expr7
14017// + expr7
14018ExprParser.prototype.parse_expr7 = function() {
14019 var pos = this.reader.tell();
14020 var token = this.tokenizer.get();
14021 if (token.type == TOKEN_NOT) {
14022 var node = Node(NODE_NOT);
14023 node.pos = token.pos;
14024 node.left = this.parse_expr7();
14025 return node;
14026 }
14027 else if (token.type == TOKEN_MINUS) {
14028 var node = Node(NODE_MINUS);
14029 node.pos = token.pos;
14030 node.left = this.parse_expr7();
14031 return node;
14032 }
14033 else if (token.type == TOKEN_PLUS) {
14034 var node = Node(NODE_PLUS);
14035 node.pos = token.pos;
14036 node.left = this.parse_expr7();
14037 return node;
14038 }
14039 else {
14040 this.reader.seek_set(pos);
14041 var node = this.parse_expr8();
14042 return node;
14043 }
14044}
14045
14046// expr8: expr8[expr1]
14047// expr8[expr1 : expr1]
14048// expr8.name
14049// expr8->name(expr1, ...)
14050// expr8->s:user_func(expr1, ...)
14051// expr8->{lambda}(expr1, ...)
14052// expr8(expr1, ...)
14053ExprParser.prototype.parse_expr8 = function() {
14054 var left = this.parse_expr9();
14055 while (TRUE) {
14056 var pos = this.reader.tell();
14057 var c = this.reader.peek();
14058 var token = this.tokenizer.get();
14059 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
14060 var npos = token.pos;
14061 if (this.tokenizer.peek().type == TOKEN_COLON) {
14062 this.tokenizer.get();
14063 var node = Node(NODE_SLICE);
14064 node.pos = npos;
14065 node.left = left;
14066 node.rlist = [NIL, NIL];
14067 var token = this.tokenizer.peek();
14068 if (token.type != TOKEN_SQCLOSE) {
14069 node.rlist[1] = this.parse_expr1();
14070 }
14071 var token = this.tokenizer.get();
14072 if (token.type != TOKEN_SQCLOSE) {
14073 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14074 }
14075 var left = node;
14076 }
14077 else {
14078 var right = this.parse_expr1();
14079 if (this.tokenizer.peek().type == TOKEN_COLON) {
14080 this.tokenizer.get();
14081 var node = Node(NODE_SLICE);
14082 node.pos = npos;
14083 node.left = left;
14084 node.rlist = [right, NIL];
14085 var token = this.tokenizer.peek();
14086 if (token.type != TOKEN_SQCLOSE) {
14087 node.rlist[1] = this.parse_expr1();
14088 }
14089 var token = this.tokenizer.get();
14090 if (token.type != TOKEN_SQCLOSE) {
14091 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14092 }
14093 var left = node;
14094 }
14095 else {
14096 var node = Node(NODE_SUBSCRIPT);
14097 node.pos = npos;
14098 node.left = left;
14099 node.right = right;
14100 var token = this.tokenizer.get();
14101 if (token.type != TOKEN_SQCLOSE) {
14102 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14103 }
14104 var left = node;
14105 }
14106 }
14107 delete node;
14108 }
14109 else if (token.type == TOKEN_ARROW) {
14110 var funcname_or_lambda = this.parse_expr9();
14111 var token = this.tokenizer.get();
14112 if (token.type != TOKEN_POPEN) {
14113 throw Err("E107: Missing parentheses: lambda", token.pos);
14114 }
14115 var right = Node(NODE_CALL);
14116 right.pos = token.pos;
14117 right.left = funcname_or_lambda;
14118 right.rlist = this.parse_rlist();
14119 var node = Node(NODE_METHOD);
14120 node.pos = token.pos;
14121 node.left = left;
14122 node.right = right;
14123 var left = node;
14124 delete node;
14125 }
14126 else if (token.type == TOKEN_POPEN) {
14127 var node = Node(NODE_CALL);
14128 node.pos = token.pos;
14129 node.left = left;
14130 node.rlist = this.parse_rlist();
14131 var left = node;
14132 delete node;
14133 }
14134 else if (!iswhite(c) && token.type == TOKEN_DOT) {
14135 // TODO check scriptversion?
14136 var node = this.parse_dot(token, left);
14137 if (node === NIL) {
14138 this.reader.seek_set(pos);
14139 break;
14140 }
14141 var left = node;
14142 delete node;
14143 }
14144 else {
14145 this.reader.seek_set(pos);
14146 break;
14147 }
14148 }
14149 return left;
14150}
14151
14152ExprParser.prototype.parse_rlist = function() {
14153 var rlist = [];
14154 var token = this.tokenizer.peek();
14155 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
14156 this.tokenizer.get();
14157 }
14158 else {
14159 while (TRUE) {
14160 viml_add(rlist, this.parse_expr1());
14161 var token = this.tokenizer.get();
14162 if (token.type == TOKEN_COMMA) {
14163 // XXX: Vim allows foo(a, b, ). Lint should warn it.
14164 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
14165 this.tokenizer.get();
14166 break;
14167 }
14168 }
14169 else if (token.type == TOKEN_PCLOSE) {
14170 break;
14171 }
14172 else {
14173 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14174 }
14175 }
14176 }
14177 if (viml_len(rlist) > MAX_FUNC_ARGS) {
14178 // TODO: funcname E740: Too many arguments for function: %s
14179 throw Err("E740: Too many arguments for function", token.pos);
14180 }
14181 return rlist;
14182}
14183
14184// expr9: number
14185// "string"
14186// 'string'
14187// [expr1, ...]
14188// {expr1: expr1, ...}
14189// #{literal_key1: expr1, ...}
14190// {args -> expr1}
14191// &option
14192// (expr1)
14193// variable
14194// var{ria}ble
14195// $VAR
14196// @r
14197// function(expr1, ...)
14198// func{ti}on(expr1, ...)
14199ExprParser.prototype.parse_expr9 = function() {
14200 var pos = this.reader.tell();
14201 var token = this.tokenizer.get();
14202 var node = Node(-1);
14203 if (token.type == TOKEN_NUMBER) {
14204 var node = Node(NODE_NUMBER);
14205 node.pos = token.pos;
14206 node.value = token.value;
14207 }
14208 else if (token.type == TOKEN_BLOB) {
14209 var node = Node(NODE_BLOB);
14210 node.pos = token.pos;
14211 node.value = token.value;
14212 }
14213 else if (token.type == TOKEN_DQUOTE) {
14214 this.reader.seek_set(pos);
14215 var node = Node(NODE_STRING);
14216 node.pos = token.pos;
14217 node.value = "\"" + this.tokenizer.get_dstring() + "\"";
14218 }
14219 else if (token.type == TOKEN_SQUOTE) {
14220 this.reader.seek_set(pos);
14221 var node = Node(NODE_STRING);
14222 node.pos = token.pos;
14223 node.value = "'" + this.tokenizer.get_sstring() + "'";
14224 }
14225 else if (token.type == TOKEN_SQOPEN) {
14226 var node = Node(NODE_LIST);
14227 node.pos = token.pos;
14228 node.value = [];
14229 var token = this.tokenizer.peek();
14230 if (token.type == TOKEN_SQCLOSE) {
14231 this.tokenizer.get();
14232 }
14233 else {
14234 while (TRUE) {
14235 viml_add(node.value, this.parse_expr1());
14236 var token = this.tokenizer.peek();
14237 if (token.type == TOKEN_COMMA) {
14238 this.tokenizer.get();
14239 if (this.tokenizer.peek().type == TOKEN_SQCLOSE) {
14240 this.tokenizer.get();
14241 break;
14242 }
14243 }
14244 else if (token.type == TOKEN_SQCLOSE) {
14245 this.tokenizer.get();
14246 break;
14247 }
14248 else {
14249 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14250 }
14251 }
14252 }
14253 }
14254 else if (token.type == TOKEN_COPEN || token.type == TOKEN_LITCOPEN) {
14255 var is_litdict = token.type == TOKEN_LITCOPEN;
14256 var savepos = this.reader.tell();
14257 var nodepos = token.pos;
14258 var token = this.tokenizer.get();
14259 var lambda = token.type == TOKEN_ARROW;
14260 if (!lambda && !(token.type == TOKEN_SQUOTE || token.type == TOKEN_DQUOTE)) {
14261 // if the token type is stirng, we cannot peek next token and we can
14262 // assume it's not lambda.
14263 var token2 = this.tokenizer.peek();
14264 var lambda = token2.type == TOKEN_ARROW || token2.type == TOKEN_COMMA;
14265 }
14266 // fallback to dict or {expr} if true
14267 var fallback = FALSE;
14268 if (lambda) {
14269 // lambda {token,...} {->...} {token->...}
14270 var node = Node(NODE_LAMBDA);
14271 node.pos = nodepos;
14272 node.rlist = [];
14273 var named = {};
14274 while (TRUE) {
14275 if (token.type == TOKEN_ARROW) {
14276 break;
14277 }
14278 else if (token.type == TOKEN_IDENTIFIER) {
14279 if (!isargname(token.value)) {
14280 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
14281 }
14282 else if (viml_has_key(named, token.value)) {
14283 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
14284 }
14285 named[token.value] = 1;
14286 var varnode = Node(NODE_IDENTIFIER);
14287 varnode.pos = token.pos;
14288 varnode.value = token.value;
14289 // XXX: Vim doesn't skip white space before comma. {a ,b -> ...} => E475
14290 if (iswhite(this.reader.p(0)) && this.tokenizer.peek().type == TOKEN_COMMA) {
14291 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
14292 }
14293 var token = this.tokenizer.get();
14294 viml_add(node.rlist, varnode);
14295 if (token.type == TOKEN_COMMA) {
14296 // XXX: Vim allows last comma. {a, b, -> ...} => OK
14297 var token = this.tokenizer.peek();
14298 if (token.type == TOKEN_ARROW) {
14299 this.tokenizer.get();
14300 break;
14301 }
14302 }
14303 else if (token.type == TOKEN_ARROW) {
14304 break;
14305 }
14306 else {
14307 throw Err(viml_printf("unexpected token: %s, type: %d", token.value, token.type), token.pos);
14308 }
14309 }
14310 else if (token.type == TOKEN_DOTDOTDOT) {
14311 var varnode = Node(NODE_IDENTIFIER);
14312 varnode.pos = token.pos;
14313 varnode.value = token.value;
14314 viml_add(node.rlist, varnode);
14315 var token = this.tokenizer.peek();
14316 if (token.type == TOKEN_ARROW) {
14317 this.tokenizer.get();
14318 break;
14319 }
14320 else {
14321 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14322 }
14323 }
14324 else {
14325 var fallback = TRUE;
14326 break;
14327 }
14328 var token = this.tokenizer.get();
14329 }
14330 if (!fallback) {
14331 node.left = this.parse_expr1();
14332 var token = this.tokenizer.get();
14333 if (token.type != TOKEN_CCLOSE) {
14334 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14335 }
14336 return node;
14337 }
14338 }
14339 // dict
14340 var node = Node(NODE_DICT);
14341 node.pos = nodepos;
14342 node.value = [];
14343 this.reader.seek_set(savepos);
14344 var token = this.tokenizer.peek();
14345 if (token.type == TOKEN_CCLOSE) {
14346 this.tokenizer.get();
14347 return node;
14348 }
14349 while (1) {
14350 var key = is_litdict ? this.tokenizer.parse_dict_literal_key() : this.parse_expr1();
14351 var token = this.tokenizer.get();
14352 if (token.type == TOKEN_CCLOSE) {
14353 if (!viml_empty(node.value)) {
14354 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14355 }
14356 this.reader.seek_set(pos);
14357 var node = this.parse_identifier();
14358 break;
14359 }
14360 if (token.type != TOKEN_COLON) {
14361 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14362 }
14363 var val = this.parse_expr1();
14364 viml_add(node.value, [key, val]);
14365 var token = this.tokenizer.get();
14366 if (token.type == TOKEN_COMMA) {
14367 if (this.tokenizer.peek().type == TOKEN_CCLOSE) {
14368 this.tokenizer.get();
14369 break;
14370 }
14371 }
14372 else if (token.type == TOKEN_CCLOSE) {
14373 break;
14374 }
14375 else {
14376 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14377 }
14378 }
14379 return node;
14380 }
14381 else if (token.type == TOKEN_POPEN) {
14382 var node = this.parse_expr1();
14383 var token = this.tokenizer.get();
14384 if (token.type != TOKEN_PCLOSE) {
14385 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14386 }
14387 }
14388 else if (token.type == TOKEN_OPTION) {
14389 var node = Node(NODE_OPTION);
14390 node.pos = token.pos;
14391 node.value = token.value;
14392 }
14393 else if (token.type == TOKEN_IDENTIFIER) {
14394 this.reader.seek_set(pos);
14395 var node = this.parse_identifier();
14396 }
14397 else if (FALSE && (token.type == TOKEN_COLON || token.type == TOKEN_SHARP)) {
14398 // XXX: no parse error but invalid expression
14399 this.reader.seek_set(pos);
14400 var node = this.parse_identifier();
14401 }
14402 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
14403 this.reader.seek_set(pos);
14404 var node = this.parse_identifier();
14405 }
14406 else if (token.type == TOKEN_IS || token.type == TOKEN_ISCS || token.type == TOKEN_ISNOT || token.type == TOKEN_ISNOTCS) {
14407 this.reader.seek_set(pos);
14408 var node = this.parse_identifier();
14409 }
14410 else if (token.type == TOKEN_ENV) {
14411 var node = Node(NODE_ENV);
14412 node.pos = token.pos;
14413 node.value = token.value;
14414 }
14415 else if (token.type == TOKEN_REG) {
14416 var node = Node(NODE_REG);
14417 node.pos = token.pos;
14418 node.value = token.value;
14419 }
14420 else {
14421 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14422 }
14423 return node;
14424}
14425
14426// SUBSCRIPT or CONCAT
14427// dict "." [0-9A-Za-z_]+ => (subscript dict key)
14428// str "." expr6 => (concat str expr6)
14429ExprParser.prototype.parse_dot = function(token, left) {
14430 if (left.type != NODE_IDENTIFIER && left.type != NODE_CURLYNAME && left.type != NODE_DICT && left.type != NODE_SUBSCRIPT && left.type != NODE_CALL && left.type != NODE_DOT) {
14431 return NIL;
14432 }
14433 if (!iswordc(this.reader.p(0))) {
14434 return NIL;
14435 }
14436 var pos = this.reader.getpos();
14437 var name = this.reader.read_word();
14438 if (isnamec(this.reader.p(0))) {
14439 // XXX: foo is str => ok, foo is obj => invalid expression
14440 // foo.s:bar or foo.bar#baz
14441 return NIL;
14442 }
14443 var node = Node(NODE_DOT);
14444 node.pos = token.pos;
14445 node.left = left;
14446 node.right = Node(NODE_IDENTIFIER);
14447 node.right.pos = pos;
14448 node.right.value = name;
14449 return node;
14450}
14451
14452// CONCAT
14453// str ".." expr6 => (concat str expr6)
14454ExprParser.prototype.parse_concat = function(token, left) {
14455 if (left.type != NODE_IDENTIFIER && left.type != NODE_CURLYNAME && left.type != NODE_DICT && left.type != NODE_SUBSCRIPT && left.type != NODE_CALL && left.type != NODE_DOT) {
14456 return NIL;
14457 }
14458 if (!iswordc(this.reader.p(0))) {
14459 return NIL;
14460 }
14461 var pos = this.reader.getpos();
14462 var name = this.reader.read_word();
14463 if (isnamec(this.reader.p(0))) {
14464 // XXX: foo is str => ok, foo is obj => invalid expression
14465 // foo.s:bar or foo.bar#baz
14466 return NIL;
14467 }
14468 var node = Node(NODE_CONCAT);
14469 node.pos = token.pos;
14470 node.left = left;
14471 node.right = Node(NODE_IDENTIFIER);
14472 node.right.pos = pos;
14473 node.right.value = name;
14474 return node;
14475}
14476
14477ExprParser.prototype.parse_identifier = function() {
14478 this.reader.skip_white();
14479 var npos = this.reader.getpos();
14480 var curly_parts = this.parse_curly_parts();
14481 if (viml_len(curly_parts) == 1 && curly_parts[0].type == NODE_CURLYNAMEPART) {
14482 var node = Node(NODE_IDENTIFIER);
14483 node.pos = npos;
14484 node.value = curly_parts[0].value;
14485 return node;
14486 }
14487 else {
14488 var node = Node(NODE_CURLYNAME);
14489 node.pos = npos;
14490 node.value = curly_parts;
14491 return node;
14492 }
14493}
14494
14495ExprParser.prototype.parse_curly_parts = function() {
14496 var curly_parts = [];
14497 var c = this.reader.peek();
14498 var pos = this.reader.getpos();
14499 if (c == "<" && viml_equalci(this.reader.peekn(5), "<SID>")) {
14500 var name = this.reader.getn(5);
14501 var node = Node(NODE_CURLYNAMEPART);
14502 node.curly = FALSE;
14503 // Keep backword compatibility for the curly attribute
14504 node.pos = pos;
14505 node.value = name;
14506 viml_add(curly_parts, node);
14507 }
14508 while (TRUE) {
14509 var c = this.reader.peek();
14510 if (isnamec(c)) {
14511 var pos = this.reader.getpos();
14512 var name = this.reader.read_name();
14513 var node = Node(NODE_CURLYNAMEPART);
14514 node.curly = FALSE;
14515 // Keep backword compatibility for the curly attribute
14516 node.pos = pos;
14517 node.value = name;
14518 viml_add(curly_parts, node);
14519 }
14520 else if (c == "{") {
14521 this.reader.get();
14522 var pos = this.reader.getpos();
14523 var node = Node(NODE_CURLYNAMEEXPR);
14524 node.curly = TRUE;
14525 // Keep backword compatibility for the curly attribute
14526 node.pos = pos;
14527 node.value = this.parse_expr1();
14528 viml_add(curly_parts, node);
14529 this.reader.skip_white();
14530 var c = this.reader.p(0);
14531 if (c != "}") {
14532 throw Err(viml_printf("unexpected token: %s", c), this.reader.getpos());
14533 }
14534 this.reader.seek_cur(1);
14535 }
14536 else {
14537 break;
14538 }
14539 }
14540 return curly_parts;
14541}
14542
14543function LvalueParser() { ExprParser.apply(this, arguments); this.__init__.apply(this, arguments); }
14544LvalueParser.prototype = Object.create(ExprParser.prototype);
14545LvalueParser.prototype.parse = function() {
14546 return this.parse_lv8();
14547}
14548
14549// expr8: expr8[expr1]
14550// expr8[expr1 : expr1]
14551// expr8.name
14552LvalueParser.prototype.parse_lv8 = function() {
14553 var left = this.parse_lv9();
14554 while (TRUE) {
14555 var pos = this.reader.tell();
14556 var c = this.reader.peek();
14557 var token = this.tokenizer.get();
14558 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
14559 var npos = token.pos;
14560 var node = Node(-1);
14561 if (this.tokenizer.peek().type == TOKEN_COLON) {
14562 this.tokenizer.get();
14563 var node = Node(NODE_SLICE);
14564 node.pos = npos;
14565 node.left = left;
14566 node.rlist = [NIL, NIL];
14567 var token = this.tokenizer.peek();
14568 if (token.type != TOKEN_SQCLOSE) {
14569 node.rlist[1] = this.parse_expr1();
14570 }
14571 var token = this.tokenizer.get();
14572 if (token.type != TOKEN_SQCLOSE) {
14573 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14574 }
14575 }
14576 else {
14577 var right = this.parse_expr1();
14578 if (this.tokenizer.peek().type == TOKEN_COLON) {
14579 this.tokenizer.get();
14580 var node = Node(NODE_SLICE);
14581 node.pos = npos;
14582 node.left = left;
14583 node.rlist = [right, NIL];
14584 var token = this.tokenizer.peek();
14585 if (token.type != TOKEN_SQCLOSE) {
14586 node.rlist[1] = this.parse_expr1();
14587 }
14588 var token = this.tokenizer.get();
14589 if (token.type != TOKEN_SQCLOSE) {
14590 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14591 }
14592 }
14593 else {
14594 var node = Node(NODE_SUBSCRIPT);
14595 node.pos = npos;
14596 node.left = left;
14597 node.right = right;
14598 var token = this.tokenizer.get();
14599 if (token.type != TOKEN_SQCLOSE) {
14600 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14601 }
14602 }
14603 }
14604 var left = node;
14605 delete node;
14606 }
14607 else if (!iswhite(c) && token.type == TOKEN_DOT) {
14608 var node = this.parse_dot(token, left);
14609 if (node === NIL) {
14610 this.reader.seek_set(pos);
14611 break;
14612 }
14613 var left = node;
14614 delete node;
14615 }
14616 else {
14617 this.reader.seek_set(pos);
14618 break;
14619 }
14620 }
14621 return left;
14622}
14623
14624// expr9: &option
14625// variable
14626// var{ria}ble
14627// $VAR
14628// @r
14629LvalueParser.prototype.parse_lv9 = function() {
14630 var pos = this.reader.tell();
14631 var token = this.tokenizer.get();
14632 var node = Node(-1);
14633 if (token.type == TOKEN_COPEN) {
14634 this.reader.seek_set(pos);
14635 var node = this.parse_identifier();
14636 }
14637 else if (token.type == TOKEN_OPTION) {
14638 var node = Node(NODE_OPTION);
14639 node.pos = token.pos;
14640 node.value = token.value;
14641 }
14642 else if (token.type == TOKEN_IDENTIFIER) {
14643 this.reader.seek_set(pos);
14644 var node = this.parse_identifier();
14645 }
14646 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
14647 this.reader.seek_set(pos);
14648 var node = this.parse_identifier();
14649 }
14650 else if (token.type == TOKEN_ENV) {
14651 var node = Node(NODE_ENV);
14652 node.pos = token.pos;
14653 node.value = token.value;
14654 }
14655 else if (token.type == TOKEN_REG) {
14656 var node = Node(NODE_REG);
14657 node.pos = token.pos;
14658 node.pos = token.pos;
14659 node.value = token.value;
14660 }
14661 else {
14662 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
14663 }
14664 return node;
14665}
14666
14667function StringReader() { this.__init__.apply(this, arguments); }
14668StringReader.prototype.__init__ = function(lines) {
14669 this.buf = [];
14670 this.pos = [];
14671 var lnum = 0;
14672 var offset = 0;
14673 while (lnum < viml_len(lines)) {
14674 var col = 0;
14675 var __c7 = viml_split(lines[lnum], "\\zs");
14676 for (var __i7 = 0; __i7 < __c7.length; ++__i7) {
14677 var c = __c7[__i7];
14678 viml_add(this.buf, c);
14679 viml_add(this.pos, [lnum + 1, col + 1, offset]);
14680 col += viml_len(c);
14681 offset += viml_len(c);
14682 }
14683 while (lnum + 1 < viml_len(lines) && viml_eqregh(lines[lnum + 1], "^\\s*\\\\")) {
14684 var skip = TRUE;
14685 var col = 0;
14686 var __c8 = viml_split(lines[lnum + 1], "\\zs");
14687 for (var __i8 = 0; __i8 < __c8.length; ++__i8) {
14688 var c = __c8[__i8];
14689 if (skip) {
14690 if (c == "\\") {
14691 var skip = FALSE;
14692 }
14693 }
14694 else {
14695 viml_add(this.buf, c);
14696 viml_add(this.pos, [lnum + 2, col + 1, offset]);
14697 }
14698 col += viml_len(c);
14699 offset += viml_len(c);
14700 }
14701 lnum += 1;
14702 offset += 1;
14703 }
14704 viml_add(this.buf, "<EOL>");
14705 viml_add(this.pos, [lnum + 1, col + 1, offset]);
14706 lnum += 1;
14707 offset += 1;
14708 }
14709 // for <EOF>
14710 viml_add(this.pos, [lnum + 1, 0, offset]);
14711 this.i = 0;
14712}
14713
14714StringReader.prototype.eof = function() {
14715 return this.i >= viml_len(this.buf);
14716}
14717
14718StringReader.prototype.tell = function() {
14719 return this.i;
14720}
14721
14722StringReader.prototype.seek_set = function(i) {
14723 this.i = i;
14724}
14725
14726StringReader.prototype.seek_cur = function(i) {
14727 this.i = this.i + i;
14728}
14729
14730StringReader.prototype.seek_end = function(i) {
14731 this.i = viml_len(this.buf) + i;
14732}
14733
14734StringReader.prototype.p = function(i) {
14735 if (this.i >= viml_len(this.buf)) {
14736 return "<EOF>";
14737 }
14738 return this.buf[this.i + i];
14739}
14740
14741StringReader.prototype.peek = function() {
14742 if (this.i >= viml_len(this.buf)) {
14743 return "<EOF>";
14744 }
14745 return this.buf[this.i];
14746}
14747
14748StringReader.prototype.get = function() {
14749 if (this.i >= viml_len(this.buf)) {
14750 return "<EOF>";
14751 }
14752 this.i += 1;
14753 return this.buf[this.i - 1];
14754}
14755
14756StringReader.prototype.peekn = function(n) {
14757 var pos = this.tell();
14758 var r = this.getn(n);
14759 this.seek_set(pos);
14760 return r;
14761}
14762
14763StringReader.prototype.getn = function(n) {
14764 var r = "";
14765 var j = 0;
14766 while (this.i < viml_len(this.buf) && (n < 0 || j < n)) {
14767 var c = this.buf[this.i];
14768 if (c == "<EOL>") {
14769 break;
14770 }
14771 r += c;
14772 this.i += 1;
14773 j += 1;
14774 }
14775 return r;
14776}
14777
14778StringReader.prototype.peekline = function() {
14779 return this.peekn(-1);
14780}
14781
14782StringReader.prototype.readline = function() {
14783 var r = this.getn(-1);
14784 this.get();
14785 return r;
14786}
14787
14788StringReader.prototype.getstr = function(begin, end) {
14789 var r = "";
14790 var __c9 = viml_range(begin.i, end.i - 1);
14791 for (var __i9 = 0; __i9 < __c9.length; ++__i9) {
14792 var i = __c9[__i9];
14793 if (i >= viml_len(this.buf)) {
14794 break;
14795 }
14796 var c = this.buf[i];
14797 if (c == "<EOL>") {
14798 var c = "\n";
14799 }
14800 r += c;
14801 }
14802 return r;
14803}
14804
14805StringReader.prototype.getpos = function() {
14806 var __tmp = this.pos[this.i];
14807 var lnum = __tmp[0];
14808 var col = __tmp[1];
14809 var offset = __tmp[2];
14810 return {"i":this.i, "lnum":lnum, "col":col, "offset":offset};
14811}
14812
14813StringReader.prototype.setpos = function(pos) {
14814 this.i = pos.i;
14815}
14816
14817StringReader.prototype.read_alpha = function() {
14818 var r = "";
14819 while (isalpha(this.peekn(1))) {
14820 r += this.getn(1);
14821 }
14822 return r;
14823}
14824
14825StringReader.prototype.read_alnum = function() {
14826 var r = "";
14827 while (isalnum(this.peekn(1))) {
14828 r += this.getn(1);
14829 }
14830 return r;
14831}
14832
14833StringReader.prototype.read_digit = function() {
14834 var r = "";
14835 while (isdigit(this.peekn(1))) {
14836 r += this.getn(1);
14837 }
14838 return r;
14839}
14840
14841StringReader.prototype.read_odigit = function() {
14842 var r = "";
14843 while (isodigit(this.peekn(1))) {
14844 r += this.getn(1);
14845 }
14846 return r;
14847}
14848
14849StringReader.prototype.read_blob = function() {
14850 var r = "";
14851 while (1) {
14852 var s = this.peekn(2);
14853 if (viml_eqregh(s, "^[0-9A-Fa-f][0-9A-Fa-f]$")) {
14854 r += this.getn(2);
14855 }
14856 else if (viml_eqregh(s, "^\\.[0-9A-Fa-f]$")) {
14857 r += this.getn(1);
14858 }
14859 else if (viml_eqregh(s, "^[0-9A-Fa-f][^0-9A-Fa-f]$")) {
14860 throw Err("E973: Blob literal should have an even number of hex characters:" + s, this.getpos());
14861 }
14862 else {
14863 break;
14864 }
14865 }
14866 return r;
14867}
14868
14869StringReader.prototype.read_xdigit = function() {
14870 var r = "";
14871 while (isxdigit(this.peekn(1))) {
14872 r += this.getn(1);
14873 }
14874 return r;
14875}
14876
14877StringReader.prototype.read_bdigit = function() {
14878 var r = "";
14879 while (this.peekn(1) == "0" || this.peekn(1) == "1") {
14880 r += this.getn(1);
14881 }
14882 return r;
14883}
14884
14885StringReader.prototype.read_integer = function() {
14886 var r = "";
14887 var c = this.peekn(1);
14888 if (c == "-" || c == "+") {
14889 var r = this.getn(1);
14890 }
14891 return r + this.read_digit();
14892}
14893
14894StringReader.prototype.read_word = function() {
14895 var r = "";
14896 while (iswordc(this.peekn(1))) {
14897 r += this.getn(1);
14898 }
14899 return r;
14900}
14901
14902StringReader.prototype.read_white = function() {
14903 var r = "";
14904 while (iswhite(this.peekn(1))) {
14905 r += this.getn(1);
14906 }
14907 return r;
14908}
14909
14910StringReader.prototype.read_nonwhite = function() {
14911 var r = "";
14912 var ch = this.peekn(1);
14913 while (!iswhite(ch) && ch != "") {
14914 r += this.getn(1);
14915 var ch = this.peekn(1);
14916 }
14917 return r;
14918}
14919
14920StringReader.prototype.read_name = function() {
14921 var r = "";
14922 while (isnamec(this.peekn(1))) {
14923 r += this.getn(1);
14924 }
14925 return r;
14926}
14927
14928StringReader.prototype.skip_white = function() {
14929 while (iswhite(this.peekn(1))) {
14930 this.seek_cur(1);
14931 }
14932}
14933
14934StringReader.prototype.skip_white_and_colon = function() {
14935 while (TRUE) {
14936 var c = this.peekn(1);
14937 if (!iswhite(c) && c != ":") {
14938 break;
14939 }
14940 this.seek_cur(1);
14941 }
14942}
14943
14944function Compiler() { this.__init__.apply(this, arguments); }
14945Compiler.prototype.__init__ = function() {
14946 this.indent = [""];
14947 this.lines = [];
14948}
14949
14950Compiler.prototype.out = function() {
14951 var a000 = Array.prototype.slice.call(arguments, 0);
14952 if (viml_len(a000) == 1) {
14953 if (a000[0][0] == ")") {
14954 this.lines[this.lines.length - 1] += a000[0];
14955 }
14956 else {
14957 viml_add(this.lines, this.indent[0] + a000[0]);
14958 }
14959 }
14960 else {
14961 viml_add(this.lines, this.indent[0] + viml_printf.apply(null, a000));
14962 }
14963}
14964
14965Compiler.prototype.incindent = function(s) {
14966 viml_insert(this.indent, this.indent[0] + s);
14967}
14968
14969Compiler.prototype.decindent = function() {
14970 viml_remove(this.indent, 0);
14971}
14972
14973Compiler.prototype.compile = function(node) {
14974 if (node.type == NODE_TOPLEVEL) {
14975 return this.compile_toplevel(node);
14976 }
14977 else if (node.type == NODE_COMMENT) {
14978 this.compile_comment(node);
14979 return NIL;
14980 }
14981 else if (node.type == NODE_EXCMD) {
14982 this.compile_excmd(node);
14983 return NIL;
14984 }
14985 else if (node.type == NODE_FUNCTION) {
14986 this.compile_function(node);
14987 return NIL;
14988 }
14989 else if (node.type == NODE_DELFUNCTION) {
14990 this.compile_delfunction(node);
14991 return NIL;
14992 }
14993 else if (node.type == NODE_RETURN) {
14994 this.compile_return(node);
14995 return NIL;
14996 }
14997 else if (node.type == NODE_EXCALL) {
14998 this.compile_excall(node);
14999 return NIL;
15000 }
15001 else if (node.type == NODE_EVAL) {
15002 this.compile_eval(node);
15003 return NIL;
15004 }
15005 else if (node.type == NODE_LET) {
15006 this.compile_let(node);
15007 return NIL;
15008 }
15009 else if (node.type == NODE_CONST) {
15010 this.compile_const(node);
15011 return NIL;
15012 }
15013 else if (node.type == NODE_UNLET) {
15014 this.compile_unlet(node);
15015 return NIL;
15016 }
15017 else if (node.type == NODE_LOCKVAR) {
15018 this.compile_lockvar(node);
15019 return NIL;
15020 }
15021 else if (node.type == NODE_UNLOCKVAR) {
15022 this.compile_unlockvar(node);
15023 return NIL;
15024 }
15025 else if (node.type == NODE_IF) {
15026 this.compile_if(node);
15027 return NIL;
15028 }
15029 else if (node.type == NODE_WHILE) {
15030 this.compile_while(node);
15031 return NIL;
15032 }
15033 else if (node.type == NODE_FOR) {
15034 this.compile_for(node);
15035 return NIL;
15036 }
15037 else if (node.type == NODE_CONTINUE) {
15038 this.compile_continue(node);
15039 return NIL;
15040 }
15041 else if (node.type == NODE_BREAK) {
15042 this.compile_break(node);
15043 return NIL;
15044 }
15045 else if (node.type == NODE_TRY) {
15046 this.compile_try(node);
15047 return NIL;
15048 }
15049 else if (node.type == NODE_THROW) {
15050 this.compile_throw(node);
15051 return NIL;
15052 }
15053 else if (node.type == NODE_ECHO) {
15054 this.compile_echo(node);
15055 return NIL;
15056 }
15057 else if (node.type == NODE_ECHON) {
15058 this.compile_echon(node);
15059 return NIL;
15060 }
15061 else if (node.type == NODE_ECHOHL) {
15062 this.compile_echohl(node);
15063 return NIL;
15064 }
15065 else if (node.type == NODE_ECHOMSG) {
15066 this.compile_echomsg(node);
15067 return NIL;
15068 }
15069 else if (node.type == NODE_ECHOERR) {
15070 this.compile_echoerr(node);
15071 return NIL;
15072 }
15073 else if (node.type == NODE_EXECUTE) {
15074 this.compile_execute(node);
15075 return NIL;
15076 }
15077 else if (node.type == NODE_TERNARY) {
15078 return this.compile_ternary(node);
15079 }
15080 else if (node.type == NODE_OR) {
15081 return this.compile_or(node);
15082 }
15083 else if (node.type == NODE_AND) {
15084 return this.compile_and(node);
15085 }
15086 else if (node.type == NODE_EQUAL) {
15087 return this.compile_equal(node);
15088 }
15089 else if (node.type == NODE_EQUALCI) {
15090 return this.compile_equalci(node);
15091 }
15092 else if (node.type == NODE_EQUALCS) {
15093 return this.compile_equalcs(node);
15094 }
15095 else if (node.type == NODE_NEQUAL) {
15096 return this.compile_nequal(node);
15097 }
15098 else if (node.type == NODE_NEQUALCI) {
15099 return this.compile_nequalci(node);
15100 }
15101 else if (node.type == NODE_NEQUALCS) {
15102 return this.compile_nequalcs(node);
15103 }
15104 else if (node.type == NODE_GREATER) {
15105 return this.compile_greater(node);
15106 }
15107 else if (node.type == NODE_GREATERCI) {
15108 return this.compile_greaterci(node);
15109 }
15110 else if (node.type == NODE_GREATERCS) {
15111 return this.compile_greatercs(node);
15112 }
15113 else if (node.type == NODE_GEQUAL) {
15114 return this.compile_gequal(node);
15115 }
15116 else if (node.type == NODE_GEQUALCI) {
15117 return this.compile_gequalci(node);
15118 }
15119 else if (node.type == NODE_GEQUALCS) {
15120 return this.compile_gequalcs(node);
15121 }
15122 else if (node.type == NODE_SMALLER) {
15123 return this.compile_smaller(node);
15124 }
15125 else if (node.type == NODE_SMALLERCI) {
15126 return this.compile_smallerci(node);
15127 }
15128 else if (node.type == NODE_SMALLERCS) {
15129 return this.compile_smallercs(node);
15130 }
15131 else if (node.type == NODE_SEQUAL) {
15132 return this.compile_sequal(node);
15133 }
15134 else if (node.type == NODE_SEQUALCI) {
15135 return this.compile_sequalci(node);
15136 }
15137 else if (node.type == NODE_SEQUALCS) {
15138 return this.compile_sequalcs(node);
15139 }
15140 else if (node.type == NODE_MATCH) {
15141 return this.compile_match(node);
15142 }
15143 else if (node.type == NODE_MATCHCI) {
15144 return this.compile_matchci(node);
15145 }
15146 else if (node.type == NODE_MATCHCS) {
15147 return this.compile_matchcs(node);
15148 }
15149 else if (node.type == NODE_NOMATCH) {
15150 return this.compile_nomatch(node);
15151 }
15152 else if (node.type == NODE_NOMATCHCI) {
15153 return this.compile_nomatchci(node);
15154 }
15155 else if (node.type == NODE_NOMATCHCS) {
15156 return this.compile_nomatchcs(node);
15157 }
15158 else if (node.type == NODE_IS) {
15159 return this.compile_is(node);
15160 }
15161 else if (node.type == NODE_ISCI) {
15162 return this.compile_isci(node);
15163 }
15164 else if (node.type == NODE_ISCS) {
15165 return this.compile_iscs(node);
15166 }
15167 else if (node.type == NODE_ISNOT) {
15168 return this.compile_isnot(node);
15169 }
15170 else if (node.type == NODE_ISNOTCI) {
15171 return this.compile_isnotci(node);
15172 }
15173 else if (node.type == NODE_ISNOTCS) {
15174 return this.compile_isnotcs(node);
15175 }
15176 else if (node.type == NODE_ADD) {
15177 return this.compile_add(node);
15178 }
15179 else if (node.type == NODE_SUBTRACT) {
15180 return this.compile_subtract(node);
15181 }
15182 else if (node.type == NODE_CONCAT) {
15183 return this.compile_concat(node);
15184 }
15185 else if (node.type == NODE_MULTIPLY) {
15186 return this.compile_multiply(node);
15187 }
15188 else if (node.type == NODE_DIVIDE) {
15189 return this.compile_divide(node);
15190 }
15191 else if (node.type == NODE_REMAINDER) {
15192 return this.compile_remainder(node);
15193 }
15194 else if (node.type == NODE_NOT) {
15195 return this.compile_not(node);
15196 }
15197 else if (node.type == NODE_PLUS) {
15198 return this.compile_plus(node);
15199 }
15200 else if (node.type == NODE_MINUS) {
15201 return this.compile_minus(node);
15202 }
15203 else if (node.type == NODE_SUBSCRIPT) {
15204 return this.compile_subscript(node);
15205 }
15206 else if (node.type == NODE_SLICE) {
15207 return this.compile_slice(node);
15208 }
15209 else if (node.type == NODE_DOT) {
15210 return this.compile_dot(node);
15211 }
15212 else if (node.type == NODE_METHOD) {
15213 return this.compile_method(node);
15214 }
15215 else if (node.type == NODE_CALL) {
15216 return this.compile_call(node);
15217 }
15218 else if (node.type == NODE_NUMBER) {
15219 return this.compile_number(node);
15220 }
15221 else if (node.type == NODE_BLOB) {
15222 return this.compile_blob(node);
15223 }
15224 else if (node.type == NODE_STRING) {
15225 return this.compile_string(node);
15226 }
15227 else if (node.type == NODE_LIST) {
15228 return this.compile_list(node);
15229 }
15230 else if (node.type == NODE_DICT) {
15231 return this.compile_dict(node);
15232 }
15233 else if (node.type == NODE_OPTION) {
15234 return this.compile_option(node);
15235 }
15236 else if (node.type == NODE_IDENTIFIER) {
15237 return this.compile_identifier(node);
15238 }
15239 else if (node.type == NODE_CURLYNAME) {
15240 return this.compile_curlyname(node);
15241 }
15242 else if (node.type == NODE_ENV) {
15243 return this.compile_env(node);
15244 }
15245 else if (node.type == NODE_REG) {
15246 return this.compile_reg(node);
15247 }
15248 else if (node.type == NODE_CURLYNAMEPART) {
15249 return this.compile_curlynamepart(node);
15250 }
15251 else if (node.type == NODE_CURLYNAMEEXPR) {
15252 return this.compile_curlynameexpr(node);
15253 }
15254 else if (node.type == NODE_LAMBDA) {
15255 return this.compile_lambda(node);
15256 }
15257 else if (node.type == NODE_HEREDOC) {
15258 return this.compile_heredoc(node);
15259 }
15260 else {
15261 throw viml_printf("Compiler: unknown node: %s", viml_string(node));
15262 }
15263 return NIL;
15264}
15265
15266Compiler.prototype.compile_body = function(body) {
15267 var __c10 = body;
15268 for (var __i10 = 0; __i10 < __c10.length; ++__i10) {
15269 var node = __c10[__i10];
15270 this.compile(node);
15271 }
15272}
15273
15274Compiler.prototype.compile_toplevel = function(node) {
15275 this.compile_body(node.body);
15276 return this.lines;
15277}
15278
15279Compiler.prototype.compile_comment = function(node) {
15280 this.out(";%s", node.str);
15281}
15282
15283Compiler.prototype.compile_excmd = function(node) {
15284 this.out("(excmd \"%s\")", viml_escape(node.str, "\\\""));
15285}
15286
15287Compiler.prototype.compile_function = function(node) {
15288 var left = this.compile(node.left);
15289 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
15290 var default_args = node.default_args.map((function(vval) { return this.compile(vval); }).bind(this));
15291 if (!viml_empty(rlist)) {
15292 var remaining = FALSE;
15293 if (rlist[rlist.length - 1] == "...") {
15294 viml_remove(rlist, -1);
15295 var remaining = TRUE;
15296 }
15297 var __c11 = viml_range(viml_len(rlist));
15298 for (var __i11 = 0; __i11 < __c11.length; ++__i11) {
15299 var i = __c11[__i11];
15300 if (i < viml_len(rlist) - viml_len(default_args)) {
15301 left += viml_printf(" %s", rlist[i]);
15302 }
15303 else {
15304 left += viml_printf(" (%s %s)", rlist[i], default_args[i + viml_len(default_args) - viml_len(rlist)]);
15305 }
15306 }
15307 if (remaining) {
15308 left += " . ...";
15309 }
15310 }
15311 this.out("(function (%s)", left);
15312 this.incindent(" ");
15313 this.compile_body(node.body);
15314 this.out(")");
15315 this.decindent();
15316}
15317
15318Compiler.prototype.compile_delfunction = function(node) {
15319 this.out("(delfunction %s)", this.compile(node.left));
15320}
15321
15322Compiler.prototype.compile_return = function(node) {
15323 if (node.left === NIL) {
15324 this.out("(return)");
15325 }
15326 else {
15327 this.out("(return %s)", this.compile(node.left));
15328 }
15329}
15330
15331Compiler.prototype.compile_excall = function(node) {
15332 this.out("(call %s)", this.compile(node.left));
15333}
15334
15335Compiler.prototype.compile_eval = function(node) {
15336 this.out("(eval %s)", this.compile(node.left));
15337}
15338
15339Compiler.prototype.compile_let = function(node) {
15340 var left = "";
15341 if (node.left !== NIL) {
15342 var left = this.compile(node.left);
15343 }
15344 else {
15345 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
15346 if (node.rest !== NIL) {
15347 left += " . " + this.compile(node.rest);
15348 }
15349 var left = "(" + left + ")";
15350 }
15351 var right = this.compile(node.right);
15352 this.out("(let %s %s %s)", node.op, left, right);
15353}
15354
15355// TODO: merge with s:Compiler.compile_let() ?
15356Compiler.prototype.compile_const = function(node) {
15357 var left = "";
15358 if (node.left !== NIL) {
15359 var left = this.compile(node.left);
15360 }
15361 else {
15362 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
15363 if (node.rest !== NIL) {
15364 left += " . " + this.compile(node.rest);
15365 }
15366 var left = "(" + left + ")";
15367 }
15368 var right = this.compile(node.right);
15369 this.out("(const %s %s %s)", node.op, left, right);
15370}
15371
15372Compiler.prototype.compile_unlet = function(node) {
15373 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15374 this.out("(unlet %s)", viml_join(list, " "));
15375}
15376
15377Compiler.prototype.compile_lockvar = function(node) {
15378 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15379 if (node.depth === NIL) {
15380 this.out("(lockvar %s)", viml_join(list, " "));
15381 }
15382 else {
15383 this.out("(lockvar %s %s)", node.depth, viml_join(list, " "));
15384 }
15385}
15386
15387Compiler.prototype.compile_unlockvar = function(node) {
15388 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15389 if (node.depth === NIL) {
15390 this.out("(unlockvar %s)", viml_join(list, " "));
15391 }
15392 else {
15393 this.out("(unlockvar %s %s)", node.depth, viml_join(list, " "));
15394 }
15395}
15396
15397Compiler.prototype.compile_if = function(node) {
15398 this.out("(if %s", this.compile(node.cond));
15399 this.incindent(" ");
15400 this.compile_body(node.body);
15401 this.decindent();
15402 var __c12 = node.elseif;
15403 for (var __i12 = 0; __i12 < __c12.length; ++__i12) {
15404 var enode = __c12[__i12];
15405 this.out(" elseif %s", this.compile(enode.cond));
15406 this.incindent(" ");
15407 this.compile_body(enode.body);
15408 this.decindent();
15409 }
15410 if (node._else !== NIL) {
15411 this.out(" else");
15412 this.incindent(" ");
15413 this.compile_body(node._else.body);
15414 this.decindent();
15415 }
15416 this.incindent(" ");
15417 this.out(")");
15418 this.decindent();
15419}
15420
15421Compiler.prototype.compile_while = function(node) {
15422 this.out("(while %s", this.compile(node.cond));
15423 this.incindent(" ");
15424 this.compile_body(node.body);
15425 this.out(")");
15426 this.decindent();
15427}
15428
15429Compiler.prototype.compile_for = function(node) {
15430 var left = "";
15431 if (node.left !== NIL) {
15432 var left = this.compile(node.left);
15433 }
15434 else {
15435 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
15436 if (node.rest !== NIL) {
15437 left += " . " + this.compile(node.rest);
15438 }
15439 var left = "(" + left + ")";
15440 }
15441 var right = this.compile(node.right);
15442 this.out("(for %s %s", left, right);
15443 this.incindent(" ");
15444 this.compile_body(node.body);
15445 this.out(")");
15446 this.decindent();
15447}
15448
15449Compiler.prototype.compile_continue = function(node) {
15450 this.out("(continue)");
15451}
15452
15453Compiler.prototype.compile_break = function(node) {
15454 this.out("(break)");
15455}
15456
15457Compiler.prototype.compile_try = function(node) {
15458 this.out("(try");
15459 this.incindent(" ");
15460 this.compile_body(node.body);
15461 var __c13 = node.catch;
15462 for (var __i13 = 0; __i13 < __c13.length; ++__i13) {
15463 var cnode = __c13[__i13];
15464 if (cnode.pattern !== NIL) {
15465 this.decindent();
15466 this.out(" catch /%s/", cnode.pattern);
15467 this.incindent(" ");
15468 this.compile_body(cnode.body);
15469 }
15470 else {
15471 this.decindent();
15472 this.out(" catch");
15473 this.incindent(" ");
15474 this.compile_body(cnode.body);
15475 }
15476 }
15477 if (node._finally !== NIL) {
15478 this.decindent();
15479 this.out(" finally");
15480 this.incindent(" ");
15481 this.compile_body(node._finally.body);
15482 }
15483 this.out(")");
15484 this.decindent();
15485}
15486
15487Compiler.prototype.compile_throw = function(node) {
15488 this.out("(throw %s)", this.compile(node.left));
15489}
15490
15491Compiler.prototype.compile_echo = function(node) {
15492 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15493 this.out("(echo %s)", viml_join(list, " "));
15494}
15495
15496Compiler.prototype.compile_echon = function(node) {
15497 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15498 this.out("(echon %s)", viml_join(list, " "));
15499}
15500
15501Compiler.prototype.compile_echohl = function(node) {
15502 this.out("(echohl \"%s\")", viml_escape(node.str, "\\\""));
15503}
15504
15505Compiler.prototype.compile_echomsg = function(node) {
15506 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15507 this.out("(echomsg %s)", viml_join(list, " "));
15508}
15509
15510Compiler.prototype.compile_echoerr = function(node) {
15511 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15512 this.out("(echoerr %s)", viml_join(list, " "));
15513}
15514
15515Compiler.prototype.compile_execute = function(node) {
15516 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
15517 this.out("(execute %s)", viml_join(list, " "));
15518}
15519
15520Compiler.prototype.compile_ternary = function(node) {
15521 return viml_printf("(?: %s %s %s)", this.compile(node.cond), this.compile(node.left), this.compile(node.right));
15522}
15523
15524Compiler.prototype.compile_or = function(node) {
15525 return viml_printf("(|| %s %s)", this.compile(node.left), this.compile(node.right));
15526}
15527
15528Compiler.prototype.compile_and = function(node) {
15529 return viml_printf("(&& %s %s)", this.compile(node.left), this.compile(node.right));
15530}
15531
15532Compiler.prototype.compile_equal = function(node) {
15533 return viml_printf("(== %s %s)", this.compile(node.left), this.compile(node.right));
15534}
15535
15536Compiler.prototype.compile_equalci = function(node) {
15537 return viml_printf("(==? %s %s)", this.compile(node.left), this.compile(node.right));
15538}
15539
15540Compiler.prototype.compile_equalcs = function(node) {
15541 return viml_printf("(==# %s %s)", this.compile(node.left), this.compile(node.right));
15542}
15543
15544Compiler.prototype.compile_nequal = function(node) {
15545 return viml_printf("(!= %s %s)", this.compile(node.left), this.compile(node.right));
15546}
15547
15548Compiler.prototype.compile_nequalci = function(node) {
15549 return viml_printf("(!=? %s %s)", this.compile(node.left), this.compile(node.right));
15550}
15551
15552Compiler.prototype.compile_nequalcs = function(node) {
15553 return viml_printf("(!=# %s %s)", this.compile(node.left), this.compile(node.right));
15554}
15555
15556Compiler.prototype.compile_greater = function(node) {
15557 return viml_printf("(> %s %s)", this.compile(node.left), this.compile(node.right));
15558}
15559
15560Compiler.prototype.compile_greaterci = function(node) {
15561 return viml_printf("(>? %s %s)", this.compile(node.left), this.compile(node.right));
15562}
15563
15564Compiler.prototype.compile_greatercs = function(node) {
15565 return viml_printf("(># %s %s)", this.compile(node.left), this.compile(node.right));
15566}
15567
15568Compiler.prototype.compile_gequal = function(node) {
15569 return viml_printf("(>= %s %s)", this.compile(node.left), this.compile(node.right));
15570}
15571
15572Compiler.prototype.compile_gequalci = function(node) {
15573 return viml_printf("(>=? %s %s)", this.compile(node.left), this.compile(node.right));
15574}
15575
15576Compiler.prototype.compile_gequalcs = function(node) {
15577 return viml_printf("(>=# %s %s)", this.compile(node.left), this.compile(node.right));
15578}
15579
15580Compiler.prototype.compile_smaller = function(node) {
15581 return viml_printf("(< %s %s)", this.compile(node.left), this.compile(node.right));
15582}
15583
15584Compiler.prototype.compile_smallerci = function(node) {
15585 return viml_printf("(<? %s %s)", this.compile(node.left), this.compile(node.right));
15586}
15587
15588Compiler.prototype.compile_smallercs = function(node) {
15589 return viml_printf("(<# %s %s)", this.compile(node.left), this.compile(node.right));
15590}
15591
15592Compiler.prototype.compile_sequal = function(node) {
15593 return viml_printf("(<= %s %s)", this.compile(node.left), this.compile(node.right));
15594}
15595
15596Compiler.prototype.compile_sequalci = function(node) {
15597 return viml_printf("(<=? %s %s)", this.compile(node.left), this.compile(node.right));
15598}
15599
15600Compiler.prototype.compile_sequalcs = function(node) {
15601 return viml_printf("(<=# %s %s)", this.compile(node.left), this.compile(node.right));
15602}
15603
15604Compiler.prototype.compile_match = function(node) {
15605 return viml_printf("(=~ %s %s)", this.compile(node.left), this.compile(node.right));
15606}
15607
15608Compiler.prototype.compile_matchci = function(node) {
15609 return viml_printf("(=~? %s %s)", this.compile(node.left), this.compile(node.right));
15610}
15611
15612Compiler.prototype.compile_matchcs = function(node) {
15613 return viml_printf("(=~# %s %s)", this.compile(node.left), this.compile(node.right));
15614}
15615
15616Compiler.prototype.compile_nomatch = function(node) {
15617 return viml_printf("(!~ %s %s)", this.compile(node.left), this.compile(node.right));
15618}
15619
15620Compiler.prototype.compile_nomatchci = function(node) {
15621 return viml_printf("(!~? %s %s)", this.compile(node.left), this.compile(node.right));
15622}
15623
15624Compiler.prototype.compile_nomatchcs = function(node) {
15625 return viml_printf("(!~# %s %s)", this.compile(node.left), this.compile(node.right));
15626}
15627
15628Compiler.prototype.compile_is = function(node) {
15629 return viml_printf("(is %s %s)", this.compile(node.left), this.compile(node.right));
15630}
15631
15632Compiler.prototype.compile_isci = function(node) {
15633 return viml_printf("(is? %s %s)", this.compile(node.left), this.compile(node.right));
15634}
15635
15636Compiler.prototype.compile_iscs = function(node) {
15637 return viml_printf("(is# %s %s)", this.compile(node.left), this.compile(node.right));
15638}
15639
15640Compiler.prototype.compile_isnot = function(node) {
15641 return viml_printf("(isnot %s %s)", this.compile(node.left), this.compile(node.right));
15642}
15643
15644Compiler.prototype.compile_isnotci = function(node) {
15645 return viml_printf("(isnot? %s %s)", this.compile(node.left), this.compile(node.right));
15646}
15647
15648Compiler.prototype.compile_isnotcs = function(node) {
15649 return viml_printf("(isnot# %s %s)", this.compile(node.left), this.compile(node.right));
15650}
15651
15652Compiler.prototype.compile_add = function(node) {
15653 return viml_printf("(+ %s %s)", this.compile(node.left), this.compile(node.right));
15654}
15655
15656Compiler.prototype.compile_subtract = function(node) {
15657 return viml_printf("(- %s %s)", this.compile(node.left), this.compile(node.right));
15658}
15659
15660Compiler.prototype.compile_concat = function(node) {
15661 return viml_printf("(concat %s %s)", this.compile(node.left), this.compile(node.right));
15662}
15663
15664Compiler.prototype.compile_multiply = function(node) {
15665 return viml_printf("(* %s %s)", this.compile(node.left), this.compile(node.right));
15666}
15667
15668Compiler.prototype.compile_divide = function(node) {
15669 return viml_printf("(/ %s %s)", this.compile(node.left), this.compile(node.right));
15670}
15671
15672Compiler.prototype.compile_remainder = function(node) {
15673 return viml_printf("(%% %s %s)", this.compile(node.left), this.compile(node.right));
15674}
15675
15676Compiler.prototype.compile_not = function(node) {
15677 return viml_printf("(! %s)", this.compile(node.left));
15678}
15679
15680Compiler.prototype.compile_plus = function(node) {
15681 return viml_printf("(+ %s)", this.compile(node.left));
15682}
15683
15684Compiler.prototype.compile_minus = function(node) {
15685 return viml_printf("(- %s)", this.compile(node.left));
15686}
15687
15688Compiler.prototype.compile_subscript = function(node) {
15689 return viml_printf("(subscript %s %s)", this.compile(node.left), this.compile(node.right));
15690}
15691
15692Compiler.prototype.compile_slice = function(node) {
15693 var r0 = node.rlist[0] === NIL ? "nil" : this.compile(node.rlist[0]);
15694 var r1 = node.rlist[1] === NIL ? "nil" : this.compile(node.rlist[1]);
15695 return viml_printf("(slice %s %s %s)", this.compile(node.left), r0, r1);
15696}
15697
15698Compiler.prototype.compile_dot = function(node) {
15699 return viml_printf("(dot %s %s)", this.compile(node.left), this.compile(node.right));
15700}
15701
15702Compiler.prototype.compile_method = function(node) {
15703 return viml_printf("(method %s %s)", this.compile(node.left), this.compile(node.right));
15704}
15705
15706Compiler.prototype.compile_call = function(node) {
15707 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
15708 if (viml_empty(rlist)) {
15709 return viml_printf("(%s)", this.compile(node.left));
15710 }
15711 else {
15712 return viml_printf("(%s %s)", this.compile(node.left), viml_join(rlist, " "));
15713 }
15714}
15715
15716Compiler.prototype.compile_number = function(node) {
15717 return node.value;
15718}
15719
15720Compiler.prototype.compile_blob = function(node) {
15721 return node.value;
15722}
15723
15724Compiler.prototype.compile_string = function(node) {
15725 return node.value;
15726}
15727
15728Compiler.prototype.compile_list = function(node) {
15729 var value = node.value.map((function(vval) { return this.compile(vval); }).bind(this));
15730 if (viml_empty(value)) {
15731 return "(list)";
15732 }
15733 else {
15734 return viml_printf("(list %s)", viml_join(value, " "));
15735 }
15736}
15737
15738Compiler.prototype.compile_dict = function(node) {
15739 var value = node.value.map((function(vval) { return "(" + this.compile(vval[0]) + " " + this.compile(vval[1]) + ")"; }).bind(this));
15740 if (viml_empty(value)) {
15741 return "(dict)";
15742 }
15743 else {
15744 return viml_printf("(dict %s)", viml_join(value, " "));
15745 }
15746}
15747
15748Compiler.prototype.compile_option = function(node) {
15749 return node.value;
15750}
15751
15752Compiler.prototype.compile_identifier = function(node) {
15753 return node.value;
15754}
15755
15756Compiler.prototype.compile_curlyname = function(node) {
15757 return viml_join(node.value.map((function(vval) { return this.compile(vval); }).bind(this)), "");
15758}
15759
15760Compiler.prototype.compile_env = function(node) {
15761 return node.value;
15762}
15763
15764Compiler.prototype.compile_reg = function(node) {
15765 return node.value;
15766}
15767
15768Compiler.prototype.compile_curlynamepart = function(node) {
15769 return node.value;
15770}
15771
15772Compiler.prototype.compile_curlynameexpr = function(node) {
15773 return "{" + this.compile(node.value) + "}";
15774}
15775
15776Compiler.prototype.escape_string = function(str) {
15777 var m = {"\n":"\\n", "\t":"\\t", "\r":"\\r"};
15778 var out = "\"";
15779 var __c14 = viml_range(viml_len(str));
15780 for (var __i14 = 0; __i14 < __c14.length; ++__i14) {
15781 var i = __c14[__i14];
15782 var c = str[i];
15783 if (viml_has_key(m, c)) {
15784 out += m[c];
15785 }
15786 else {
15787 out += c;
15788 }
15789 }
15790 out += "\"";
15791 return out;
15792}
15793
15794Compiler.prototype.compile_lambda = function(node) {
15795 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
15796 return viml_printf("(lambda (%s) %s)", viml_join(rlist, " "), this.compile(node.left));
15797}
15798
15799Compiler.prototype.compile_heredoc = function(node) {
15800 if (viml_empty(node.rlist)) {
15801 var rlist = "(list)";
15802 }
15803 else {
15804 var rlist = "(list " + viml_join(node.rlist.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
15805 }
15806 if (viml_empty(node.body)) {
15807 var body = "(list)";
15808 }
15809 else {
15810 var body = "(list " + viml_join(node.body.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
15811 }
15812 var op = this.escape_string(node.op);
15813 return viml_printf("(heredoc %s %s %s)", rlist, op, body);
15814}
15815
15816// TODO: under construction
15817function RegexpParser() { this.__init__.apply(this, arguments); }
15818RegexpParser.prototype.RE_VERY_NOMAGIC = 1;
15819RegexpParser.prototype.RE_NOMAGIC = 2;
15820RegexpParser.prototype.RE_MAGIC = 3;
15821RegexpParser.prototype.RE_VERY_MAGIC = 4;
15822RegexpParser.prototype.__init__ = function(reader, cmd, delim) {
15823 this.reader = reader;
15824 this.cmd = cmd;
15825 this.delim = delim;
15826 this.reg_magic = this.RE_MAGIC;
15827}
15828
15829RegexpParser.prototype.isend = function(c) {
15830 return c == "<EOF>" || c == "<EOL>" || c == this.delim;
15831}
15832
15833RegexpParser.prototype.parse_regexp = function() {
15834 var prevtoken = "";
15835 var ntoken = "";
15836 var ret = [];
15837 if (this.reader.peekn(4) == "\\%#=") {
15838 var epos = this.reader.getpos();
15839 var token = this.reader.getn(5);
15840 if (token != "\\%#=0" && token != "\\%#=1" && token != "\\%#=2") {
15841 throw Err("E864: \\%#= can only be followed by 0, 1, or 2", epos);
15842 }
15843 viml_add(ret, token);
15844 }
15845 while (!this.isend(this.reader.peek())) {
15846 var prevtoken = ntoken;
15847 var __tmp = this.get_token();
15848 var token = __tmp[0];
15849 var ntoken = __tmp[1];
15850 if (ntoken == "\\m") {
15851 this.reg_magic = this.RE_MAGIC;
15852 }
15853 else if (ntoken == "\\M") {
15854 this.reg_magic = this.RE_NOMAGIC;
15855 }
15856 else if (ntoken == "\\v") {
15857 this.reg_magic = this.RE_VERY_MAGIC;
15858 }
15859 else if (ntoken == "\\V") {
15860 this.reg_magic = this.RE_VERY_NOMAGIC;
15861 }
15862 else if (ntoken == "\\*") {
15863 // '*' is not magic as the very first character.
15864 if (prevtoken == "" || prevtoken == "\\^" || prevtoken == "\\&" || prevtoken == "\\|" || prevtoken == "\\(") {
15865 var ntoken = "*";
15866 }
15867 }
15868 else if (ntoken == "\\^") {
15869 // '^' is only magic as the very first character.
15870 if (this.reg_magic != this.RE_VERY_MAGIC && prevtoken != "" && prevtoken != "\\&" && prevtoken != "\\|" && prevtoken != "\\n" && prevtoken != "\\(" && prevtoken != "\\%(") {
15871 var ntoken = "^";
15872 }
15873 }
15874 else if (ntoken == "\\$") {
15875 // '$' is only magic as the very last character
15876 var pos = this.reader.tell();
15877 if (this.reg_magic != this.RE_VERY_MAGIC) {
15878 while (!this.isend(this.reader.peek())) {
15879 var __tmp = this.get_token();
15880 var t = __tmp[0];
15881 var n = __tmp[1];
15882 // XXX: Vim doesn't check \v and \V?
15883 if (n == "\\c" || n == "\\C" || n == "\\m" || n == "\\M" || n == "\\Z") {
15884 continue;
15885 }
15886 if (n != "\\|" && n != "\\&" && n != "\\n" && n != "\\)") {
15887 var ntoken = "$";
15888 }
15889 break;
15890 }
15891 }
15892 this.reader.seek_set(pos);
15893 }
15894 else if (ntoken == "\\?") {
15895 // '?' is literal in '?' command.
15896 if (this.cmd == "?") {
15897 var ntoken = "?";
15898 }
15899 }
15900 viml_add(ret, ntoken);
15901 }
15902 return ret;
15903}
15904
15905// @return [actual_token, normalized_token]
15906RegexpParser.prototype.get_token = function() {
15907 if (this.reg_magic == this.RE_VERY_MAGIC) {
15908 return this.get_token_very_magic();
15909 }
15910 else if (this.reg_magic == this.RE_MAGIC) {
15911 return this.get_token_magic();
15912 }
15913 else if (this.reg_magic == this.RE_NOMAGIC) {
15914 return this.get_token_nomagic();
15915 }
15916 else if (this.reg_magic == this.RE_VERY_NOMAGIC) {
15917 return this.get_token_very_nomagic();
15918 }
15919}
15920
15921RegexpParser.prototype.get_token_very_magic = function() {
15922 if (this.isend(this.reader.peek())) {
15923 return ["<END>", "<END>"];
15924 }
15925 var c = this.reader.get();
15926 if (c == "\\") {
15927 return this.get_token_backslash_common();
15928 }
15929 else if (c == "*") {
15930 return ["*", "\\*"];
15931 }
15932 else if (c == "+") {
15933 return ["+", "\\+"];
15934 }
15935 else if (c == "=") {
15936 return ["=", "\\="];
15937 }
15938 else if (c == "?") {
15939 return ["?", "\\?"];
15940 }
15941 else if (c == "{") {
15942 return this.get_token_brace("{");
15943 }
15944 else if (c == "@") {
15945 return this.get_token_at("@");
15946 }
15947 else if (c == "^") {
15948 return ["^", "\\^"];
15949 }
15950 else if (c == "$") {
15951 return ["$", "\\$"];
15952 }
15953 else if (c == ".") {
15954 return [".", "\\."];
15955 }
15956 else if (c == "<") {
15957 return ["<", "\\<"];
15958 }
15959 else if (c == ">") {
15960 return [">", "\\>"];
15961 }
15962 else if (c == "%") {
15963 return this.get_token_percent("%");
15964 }
15965 else if (c == "[") {
15966 return this.get_token_sq("[");
15967 }
15968 else if (c == "~") {
15969 return ["~", "\\~"];
15970 }
15971 else if (c == "|") {
15972 return ["|", "\\|"];
15973 }
15974 else if (c == "&") {
15975 return ["&", "\\&"];
15976 }
15977 else if (c == "(") {
15978 return ["(", "\\("];
15979 }
15980 else if (c == ")") {
15981 return [")", "\\)"];
15982 }
15983 return [c, c];
15984}
15985
15986RegexpParser.prototype.get_token_magic = function() {
15987 if (this.isend(this.reader.peek())) {
15988 return ["<END>", "<END>"];
15989 }
15990 var c = this.reader.get();
15991 if (c == "\\") {
15992 var pos = this.reader.tell();
15993 var c = this.reader.get();
15994 if (c == "+") {
15995 return ["\\+", "\\+"];
15996 }
15997 else if (c == "=") {
15998 return ["\\=", "\\="];
15999 }
16000 else if (c == "?") {
16001 return ["\\?", "\\?"];
16002 }
16003 else if (c == "{") {
16004 return this.get_token_brace("\\{");
16005 }
16006 else if (c == "@") {
16007 return this.get_token_at("\\@");
16008 }
16009 else if (c == "<") {
16010 return ["\\<", "\\<"];
16011 }
16012 else if (c == ">") {
16013 return ["\\>", "\\>"];
16014 }
16015 else if (c == "%") {
16016 return this.get_token_percent("\\%");
16017 }
16018 else if (c == "|") {
16019 return ["\\|", "\\|"];
16020 }
16021 else if (c == "&") {
16022 return ["\\&", "\\&"];
16023 }
16024 else if (c == "(") {
16025 return ["\\(", "\\("];
16026 }
16027 else if (c == ")") {
16028 return ["\\)", "\\)"];
16029 }
16030 this.reader.seek_set(pos);
16031 return this.get_token_backslash_common();
16032 }
16033 else if (c == "*") {
16034 return ["*", "\\*"];
16035 }
16036 else if (c == "^") {
16037 return ["^", "\\^"];
16038 }
16039 else if (c == "$") {
16040 return ["$", "\\$"];
16041 }
16042 else if (c == ".") {
16043 return [".", "\\."];
16044 }
16045 else if (c == "[") {
16046 return this.get_token_sq("[");
16047 }
16048 else if (c == "~") {
16049 return ["~", "\\~"];
16050 }
16051 return [c, c];
16052}
16053
16054RegexpParser.prototype.get_token_nomagic = function() {
16055 if (this.isend(this.reader.peek())) {
16056 return ["<END>", "<END>"];
16057 }
16058 var c = this.reader.get();
16059 if (c == "\\") {
16060 var pos = this.reader.tell();
16061 var c = this.reader.get();
16062 if (c == "*") {
16063 return ["\\*", "\\*"];
16064 }
16065 else if (c == "+") {
16066 return ["\\+", "\\+"];
16067 }
16068 else if (c == "=") {
16069 return ["\\=", "\\="];
16070 }
16071 else if (c == "?") {
16072 return ["\\?", "\\?"];
16073 }
16074 else if (c == "{") {
16075 return this.get_token_brace("\\{");
16076 }
16077 else if (c == "@") {
16078 return this.get_token_at("\\@");
16079 }
16080 else if (c == ".") {
16081 return ["\\.", "\\."];
16082 }
16083 else if (c == "<") {
16084 return ["\\<", "\\<"];
16085 }
16086 else if (c == ">") {
16087 return ["\\>", "\\>"];
16088 }
16089 else if (c == "%") {
16090 return this.get_token_percent("\\%");
16091 }
16092 else if (c == "~") {
16093 return ["\\~", "\\^"];
16094 }
16095 else if (c == "[") {
16096 return this.get_token_sq("\\[");
16097 }
16098 else if (c == "|") {
16099 return ["\\|", "\\|"];
16100 }
16101 else if (c == "&") {
16102 return ["\\&", "\\&"];
16103 }
16104 else if (c == "(") {
16105 return ["\\(", "\\("];
16106 }
16107 else if (c == ")") {
16108 return ["\\)", "\\)"];
16109 }
16110 this.reader.seek_set(pos);
16111 return this.get_token_backslash_common();
16112 }
16113 else if (c == "^") {
16114 return ["^", "\\^"];
16115 }
16116 else if (c == "$") {
16117 return ["$", "\\$"];
16118 }
16119 return [c, c];
16120}
16121
16122RegexpParser.prototype.get_token_very_nomagic = function() {
16123 if (this.isend(this.reader.peek())) {
16124 return ["<END>", "<END>"];
16125 }
16126 var c = this.reader.get();
16127 if (c == "\\") {
16128 var pos = this.reader.tell();
16129 var c = this.reader.get();
16130 if (c == "*") {
16131 return ["\\*", "\\*"];
16132 }
16133 else if (c == "+") {
16134 return ["\\+", "\\+"];
16135 }
16136 else if (c == "=") {
16137 return ["\\=", "\\="];
16138 }
16139 else if (c == "?") {
16140 return ["\\?", "\\?"];
16141 }
16142 else if (c == "{") {
16143 return this.get_token_brace("\\{");
16144 }
16145 else if (c == "@") {
16146 return this.get_token_at("\\@");
16147 }
16148 else if (c == "^") {
16149 return ["\\^", "\\^"];
16150 }
16151 else if (c == "$") {
16152 return ["\\$", "\\$"];
16153 }
16154 else if (c == "<") {
16155 return ["\\<", "\\<"];
16156 }
16157 else if (c == ">") {
16158 return ["\\>", "\\>"];
16159 }
16160 else if (c == "%") {
16161 return this.get_token_percent("\\%");
16162 }
16163 else if (c == "~") {
16164 return ["\\~", "\\~"];
16165 }
16166 else if (c == "[") {
16167 return this.get_token_sq("\\[");
16168 }
16169 else if (c == "|") {
16170 return ["\\|", "\\|"];
16171 }
16172 else if (c == "&") {
16173 return ["\\&", "\\&"];
16174 }
16175 else if (c == "(") {
16176 return ["\\(", "\\("];
16177 }
16178 else if (c == ")") {
16179 return ["\\)", "\\)"];
16180 }
16181 this.reader.seek_set(pos);
16182 return this.get_token_backslash_common();
16183 }
16184 return [c, c];
16185}
16186
16187RegexpParser.prototype.get_token_backslash_common = function() {
16188 var cclass = "iIkKfFpPsSdDxXoOwWhHaAlLuU";
16189 var c = this.reader.get();
16190 if (c == "\\") {
16191 return ["\\\\", "\\\\"];
16192 }
16193 else if (viml_stridx(cclass, c) != -1) {
16194 return ["\\" + c, "\\" + c];
16195 }
16196 else if (c == "_") {
16197 var epos = this.reader.getpos();
16198 var c = this.reader.get();
16199 if (viml_stridx(cclass, c) != -1) {
16200 return ["\\_" + c, "\\_ . c"];
16201 }
16202 else if (c == "^") {
16203 return ["\\_^", "\\_^"];
16204 }
16205 else if (c == "$") {
16206 return ["\\_$", "\\_$"];
16207 }
16208 else if (c == ".") {
16209 return ["\\_.", "\\_."];
16210 }
16211 else if (c == "[") {
16212 return this.get_token_sq("\\_[");
16213 }
16214 throw Err("E63: Invalid use of \\_", epos);
16215 }
16216 else if (viml_stridx("etrb", c) != -1) {
16217 return ["\\" + c, "\\" + c];
16218 }
16219 else if (viml_stridx("123456789", c) != -1) {
16220 return ["\\" + c, "\\" + c];
16221 }
16222 else if (c == "z") {
16223 var epos = this.reader.getpos();
16224 var c = this.reader.get();
16225 if (viml_stridx("123456789", c) != -1) {
16226 return ["\\z" + c, "\\z" + c];
16227 }
16228 else if (c == "s") {
16229 return ["\\zs", "\\zs"];
16230 }
16231 else if (c == "e") {
16232 return ["\\ze", "\\ze"];
16233 }
16234 else if (c == "(") {
16235 return ["\\z(", "\\z("];
16236 }
16237 throw Err("E68: Invalid character after \\z", epos);
16238 }
16239 else if (viml_stridx("cCmMvVZ", c) != -1) {
16240 return ["\\" + c, "\\" + c];
16241 }
16242 else if (c == "%") {
16243 var epos = this.reader.getpos();
16244 var c = this.reader.get();
16245 if (c == "d") {
16246 var r = this.getdecchrs();
16247 if (r != "") {
16248 return ["\\%d" + r, "\\%d" + r];
16249 }
16250 }
16251 else if (c == "o") {
16252 var r = this.getoctchrs();
16253 if (r != "") {
16254 return ["\\%o" + r, "\\%o" + r];
16255 }
16256 }
16257 else if (c == "x") {
16258 var r = this.gethexchrs(2);
16259 if (r != "") {
16260 return ["\\%x" + r, "\\%x" + r];
16261 }
16262 }
16263 else if (c == "u") {
16264 var r = this.gethexchrs(4);
16265 if (r != "") {
16266 return ["\\%u" + r, "\\%u" + r];
16267 }
16268 }
16269 else if (c == "U") {
16270 var r = this.gethexchrs(8);
16271 if (r != "") {
16272 return ["\\%U" + r, "\\%U" + r];
16273 }
16274 }
16275 throw Err("E678: Invalid character after \\%[dxouU]", epos);
16276 }
16277 return ["\\" + c, c];
16278}
16279
16280// \{}
16281RegexpParser.prototype.get_token_brace = function(pre) {
16282 var r = "";
16283 var minus = "";
16284 var comma = "";
16285 var n = "";
16286 var m = "";
16287 if (this.reader.p(0) == "-") {
16288 var minus = this.reader.get();
16289 r += minus;
16290 }
16291 if (isdigit(this.reader.p(0))) {
16292 var n = this.reader.read_digit();
16293 r += n;
16294 }
16295 if (this.reader.p(0) == ",") {
16296 var comma = this.rader.get();
16297 r += comma;
16298 }
16299 if (isdigit(this.reader.p(0))) {
16300 var m = this.reader.read_digit();
16301 r += m;
16302 }
16303 if (this.reader.p(0) == "\\") {
16304 r += this.reader.get();
16305 }
16306 if (this.reader.p(0) != "}") {
16307 throw Err("E554: Syntax error in \\{...}", this.reader.getpos());
16308 }
16309 this.reader.get();
16310 return [pre + r, "\\{" + minus + n + comma + m + "}"];
16311}
16312
16313// \[]
16314RegexpParser.prototype.get_token_sq = function(pre) {
16315 var start = this.reader.tell();
16316 var r = "";
16317 // Complement of range
16318 if (this.reader.p(0) == "^") {
16319 r += this.reader.get();
16320 }
16321 // At the start ']' and '-' mean the literal character.
16322 if (this.reader.p(0) == "]" || this.reader.p(0) == "-") {
16323 r += this.reader.get();
16324 }
16325 while (TRUE) {
16326 var startc = 0;
16327 var c = this.reader.p(0);
16328 if (this.isend(c)) {
16329 // If there is no matching ']', we assume the '[' is a normal character.
16330 this.reader.seek_set(start);
16331 return [pre, "["];
16332 }
16333 else if (c == "]") {
16334 this.reader.seek_cur(1);
16335 return [pre + r + "]", "\\[" + r + "]"];
16336 }
16337 else if (c == "[") {
16338 var e = this.get_token_sq_char_class();
16339 if (e == "") {
16340 var e = this.get_token_sq_equi_class();
16341 if (e == "") {
16342 var e = this.get_token_sq_coll_element();
16343 if (e == "") {
16344 var __tmp = this.get_token_sq_c();
16345 var e = __tmp[0];
16346 var startc = __tmp[1];
16347 }
16348 }
16349 }
16350 r += e;
16351 }
16352 else {
16353 var __tmp = this.get_token_sq_c();
16354 var e = __tmp[0];
16355 var startc = __tmp[1];
16356 r += e;
16357 }
16358 if (startc != 0 && this.reader.p(0) == "-" && !this.isend(this.reader.p(1)) && !(this.reader.p(1) == "\\" && this.reader.p(2) == "n")) {
16359 this.reader.seek_cur(1);
16360 r += "-";
16361 var c = this.reader.p(0);
16362 if (c == "[") {
16363 var e = this.get_token_sq_coll_element();
16364 if (e != "") {
16365 var endc = viml_char2nr(e[2]);
16366 }
16367 else {
16368 var __tmp = this.get_token_sq_c();
16369 var e = __tmp[0];
16370 var endc = __tmp[1];
16371 }
16372 r += e;
16373 }
16374 else {
16375 var __tmp = this.get_token_sq_c();
16376 var e = __tmp[0];
16377 var endc = __tmp[1];
16378 r += e;
16379 }
16380 if (startc > endc || endc > startc + 256) {
16381 throw Err("E16: Invalid range", this.reader.getpos());
16382 }
16383 }
16384 }
16385}
16386
16387// [c]
16388RegexpParser.prototype.get_token_sq_c = function() {
16389 var c = this.reader.p(0);
16390 if (c == "\\") {
16391 this.reader.seek_cur(1);
16392 var c = this.reader.p(0);
16393 if (c == "n") {
16394 this.reader.seek_cur(1);
16395 return ["\\n", 0];
16396 }
16397 else if (c == "r") {
16398 this.reader.seek_cur(1);
16399 return ["\\r", 13];
16400 }
16401 else if (c == "t") {
16402 this.reader.seek_cur(1);
16403 return ["\\t", 9];
16404 }
16405 else if (c == "e") {
16406 this.reader.seek_cur(1);
16407 return ["\\e", 27];
16408 }
16409 else if (c == "b") {
16410 this.reader.seek_cur(1);
16411 return ["\\b", 8];
16412 }
16413 else if (viml_stridx("]^-\\", c) != -1) {
16414 this.reader.seek_cur(1);
16415 return ["\\" + c, viml_char2nr(c)];
16416 }
16417 else if (viml_stridx("doxuU", c) != -1) {
16418 var __tmp = this.get_token_sq_coll_char();
16419 var c = __tmp[0];
16420 var n = __tmp[1];
16421 return [c, n];
16422 }
16423 else {
16424 return ["\\", viml_char2nr("\\")];
16425 }
16426 }
16427 else if (c == "-") {
16428 this.reader.seek_cur(1);
16429 return ["-", viml_char2nr("-")];
16430 }
16431 else {
16432 this.reader.seek_cur(1);
16433 return [c, viml_char2nr(c)];
16434 }
16435}
16436
16437// [\d123]
16438RegexpParser.prototype.get_token_sq_coll_char = function() {
16439 var pos = this.reader.tell();
16440 var c = this.reader.get();
16441 if (c == "d") {
16442 var r = this.getdecchrs();
16443 var n = viml_str2nr(r, 10);
16444 }
16445 else if (c == "o") {
16446 var r = this.getoctchrs();
16447 var n = viml_str2nr(r, 8);
16448 }
16449 else if (c == "x") {
16450 var r = this.gethexchrs(2);
16451 var n = viml_str2nr(r, 16);
16452 }
16453 else if (c == "u") {
16454 var r = this.gethexchrs(4);
16455 var n = viml_str2nr(r, 16);
16456 }
16457 else if (c == "U") {
16458 var r = this.gethexchrs(8);
16459 var n = viml_str2nr(r, 16);
16460 }
16461 else {
16462 var r = "";
16463 }
16464 if (r == "") {
16465 this.reader.seek_set(pos);
16466 return "\\";
16467 }
16468 return ["\\" + c + r, n];
16469}
16470
16471// [[.a.]]
16472RegexpParser.prototype.get_token_sq_coll_element = function() {
16473 if (this.reader.p(0) == "[" && this.reader.p(1) == "." && !this.isend(this.reader.p(2)) && this.reader.p(3) == "." && this.reader.p(4) == "]") {
16474 return this.reader.getn(5);
16475 }
16476 return "";
16477}
16478
16479// [[=a=]]
16480RegexpParser.prototype.get_token_sq_equi_class = function() {
16481 if (this.reader.p(0) == "[" && this.reader.p(1) == "=" && !this.isend(this.reader.p(2)) && this.reader.p(3) == "=" && this.reader.p(4) == "]") {
16482 return this.reader.getn(5);
16483 }
16484 return "";
16485}
16486
16487// [[:alpha:]]
16488RegexpParser.prototype.get_token_sq_char_class = function() {
16489 var class_names = ["alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "xdigit", "tab", "return", "backspace", "escape"];
16490 var pos = this.reader.tell();
16491 if (this.reader.p(0) == "[" && this.reader.p(1) == ":") {
16492 this.reader.seek_cur(2);
16493 var r = this.reader.read_alpha();
16494 if (this.reader.p(0) == ":" && this.reader.p(1) == "]") {
16495 this.reader.seek_cur(2);
16496 var __c15 = class_names;
16497 for (var __i15 = 0; __i15 < __c15.length; ++__i15) {
16498 var name = __c15[__i15];
16499 if (r == name) {
16500 return "[:" + name + ":]";
16501 }
16502 }
16503 }
16504 }
16505 this.reader.seek_set(pos);
16506 return "";
16507}
16508
16509// \@...
16510RegexpParser.prototype.get_token_at = function(pre) {
16511 var epos = this.reader.getpos();
16512 var c = this.reader.get();
16513 if (c == ">") {
16514 return [pre + ">", "\\@>"];
16515 }
16516 else if (c == "=") {
16517 return [pre + "=", "\\@="];
16518 }
16519 else if (c == "!") {
16520 return [pre + "!", "\\@!"];
16521 }
16522 else if (c == "<") {
16523 var c = this.reader.get();
16524 if (c == "=") {
16525 return [pre + "<=", "\\@<="];
16526 }
16527 else if (c == "!") {
16528 return [pre + "<!", "\\@<!"];
16529 }
16530 }
16531 throw Err("E64: @ follows nothing", epos);
16532}
16533
16534// \%...
16535RegexpParser.prototype.get_token_percent = function(pre) {
16536 var c = this.reader.get();
16537 if (c == "^") {
16538 return [pre + "^", "\\%^"];
16539 }
16540 else if (c == "$") {
16541 return [pre + "$", "\\%$"];
16542 }
16543 else if (c == "V") {
16544 return [pre + "V", "\\%V"];
16545 }
16546 else if (c == "#") {
16547 return [pre + "#", "\\%#"];
16548 }
16549 else if (c == "[") {
16550 return this.get_token_percent_sq(pre + "[");
16551 }
16552 else if (c == "(") {
16553 return [pre + "(", "\\%("];
16554 }
16555 else {
16556 return this.get_token_mlcv(pre);
16557 }
16558}
16559
16560// \%[]
16561RegexpParser.prototype.get_token_percent_sq = function(pre) {
16562 var r = "";
16563 while (TRUE) {
16564 var c = this.reader.peek();
16565 if (this.isend(c)) {
16566 throw Err("E69: Missing ] after \\%[", this.reader.getpos());
16567 }
16568 else if (c == "]") {
16569 if (r == "") {
16570 throw Err("E70: Empty \\%[", this.reader.getpos());
16571 }
16572 this.reader.seek_cur(1);
16573 break;
16574 }
16575 this.reader.seek_cur(1);
16576 r += c;
16577 }
16578 return [pre + r + "]", "\\%[" + r + "]"];
16579}
16580
16581// \%'m \%l \%c \%v
16582RegexpParser.prototype.get_token_mlvc = function(pre) {
16583 var r = "";
16584 var cmp = "";
16585 if (this.reader.p(0) == "<" || this.reader.p(0) == ">") {
16586 var cmp = this.reader.get();
16587 r += cmp;
16588 }
16589 if (this.reader.p(0) == "'") {
16590 r += this.reader.get();
16591 var c = this.reader.p(0);
16592 if (this.isend(c)) {
16593 // FIXME: Should be error? Vim allow this.
16594 var c = "";
16595 }
16596 else {
16597 var c = this.reader.get();
16598 }
16599 return [pre + r + c, "\\%" + cmp + "'" + c];
16600 }
16601 else if (isdigit(this.reader.p(0))) {
16602 var d = this.reader.read_digit();
16603 r += d;
16604 var c = this.reader.p(0);
16605 if (c == "l") {
16606 this.reader.get();
16607 return [pre + r + "l", "\\%" + cmp + d + "l"];
16608 }
16609 else if (c == "c") {
16610 this.reader.get();
16611 return [pre + r + "c", "\\%" + cmp + d + "c"];
16612 }
16613 else if (c == "v") {
16614 this.reader.get();
16615 return [pre + r + "v", "\\%" + cmp + d + "v"];
16616 }
16617 }
16618 throw Err("E71: Invalid character after %", this.reader.getpos());
16619}
16620
16621RegexpParser.prototype.getdecchrs = function() {
16622 return this.reader.read_digit();
16623}
16624
16625RegexpParser.prototype.getoctchrs = function() {
16626 return this.reader.read_odigit();
16627}
16628
16629RegexpParser.prototype.gethexchrs = function(n) {
16630 var r = "";
16631 var __c16 = viml_range(n);
16632 for (var __i16 = 0; __i16 < __c16.length; ++__i16) {
16633 var i = __c16[__i16];
16634 var c = this.reader.peek();
16635 if (!isxdigit(c)) {
16636 break;
16637 }
16638 r += this.reader.get();
16639 }
16640 return r;
16641}
16642
16643if (__webpack_require__.c[__webpack_require__.s] === module) {
16644 main();
16645}
16646else {
16647 module.exports = {
16648 VimLParser: VimLParser,
16649 StringReader: StringReader,
16650 Compiler: Compiler
16651 };
16652}
16653
16654
16655/***/ }),
16656
16657/***/ 61:
16658/***/ ((module) => {
16659
16660"use strict";
16661module.exports = require("child_process");;
16662
16663/***/ }),
16664
16665/***/ 25:
16666/***/ ((module) => {
16667
16668"use strict";
16669module.exports = require("crypto");;
16670
16671/***/ }),
16672
16673/***/ 70:
16674/***/ ((module) => {
16675
16676"use strict";
16677module.exports = require("events");;
16678
16679/***/ }),
16680
16681/***/ 60:
16682/***/ ((module) => {
16683
16684"use strict";
16685module.exports = require("fs");;
16686
16687/***/ }),
16688
16689/***/ 26:
16690/***/ ((module) => {
16691
16692"use strict";
16693module.exports = require("net");;
16694
16695/***/ }),
16696
16697/***/ 24:
16698/***/ ((module) => {
16699
16700"use strict";
16701module.exports = require("os");;
16702
16703/***/ }),
16704
16705/***/ 23:
16706/***/ ((module) => {
16707
16708"use strict";
16709module.exports = require("path");;
16710
16711/***/ }),
16712
16713/***/ 59:
16714/***/ ((module) => {
16715
16716"use strict";
16717module.exports = require("url");;
16718
16719/***/ }),
16720
16721/***/ 10:
16722/***/ ((module) => {
16723
16724"use strict";
16725module.exports = require("util");;
16726
16727/***/ })
16728
16729/******/ });
16730/************************************************************************/
16731/******/ // The module cache
16732/******/ var __webpack_module_cache__ = {};
16733/******/
16734/******/ // The require function
16735/******/ function __webpack_require__(moduleId) {
16736/******/ // Check if module is in cache
16737/******/ var cachedModule = __webpack_module_cache__[moduleId];
16738/******/ if (cachedModule !== undefined) {
16739/******/ return cachedModule.exports;
16740/******/ }
16741/******/ // Create a new module (and put it into the cache)
16742/******/ var module = __webpack_module_cache__[moduleId] = {
16743/******/ id: moduleId,
16744/******/ loaded: false,
16745/******/ exports: {}
16746/******/ };
16747/******/
16748/******/ // Execute the module function
16749/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
16750/******/
16751/******/ // Flag the module as loaded
16752/******/ module.loaded = true;
16753/******/
16754/******/ // Return the exports of the module
16755/******/ return module.exports;
16756/******/ }
16757/******/
16758/******/ // expose the module cache
16759/******/ __webpack_require__.c = __webpack_module_cache__;
16760/******/
16761/************************************************************************/
16762/******/ /* webpack/runtime/define property getters */
16763/******/ (() => {
16764/******/ // define getter functions for harmony exports
16765/******/ __webpack_require__.d = (exports, definition) => {
16766/******/ for(var key in definition) {
16767/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
16768/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
16769/******/ }
16770/******/ }
16771/******/ };
16772/******/ })();
16773/******/
16774/******/ /* webpack/runtime/hasOwnProperty shorthand */
16775/******/ (() => {
16776/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
16777/******/ })();
16778/******/
16779/******/ /* webpack/runtime/make namespace object */
16780/******/ (() => {
16781/******/ // define __esModule on exports
16782/******/ __webpack_require__.r = (exports) => {
16783/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
16784/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16785/******/ }
16786/******/ Object.defineProperty(exports, '__esModule', { value: true });
16787/******/ };
16788/******/ })();
16789/******/
16790/******/ /* webpack/runtime/node module decorator */
16791/******/ (() => {
16792/******/ __webpack_require__.nmd = (module) => {
16793/******/ module.paths = [];
16794/******/ if (!module.children) module.children = [];
16795/******/ return module;
16796/******/ };
16797/******/ })();
16798/******/
16799/************************************************************************/
16800/******/
16801/******/ // module cache are used so entry inlining is disabled
16802/******/ // startup
16803/******/ // Load entry module and return exports
16804/******/ var __webpack_exports__ = __webpack_require__(__webpack_require__.s = 391);
16805/******/ var __webpack_export_target__ = exports;
16806/******/ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
16807/******/ if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
16808/******/
16809/******/ })()
16810;
\No newline at end of file