UNPKG

617 kBJavaScriptView Raw
1(function(e, a) { for(var i in a) e[i] = a[i]; if(a.__esModule) Object.defineProperty(e, "__esModule", { value: true }); }(exports,
2/******/ (() => { // webpackBootstrap
3/******/ var __webpack_modules__ = ({
4
5/***/ 49:
6/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7
8/*
9colors.js
10
11Copyright (c) 2010
12
13Marak Squires
14Alexis Sellier (cloudhead)
15
16Permission is hereby granted, free of charge, to any person obtaining a copy
17of this software and associated documentation files (the "Software"), to deal
18in the Software without restriction, including without limitation the rights
19to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20copies of the Software, and to permit persons to whom the Software is
21furnished to do so, subject to the following conditions:
22
23The above copyright notice and this permission notice shall be included in
24all copies or substantial portions of the Software.
25
26THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32THE SOFTWARE.
33
34*/
35
36var isHeadless = false;
37
38if (typeof module !== 'undefined') {
39 isHeadless = true;
40}
41
42if (!isHeadless) {
43 var exports = {};
44 var module = {};
45 var colors = exports;
46 exports.mode = "browser";
47} else {
48 exports.mode = "console";
49}
50
51//
52// Prototypes the string object to have additional method calls that add terminal colors
53//
54var addProperty = function (color, func) {
55 exports[color] = function (str) {
56 return func.apply(str);
57 };
58 String.prototype.__defineGetter__(color, func);
59};
60
61function stylize(str, style) {
62
63 var styles;
64
65 if (exports.mode === 'console') {
66 styles = {
67 //styles
68 'bold' : ['\x1B[1m', '\x1B[22m'],
69 'italic' : ['\x1B[3m', '\x1B[23m'],
70 'underline' : ['\x1B[4m', '\x1B[24m'],
71 'inverse' : ['\x1B[7m', '\x1B[27m'],
72 'strikethrough' : ['\x1B[9m', '\x1B[29m'],
73 //text colors
74 //grayscale
75 'white' : ['\x1B[37m', '\x1B[39m'],
76 'grey' : ['\x1B[90m', '\x1B[39m'],
77 'black' : ['\x1B[30m', '\x1B[39m'],
78 //colors
79 'blue' : ['\x1B[34m', '\x1B[39m'],
80 'cyan' : ['\x1B[36m', '\x1B[39m'],
81 'green' : ['\x1B[32m', '\x1B[39m'],
82 'magenta' : ['\x1B[35m', '\x1B[39m'],
83 'red' : ['\x1B[31m', '\x1B[39m'],
84 'yellow' : ['\x1B[33m', '\x1B[39m'],
85 //background colors
86 //grayscale
87 'whiteBG' : ['\x1B[47m', '\x1B[49m'],
88 'greyBG' : ['\x1B[49;5;8m', '\x1B[49m'],
89 'blackBG' : ['\x1B[40m', '\x1B[49m'],
90 //colors
91 'blueBG' : ['\x1B[44m', '\x1B[49m'],
92 'cyanBG' : ['\x1B[46m', '\x1B[49m'],
93 'greenBG' : ['\x1B[42m', '\x1B[49m'],
94 'magentaBG' : ['\x1B[45m', '\x1B[49m'],
95 'redBG' : ['\x1B[41m', '\x1B[49m'],
96 'yellowBG' : ['\x1B[43m', '\x1B[49m']
97 };
98 } else if (exports.mode === 'browser') {
99 styles = {
100 //styles
101 'bold' : ['<b>', '</b>'],
102 'italic' : ['<i>', '</i>'],
103 'underline' : ['<u>', '</u>'],
104 'inverse' : ['<span style="background-color:black;color:white;">', '</span>'],
105 'strikethrough' : ['<del>', '</del>'],
106 //text colors
107 //grayscale
108 'white' : ['<span style="color:white;">', '</span>'],
109 'grey' : ['<span style="color:gray;">', '</span>'],
110 'black' : ['<span style="color:black;">', '</span>'],
111 //colors
112 'blue' : ['<span style="color:blue;">', '</span>'],
113 'cyan' : ['<span style="color:cyan;">', '</span>'],
114 'green' : ['<span style="color:green;">', '</span>'],
115 'magenta' : ['<span style="color:magenta;">', '</span>'],
116 'red' : ['<span style="color:red;">', '</span>'],
117 'yellow' : ['<span style="color:yellow;">', '</span>'],
118 //background colors
119 //grayscale
120 'whiteBG' : ['<span style="background-color:white;">', '</span>'],
121 'greyBG' : ['<span style="background-color:gray;">', '</span>'],
122 'blackBG' : ['<span style="background-color:black;">', '</span>'],
123 //colors
124 'blueBG' : ['<span style="background-color:blue;">', '</span>'],
125 'cyanBG' : ['<span style="background-color:cyan;">', '</span>'],
126 'greenBG' : ['<span style="background-color:green;">', '</span>'],
127 'magentaBG' : ['<span style="background-color:magenta;">', '</span>'],
128 'redBG' : ['<span style="background-color:red;">', '</span>'],
129 'yellowBG' : ['<span style="background-color:yellow;">', '</span>']
130 };
131 } else if (exports.mode === 'none') {
132 return str + '';
133 } else {
134 console.log('unsupported mode, try "browser", "console" or "none"');
135 }
136 return styles[style][0] + str + styles[style][1];
137}
138
139function applyTheme(theme) {
140
141 //
142 // Remark: This is a list of methods that exist
143 // on String that you should not overwrite.
144 //
145 var stringPrototypeBlacklist = [
146 '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
147 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
148 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
149 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
150 ];
151
152 Object.keys(theme).forEach(function (prop) {
153 if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
154 console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
155 }
156 else {
157 if (typeof(theme[prop]) === 'string') {
158 addProperty(prop, function () {
159 return exports[theme[prop]](this);
160 });
161 }
162 else {
163 addProperty(prop, function () {
164 var ret = this;
165 for (var t = 0; t < theme[prop].length; t++) {
166 ret = exports[theme[prop][t]](ret);
167 }
168 return ret;
169 });
170 }
171 }
172 });
173}
174
175
176//
177// Iterate through all default styles and colors
178//
179var x = ['bold', 'underline', 'strikethrough', 'italic', 'inverse', 'grey', 'black', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta', 'greyBG', 'blackBG', 'yellowBG', 'redBG', 'greenBG', 'blueBG', 'whiteBG', 'cyanBG', 'magentaBG'];
180x.forEach(function (style) {
181
182 // __defineGetter__ at the least works in more browsers
183 // http://robertnyman.com/javascript/javascript-getters-setters.html
184 // Object.defineProperty only works in Chrome
185 addProperty(style, function () {
186 return stylize(this, style);
187 });
188});
189
190function sequencer(map) {
191 return function () {
192 if (!isHeadless) {
193 return this.replace(/( )/, '$1');
194 }
195 var exploded = this.split(""), i = 0;
196 exploded = exploded.map(map);
197 return exploded.join("");
198 };
199}
200
201var rainbowMap = (function () {
202 var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
203 return function (letter, i, exploded) {
204 if (letter === " ") {
205 return letter;
206 } else {
207 return stylize(letter, rainbowColors[i++ % rainbowColors.length]);
208 }
209 };
210})();
211
212exports.themes = {};
213
214exports.addSequencer = function (name, map) {
215 addProperty(name, sequencer(map));
216};
217
218exports.addSequencer('rainbow', rainbowMap);
219exports.addSequencer('zebra', function (letter, i, exploded) {
220 return i % 2 === 0 ? letter : letter.inverse;
221});
222
223exports.setTheme = function (theme) {
224 if (typeof theme === 'string') {
225 try {
226 exports.themes[theme] = __webpack_require__(50)(theme);
227 applyTheme(exports.themes[theme]);
228 return exports.themes[theme];
229 } catch (err) {
230 console.log(err);
231 return err;
232 }
233 } else {
234 applyTheme(theme);
235 }
236};
237
238
239addProperty('stripColors', function () {
240 return ("" + this).replace(/\x1B\[\d+m/g, '');
241});
242
243// please no
244function zalgo(text, options) {
245 var soul = {
246 "up" : [
247 '̍', '̎', '̄', '̅',
248 '̿', '̑', '̆', '̐',
249 '͒', '͗', '͑', '̇',
250 '̈', '̊', '͂', '̓',
251 '̈', '͊', '͋', '͌',
252 '̃', '̂', '̌', '͐',
253 '̀', '́', '̋', '̏',
254 '̒', '̓', '̔', '̽',
255 '̉', 'ͣ', 'ͤ', 'ͥ',
256 'ͦ', 'ͧ', 'ͨ', 'ͩ',
257 'ͪ', 'ͫ', 'ͬ', 'ͭ',
258 'ͮ', 'ͯ', '̾', '͛',
259 '͆', '̚'
260 ],
261 "down" : [
262 '̖', '̗', '̘', '̙',
263 '̜', '̝', '̞', '̟',
264 '̠', '̤', '̥', '̦',
265 '̩', '̪', '̫', '̬',
266 '̭', '̮', '̯', '̰',
267 '̱', '̲', '̳', '̹',
268 '̺', '̻', '̼', 'ͅ',
269 '͇', '͈', '͉', '͍',
270 '͎', '͓', '͔', '͕',
271 '͖', '͙', '͚', '̣'
272 ],
273 "mid" : [
274 '̕', '̛', '̀', '́',
275 '͘', '̡', '̢', '̧',
276 '̨', '̴', '̵', '̶',
277 '͜', '͝', '͞',
278 '͟', '͠', '͢', '̸',
279 '̷', '͡', ' ҉'
280 ]
281 },
282 all = [].concat(soul.up, soul.down, soul.mid),
283 zalgo = {};
284
285 function randomNumber(range) {
286 var r = Math.floor(Math.random() * range);
287 return r;
288 }
289
290 function is_char(character) {
291 var bool = false;
292 all.filter(function (i) {
293 bool = (i === character);
294 });
295 return bool;
296 }
297
298 function heComes(text, options) {
299 var result = '', counts, l;
300 options = options || {};
301 options["up"] = options["up"] || true;
302 options["mid"] = options["mid"] || true;
303 options["down"] = options["down"] || true;
304 options["size"] = options["size"] || "maxi";
305 text = text.split('');
306 for (l in text) {
307 if (is_char(l)) {
308 continue;
309 }
310 result = result + text[l];
311 counts = {"up" : 0, "down" : 0, "mid" : 0};
312 switch (options.size) {
313 case 'mini':
314 counts.up = randomNumber(8);
315 counts.min = randomNumber(2);
316 counts.down = randomNumber(8);
317 break;
318 case 'maxi':
319 counts.up = randomNumber(16) + 3;
320 counts.min = randomNumber(4) + 1;
321 counts.down = randomNumber(64) + 3;
322 break;
323 default:
324 counts.up = randomNumber(8) + 1;
325 counts.mid = randomNumber(6) / 2;
326 counts.down = randomNumber(8) + 1;
327 break;
328 }
329
330 var arr = ["up", "mid", "down"];
331 for (var d in arr) {
332 var index = arr[d];
333 for (var i = 0 ; i <= counts[index]; i++) {
334 if (options[index]) {
335 result = result + soul[index][randomNumber(soul[index].length)];
336 }
337 }
338 }
339 }
340 return result;
341 }
342 return heComes(text);
343}
344
345
346// don't summon zalgo
347addProperty('zalgo', function () {
348 return zalgo(this);
349});
350
351
352/***/ }),
353
354/***/ 50:
355/***/ ((module) => {
356
357function webpackEmptyContext(req) {
358 var e = new Error("Cannot find module '" + req + "'");
359 e.code = 'MODULE_NOT_FOUND';
360 throw e;
361}
362webpackEmptyContext.keys = () => [];
363webpackEmptyContext.resolve = webpackEmptyContext;
364webpackEmptyContext.id = 50;
365module.exports = webpackEmptyContext;
366
367/***/ }),
368
369/***/ 47:
370/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
371
372var fs = __webpack_require__(40),
373 Path = __webpack_require__(13),
374 util = __webpack_require__(48),
375 colors = __webpack_require__(49),
376 EE = __webpack_require__(51).EventEmitter,
377 fsExists = fs.exists ? fs.exists : Path.exists,
378 fsExistsSync = fs.existsSync ? fs.existsSync : Path.existsSync;
379
380module.exports = function(dir, iterator, options, callback){
381 return FindUp(dir, iterator, options, callback);
382};
383
384function FindUp(dir, iterator, options, callback){
385 if (!(this instanceof FindUp)) {
386 return new FindUp(dir, iterator, options, callback);
387 }
388 if(typeof options === 'function'){
389 callback = options;
390 options = {};
391 }
392 options = options || {};
393
394 EE.call(this);
395 this.found = false;
396 this.stopPlease = false;
397 var self = this;
398
399 if(typeof iterator === 'string'){
400 var file = iterator;
401 iterator = function(dir, cb){
402 return fsExists(Path.join(dir, file), cb);
403 };
404 }
405
406 if(callback) {
407 this.on('found', function(dir){
408 if(options.verbose) console.log(('found '+ dir ).green);
409 callback(null, dir);
410 self.stop();
411 });
412
413 this.on('end', function(){
414 if(options.verbose) console.log('end'.grey);
415 if(!self.found) callback(new Error('not found'));
416 });
417
418 this.on('error', function(err){
419 if(options.verbose) console.log('error'.red, err);
420 callback(err);
421 });
422 }
423
424 this._find(dir, iterator, options, callback);
425}
426util.inherits(FindUp, EE);
427
428FindUp.prototype._find = function(dir, iterator, options, callback){
429 var self = this;
430
431 iterator(dir, function(exists){
432 if(options.verbose) console.log(('traverse '+ dir).grey);
433 if(exists) {
434 self.found = true;
435 self.emit('found', dir);
436 }
437
438 var parentDir = Path.join(dir, '..');
439 if (self.stopPlease) return self.emit('end');
440 if (dir === parentDir) return self.emit('end');
441 if(dir.indexOf('../../') !== -1 ) return self.emit('error', new Error(dir + ' is not correct.'));
442 self._find(parentDir, iterator, options, callback);
443 });
444};
445
446FindUp.prototype.stop = function(){
447 this.stopPlease = true;
448};
449
450module.exports.FindUp = FindUp;
451
452module.exports.sync = function(dir, iteratorSync){
453 if(typeof iteratorSync === 'string'){
454 var file = iteratorSync;
455 iteratorSync = function(dir){
456 return fsExistsSync(Path.join(dir, file));
457 };
458 }
459 var initialDir = dir;
460 while(dir !== Path.join(dir, '..')){
461 if(dir.indexOf('../../') !== -1 ) throw new Error(initialDir + ' is not correct.');
462 if(iteratorSync(dir)) return dir;
463 dir = Path.join(dir, '..');
464 }
465 throw new Error('not found');
466};
467
468
469/***/ }),
470
471/***/ 44:
472/***/ ((__unused_webpack_module, exports) => {
473
474"use strict";
475
476Object.defineProperty(exports, "__esModule", ({ value: true }));
477exports.projectRootPatterns = exports.sortTexts = void 0;
478exports.sortTexts = {
479 one: "00001",
480 two: "00002",
481 three: "00003",
482 four: "00004",
483};
484exports.projectRootPatterns = [".git", "autoload", "plugin"];
485
486
487/***/ }),
488
489/***/ 53:
490/***/ ((__unused_webpack_module, exports) => {
491
492"use strict";
493
494Object.defineProperty(exports, "__esModule", ({ value: true }));
495exports.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;
496exports.errorLinePattern = /[^:]+:\s*(.+?):\s*line\s*([0-9]+)\s*col\s*([0-9]+)/;
497exports.commentPattern = /^[ \t]*("|')/;
498exports.keywordPattern = /[\w#&$<>.:]/;
499exports.builtinFunctionPattern = /^((<SID>|\b(v|g|b|s|l|a):)?[\w#&]+)[ \t]*\([^)]*\)/;
500exports.wordPrePattern = /^.*?(((<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+)|(<SID>|<SID|<SI|<S|<|\b(v|g|b|s|l|a):))$/;
501exports.wordNextPattern = /^((SID>|ID>|D>|>|<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+|(:[\w#&$.]+)).*?(\r\n|\r|\n)?$/;
502exports.colorschemePattern = /\bcolorscheme[ \t]+\w*$/;
503exports.mapCommandPattern = /^([ \t]*(\[ \t]*)?)\w*map[ \t]+/;
504exports.highlightLinkPattern = /^[ \t]*(hi|highlight)[ \t]+link([ \t]+[^ \t]+)*[ \t]*$/;
505exports.highlightPattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]*$/;
506exports.highlightValuePattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]+([^ \t=]+)=[^ \t=]*$/;
507exports.autocmdPattern = /^[ \t]*(au|autocmd)!?[ \t]+([^ \t,]+,)*[^ \t,]*$/;
508exports.builtinVariablePattern = [
509 /\bv:\w*$/,
510];
511exports.optionPattern = [
512 /(^|[ \t]+)&\w*$/,
513 /(^|[ \t]+)set(l|local|g|global)?[ \t]+\w+$/,
514];
515exports.notFunctionPattern = [
516 /^[ \t]*\\$/,
517 /^[ \t]*\w+$/,
518 /^[ \t]*"/,
519 /(let|set|colorscheme)[ \t][^ \t]*$/,
520 /[^([,\\ \t\w#>]\w*$/,
521 /^[ \t]*(hi|highlight)([ \t]+link)?([ \t]+[^ \t]+)*[ \t]*$/,
522 exports.autocmdPattern,
523];
524exports.commandPattern = [
525 /(^|[ \t]):\w+$/,
526 /^[ \t]*\w+$/,
527 /:?silent!?[ \t]\w+/,
528];
529exports.featurePattern = [
530 /\bhas\([ \t]*["']\w*/,
531];
532exports.expandPattern = [
533 /\bexpand\(['"]<\w*$/,
534 /\bexpand\([ \t]*['"]\w*$/,
535];
536exports.notIdentifierPattern = [
537 exports.commentPattern,
538 /("|'):\w*$/,
539 /^[ \t]*\\$/,
540 /^[ \t]*call[ \t]+[^ \t()]*$/,
541 /('|"|#|&|\$|<)\w*$/,
542];
543
544
545/***/ }),
546
547/***/ 46:
548/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
549
550"use strict";
551
552var __assign = (this && this.__assign) || function () {
553 __assign = Object.assign || function(t) {
554 for (var s, i = 1, n = arguments.length; i < n; i++) {
555 s = arguments[i];
556 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
557 t[p] = s[p];
558 }
559 return t;
560 };
561 return __assign.apply(this, arguments);
562};
563var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
564 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
565 return new (P || (P = Promise))(function (resolve, reject) {
566 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
567 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
568 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
569 step((generator = generator.apply(thisArg, _arguments || [])).next());
570 });
571};
572var __generator = (this && this.__generator) || function (thisArg, body) {
573 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
574 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
575 function verb(n) { return function (v) { return step([n, v]); }; }
576 function step(op) {
577 if (f) throw new TypeError("Generator is already executing.");
578 while (_) try {
579 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;
580 if (y = 0, t) op = [op[0] & 2, t.value];
581 switch (op[0]) {
582 case 0: case 1: t = op; break;
583 case 4: _.label++; return { value: op[1], done: false };
584 case 5: _.label++; y = op[1]; op = [0]; continue;
585 case 7: op = _.ops.pop(); _.trys.pop(); continue;
586 default:
587 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
588 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
589 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
590 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
591 if (t[2]) _.ops.pop();
592 _.trys.pop(); continue;
593 }
594 op = body.call(thisArg, _);
595 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
596 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
597 }
598};
599var __spreadArrays = (this && this.__spreadArrays) || function () {
600 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
601 for (var r = Array(s), k = 0, i = 0; i < il; i++)
602 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
603 r[k] = a[j];
604 return r;
605};
606var __importDefault = (this && this.__importDefault) || function (mod) {
607 return (mod && mod.__esModule) ? mod : { "default": mod };
608};
609Object.defineProperty(exports, "__esModule", ({ value: true }));
610exports.getRealPath = exports.isSymbolLink = exports.removeSnippets = exports.handleParse = exports.getWordFromPosition = exports.markupSnippets = exports.findProjectRoot = exports.pcb = exports.executeFile = exports.isSomeMatchPattern = void 0;
611var child_process_1 = __webpack_require__(41);
612var findup_1 = __importDefault(__webpack_require__(47));
613var fs_1 = __importDefault(__webpack_require__(40));
614var path_1 = __importDefault(__webpack_require__(13));
615var vscode_languageserver_1 = __webpack_require__(2);
616var vimparser_1 = __webpack_require__(52);
617var patterns_1 = __webpack_require__(53);
618function isSomeMatchPattern(patterns, line) {
619 return patterns.some(function (p) { return p.test(line); });
620}
621exports.isSomeMatchPattern = isSomeMatchPattern;
622function executeFile(input, command, args, option) {
623 return new Promise(function (resolve, reject) {
624 var stdout = "";
625 var stderr = "";
626 var error;
627 var isPassAsText = false;
628 args = (args || []).map(function (arg) {
629 if (/%text/.test(arg)) {
630 isPassAsText = true;
631 return arg.replace(/%text/g, input.toString());
632 }
633 return arg;
634 });
635 var cp = child_process_1.spawn(command, args, option);
636 cp.stdout.on("data", function (data) {
637 stdout += data;
638 });
639 cp.stderr.on("data", function (data) {
640 stderr += data;
641 });
642 cp.on("error", function (err) {
643 error = err;
644 reject(error);
645 });
646 cp.on("close", function (code) {
647 if (!error) {
648 resolve({ code: code, stdout: stdout, stderr: stderr });
649 }
650 });
651 // error will occur when cp get error
652 if (!isPassAsText) {
653 input.pipe(cp.stdin).on("error", function () { return; });
654 }
655 });
656}
657exports.executeFile = executeFile;
658// cover cb type async function to promise
659function pcb(cb) {
660 return function () {
661 var args = [];
662 for (var _i = 0; _i < arguments.length; _i++) {
663 args[_i] = arguments[_i];
664 }
665 return new Promise(function (resolve) {
666 cb.apply(void 0, __spreadArrays(args, [function () {
667 var params = [];
668 for (var _i = 0; _i < arguments.length; _i++) {
669 params[_i] = arguments[_i];
670 }
671 resolve(params);
672 }]));
673 });
674 };
675}
676exports.pcb = pcb;
677// find work dirname by root patterns
678function findProjectRoot(filePath, rootPatterns) {
679 return __awaiter(this, void 0, void 0, function () {
680 var dirname, patterns, dirCandidate, _i, patterns_2, pattern, _a, err, dir;
681 return __generator(this, function (_b) {
682 switch (_b.label) {
683 case 0:
684 dirname = path_1.default.dirname(filePath);
685 patterns = [].concat(rootPatterns);
686 dirCandidate = "";
687 _i = 0, patterns_2 = patterns;
688 _b.label = 1;
689 case 1:
690 if (!(_i < patterns_2.length)) return [3 /*break*/, 4];
691 pattern = patterns_2[_i];
692 return [4 /*yield*/, pcb(findup_1.default)(dirname, pattern)];
693 case 2:
694 _a = _b.sent(), err = _a[0], dir = _a[1];
695 if (!err && dir && dir !== "/" && dir.length > dirCandidate.length) {
696 dirCandidate = dir;
697 }
698 _b.label = 3;
699 case 3:
700 _i++;
701 return [3 /*break*/, 1];
702 case 4:
703 if (dirCandidate.length) {
704 return [2 /*return*/, dirCandidate];
705 }
706 return [2 /*return*/, dirname];
707 }
708 });
709 });
710}
711exports.findProjectRoot = findProjectRoot;
712function markupSnippets(snippets) {
713 return [
714 "```vim",
715 snippets.replace(/\$\{[0-9]+(:([^}]+))?\}/g, "$2"),
716 "```",
717 ].join("\n");
718}
719exports.markupSnippets = markupSnippets;
720function getWordFromPosition(doc, position) {
721 if (!doc) {
722 return;
723 }
724 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)));
725 // not keyword position
726 if (!character || !patterns_1.keywordPattern.test(character)) {
727 return;
728 }
729 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)));
730 // comment line
731 if (patterns_1.commentPattern.test(currentLine)) {
732 return;
733 }
734 var preSegment = currentLine.slice(0, position.character);
735 var nextSegment = currentLine.slice(position.character);
736 var wordLeft = preSegment.match(patterns_1.wordPrePattern);
737 var wordRight = nextSegment.match(patterns_1.wordNextPattern);
738 var word = "" + (wordLeft && wordLeft[1] || "") + (wordRight && wordRight[1] || "");
739 return {
740 word: word,
741 left: wordLeft && wordLeft[1] || "",
742 right: wordRight && wordRight[1] || "",
743 wordLeft: wordLeft && wordLeft[1]
744 ? preSegment.replace(new RegExp(wordLeft[1] + "$"), word)
745 : "" + preSegment + word,
746 wordRight: wordRight && wordRight[1]
747 ? nextSegment.replace(new RegExp("^" + wordRight[1]), word)
748 : "" + word + nextSegment,
749 };
750}
751exports.getWordFromPosition = getWordFromPosition;
752// parse vim buffer
753function handleParse(textDoc) {
754 return __awaiter(this, void 0, void 0, function () {
755 var text, tokens, node;
756 return __generator(this, function (_a) {
757 text = textDoc instanceof Object ? textDoc.getText() : textDoc;
758 tokens = new vimparser_1.StringReader(text.split(/\r\n|\r|\n/));
759 try {
760 node = new vimparser_1.VimLParser(true).parse(tokens);
761 return [2 /*return*/, [node, ""]];
762 }
763 catch (error) {
764 return [2 /*return*/, [null, error]];
765 }
766 return [2 /*return*/];
767 });
768 });
769}
770exports.handleParse = handleParse;
771// remove snippets of completionItem
772function removeSnippets(completionItems) {
773 if (completionItems === void 0) { completionItems = []; }
774 return completionItems.map(function (item) {
775 if (item.insertTextFormat === vscode_languageserver_1.InsertTextFormat.Snippet) {
776 return __assign(__assign({}, item), { insertText: item.label, insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText });
777 }
778 return item;
779 });
780}
781exports.removeSnippets = removeSnippets;
782var isSymbolLink = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
783 return __generator(this, function (_a) {
784 return [2 /*return*/, new Promise(function (resolve) {
785 fs_1.default.lstat(filePath, function (err, stats) {
786 resolve({
787 err: err,
788 stats: stats && stats.isSymbolicLink(),
789 });
790 });
791 })];
792 });
793}); };
794exports.isSymbolLink = isSymbolLink;
795var getRealPath = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
796 var _a, err, stats;
797 return __generator(this, function (_b) {
798 switch (_b.label) {
799 case 0: return [4 /*yield*/, exports.isSymbolLink(filePath)];
800 case 1:
801 _a = _b.sent(), err = _a.err, stats = _a.stats;
802 if (!err && stats) {
803 return [2 /*return*/, new Promise(function (resolve) {
804 fs_1.default.realpath(filePath, function (error, realPath) {
805 if (error) {
806 return resolve(filePath);
807 }
808 resolve(realPath);
809 });
810 })];
811 }
812 return [2 /*return*/, filePath];
813 }
814 });
815}); };
816exports.getRealPath = getRealPath;
817
818
819/***/ }),
820
821/***/ 370:
822/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
823
824"use strict";
825
826var __assign = (this && this.__assign) || function () {
827 __assign = Object.assign || function(t) {
828 for (var s, i = 1, n = arguments.length; i < n; i++) {
829 s = arguments[i];
830 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
831 t[p] = s[p];
832 }
833 return t;
834 };
835 return __assign.apply(this, arguments);
836};
837var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
838 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
839 return new (P || (P = Promise))(function (resolve, reject) {
840 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
841 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
842 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
843 step((generator = generator.apply(thisArg, _arguments || [])).next());
844 });
845};
846var __generator = (this && this.__generator) || function (thisArg, body) {
847 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
848 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
849 function verb(n) { return function (v) { return step([n, v]); }; }
850 function step(op) {
851 if (f) throw new TypeError("Generator is already executing.");
852 while (_) try {
853 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;
854 if (y = 0, t) op = [op[0] & 2, t.value];
855 switch (op[0]) {
856 case 0: case 1: t = op; break;
857 case 4: _.label++; return { value: op[1], done: false };
858 case 5: _.label++; y = op[1]; op = [0]; continue;
859 case 7: op = _.ops.pop(); _.trys.pop(); continue;
860 default:
861 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
862 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
863 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
864 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
865 if (t[2]) _.ops.pop();
866 _.trys.pop(); continue;
867 }
868 op = body.call(thisArg, _);
869 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
870 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
871 }
872};
873Object.defineProperty(exports, "__esModule", ({ value: true }));
874/*
875 * vim builtin completion items
876 *
877 * 1. functions
878 * 2. options
879 * 3. variables
880 * 4. commands
881 * 5. has features
882 * 6. expand Keyword
883 */
884var fs_1 = __webpack_require__(40);
885var path_1 = __webpack_require__(13);
886var vscode_languageserver_1 = __webpack_require__(2);
887var constant_1 = __webpack_require__(44);
888var util_1 = __webpack_require__(46);
889var EVAL_PATH = "/doc/eval.txt";
890var OPTIONS_PATH = "/doc/options.txt";
891var INDEX_PATH = "/doc/index.txt";
892var API_PATH = "/doc/api.txt";
893var AUTOCMD_PATH = "/doc/autocmd.txt";
894var POPUP_PATH = "/doc/popup.txt";
895var CHANNEL_PATH = "/doc/channel.txt";
896var TEXTPROP_PATH = "/doc/textprop.txt";
897var TERMINAL_PATH = "/doc/terminal.txt";
898var TESTING_PATH = "/doc/testing.txt";
899var Server = /** @class */ (function () {
900 function Server(config) {
901 this.config = config;
902 // completion items
903 this.vimPredefinedVariablesItems = [];
904 this.vimOptionItems = [];
905 this.vimBuiltinFunctionItems = [];
906 this.vimCommandItems = [];
907 this.vimFeatureItems = [];
908 this.vimExpandKeywordItems = [];
909 this.vimAutocmdItems = [];
910 // documents
911 this.vimBuiltFunctionDocuments = {};
912 this.vimOptionDocuments = {};
913 this.vimPredefinedVariableDocuments = {};
914 this.vimCommandDocuments = {};
915 this.vimFeatureDocuments = {};
916 this.expandKeywordDocuments = {};
917 // signature help
918 this.vimBuiltFunctionSignatureHelp = {};
919 // raw docs
920 this.text = {};
921 }
922 Server.prototype.build = function () {
923 return __awaiter(this, void 0, void 0, function () {
924 var vimruntime, paths, index, p, _a, err, data;
925 return __generator(this, function (_b) {
926 switch (_b.label) {
927 case 0:
928 vimruntime = this.config.vimruntime;
929 if (!vimruntime) return [3 /*break*/, 5];
930 paths = [
931 EVAL_PATH,
932 OPTIONS_PATH,
933 INDEX_PATH,
934 API_PATH,
935 AUTOCMD_PATH,
936 POPUP_PATH,
937 CHANNEL_PATH,
938 TEXTPROP_PATH,
939 TERMINAL_PATH,
940 TESTING_PATH,
941 ];
942 index = 0;
943 _b.label = 1;
944 case 1:
945 if (!(index < paths.length)) return [3 /*break*/, 4];
946 p = path_1.join(vimruntime, paths[index]);
947 return [4 /*yield*/, util_1.pcb(fs_1.readFile)(p, "utf-8")];
948 case 2:
949 _a = _b.sent(), err = _a[0], data = _a[1];
950 if (err) {
951 // tslint:disable-next-line: no-console
952 console.error("[vimls]: read " + p + " error: " + err.message);
953 }
954 this.text[paths[index]] = (data && data.toString().split("\n")) || [];
955 _b.label = 3;
956 case 3:
957 index++;
958 return [3 /*break*/, 1];
959 case 4:
960 this.resolveVimPredefinedVariables();
961 this.resolveVimOptions();
962 this.resolveBuiltinFunctions();
963 this.resolveBuiltinFunctionsDocument();
964 this.resolveBuiltinVimPopupFunctionsDocument();
965 this.resolveBuiltinVimChannelFunctionsDocument();
966 this.resolveBuiltinVimJobFunctionsDocument();
967 this.resolveBuiltinVimTextpropFunctionsDocument();
968 this.resolveBuiltinVimTerminalFunctionsDocument();
969 this.resolveBuiltinVimTestingFunctionsDocument();
970 this.resolveBuiltinNvimFunctions();
971 this.resolveExpandKeywords();
972 this.resolveVimCommands();
973 this.resolveVimFeatures();
974 this.resolveVimAutocmds();
975 _b.label = 5;
976 case 5: return [2 /*return*/];
977 }
978 });
979 });
980 };
981 Server.prototype.serialize = function () {
982 var str = JSON.stringify({
983 completionItems: {
984 commands: this.vimCommandItems,
985 functions: this.vimBuiltinFunctionItems,
986 variables: this.vimPredefinedVariablesItems,
987 options: this.vimOptionItems,
988 features: this.vimFeatureItems,
989 expandKeywords: this.vimExpandKeywordItems,
990 autocmds: this.vimAutocmdItems,
991 },
992 signatureHelp: this.vimBuiltFunctionSignatureHelp,
993 documents: {
994 commands: this.vimCommandDocuments,
995 functions: this.vimBuiltFunctionDocuments,
996 variables: this.vimPredefinedVariableDocuments,
997 options: this.vimOptionDocuments,
998 features: this.vimFeatureDocuments,
999 expandKeywords: this.expandKeywordDocuments,
1000 },
1001 }, null, 2);
1002 fs_1.writeFileSync("./src/docs/builtin-docs.json", str, "utf-8");
1003 };
1004 Server.prototype.formatFunctionSnippets = function (fname, snippets) {
1005 if (snippets === "") {
1006 return fname + "(${0})";
1007 }
1008 var idx = 0;
1009 if (/^\[.+\]/.test(snippets)) {
1010 return fname + "(${1})${0}";
1011 }
1012 var str = snippets.split("[")[0].trim().replace(/\{?(\w+)\}?/g, function (m, g1) {
1013 return "${" + (idx += 1) + ":" + g1 + "}";
1014 });
1015 return fname + "(" + str + ")${0}";
1016 };
1017 // get vim predefined variables from vim document eval.txt
1018 Server.prototype.resolveVimPredefinedVariables = function () {
1019 var evalText = this.text[EVAL_PATH] || [];
1020 var isMatchLine = false;
1021 var completionItem;
1022 for (var _i = 0, evalText_1 = evalText; _i < evalText_1.length; _i++) {
1023 var line = evalText_1[_i];
1024 if (!isMatchLine) {
1025 if (/\*vim-variable\*/.test(line)) {
1026 isMatchLine = true;
1027 }
1028 continue;
1029 }
1030 else {
1031 var m = line.match(/^(v:[^ \t]+)[ \t]+([^ ].*)$/);
1032 if (m) {
1033 if (completionItem) {
1034 this.vimPredefinedVariablesItems.push(completionItem);
1035 this.vimPredefinedVariableDocuments[completionItem.label].pop();
1036 completionItem = undefined;
1037 }
1038 var label = m[1];
1039 completionItem = {
1040 label: label,
1041 kind: vscode_languageserver_1.CompletionItemKind.Variable,
1042 sortText: constant_1.sortTexts.four,
1043 insertText: label.slice(2),
1044 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1045 };
1046 if (!this.vimPredefinedVariableDocuments[label]) {
1047 this.vimPredefinedVariableDocuments[label] = [];
1048 }
1049 this.vimPredefinedVariableDocuments[label].push(m[2]);
1050 }
1051 else if (/^\s*$/.test(line) && completionItem) {
1052 this.vimPredefinedVariablesItems.push(completionItem);
1053 completionItem = undefined;
1054 }
1055 else if (completionItem) {
1056 this.vimPredefinedVariableDocuments[completionItem.label].push(line);
1057 }
1058 else if (/===============/.test(line)) {
1059 break;
1060 }
1061 }
1062 }
1063 };
1064 // get vim options from vim document options.txt
1065 Server.prototype.resolveVimOptions = function () {
1066 var optionsText = this.text[OPTIONS_PATH] || [];
1067 var isMatchLine = false;
1068 var completionItem;
1069 for (var _i = 0, optionsText_1 = optionsText; _i < optionsText_1.length; _i++) {
1070 var line = optionsText_1[_i];
1071 if (!isMatchLine) {
1072 if (/\*'aleph'\*/.test(line)) {
1073 isMatchLine = true;
1074 }
1075 continue;
1076 }
1077 else {
1078 var m = line.match(/^'([^']+)'[ \t]+('[^']+')?[ \t]+([^ \t].*)$/);
1079 if (m) {
1080 var label = m[1];
1081 completionItem = {
1082 label: label,
1083 kind: vscode_languageserver_1.CompletionItemKind.Property,
1084 detail: m[3].trim().split(/[ \t]/)[0],
1085 documentation: "",
1086 sortText: "00004",
1087 insertText: m[1],
1088 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1089 };
1090 if (!this.vimOptionDocuments[label]) {
1091 this.vimOptionDocuments[label] = [];
1092 }
1093 this.vimOptionDocuments[label].push(m[3]);
1094 }
1095 else if (/^\s*$/.test(line) && completionItem) {
1096 this.vimOptionItems.push(completionItem);
1097 completionItem = undefined;
1098 }
1099 else if (completionItem) {
1100 this.vimOptionDocuments[completionItem.label].push(line);
1101 }
1102 }
1103 }
1104 };
1105 // get vim builtin function from document eval.txt
1106 Server.prototype.resolveBuiltinFunctions = function () {
1107 var evalText = this.text[EVAL_PATH] || [];
1108 var isMatchLine = false;
1109 var completionItem;
1110 for (var _i = 0, evalText_2 = evalText; _i < evalText_2.length; _i++) {
1111 var line = evalText_2[_i];
1112 if (!isMatchLine) {
1113 if (/\*functions\*/.test(line)) {
1114 isMatchLine = true;
1115 }
1116 continue;
1117 }
1118 else {
1119 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1120 if (m) {
1121 if (completionItem) {
1122 this.vimBuiltinFunctionItems.push(completionItem);
1123 }
1124 var label = m[2];
1125 completionItem = {
1126 label: label,
1127 kind: vscode_languageserver_1.CompletionItemKind.Function,
1128 detail: (m[4] || "").split(/[ \t]/)[0],
1129 sortText: "00004",
1130 insertText: this.formatFunctionSnippets(m[2], m[3]),
1131 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
1132 };
1133 this.vimBuiltFunctionSignatureHelp[label] = [
1134 m[3],
1135 (m[4] || "").split(/[ \t]/)[0],
1136 ];
1137 }
1138 else if (/^[ \t]*$/.test(line)) {
1139 if (completionItem) {
1140 this.vimBuiltinFunctionItems.push(completionItem);
1141 completionItem = undefined;
1142 break;
1143 }
1144 }
1145 else if (completionItem) {
1146 if (completionItem.detail === "") {
1147 completionItem.detail = line.trim().split(/[ \t]/)[0];
1148 if (this.vimBuiltFunctionSignatureHelp[completionItem.label]) {
1149 this.vimBuiltFunctionSignatureHelp[completionItem.label][1] = line.trim().split(/[ \t]/)[0];
1150 }
1151 }
1152 }
1153 }
1154 }
1155 };
1156 Server.prototype.resolveBuiltinFunctionsDocument = function () {
1157 var evalText = this.text[EVAL_PATH] || [];
1158 var isMatchLine = false;
1159 var label = "";
1160 for (var idx = 0; idx < evalText.length; idx++) {
1161 var line = evalText[idx];
1162 if (!isMatchLine) {
1163 if (/\*abs\(\)\*/.test(line)) {
1164 isMatchLine = true;
1165 idx -= 1;
1166 }
1167 continue;
1168 }
1169 else {
1170 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1171 if (m) {
1172 if (label) {
1173 this.vimBuiltFunctionDocuments[label].pop();
1174 }
1175 label = m[2];
1176 if (!this.vimBuiltFunctionDocuments[label]) {
1177 this.vimBuiltFunctionDocuments[label] = [];
1178 }
1179 }
1180 else if (/^[ \t]*\*string-match\*[ \t]*$/.test(line)) {
1181 if (label) {
1182 this.vimBuiltFunctionDocuments[label].pop();
1183 }
1184 break;
1185 }
1186 else if (label) {
1187 this.vimBuiltFunctionDocuments[label].push(line);
1188 }
1189 }
1190 }
1191 };
1192 Server.prototype.resolveBuiltinVimPopupFunctionsDocument = function () {
1193 var popupText = this.text[POPUP_PATH] || [];
1194 var isMatchLine = false;
1195 var label = "";
1196 for (var idx = 0; idx < popupText.length; idx++) {
1197 var line = popupText[idx];
1198 if (!isMatchLine) {
1199 if (/^DETAILS\s+\*popup-function-details\*/.test(line)) {
1200 isMatchLine = true;
1201 idx += 1;
1202 }
1203 continue;
1204 }
1205 else {
1206 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1207 if (m) {
1208 if (label) {
1209 this.vimBuiltFunctionDocuments[label].pop();
1210 }
1211 label = m[2];
1212 if (!this.vimBuiltFunctionDocuments[label]) {
1213 this.vimBuiltFunctionDocuments[label] = [];
1214 }
1215 }
1216 else if (/^=+$/.test(line)) {
1217 if (label) {
1218 this.vimBuiltFunctionDocuments[label].pop();
1219 }
1220 break;
1221 }
1222 else if (label) {
1223 this.vimBuiltFunctionDocuments[label].push(line);
1224 }
1225 }
1226 }
1227 };
1228 Server.prototype.resolveBuiltinVimChannelFunctionsDocument = function () {
1229 var channelText = this.text[CHANNEL_PATH] || [];
1230 var isMatchLine = false;
1231 var label = "";
1232 for (var idx = 0; idx < channelText.length; idx++) {
1233 var line = channelText[idx];
1234 if (!isMatchLine) {
1235 if (/^8\.\sChannel\sfunctions\sdetails\s+\*channel-functions-details\*/.test(line)) {
1236 isMatchLine = true;
1237 idx += 1;
1238 }
1239 continue;
1240 }
1241 else {
1242 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1243 if (m) {
1244 if (label) {
1245 this.vimBuiltFunctionDocuments[label].pop();
1246 }
1247 label = m[2];
1248 if (!this.vimBuiltFunctionDocuments[label]) {
1249 this.vimBuiltFunctionDocuments[label] = [];
1250 }
1251 }
1252 else if (/^=+$/.test(line)) {
1253 if (label) {
1254 this.vimBuiltFunctionDocuments[label].pop();
1255 }
1256 break;
1257 }
1258 else if (label) {
1259 this.vimBuiltFunctionDocuments[label].push(line);
1260 }
1261 }
1262 }
1263 };
1264 Server.prototype.resolveBuiltinVimJobFunctionsDocument = function () {
1265 var channelText = this.text[CHANNEL_PATH] || [];
1266 var isMatchLine = false;
1267 var label = "";
1268 for (var idx = 0; idx < channelText.length; idx++) {
1269 var line = channelText[idx];
1270 if (!isMatchLine) {
1271 if (/^11\.\sJob\sfunctions\s+\*job-functions-details\*/.test(line)) {
1272 isMatchLine = true;
1273 idx += 1;
1274 }
1275 continue;
1276 }
1277 else {
1278 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1279 if (m) {
1280 if (label) {
1281 this.vimBuiltFunctionDocuments[label].pop();
1282 }
1283 label = m[2];
1284 if (!this.vimBuiltFunctionDocuments[label]) {
1285 this.vimBuiltFunctionDocuments[label] = [];
1286 }
1287 }
1288 else if (/^=+$/.test(line)) {
1289 if (label) {
1290 this.vimBuiltFunctionDocuments[label].pop();
1291 }
1292 break;
1293 }
1294 else if (label) {
1295 this.vimBuiltFunctionDocuments[label].push(line);
1296 }
1297 }
1298 }
1299 };
1300 Server.prototype.resolveBuiltinVimTextpropFunctionsDocument = function () {
1301 var textpropText = this.text[TEXTPROP_PATH] || [];
1302 var isMatchLine = false;
1303 var label = "";
1304 // tslint:disable-next-line: prefer-for-of
1305 for (var idx = 0; idx < textpropText.length; idx++) {
1306 var line = textpropText[idx];
1307 if (!isMatchLine) {
1308 if (/^\s+\*prop_add\(\)\*\s\*E965/.test(line)) {
1309 isMatchLine = true;
1310 }
1311 continue;
1312 }
1313 else {
1314 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1315 if (m) {
1316 if (label) {
1317 this.vimBuiltFunctionDocuments[label].pop();
1318 }
1319 label = m[2];
1320 if (!this.vimBuiltFunctionDocuments[label]) {
1321 this.vimBuiltFunctionDocuments[label] = [];
1322 }
1323 }
1324 else if (/^=+$/.test(line)) {
1325 if (label) {
1326 this.vimBuiltFunctionDocuments[label].pop();
1327 }
1328 break;
1329 }
1330 else if (label) {
1331 this.vimBuiltFunctionDocuments[label].push(line);
1332 }
1333 }
1334 }
1335 };
1336 Server.prototype.resolveBuiltinVimTerminalFunctionsDocument = function () {
1337 var terminalText = this.text[TERMINAL_PATH] || [];
1338 var isMatchLine = false;
1339 var label = "";
1340 // tslint:disable-next-line: prefer-for-of
1341 for (var idx = 0; idx < terminalText.length; idx++) {
1342 var line = terminalText[idx];
1343 if (!isMatchLine) {
1344 if (/^\s+\*term_dumpdiff\(\)/.test(line)) {
1345 isMatchLine = true;
1346 }
1347 continue;
1348 }
1349 else {
1350 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1351 if (m) {
1352 if (label) {
1353 this.vimBuiltFunctionDocuments[label].pop();
1354 }
1355 label = m[2];
1356 if (!this.vimBuiltFunctionDocuments[label]) {
1357 this.vimBuiltFunctionDocuments[label] = [];
1358 }
1359 }
1360 else if (/^=+$/.test(line)) {
1361 if (label) {
1362 this.vimBuiltFunctionDocuments[label].pop();
1363 }
1364 break;
1365 }
1366 else if (label) {
1367 this.vimBuiltFunctionDocuments[label].push(line);
1368 }
1369 }
1370 }
1371 };
1372 Server.prototype.resolveBuiltinVimTestingFunctionsDocument = function () {
1373 var testingText = this.text[TESTING_PATH] || [];
1374 var isMatchLine = false;
1375 var label = "";
1376 // tslint:disable-next-line: prefer-for-of
1377 for (var idx = 0; idx < testingText.length; idx++) {
1378 var line = testingText[idx];
1379 if (!isMatchLine) {
1380 if (/^2\.\sTest\sfunctions\s+\*test-functions-details\*/.test(line)) {
1381 isMatchLine = true;
1382 idx += 1;
1383 }
1384 continue;
1385 }
1386 else {
1387 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
1388 if (m) {
1389 if (label) {
1390 this.vimBuiltFunctionDocuments[label].pop();
1391 }
1392 label = m[2];
1393 if (!this.vimBuiltFunctionDocuments[label]) {
1394 this.vimBuiltFunctionDocuments[label] = [];
1395 }
1396 }
1397 else if (/^=+$/.test(line)) {
1398 if (label) {
1399 this.vimBuiltFunctionDocuments[label].pop();
1400 }
1401 break;
1402 }
1403 else if (label) {
1404 this.vimBuiltFunctionDocuments[label].push(line);
1405 }
1406 }
1407 }
1408 };
1409 Server.prototype.resolveBuiltinNvimFunctions = function () {
1410 var evalText = this.text[API_PATH] || [];
1411 var completionItem;
1412 var pattern = /^((nvim_\w+)\(([^)]*)\))[ \t]*/m;
1413 for (var idx = 0; idx < evalText.length; idx++) {
1414 var line = evalText[idx];
1415 var m = line.match(pattern);
1416 if (!m && evalText[idx + 1]) {
1417 m = [line, evalText[idx + 1].trim()].join(" ").match(pattern);
1418 if (m) {
1419 idx++;
1420 }
1421 }
1422 if (m) {
1423 if (completionItem) {
1424 this.vimBuiltinFunctionItems.push(completionItem);
1425 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
1426 this.vimBuiltFunctionDocuments[completionItem.label].pop();
1427 }
1428 }
1429 var label = m[2];
1430 completionItem = {
1431 label: label,
1432 kind: vscode_languageserver_1.CompletionItemKind.Function,
1433 detail: "",
1434 documentation: "",
1435 sortText: "00004",
1436 insertText: this.formatFunctionSnippets(m[2], m[3]),
1437 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
1438 };
1439 if (!this.vimBuiltFunctionDocuments[label]) {
1440 this.vimBuiltFunctionDocuments[label] = [];
1441 }
1442 this.vimBuiltFunctionSignatureHelp[label] = [
1443 m[3],
1444 "",
1445 ];
1446 }
1447 else if (/^(================|[ \t]*vim:tw=78:ts=8:ft=help:norl:)/.test(line)) {
1448 if (completionItem) {
1449 this.vimBuiltinFunctionItems.push(completionItem);
1450 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
1451 this.vimBuiltFunctionDocuments[completionItem.label].pop();
1452 }
1453 completionItem = undefined;
1454 }
1455 }
1456 else if (completionItem && !/^[ \t]\*nvim(_\w+)+\(\)\*\s*$/.test(line)) {
1457 this.vimBuiltFunctionDocuments[completionItem.label].push(line);
1458 }
1459 }
1460 };
1461 Server.prototype.resolveVimCommands = function () {
1462 var indexText = this.text[INDEX_PATH] || [];
1463 var isMatchLine = false;
1464 var completionItem;
1465 for (var _i = 0, indexText_1 = indexText; _i < indexText_1.length; _i++) {
1466 var line = indexText_1[_i];
1467 if (!isMatchLine) {
1468 if (/\*ex-cmd-index\*/.test(line)) {
1469 isMatchLine = true;
1470 }
1471 continue;
1472 }
1473 else {
1474 var m = line.match(/^\|?:([^ \t]+?)\|?[ \t]+:([^ \t]+)[ \t]+([^ \t].*)$/);
1475 if (m) {
1476 if (completionItem) {
1477 this.vimCommandItems.push(completionItem);
1478 }
1479 var label = m[1];
1480 completionItem = {
1481 label: m[1],
1482 kind: vscode_languageserver_1.CompletionItemKind.Operator,
1483 detail: m[2],
1484 documentation: m[3],
1485 sortText: "00004",
1486 insertText: m[1],
1487 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1488 };
1489 if (!this.vimCommandDocuments[label]) {
1490 this.vimCommandDocuments[label] = [];
1491 }
1492 this.vimCommandDocuments[label].push(m[3]);
1493 }
1494 else if (/^[ \t]*$/.test(line)) {
1495 if (completionItem) {
1496 this.vimCommandItems.push(completionItem);
1497 completionItem = undefined;
1498 break;
1499 }
1500 }
1501 else if (completionItem) {
1502 completionItem.documentation += " " + line.trim();
1503 this.vimCommandDocuments[completionItem.label].push(line);
1504 }
1505 }
1506 }
1507 };
1508 Server.prototype.resolveVimFeatures = function () {
1509 var text = this.text[EVAL_PATH] || [];
1510 var isMatchLine = false;
1511 var completionItem;
1512 var features = [];
1513 for (var idx = 0; idx < text.length; idx++) {
1514 var line = text[idx];
1515 if (!isMatchLine) {
1516 if (/^[ \t]*acl[ \t]/.test(line)) {
1517 isMatchLine = true;
1518 idx -= 1;
1519 }
1520 continue;
1521 }
1522 else {
1523 var m = line.match(/^[ \t]*\*?([^ \t]+?)\*?[ \t]+([^ \t].*)$/);
1524 if (m) {
1525 if (completionItem) {
1526 features.push(completionItem);
1527 }
1528 var label = m[1];
1529 completionItem = {
1530 label: m[1],
1531 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
1532 documentation: "",
1533 sortText: "00004",
1534 insertText: m[1],
1535 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1536 };
1537 if (!this.vimFeatureDocuments[label]) {
1538 this.vimFeatureDocuments[label] = [];
1539 }
1540 this.vimFeatureDocuments[label].push(m[2]);
1541 }
1542 else if (/^[ \t]*$/.test(line)) {
1543 if (completionItem) {
1544 features.push(completionItem);
1545 break;
1546 }
1547 }
1548 else if (completionItem) {
1549 this.vimFeatureDocuments[completionItem.label].push(line);
1550 }
1551 }
1552 }
1553 this.vimFeatureItems = features;
1554 };
1555 Server.prototype.resolveVimAutocmds = function () {
1556 var text = this.text[AUTOCMD_PATH] || [];
1557 var isMatchLine = false;
1558 for (var idx = 0; idx < text.length; idx++) {
1559 var line = text[idx];
1560 if (!isMatchLine) {
1561 if (/^\|BufNewFile\|/.test(line)) {
1562 isMatchLine = true;
1563 idx -= 1;
1564 }
1565 continue;
1566 }
1567 else {
1568 var m = line.match(/^\|([^ \t]+)\|[ \t]+([^ \t].*)$/);
1569 if (m) {
1570 this.vimAutocmdItems.push({
1571 label: m[1],
1572 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
1573 documentation: m[2],
1574 sortText: "00004",
1575 insertText: m[1],
1576 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1577 });
1578 if (m[1] === "Signal") {
1579 break;
1580 }
1581 }
1582 }
1583 }
1584 };
1585 Server.prototype.resolveExpandKeywords = function () {
1586 var _this = this;
1587 this.vimExpandKeywordItems = [
1588 "<cfile>,file name under the cursor",
1589 "<afile>,autocmd file name",
1590 "<abuf>,autocmd buffer number (as a String!)",
1591 "<amatch>,autocmd matched name",
1592 "<sfile>,sourced script file or function name",
1593 "<slnum>,sourced script file line number",
1594 "<cword>,word under the cursor",
1595 "<cWORD>,WORD under the cursor",
1596 "<client>,the {clientid} of the last received message `server2client()`",
1597 ].map(function (line) {
1598 var item = line.split(",");
1599 _this.expandKeywordDocuments[item[0]] = [
1600 item[1],
1601 ];
1602 return {
1603 label: item[0],
1604 kind: vscode_languageserver_1.CompletionItemKind.Keyword,
1605 documentation: item[1],
1606 sortText: "00004",
1607 insertText: item[0],
1608 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
1609 };
1610 });
1611 };
1612 return Server;
1613}());
1614function main() {
1615 return __awaiter(this, void 0, void 0, function () {
1616 var servers, idx, server;
1617 return __generator(this, function (_a) {
1618 switch (_a.label) {
1619 case 0:
1620 servers = [];
1621 idx = 2;
1622 _a.label = 1;
1623 case 1:
1624 if (!(idx < process.argv.length)) return [3 /*break*/, 4];
1625 servers.push(new Server({
1626 vimruntime: process.argv[idx],
1627 }));
1628 return [4 /*yield*/, servers[servers.length - 1].build()];
1629 case 2:
1630 _a.sent();
1631 _a.label = 3;
1632 case 3:
1633 idx++;
1634 return [3 /*break*/, 1];
1635 case 4:
1636 server = servers.reduce(function (pre, next) {
1637 // merge functions
1638 next.vimBuiltinFunctionItems.forEach(function (item) {
1639 var label = item.label;
1640 if (!pre.vimBuiltFunctionDocuments[label]) {
1641 pre.vimBuiltinFunctionItems.push(item);
1642 pre.vimBuiltFunctionDocuments[label] = next.vimBuiltFunctionDocuments[label];
1643 }
1644 });
1645 // merge commands
1646 next.vimCommandItems.forEach(function (item) {
1647 var label = item.label;
1648 if (!pre.vimCommandDocuments[label]) {
1649 pre.vimCommandItems.push(item);
1650 pre.vimCommandDocuments[label] = next.vimCommandDocuments[label];
1651 }
1652 });
1653 // merge options
1654 next.vimOptionItems.forEach(function (item) {
1655 var label = item.label;
1656 if (!pre.vimOptionDocuments[label]) {
1657 pre.vimOptionItems.push(item);
1658 pre.vimOptionDocuments[label] = next.vimOptionDocuments[label];
1659 }
1660 });
1661 // merge variables
1662 next.vimPredefinedVariablesItems.forEach(function (item) {
1663 var label = item.label;
1664 if (!pre.vimPredefinedVariableDocuments[label]) {
1665 pre.vimPredefinedVariablesItems.push(item);
1666 pre.vimPredefinedVariableDocuments[label] = next.vimPredefinedVariableDocuments[label];
1667 }
1668 });
1669 // merge features
1670 next.vimFeatureItems.forEach(function (item) {
1671 var label = item.label;
1672 if (!pre.vimFeatureDocuments[label]) {
1673 pre.vimFeatureItems.push(item);
1674 pre.vimFeatureDocuments[label] = next.vimFeatureDocuments[label];
1675 }
1676 });
1677 // merge expand key words
1678 next.vimExpandKeywordItems.forEach(function (item) {
1679 var label = item.label;
1680 if (!pre.expandKeywordDocuments[label]) {
1681 pre.vimExpandKeywordItems.push(item);
1682 pre.expandKeywordDocuments[label] = next.expandKeywordDocuments[label];
1683 }
1684 });
1685 // merge autocmd
1686 next.vimAutocmdItems.forEach(function (item) {
1687 var label = item.label;
1688 if (!pre.vimAutocmdItems.some(function (n) { return n.label === label; })) {
1689 pre.vimAutocmdItems.push(item);
1690 }
1691 });
1692 // merge signature help
1693 pre.vimBuiltFunctionSignatureHelp = __assign(__assign({}, next.vimBuiltFunctionSignatureHelp), pre.vimBuiltFunctionSignatureHelp);
1694 return pre;
1695 });
1696 server.serialize();
1697 return [2 /*return*/];
1698 }
1699 });
1700 });
1701}
1702main();
1703
1704
1705/***/ }),
1706
1707/***/ 10:
1708/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1709
1710"use strict";
1711/*---------------------------------------------------------------------------------------------
1712 * Copyright (c) Microsoft Corporation. All rights reserved.
1713 * Licensed under the MIT License. See License.txt in the project root for license information.
1714 *--------------------------------------------------------------------------------------------*/
1715
1716Object.defineProperty(exports, "__esModule", ({ value: true }));
1717const events_1 = __webpack_require__(8);
1718const Is = __webpack_require__(5);
1719var CancellationToken;
1720(function (CancellationToken) {
1721 CancellationToken.None = Object.freeze({
1722 isCancellationRequested: false,
1723 onCancellationRequested: events_1.Event.None
1724 });
1725 CancellationToken.Cancelled = Object.freeze({
1726 isCancellationRequested: true,
1727 onCancellationRequested: events_1.Event.None
1728 });
1729 function is(value) {
1730 let candidate = value;
1731 return candidate && (candidate === CancellationToken.None
1732 || candidate === CancellationToken.Cancelled
1733 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
1734 }
1735 CancellationToken.is = is;
1736})(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
1737const shortcutEvent = Object.freeze(function (callback, context) {
1738 let handle = setTimeout(callback.bind(context), 0);
1739 return { dispose() { clearTimeout(handle); } };
1740});
1741class MutableToken {
1742 constructor() {
1743 this._isCancelled = false;
1744 }
1745 cancel() {
1746 if (!this._isCancelled) {
1747 this._isCancelled = true;
1748 if (this._emitter) {
1749 this._emitter.fire(undefined);
1750 this.dispose();
1751 }
1752 }
1753 }
1754 get isCancellationRequested() {
1755 return this._isCancelled;
1756 }
1757 get onCancellationRequested() {
1758 if (this._isCancelled) {
1759 return shortcutEvent;
1760 }
1761 if (!this._emitter) {
1762 this._emitter = new events_1.Emitter();
1763 }
1764 return this._emitter.event;
1765 }
1766 dispose() {
1767 if (this._emitter) {
1768 this._emitter.dispose();
1769 this._emitter = undefined;
1770 }
1771 }
1772}
1773class CancellationTokenSource {
1774 get token() {
1775 if (!this._token) {
1776 // be lazy and create the token only when
1777 // actually needed
1778 this._token = new MutableToken();
1779 }
1780 return this._token;
1781 }
1782 cancel() {
1783 if (!this._token) {
1784 // save an object by returning the default
1785 // cancelled token when cancellation happens
1786 // before someone asks for the token
1787 this._token = CancellationToken.Cancelled;
1788 }
1789 else {
1790 this._token.cancel();
1791 }
1792 }
1793 dispose() {
1794 if (!this._token) {
1795 // ensure to initialize with an empty token if we had none
1796 this._token = CancellationToken.None;
1797 }
1798 else if (this._token instanceof MutableToken) {
1799 // actually dispose
1800 this._token.dispose();
1801 }
1802 }
1803}
1804exports.CancellationTokenSource = CancellationTokenSource;
1805
1806
1807/***/ }),
1808
1809/***/ 8:
1810/***/ ((__unused_webpack_module, exports) => {
1811
1812"use strict";
1813/* --------------------------------------------------------------------------------------------
1814 * Copyright (c) Microsoft Corporation. All rights reserved.
1815 * Licensed under the MIT License. See License.txt in the project root for license information.
1816 * ------------------------------------------------------------------------------------------ */
1817
1818Object.defineProperty(exports, "__esModule", ({ value: true }));
1819var Disposable;
1820(function (Disposable) {
1821 function create(func) {
1822 return {
1823 dispose: func
1824 };
1825 }
1826 Disposable.create = create;
1827})(Disposable = exports.Disposable || (exports.Disposable = {}));
1828var Event;
1829(function (Event) {
1830 const _disposable = { dispose() { } };
1831 Event.None = function () { return _disposable; };
1832})(Event = exports.Event || (exports.Event = {}));
1833class CallbackList {
1834 add(callback, context = null, bucket) {
1835 if (!this._callbacks) {
1836 this._callbacks = [];
1837 this._contexts = [];
1838 }
1839 this._callbacks.push(callback);
1840 this._contexts.push(context);
1841 if (Array.isArray(bucket)) {
1842 bucket.push({ dispose: () => this.remove(callback, context) });
1843 }
1844 }
1845 remove(callback, context = null) {
1846 if (!this._callbacks) {
1847 return;
1848 }
1849 var foundCallbackWithDifferentContext = false;
1850 for (var i = 0, len = this._callbacks.length; i < len; i++) {
1851 if (this._callbacks[i] === callback) {
1852 if (this._contexts[i] === context) {
1853 // callback & context match => remove it
1854 this._callbacks.splice(i, 1);
1855 this._contexts.splice(i, 1);
1856 return;
1857 }
1858 else {
1859 foundCallbackWithDifferentContext = true;
1860 }
1861 }
1862 }
1863 if (foundCallbackWithDifferentContext) {
1864 throw new Error('When adding a listener with a context, you should remove it with the same context');
1865 }
1866 }
1867 invoke(...args) {
1868 if (!this._callbacks) {
1869 return [];
1870 }
1871 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
1872 for (var i = 0, len = callbacks.length; i < len; i++) {
1873 try {
1874 ret.push(callbacks[i].apply(contexts[i], args));
1875 }
1876 catch (e) {
1877 // eslint-disable-next-line no-console
1878 console.error(e);
1879 }
1880 }
1881 return ret;
1882 }
1883 isEmpty() {
1884 return !this._callbacks || this._callbacks.length === 0;
1885 }
1886 dispose() {
1887 this._callbacks = undefined;
1888 this._contexts = undefined;
1889 }
1890}
1891class Emitter {
1892 constructor(_options) {
1893 this._options = _options;
1894 }
1895 /**
1896 * For the public to allow to subscribe
1897 * to events from this Emitter
1898 */
1899 get event() {
1900 if (!this._event) {
1901 this._event = (listener, thisArgs, disposables) => {
1902 if (!this._callbacks) {
1903 this._callbacks = new CallbackList();
1904 }
1905 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
1906 this._options.onFirstListenerAdd(this);
1907 }
1908 this._callbacks.add(listener, thisArgs);
1909 let result;
1910 result = {
1911 dispose: () => {
1912 this._callbacks.remove(listener, thisArgs);
1913 result.dispose = Emitter._noop;
1914 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
1915 this._options.onLastListenerRemove(this);
1916 }
1917 }
1918 };
1919 if (Array.isArray(disposables)) {
1920 disposables.push(result);
1921 }
1922 return result;
1923 };
1924 }
1925 return this._event;
1926 }
1927 /**
1928 * To be kept private to fire an event to
1929 * subscribers
1930 */
1931 fire(event) {
1932 if (this._callbacks) {
1933 this._callbacks.invoke.call(this._callbacks, event);
1934 }
1935 }
1936 dispose() {
1937 if (this._callbacks) {
1938 this._callbacks.dispose();
1939 this._callbacks = undefined;
1940 }
1941 }
1942}
1943exports.Emitter = Emitter;
1944Emitter._noop = function () { };
1945
1946
1947/***/ }),
1948
1949/***/ 5:
1950/***/ ((__unused_webpack_module, exports) => {
1951
1952"use strict";
1953/* --------------------------------------------------------------------------------------------
1954 * Copyright (c) Microsoft Corporation. All rights reserved.
1955 * Licensed under the MIT License. See License.txt in the project root for license information.
1956 * ------------------------------------------------------------------------------------------ */
1957
1958Object.defineProperty(exports, "__esModule", ({ value: true }));
1959function boolean(value) {
1960 return value === true || value === false;
1961}
1962exports.boolean = boolean;
1963function string(value) {
1964 return typeof value === 'string' || value instanceof String;
1965}
1966exports.string = string;
1967function number(value) {
1968 return typeof value === 'number' || value instanceof Number;
1969}
1970exports.number = number;
1971function error(value) {
1972 return value instanceof Error;
1973}
1974exports.error = error;
1975function func(value) {
1976 return typeof value === 'function';
1977}
1978exports.func = func;
1979function array(value) {
1980 return Array.isArray(value);
1981}
1982exports.array = array;
1983function stringArray(value) {
1984 return array(value) && value.every(elem => string(elem));
1985}
1986exports.stringArray = stringArray;
1987
1988
1989/***/ }),
1990
1991/***/ 11:
1992/***/ ((__unused_webpack_module, exports) => {
1993
1994"use strict";
1995
1996/*---------------------------------------------------------------------------------------------
1997 * Copyright (c) Microsoft Corporation. All rights reserved.
1998 * Licensed under the MIT License. See License.txt in the project root for license information.
1999 *--------------------------------------------------------------------------------------------*/
2000Object.defineProperty(exports, "__esModule", ({ value: true }));
2001var Touch;
2002(function (Touch) {
2003 Touch.None = 0;
2004 Touch.First = 1;
2005 Touch.Last = 2;
2006})(Touch = exports.Touch || (exports.Touch = {}));
2007class LinkedMap {
2008 constructor() {
2009 this._map = new Map();
2010 this._head = undefined;
2011 this._tail = undefined;
2012 this._size = 0;
2013 }
2014 clear() {
2015 this._map.clear();
2016 this._head = undefined;
2017 this._tail = undefined;
2018 this._size = 0;
2019 }
2020 isEmpty() {
2021 return !this._head && !this._tail;
2022 }
2023 get size() {
2024 return this._size;
2025 }
2026 has(key) {
2027 return this._map.has(key);
2028 }
2029 get(key) {
2030 const item = this._map.get(key);
2031 if (!item) {
2032 return undefined;
2033 }
2034 return item.value;
2035 }
2036 set(key, value, touch = Touch.None) {
2037 let item = this._map.get(key);
2038 if (item) {
2039 item.value = value;
2040 if (touch !== Touch.None) {
2041 this.touch(item, touch);
2042 }
2043 }
2044 else {
2045 item = { key, value, next: undefined, previous: undefined };
2046 switch (touch) {
2047 case Touch.None:
2048 this.addItemLast(item);
2049 break;
2050 case Touch.First:
2051 this.addItemFirst(item);
2052 break;
2053 case Touch.Last:
2054 this.addItemLast(item);
2055 break;
2056 default:
2057 this.addItemLast(item);
2058 break;
2059 }
2060 this._map.set(key, item);
2061 this._size++;
2062 }
2063 }
2064 delete(key) {
2065 const item = this._map.get(key);
2066 if (!item) {
2067 return false;
2068 }
2069 this._map.delete(key);
2070 this.removeItem(item);
2071 this._size--;
2072 return true;
2073 }
2074 shift() {
2075 if (!this._head && !this._tail) {
2076 return undefined;
2077 }
2078 if (!this._head || !this._tail) {
2079 throw new Error('Invalid list');
2080 }
2081 const item = this._head;
2082 this._map.delete(item.key);
2083 this.removeItem(item);
2084 this._size--;
2085 return item.value;
2086 }
2087 forEach(callbackfn, thisArg) {
2088 let current = this._head;
2089 while (current) {
2090 if (thisArg) {
2091 callbackfn.bind(thisArg)(current.value, current.key, this);
2092 }
2093 else {
2094 callbackfn(current.value, current.key, this);
2095 }
2096 current = current.next;
2097 }
2098 }
2099 forEachReverse(callbackfn, thisArg) {
2100 let current = this._tail;
2101 while (current) {
2102 if (thisArg) {
2103 callbackfn.bind(thisArg)(current.value, current.key, this);
2104 }
2105 else {
2106 callbackfn(current.value, current.key, this);
2107 }
2108 current = current.previous;
2109 }
2110 }
2111 values() {
2112 let result = [];
2113 let current = this._head;
2114 while (current) {
2115 result.push(current.value);
2116 current = current.next;
2117 }
2118 return result;
2119 }
2120 keys() {
2121 let result = [];
2122 let current = this._head;
2123 while (current) {
2124 result.push(current.key);
2125 current = current.next;
2126 }
2127 return result;
2128 }
2129 /* JSON RPC run on es5 which has no Symbol.iterator
2130 public keys(): IterableIterator<K> {
2131 let current = this._head;
2132 let iterator: IterableIterator<K> = {
2133 [Symbol.iterator]() {
2134 return iterator;
2135 },
2136 next():IteratorResult<K> {
2137 if (current) {
2138 let result = { value: current.key, done: false };
2139 current = current.next;
2140 return result;
2141 } else {
2142 return { value: undefined, done: true };
2143 }
2144 }
2145 };
2146 return iterator;
2147 }
2148
2149 public values(): IterableIterator<V> {
2150 let current = this._head;
2151 let iterator: IterableIterator<V> = {
2152 [Symbol.iterator]() {
2153 return iterator;
2154 },
2155 next():IteratorResult<V> {
2156 if (current) {
2157 let result = { value: current.value, done: false };
2158 current = current.next;
2159 return result;
2160 } else {
2161 return { value: undefined, done: true };
2162 }
2163 }
2164 };
2165 return iterator;
2166 }
2167 */
2168 addItemFirst(item) {
2169 // First time Insert
2170 if (!this._head && !this._tail) {
2171 this._tail = item;
2172 }
2173 else if (!this._head) {
2174 throw new Error('Invalid list');
2175 }
2176 else {
2177 item.next = this._head;
2178 this._head.previous = item;
2179 }
2180 this._head = item;
2181 }
2182 addItemLast(item) {
2183 // First time Insert
2184 if (!this._head && !this._tail) {
2185 this._head = item;
2186 }
2187 else if (!this._tail) {
2188 throw new Error('Invalid list');
2189 }
2190 else {
2191 item.previous = this._tail;
2192 this._tail.next = item;
2193 }
2194 this._tail = item;
2195 }
2196 removeItem(item) {
2197 if (item === this._head && item === this._tail) {
2198 this._head = undefined;
2199 this._tail = undefined;
2200 }
2201 else if (item === this._head) {
2202 this._head = item.next;
2203 }
2204 else if (item === this._tail) {
2205 this._tail = item.previous;
2206 }
2207 else {
2208 const next = item.next;
2209 const previous = item.previous;
2210 if (!next || !previous) {
2211 throw new Error('Invalid list');
2212 }
2213 next.previous = previous;
2214 previous.next = next;
2215 }
2216 }
2217 touch(item, touch) {
2218 if (!this._head || !this._tail) {
2219 throw new Error('Invalid list');
2220 }
2221 if ((touch !== Touch.First && touch !== Touch.Last)) {
2222 return;
2223 }
2224 if (touch === Touch.First) {
2225 if (item === this._head) {
2226 return;
2227 }
2228 const next = item.next;
2229 const previous = item.previous;
2230 // Unlink the item
2231 if (item === this._tail) {
2232 // previous must be defined since item was not head but is tail
2233 // So there are more than on item in the map
2234 previous.next = undefined;
2235 this._tail = previous;
2236 }
2237 else {
2238 // Both next and previous are not undefined since item was neither head nor tail.
2239 next.previous = previous;
2240 previous.next = next;
2241 }
2242 // Insert the node at head
2243 item.previous = undefined;
2244 item.next = this._head;
2245 this._head.previous = item;
2246 this._head = item;
2247 }
2248 else if (touch === Touch.Last) {
2249 if (item === this._tail) {
2250 return;
2251 }
2252 const next = item.next;
2253 const previous = item.previous;
2254 // Unlink the item.
2255 if (item === this._head) {
2256 // next must be defined since item was not tail but is head
2257 // So there are more than on item in the map
2258 next.previous = undefined;
2259 this._head = next;
2260 }
2261 else {
2262 // Both next and previous are not undefined since item was neither head nor tail.
2263 next.previous = previous;
2264 previous.next = next;
2265 }
2266 item.next = undefined;
2267 item.previous = this._tail;
2268 this._tail.next = item;
2269 this._tail = item;
2270 }
2271 }
2272}
2273exports.LinkedMap = LinkedMap;
2274
2275
2276/***/ }),
2277
2278/***/ 4:
2279/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2280
2281"use strict";
2282/* --------------------------------------------------------------------------------------------
2283 * Copyright (c) Microsoft Corporation. All rights reserved.
2284 * Licensed under the MIT License. See License.txt in the project root for license information.
2285 * ------------------------------------------------------------------------------------------ */
2286/// <reference path="../typings/thenable.d.ts" />
2287
2288function __export(m) {
2289 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
2290}
2291Object.defineProperty(exports, "__esModule", ({ value: true }));
2292const Is = __webpack_require__(5);
2293const messages_1 = __webpack_require__(6);
2294exports.RequestType = messages_1.RequestType;
2295exports.RequestType0 = messages_1.RequestType0;
2296exports.RequestType1 = messages_1.RequestType1;
2297exports.RequestType2 = messages_1.RequestType2;
2298exports.RequestType3 = messages_1.RequestType3;
2299exports.RequestType4 = messages_1.RequestType4;
2300exports.RequestType5 = messages_1.RequestType5;
2301exports.RequestType6 = messages_1.RequestType6;
2302exports.RequestType7 = messages_1.RequestType7;
2303exports.RequestType8 = messages_1.RequestType8;
2304exports.RequestType9 = messages_1.RequestType9;
2305exports.ResponseError = messages_1.ResponseError;
2306exports.ErrorCodes = messages_1.ErrorCodes;
2307exports.NotificationType = messages_1.NotificationType;
2308exports.NotificationType0 = messages_1.NotificationType0;
2309exports.NotificationType1 = messages_1.NotificationType1;
2310exports.NotificationType2 = messages_1.NotificationType2;
2311exports.NotificationType3 = messages_1.NotificationType3;
2312exports.NotificationType4 = messages_1.NotificationType4;
2313exports.NotificationType5 = messages_1.NotificationType5;
2314exports.NotificationType6 = messages_1.NotificationType6;
2315exports.NotificationType7 = messages_1.NotificationType7;
2316exports.NotificationType8 = messages_1.NotificationType8;
2317exports.NotificationType9 = messages_1.NotificationType9;
2318const messageReader_1 = __webpack_require__(7);
2319exports.MessageReader = messageReader_1.MessageReader;
2320exports.StreamMessageReader = messageReader_1.StreamMessageReader;
2321exports.IPCMessageReader = messageReader_1.IPCMessageReader;
2322exports.SocketMessageReader = messageReader_1.SocketMessageReader;
2323const messageWriter_1 = __webpack_require__(9);
2324exports.MessageWriter = messageWriter_1.MessageWriter;
2325exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
2326exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
2327exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
2328const events_1 = __webpack_require__(8);
2329exports.Disposable = events_1.Disposable;
2330exports.Event = events_1.Event;
2331exports.Emitter = events_1.Emitter;
2332const cancellation_1 = __webpack_require__(10);
2333exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
2334exports.CancellationToken = cancellation_1.CancellationToken;
2335const linkedMap_1 = __webpack_require__(11);
2336__export(__webpack_require__(12));
2337__export(__webpack_require__(17));
2338var CancelNotification;
2339(function (CancelNotification) {
2340 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
2341})(CancelNotification || (CancelNotification = {}));
2342var ProgressNotification;
2343(function (ProgressNotification) {
2344 ProgressNotification.type = new messages_1.NotificationType('$/progress');
2345})(ProgressNotification || (ProgressNotification = {}));
2346class ProgressType {
2347 constructor() {
2348 }
2349}
2350exports.ProgressType = ProgressType;
2351exports.NullLogger = Object.freeze({
2352 error: () => { },
2353 warn: () => { },
2354 info: () => { },
2355 log: () => { }
2356});
2357var Trace;
2358(function (Trace) {
2359 Trace[Trace["Off"] = 0] = "Off";
2360 Trace[Trace["Messages"] = 1] = "Messages";
2361 Trace[Trace["Verbose"] = 2] = "Verbose";
2362})(Trace = exports.Trace || (exports.Trace = {}));
2363(function (Trace) {
2364 function fromString(value) {
2365 if (!Is.string(value)) {
2366 return Trace.Off;
2367 }
2368 value = value.toLowerCase();
2369 switch (value) {
2370 case 'off':
2371 return Trace.Off;
2372 case 'messages':
2373 return Trace.Messages;
2374 case 'verbose':
2375 return Trace.Verbose;
2376 default:
2377 return Trace.Off;
2378 }
2379 }
2380 Trace.fromString = fromString;
2381 function toString(value) {
2382 switch (value) {
2383 case Trace.Off:
2384 return 'off';
2385 case Trace.Messages:
2386 return 'messages';
2387 case Trace.Verbose:
2388 return 'verbose';
2389 default:
2390 return 'off';
2391 }
2392 }
2393 Trace.toString = toString;
2394})(Trace = exports.Trace || (exports.Trace = {}));
2395var TraceFormat;
2396(function (TraceFormat) {
2397 TraceFormat["Text"] = "text";
2398 TraceFormat["JSON"] = "json";
2399})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
2400(function (TraceFormat) {
2401 function fromString(value) {
2402 value = value.toLowerCase();
2403 if (value === 'json') {
2404 return TraceFormat.JSON;
2405 }
2406 else {
2407 return TraceFormat.Text;
2408 }
2409 }
2410 TraceFormat.fromString = fromString;
2411})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
2412var SetTraceNotification;
2413(function (SetTraceNotification) {
2414 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
2415})(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
2416var LogTraceNotification;
2417(function (LogTraceNotification) {
2418 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
2419})(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
2420var ConnectionErrors;
2421(function (ConnectionErrors) {
2422 /**
2423 * The connection is closed.
2424 */
2425 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
2426 /**
2427 * The connection got disposed.
2428 */
2429 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
2430 /**
2431 * The connection is already in listening mode.
2432 */
2433 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
2434})(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
2435class ConnectionError extends Error {
2436 constructor(code, message) {
2437 super(message);
2438 this.code = code;
2439 Object.setPrototypeOf(this, ConnectionError.prototype);
2440 }
2441}
2442exports.ConnectionError = ConnectionError;
2443var ConnectionStrategy;
2444(function (ConnectionStrategy) {
2445 function is(value) {
2446 let candidate = value;
2447 return candidate && Is.func(candidate.cancelUndispatched);
2448 }
2449 ConnectionStrategy.is = is;
2450})(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
2451var ConnectionState;
2452(function (ConnectionState) {
2453 ConnectionState[ConnectionState["New"] = 1] = "New";
2454 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
2455 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
2456 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
2457})(ConnectionState || (ConnectionState = {}));
2458function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
2459 let sequenceNumber = 0;
2460 let notificationSquenceNumber = 0;
2461 let unknownResponseSquenceNumber = 0;
2462 const version = '2.0';
2463 let starRequestHandler = undefined;
2464 let requestHandlers = Object.create(null);
2465 let starNotificationHandler = undefined;
2466 let notificationHandlers = Object.create(null);
2467 let progressHandlers = new Map();
2468 let timer;
2469 let messageQueue = new linkedMap_1.LinkedMap();
2470 let responsePromises = Object.create(null);
2471 let requestTokens = Object.create(null);
2472 let trace = Trace.Off;
2473 let traceFormat = TraceFormat.Text;
2474 let tracer;
2475 let state = ConnectionState.New;
2476 let errorEmitter = new events_1.Emitter();
2477 let closeEmitter = new events_1.Emitter();
2478 let unhandledNotificationEmitter = new events_1.Emitter();
2479 let unhandledProgressEmitter = new events_1.Emitter();
2480 let disposeEmitter = new events_1.Emitter();
2481 function createRequestQueueKey(id) {
2482 return 'req-' + id.toString();
2483 }
2484 function createResponseQueueKey(id) {
2485 if (id === null) {
2486 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
2487 }
2488 else {
2489 return 'res-' + id.toString();
2490 }
2491 }
2492 function createNotificationQueueKey() {
2493 return 'not-' + (++notificationSquenceNumber).toString();
2494 }
2495 function addMessageToQueue(queue, message) {
2496 if (messages_1.isRequestMessage(message)) {
2497 queue.set(createRequestQueueKey(message.id), message);
2498 }
2499 else if (messages_1.isResponseMessage(message)) {
2500 queue.set(createResponseQueueKey(message.id), message);
2501 }
2502 else {
2503 queue.set(createNotificationQueueKey(), message);
2504 }
2505 }
2506 function cancelUndispatched(_message) {
2507 return undefined;
2508 }
2509 function isListening() {
2510 return state === ConnectionState.Listening;
2511 }
2512 function isClosed() {
2513 return state === ConnectionState.Closed;
2514 }
2515 function isDisposed() {
2516 return state === ConnectionState.Disposed;
2517 }
2518 function closeHandler() {
2519 if (state === ConnectionState.New || state === ConnectionState.Listening) {
2520 state = ConnectionState.Closed;
2521 closeEmitter.fire(undefined);
2522 }
2523 // If the connection is disposed don't sent close events.
2524 }
2525 function readErrorHandler(error) {
2526 errorEmitter.fire([error, undefined, undefined]);
2527 }
2528 function writeErrorHandler(data) {
2529 errorEmitter.fire(data);
2530 }
2531 messageReader.onClose(closeHandler);
2532 messageReader.onError(readErrorHandler);
2533 messageWriter.onClose(closeHandler);
2534 messageWriter.onError(writeErrorHandler);
2535 function triggerMessageQueue() {
2536 if (timer || messageQueue.size === 0) {
2537 return;
2538 }
2539 timer = setImmediate(() => {
2540 timer = undefined;
2541 processMessageQueue();
2542 });
2543 }
2544 function processMessageQueue() {
2545 if (messageQueue.size === 0) {
2546 return;
2547 }
2548 let message = messageQueue.shift();
2549 try {
2550 if (messages_1.isRequestMessage(message)) {
2551 handleRequest(message);
2552 }
2553 else if (messages_1.isNotificationMessage(message)) {
2554 handleNotification(message);
2555 }
2556 else if (messages_1.isResponseMessage(message)) {
2557 handleResponse(message);
2558 }
2559 else {
2560 handleInvalidMessage(message);
2561 }
2562 }
2563 finally {
2564 triggerMessageQueue();
2565 }
2566 }
2567 let callback = (message) => {
2568 try {
2569 // We have received a cancellation message. Check if the message is still in the queue
2570 // and cancel it if allowed to do so.
2571 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
2572 let key = createRequestQueueKey(message.params.id);
2573 let toCancel = messageQueue.get(key);
2574 if (messages_1.isRequestMessage(toCancel)) {
2575 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
2576 if (response && (response.error !== void 0 || response.result !== void 0)) {
2577 messageQueue.delete(key);
2578 response.id = toCancel.id;
2579 traceSendingResponse(response, message.method, Date.now());
2580 messageWriter.write(response);
2581 return;
2582 }
2583 }
2584 }
2585 addMessageToQueue(messageQueue, message);
2586 }
2587 finally {
2588 triggerMessageQueue();
2589 }
2590 };
2591 function handleRequest(requestMessage) {
2592 if (isDisposed()) {
2593 // we return here silently since we fired an event when the
2594 // connection got disposed.
2595 return;
2596 }
2597 function reply(resultOrError, method, startTime) {
2598 let message = {
2599 jsonrpc: version,
2600 id: requestMessage.id
2601 };
2602 if (resultOrError instanceof messages_1.ResponseError) {
2603 message.error = resultOrError.toJson();
2604 }
2605 else {
2606 message.result = resultOrError === void 0 ? null : resultOrError;
2607 }
2608 traceSendingResponse(message, method, startTime);
2609 messageWriter.write(message);
2610 }
2611 function replyError(error, method, startTime) {
2612 let message = {
2613 jsonrpc: version,
2614 id: requestMessage.id,
2615 error: error.toJson()
2616 };
2617 traceSendingResponse(message, method, startTime);
2618 messageWriter.write(message);
2619 }
2620 function replySuccess(result, method, startTime) {
2621 // The JSON RPC defines that a response must either have a result or an error
2622 // So we can't treat undefined as a valid response result.
2623 if (result === void 0) {
2624 result = null;
2625 }
2626 let message = {
2627 jsonrpc: version,
2628 id: requestMessage.id,
2629 result: result
2630 };
2631 traceSendingResponse(message, method, startTime);
2632 messageWriter.write(message);
2633 }
2634 traceReceivedRequest(requestMessage);
2635 let element = requestHandlers[requestMessage.method];
2636 let type;
2637 let requestHandler;
2638 if (element) {
2639 type = element.type;
2640 requestHandler = element.handler;
2641 }
2642 let startTime = Date.now();
2643 if (requestHandler || starRequestHandler) {
2644 let cancellationSource = new cancellation_1.CancellationTokenSource();
2645 let tokenKey = String(requestMessage.id);
2646 requestTokens[tokenKey] = cancellationSource;
2647 try {
2648 let handlerResult;
2649 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
2650 handlerResult = requestHandler
2651 ? requestHandler(cancellationSource.token)
2652 : starRequestHandler(requestMessage.method, cancellationSource.token);
2653 }
2654 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
2655 handlerResult = requestHandler
2656 ? requestHandler(...requestMessage.params, cancellationSource.token)
2657 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
2658 }
2659 else {
2660 handlerResult = requestHandler
2661 ? requestHandler(requestMessage.params, cancellationSource.token)
2662 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
2663 }
2664 let promise = handlerResult;
2665 if (!handlerResult) {
2666 delete requestTokens[tokenKey];
2667 replySuccess(handlerResult, requestMessage.method, startTime);
2668 }
2669 else if (promise.then) {
2670 promise.then((resultOrError) => {
2671 delete requestTokens[tokenKey];
2672 reply(resultOrError, requestMessage.method, startTime);
2673 }, error => {
2674 delete requestTokens[tokenKey];
2675 if (error instanceof messages_1.ResponseError) {
2676 replyError(error, requestMessage.method, startTime);
2677 }
2678 else if (error && Is.string(error.message)) {
2679 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
2680 }
2681 else {
2682 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
2683 }
2684 });
2685 }
2686 else {
2687 delete requestTokens[tokenKey];
2688 reply(handlerResult, requestMessage.method, startTime);
2689 }
2690 }
2691 catch (error) {
2692 delete requestTokens[tokenKey];
2693 if (error instanceof messages_1.ResponseError) {
2694 reply(error, requestMessage.method, startTime);
2695 }
2696 else if (error && Is.string(error.message)) {
2697 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
2698 }
2699 else {
2700 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
2701 }
2702 }
2703 }
2704 else {
2705 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
2706 }
2707 }
2708 function handleResponse(responseMessage) {
2709 if (isDisposed()) {
2710 // See handle request.
2711 return;
2712 }
2713 if (responseMessage.id === null) {
2714 if (responseMessage.error) {
2715 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
2716 }
2717 else {
2718 logger.error(`Received response message without id. No further error information provided.`);
2719 }
2720 }
2721 else {
2722 let key = String(responseMessage.id);
2723 let responsePromise = responsePromises[key];
2724 traceReceivedResponse(responseMessage, responsePromise);
2725 if (responsePromise) {
2726 delete responsePromises[key];
2727 try {
2728 if (responseMessage.error) {
2729 let error = responseMessage.error;
2730 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
2731 }
2732 else if (responseMessage.result !== void 0) {
2733 responsePromise.resolve(responseMessage.result);
2734 }
2735 else {
2736 throw new Error('Should never happen.');
2737 }
2738 }
2739 catch (error) {
2740 if (error.message) {
2741 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
2742 }
2743 else {
2744 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
2745 }
2746 }
2747 }
2748 }
2749 }
2750 function handleNotification(message) {
2751 if (isDisposed()) {
2752 // See handle request.
2753 return;
2754 }
2755 let type = undefined;
2756 let notificationHandler;
2757 if (message.method === CancelNotification.type.method) {
2758 notificationHandler = (params) => {
2759 let id = params.id;
2760 let source = requestTokens[String(id)];
2761 if (source) {
2762 source.cancel();
2763 }
2764 };
2765 }
2766 else {
2767 let element = notificationHandlers[message.method];
2768 if (element) {
2769 notificationHandler = element.handler;
2770 type = element.type;
2771 }
2772 }
2773 if (notificationHandler || starNotificationHandler) {
2774 try {
2775 traceReceivedNotification(message);
2776 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
2777 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
2778 }
2779 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
2780 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
2781 }
2782 else {
2783 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
2784 }
2785 }
2786 catch (error) {
2787 if (error.message) {
2788 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
2789 }
2790 else {
2791 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
2792 }
2793 }
2794 }
2795 else {
2796 unhandledNotificationEmitter.fire(message);
2797 }
2798 }
2799 function handleInvalidMessage(message) {
2800 if (!message) {
2801 logger.error('Received empty message.');
2802 return;
2803 }
2804 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
2805 // Test whether we find an id to reject the promise
2806 let responseMessage = message;
2807 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
2808 let key = String(responseMessage.id);
2809 let responseHandler = responsePromises[key];
2810 if (responseHandler) {
2811 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
2812 }
2813 }
2814 }
2815 function traceSendingRequest(message) {
2816 if (trace === Trace.Off || !tracer) {
2817 return;
2818 }
2819 if (traceFormat === TraceFormat.Text) {
2820 let data = undefined;
2821 if (trace === Trace.Verbose && message.params) {
2822 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2823 }
2824 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
2825 }
2826 else {
2827 logLSPMessage('send-request', message);
2828 }
2829 }
2830 function traceSendingNotification(message) {
2831 if (trace === Trace.Off || !tracer) {
2832 return;
2833 }
2834 if (traceFormat === TraceFormat.Text) {
2835 let data = undefined;
2836 if (trace === Trace.Verbose) {
2837 if (message.params) {
2838 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2839 }
2840 else {
2841 data = 'No parameters provided.\n\n';
2842 }
2843 }
2844 tracer.log(`Sending notification '${message.method}'.`, data);
2845 }
2846 else {
2847 logLSPMessage('send-notification', message);
2848 }
2849 }
2850 function traceSendingResponse(message, method, startTime) {
2851 if (trace === Trace.Off || !tracer) {
2852 return;
2853 }
2854 if (traceFormat === TraceFormat.Text) {
2855 let data = undefined;
2856 if (trace === Trace.Verbose) {
2857 if (message.error && message.error.data) {
2858 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
2859 }
2860 else {
2861 if (message.result) {
2862 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
2863 }
2864 else if (message.error === void 0) {
2865 data = 'No result returned.\n\n';
2866 }
2867 }
2868 }
2869 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
2870 }
2871 else {
2872 logLSPMessage('send-response', message);
2873 }
2874 }
2875 function traceReceivedRequest(message) {
2876 if (trace === Trace.Off || !tracer) {
2877 return;
2878 }
2879 if (traceFormat === TraceFormat.Text) {
2880 let data = undefined;
2881 if (trace === Trace.Verbose && message.params) {
2882 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2883 }
2884 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
2885 }
2886 else {
2887 logLSPMessage('receive-request', message);
2888 }
2889 }
2890 function traceReceivedNotification(message) {
2891 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
2892 return;
2893 }
2894 if (traceFormat === TraceFormat.Text) {
2895 let data = undefined;
2896 if (trace === Trace.Verbose) {
2897 if (message.params) {
2898 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
2899 }
2900 else {
2901 data = 'No parameters provided.\n\n';
2902 }
2903 }
2904 tracer.log(`Received notification '${message.method}'.`, data);
2905 }
2906 else {
2907 logLSPMessage('receive-notification', message);
2908 }
2909 }
2910 function traceReceivedResponse(message, responsePromise) {
2911 if (trace === Trace.Off || !tracer) {
2912 return;
2913 }
2914 if (traceFormat === TraceFormat.Text) {
2915 let data = undefined;
2916 if (trace === Trace.Verbose) {
2917 if (message.error && message.error.data) {
2918 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
2919 }
2920 else {
2921 if (message.result) {
2922 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
2923 }
2924 else if (message.error === void 0) {
2925 data = 'No result returned.\n\n';
2926 }
2927 }
2928 }
2929 if (responsePromise) {
2930 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
2931 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
2932 }
2933 else {
2934 tracer.log(`Received response ${message.id} without active response promise.`, data);
2935 }
2936 }
2937 else {
2938 logLSPMessage('receive-response', message);
2939 }
2940 }
2941 function logLSPMessage(type, message) {
2942 if (!tracer || trace === Trace.Off) {
2943 return;
2944 }
2945 const lspMessage = {
2946 isLSPMessage: true,
2947 type,
2948 message,
2949 timestamp: Date.now()
2950 };
2951 tracer.log(lspMessage);
2952 }
2953 function throwIfClosedOrDisposed() {
2954 if (isClosed()) {
2955 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
2956 }
2957 if (isDisposed()) {
2958 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
2959 }
2960 }
2961 function throwIfListening() {
2962 if (isListening()) {
2963 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
2964 }
2965 }
2966 function throwIfNotListening() {
2967 if (!isListening()) {
2968 throw new Error('Call listen() first.');
2969 }
2970 }
2971 function undefinedToNull(param) {
2972 if (param === void 0) {
2973 return null;
2974 }
2975 else {
2976 return param;
2977 }
2978 }
2979 function computeMessageParams(type, params) {
2980 let result;
2981 let numberOfParams = type.numberOfParams;
2982 switch (numberOfParams) {
2983 case 0:
2984 result = null;
2985 break;
2986 case 1:
2987 result = undefinedToNull(params[0]);
2988 break;
2989 default:
2990 result = [];
2991 for (let i = 0; i < params.length && i < numberOfParams; i++) {
2992 result.push(undefinedToNull(params[i]));
2993 }
2994 if (params.length < numberOfParams) {
2995 for (let i = params.length; i < numberOfParams; i++) {
2996 result.push(null);
2997 }
2998 }
2999 break;
3000 }
3001 return result;
3002 }
3003 let connection = {
3004 sendNotification: (type, ...params) => {
3005 throwIfClosedOrDisposed();
3006 let method;
3007 let messageParams;
3008 if (Is.string(type)) {
3009 method = type;
3010 switch (params.length) {
3011 case 0:
3012 messageParams = null;
3013 break;
3014 case 1:
3015 messageParams = params[0];
3016 break;
3017 default:
3018 messageParams = params;
3019 break;
3020 }
3021 }
3022 else {
3023 method = type.method;
3024 messageParams = computeMessageParams(type, params);
3025 }
3026 let notificationMessage = {
3027 jsonrpc: version,
3028 method: method,
3029 params: messageParams
3030 };
3031 traceSendingNotification(notificationMessage);
3032 messageWriter.write(notificationMessage);
3033 },
3034 onNotification: (type, handler) => {
3035 throwIfClosedOrDisposed();
3036 if (Is.func(type)) {
3037 starNotificationHandler = type;
3038 }
3039 else if (handler) {
3040 if (Is.string(type)) {
3041 notificationHandlers[type] = { type: undefined, handler };
3042 }
3043 else {
3044 notificationHandlers[type.method] = { type, handler };
3045 }
3046 }
3047 },
3048 onProgress: (_type, token, handler) => {
3049 if (progressHandlers.has(token)) {
3050 throw new Error(`Progress handler for token ${token} already registered`);
3051 }
3052 progressHandlers.set(token, handler);
3053 return {
3054 dispose: () => {
3055 progressHandlers.delete(token);
3056 }
3057 };
3058 },
3059 sendProgress: (_type, token, value) => {
3060 connection.sendNotification(ProgressNotification.type, { token, value });
3061 },
3062 onUnhandledProgress: unhandledProgressEmitter.event,
3063 sendRequest: (type, ...params) => {
3064 throwIfClosedOrDisposed();
3065 throwIfNotListening();
3066 let method;
3067 let messageParams;
3068 let token = undefined;
3069 if (Is.string(type)) {
3070 method = type;
3071 switch (params.length) {
3072 case 0:
3073 messageParams = null;
3074 break;
3075 case 1:
3076 // The cancellation token is optional so it can also be undefined.
3077 if (cancellation_1.CancellationToken.is(params[0])) {
3078 messageParams = null;
3079 token = params[0];
3080 }
3081 else {
3082 messageParams = undefinedToNull(params[0]);
3083 }
3084 break;
3085 default:
3086 const last = params.length - 1;
3087 if (cancellation_1.CancellationToken.is(params[last])) {
3088 token = params[last];
3089 if (params.length === 2) {
3090 messageParams = undefinedToNull(params[0]);
3091 }
3092 else {
3093 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
3094 }
3095 }
3096 else {
3097 messageParams = params.map(value => undefinedToNull(value));
3098 }
3099 break;
3100 }
3101 }
3102 else {
3103 method = type.method;
3104 messageParams = computeMessageParams(type, params);
3105 let numberOfParams = type.numberOfParams;
3106 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
3107 }
3108 let id = sequenceNumber++;
3109 let result = new Promise((resolve, reject) => {
3110 let requestMessage = {
3111 jsonrpc: version,
3112 id: id,
3113 method: method,
3114 params: messageParams
3115 };
3116 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
3117 traceSendingRequest(requestMessage);
3118 try {
3119 messageWriter.write(requestMessage);
3120 }
3121 catch (e) {
3122 // Writing the message failed. So we need to reject the promise.
3123 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
3124 responsePromise = null;
3125 }
3126 if (responsePromise) {
3127 responsePromises[String(id)] = responsePromise;
3128 }
3129 });
3130 if (token) {
3131 token.onCancellationRequested(() => {
3132 connection.sendNotification(CancelNotification.type, { id });
3133 });
3134 }
3135 return result;
3136 },
3137 onRequest: (type, handler) => {
3138 throwIfClosedOrDisposed();
3139 if (Is.func(type)) {
3140 starRequestHandler = type;
3141 }
3142 else if (handler) {
3143 if (Is.string(type)) {
3144 requestHandlers[type] = { type: undefined, handler };
3145 }
3146 else {
3147 requestHandlers[type.method] = { type, handler };
3148 }
3149 }
3150 },
3151 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
3152 let _sendNotification = false;
3153 let _traceFormat = TraceFormat.Text;
3154 if (sendNotificationOrTraceOptions !== void 0) {
3155 if (Is.boolean(sendNotificationOrTraceOptions)) {
3156 _sendNotification = sendNotificationOrTraceOptions;
3157 }
3158 else {
3159 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
3160 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
3161 }
3162 }
3163 trace = _value;
3164 traceFormat = _traceFormat;
3165 if (trace === Trace.Off) {
3166 tracer = undefined;
3167 }
3168 else {
3169 tracer = _tracer;
3170 }
3171 if (_sendNotification && !isClosed() && !isDisposed()) {
3172 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
3173 }
3174 },
3175 onError: errorEmitter.event,
3176 onClose: closeEmitter.event,
3177 onUnhandledNotification: unhandledNotificationEmitter.event,
3178 onDispose: disposeEmitter.event,
3179 dispose: () => {
3180 if (isDisposed()) {
3181 return;
3182 }
3183 state = ConnectionState.Disposed;
3184 disposeEmitter.fire(undefined);
3185 let error = new Error('Connection got disposed.');
3186 Object.keys(responsePromises).forEach((key) => {
3187 responsePromises[key].reject(error);
3188 });
3189 responsePromises = Object.create(null);
3190 requestTokens = Object.create(null);
3191 messageQueue = new linkedMap_1.LinkedMap();
3192 // Test for backwards compatibility
3193 if (Is.func(messageWriter.dispose)) {
3194 messageWriter.dispose();
3195 }
3196 if (Is.func(messageReader.dispose)) {
3197 messageReader.dispose();
3198 }
3199 },
3200 listen: () => {
3201 throwIfClosedOrDisposed();
3202 throwIfListening();
3203 state = ConnectionState.Listening;
3204 messageReader.listen(callback);
3205 },
3206 inspect: () => {
3207 // eslint-disable-next-line no-console
3208 console.log('inspect');
3209 }
3210 };
3211 connection.onNotification(LogTraceNotification.type, (params) => {
3212 if (trace === Trace.Off || !tracer) {
3213 return;
3214 }
3215 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
3216 });
3217 connection.onNotification(ProgressNotification.type, (params) => {
3218 const handler = progressHandlers.get(params.token);
3219 if (handler) {
3220 handler(params.value);
3221 }
3222 else {
3223 unhandledProgressEmitter.fire(params);
3224 }
3225 });
3226 return connection;
3227}
3228function isMessageReader(value) {
3229 return value.listen !== void 0 && value.read === void 0;
3230}
3231function isMessageWriter(value) {
3232 return value.write !== void 0 && value.end === void 0;
3233}
3234function createMessageConnection(input, output, logger, strategy) {
3235 if (!logger) {
3236 logger = exports.NullLogger;
3237 }
3238 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
3239 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
3240 return _createMessageConnection(reader, writer, logger, strategy);
3241}
3242exports.createMessageConnection = createMessageConnection;
3243
3244
3245/***/ }),
3246
3247/***/ 7:
3248/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3249
3250"use strict";
3251/* --------------------------------------------------------------------------------------------
3252 * Copyright (c) Microsoft Corporation. All rights reserved.
3253 * Licensed under the MIT License. See License.txt in the project root for license information.
3254 * ------------------------------------------------------------------------------------------ */
3255
3256Object.defineProperty(exports, "__esModule", ({ value: true }));
3257const events_1 = __webpack_require__(8);
3258const Is = __webpack_require__(5);
3259let DefaultSize = 8192;
3260let CR = Buffer.from('\r', 'ascii')[0];
3261let LF = Buffer.from('\n', 'ascii')[0];
3262let CRLF = '\r\n';
3263class MessageBuffer {
3264 constructor(encoding = 'utf8') {
3265 this.encoding = encoding;
3266 this.index = 0;
3267 this.buffer = Buffer.allocUnsafe(DefaultSize);
3268 }
3269 append(chunk) {
3270 var toAppend = chunk;
3271 if (typeof (chunk) === 'string') {
3272 var str = chunk;
3273 var bufferLen = Buffer.byteLength(str, this.encoding);
3274 toAppend = Buffer.allocUnsafe(bufferLen);
3275 toAppend.write(str, 0, bufferLen, this.encoding);
3276 }
3277 if (this.buffer.length - this.index >= toAppend.length) {
3278 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
3279 }
3280 else {
3281 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
3282 if (this.index === 0) {
3283 this.buffer = Buffer.allocUnsafe(newSize);
3284 toAppend.copy(this.buffer, 0, 0, toAppend.length);
3285 }
3286 else {
3287 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
3288 }
3289 }
3290 this.index += toAppend.length;
3291 }
3292 tryReadHeaders() {
3293 let result = undefined;
3294 let current = 0;
3295 while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {
3296 current++;
3297 }
3298 // No header / body separator found (e.g CRLFCRLF)
3299 if (current + 3 >= this.index) {
3300 return result;
3301 }
3302 result = Object.create(null);
3303 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
3304 headers.forEach((header) => {
3305 let index = header.indexOf(':');
3306 if (index === -1) {
3307 throw new Error('Message header must separate key and value using :');
3308 }
3309 let key = header.substr(0, index);
3310 let value = header.substr(index + 1).trim();
3311 result[key] = value;
3312 });
3313 let nextStart = current + 4;
3314 this.buffer = this.buffer.slice(nextStart);
3315 this.index = this.index - nextStart;
3316 return result;
3317 }
3318 tryReadContent(length) {
3319 if (this.index < length) {
3320 return null;
3321 }
3322 let result = this.buffer.toString(this.encoding, 0, length);
3323 let nextStart = length;
3324 this.buffer.copy(this.buffer, 0, nextStart);
3325 this.index = this.index - nextStart;
3326 return result;
3327 }
3328 get numberOfBytes() {
3329 return this.index;
3330 }
3331}
3332var MessageReader;
3333(function (MessageReader) {
3334 function is(value) {
3335 let candidate = value;
3336 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
3337 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
3338 }
3339 MessageReader.is = is;
3340})(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
3341class AbstractMessageReader {
3342 constructor() {
3343 this.errorEmitter = new events_1.Emitter();
3344 this.closeEmitter = new events_1.Emitter();
3345 this.partialMessageEmitter = new events_1.Emitter();
3346 }
3347 dispose() {
3348 this.errorEmitter.dispose();
3349 this.closeEmitter.dispose();
3350 }
3351 get onError() {
3352 return this.errorEmitter.event;
3353 }
3354 fireError(error) {
3355 this.errorEmitter.fire(this.asError(error));
3356 }
3357 get onClose() {
3358 return this.closeEmitter.event;
3359 }
3360 fireClose() {
3361 this.closeEmitter.fire(undefined);
3362 }
3363 get onPartialMessage() {
3364 return this.partialMessageEmitter.event;
3365 }
3366 firePartialMessage(info) {
3367 this.partialMessageEmitter.fire(info);
3368 }
3369 asError(error) {
3370 if (error instanceof Error) {
3371 return error;
3372 }
3373 else {
3374 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
3375 }
3376 }
3377}
3378exports.AbstractMessageReader = AbstractMessageReader;
3379class StreamMessageReader extends AbstractMessageReader {
3380 constructor(readable, encoding = 'utf8') {
3381 super();
3382 this.readable = readable;
3383 this.buffer = new MessageBuffer(encoding);
3384 this._partialMessageTimeout = 10000;
3385 }
3386 set partialMessageTimeout(timeout) {
3387 this._partialMessageTimeout = timeout;
3388 }
3389 get partialMessageTimeout() {
3390 return this._partialMessageTimeout;
3391 }
3392 listen(callback) {
3393 this.nextMessageLength = -1;
3394 this.messageToken = 0;
3395 this.partialMessageTimer = undefined;
3396 this.callback = callback;
3397 this.readable.on('data', (data) => {
3398 this.onData(data);
3399 });
3400 this.readable.on('error', (error) => this.fireError(error));
3401 this.readable.on('close', () => this.fireClose());
3402 }
3403 onData(data) {
3404 this.buffer.append(data);
3405 while (true) {
3406 if (this.nextMessageLength === -1) {
3407 let headers = this.buffer.tryReadHeaders();
3408 if (!headers) {
3409 return;
3410 }
3411 let contentLength = headers['Content-Length'];
3412 if (!contentLength) {
3413 throw new Error('Header must provide a Content-Length property.');
3414 }
3415 let length = parseInt(contentLength);
3416 if (isNaN(length)) {
3417 throw new Error('Content-Length value must be a number.');
3418 }
3419 this.nextMessageLength = length;
3420 // Take the encoding form the header. For compatibility
3421 // treat both utf-8 and utf8 as node utf8
3422 }
3423 var msg = this.buffer.tryReadContent(this.nextMessageLength);
3424 if (msg === null) {
3425 /** We haven't received the full message yet. */
3426 this.setPartialMessageTimer();
3427 return;
3428 }
3429 this.clearPartialMessageTimer();
3430 this.nextMessageLength = -1;
3431 this.messageToken++;
3432 var json = JSON.parse(msg);
3433 this.callback(json);
3434 }
3435 }
3436 clearPartialMessageTimer() {
3437 if (this.partialMessageTimer) {
3438 clearTimeout(this.partialMessageTimer);
3439 this.partialMessageTimer = undefined;
3440 }
3441 }
3442 setPartialMessageTimer() {
3443 this.clearPartialMessageTimer();
3444 if (this._partialMessageTimeout <= 0) {
3445 return;
3446 }
3447 this.partialMessageTimer = setTimeout((token, timeout) => {
3448 this.partialMessageTimer = undefined;
3449 if (token === this.messageToken) {
3450 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
3451 this.setPartialMessageTimer();
3452 }
3453 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
3454 }
3455}
3456exports.StreamMessageReader = StreamMessageReader;
3457class IPCMessageReader extends AbstractMessageReader {
3458 constructor(process) {
3459 super();
3460 this.process = process;
3461 let eventEmitter = this.process;
3462 eventEmitter.on('error', (error) => this.fireError(error));
3463 eventEmitter.on('close', () => this.fireClose());
3464 }
3465 listen(callback) {
3466 this.process.on('message', callback);
3467 }
3468}
3469exports.IPCMessageReader = IPCMessageReader;
3470class SocketMessageReader extends StreamMessageReader {
3471 constructor(socket, encoding = 'utf-8') {
3472 super(socket, encoding);
3473 }
3474}
3475exports.SocketMessageReader = SocketMessageReader;
3476
3477
3478/***/ }),
3479
3480/***/ 9:
3481/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3482
3483"use strict";
3484/* --------------------------------------------------------------------------------------------
3485 * Copyright (c) Microsoft Corporation. All rights reserved.
3486 * Licensed under the MIT License. See License.txt in the project root for license information.
3487 * ------------------------------------------------------------------------------------------ */
3488
3489Object.defineProperty(exports, "__esModule", ({ value: true }));
3490const events_1 = __webpack_require__(8);
3491const Is = __webpack_require__(5);
3492let ContentLength = 'Content-Length: ';
3493let CRLF = '\r\n';
3494var MessageWriter;
3495(function (MessageWriter) {
3496 function is(value) {
3497 let candidate = value;
3498 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
3499 Is.func(candidate.onError) && Is.func(candidate.write);
3500 }
3501 MessageWriter.is = is;
3502})(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
3503class AbstractMessageWriter {
3504 constructor() {
3505 this.errorEmitter = new events_1.Emitter();
3506 this.closeEmitter = new events_1.Emitter();
3507 }
3508 dispose() {
3509 this.errorEmitter.dispose();
3510 this.closeEmitter.dispose();
3511 }
3512 get onError() {
3513 return this.errorEmitter.event;
3514 }
3515 fireError(error, message, count) {
3516 this.errorEmitter.fire([this.asError(error), message, count]);
3517 }
3518 get onClose() {
3519 return this.closeEmitter.event;
3520 }
3521 fireClose() {
3522 this.closeEmitter.fire(undefined);
3523 }
3524 asError(error) {
3525 if (error instanceof Error) {
3526 return error;
3527 }
3528 else {
3529 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
3530 }
3531 }
3532}
3533exports.AbstractMessageWriter = AbstractMessageWriter;
3534class StreamMessageWriter extends AbstractMessageWriter {
3535 constructor(writable, encoding = 'utf8') {
3536 super();
3537 this.writable = writable;
3538 this.encoding = encoding;
3539 this.errorCount = 0;
3540 this.writable.on('error', (error) => this.fireError(error));
3541 this.writable.on('close', () => this.fireClose());
3542 }
3543 write(msg) {
3544 let json = JSON.stringify(msg);
3545 let contentLength = Buffer.byteLength(json, this.encoding);
3546 let headers = [
3547 ContentLength, contentLength.toString(), CRLF,
3548 CRLF
3549 ];
3550 try {
3551 // Header must be written in ASCII encoding
3552 this.writable.write(headers.join(''), 'ascii');
3553 // Now write the content. This can be written in any encoding
3554 this.writable.write(json, this.encoding);
3555 this.errorCount = 0;
3556 }
3557 catch (error) {
3558 this.errorCount++;
3559 this.fireError(error, msg, this.errorCount);
3560 }
3561 }
3562}
3563exports.StreamMessageWriter = StreamMessageWriter;
3564class IPCMessageWriter extends AbstractMessageWriter {
3565 constructor(process) {
3566 super();
3567 this.process = process;
3568 this.errorCount = 0;
3569 this.queue = [];
3570 this.sending = false;
3571 let eventEmitter = this.process;
3572 eventEmitter.on('error', (error) => this.fireError(error));
3573 eventEmitter.on('close', () => this.fireClose);
3574 }
3575 write(msg) {
3576 if (!this.sending && this.queue.length === 0) {
3577 // See https://github.com/nodejs/node/issues/7657
3578 this.doWriteMessage(msg);
3579 }
3580 else {
3581 this.queue.push(msg);
3582 }
3583 }
3584 doWriteMessage(msg) {
3585 try {
3586 if (this.process.send) {
3587 this.sending = true;
3588 this.process.send(msg, undefined, undefined, (error) => {
3589 this.sending = false;
3590 if (error) {
3591 this.errorCount++;
3592 this.fireError(error, msg, this.errorCount);
3593 }
3594 else {
3595 this.errorCount = 0;
3596 }
3597 if (this.queue.length > 0) {
3598 this.doWriteMessage(this.queue.shift());
3599 }
3600 });
3601 }
3602 }
3603 catch (error) {
3604 this.errorCount++;
3605 this.fireError(error, msg, this.errorCount);
3606 }
3607 }
3608}
3609exports.IPCMessageWriter = IPCMessageWriter;
3610class SocketMessageWriter extends AbstractMessageWriter {
3611 constructor(socket, encoding = 'utf8') {
3612 super();
3613 this.socket = socket;
3614 this.queue = [];
3615 this.sending = false;
3616 this.encoding = encoding;
3617 this.errorCount = 0;
3618 this.socket.on('error', (error) => this.fireError(error));
3619 this.socket.on('close', () => this.fireClose());
3620 }
3621 dispose() {
3622 super.dispose();
3623 this.socket.destroy();
3624 }
3625 write(msg) {
3626 if (!this.sending && this.queue.length === 0) {
3627 // See https://github.com/nodejs/node/issues/7657
3628 this.doWriteMessage(msg);
3629 }
3630 else {
3631 this.queue.push(msg);
3632 }
3633 }
3634 doWriteMessage(msg) {
3635 let json = JSON.stringify(msg);
3636 let contentLength = Buffer.byteLength(json, this.encoding);
3637 let headers = [
3638 ContentLength, contentLength.toString(), CRLF,
3639 CRLF
3640 ];
3641 try {
3642 // Header must be written in ASCII encoding
3643 this.sending = true;
3644 this.socket.write(headers.join(''), 'ascii', (error) => {
3645 if (error) {
3646 this.handleError(error, msg);
3647 }
3648 try {
3649 // Now write the content. This can be written in any encoding
3650 this.socket.write(json, this.encoding, (error) => {
3651 this.sending = false;
3652 if (error) {
3653 this.handleError(error, msg);
3654 }
3655 else {
3656 this.errorCount = 0;
3657 }
3658 if (this.queue.length > 0) {
3659 this.doWriteMessage(this.queue.shift());
3660 }
3661 });
3662 }
3663 catch (error) {
3664 this.handleError(error, msg);
3665 }
3666 });
3667 }
3668 catch (error) {
3669 this.handleError(error, msg);
3670 }
3671 }
3672 handleError(error, msg) {
3673 this.errorCount++;
3674 this.fireError(error, msg, this.errorCount);
3675 }
3676}
3677exports.SocketMessageWriter = SocketMessageWriter;
3678
3679
3680/***/ }),
3681
3682/***/ 6:
3683/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3684
3685"use strict";
3686/* --------------------------------------------------------------------------------------------
3687 * Copyright (c) Microsoft Corporation. All rights reserved.
3688 * Licensed under the MIT License. See License.txt in the project root for license information.
3689 * ------------------------------------------------------------------------------------------ */
3690
3691Object.defineProperty(exports, "__esModule", ({ value: true }));
3692const is = __webpack_require__(5);
3693/**
3694 * Predefined error codes.
3695 */
3696var ErrorCodes;
3697(function (ErrorCodes) {
3698 // Defined by JSON RPC
3699 ErrorCodes.ParseError = -32700;
3700 ErrorCodes.InvalidRequest = -32600;
3701 ErrorCodes.MethodNotFound = -32601;
3702 ErrorCodes.InvalidParams = -32602;
3703 ErrorCodes.InternalError = -32603;
3704 ErrorCodes.serverErrorStart = -32099;
3705 ErrorCodes.serverErrorEnd = -32000;
3706 ErrorCodes.ServerNotInitialized = -32002;
3707 ErrorCodes.UnknownErrorCode = -32001;
3708 // Defined by the protocol.
3709 ErrorCodes.RequestCancelled = -32800;
3710 ErrorCodes.ContentModified = -32801;
3711 // Defined by VSCode library.
3712 ErrorCodes.MessageWriteError = 1;
3713 ErrorCodes.MessageReadError = 2;
3714})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
3715/**
3716 * An error object return in a response in case a request
3717 * has failed.
3718 */
3719class ResponseError extends Error {
3720 constructor(code, message, data) {
3721 super(message);
3722 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
3723 this.data = data;
3724 Object.setPrototypeOf(this, ResponseError.prototype);
3725 }
3726 toJson() {
3727 return {
3728 code: this.code,
3729 message: this.message,
3730 data: this.data,
3731 };
3732 }
3733}
3734exports.ResponseError = ResponseError;
3735/**
3736 * An abstract implementation of a MessageType.
3737 */
3738class AbstractMessageType {
3739 constructor(_method, _numberOfParams) {
3740 this._method = _method;
3741 this._numberOfParams = _numberOfParams;
3742 }
3743 get method() {
3744 return this._method;
3745 }
3746 get numberOfParams() {
3747 return this._numberOfParams;
3748 }
3749}
3750exports.AbstractMessageType = AbstractMessageType;
3751/**
3752 * Classes to type request response pairs
3753 *
3754 * The type parameter RO will be removed in the next major version
3755 * of the JSON RPC library since it is a LSP concept and doesn't
3756 * belong here. For now it is tagged as default never.
3757 */
3758class RequestType0 extends AbstractMessageType {
3759 constructor(method) {
3760 super(method, 0);
3761 }
3762}
3763exports.RequestType0 = RequestType0;
3764class RequestType extends AbstractMessageType {
3765 constructor(method) {
3766 super(method, 1);
3767 }
3768}
3769exports.RequestType = RequestType;
3770class RequestType1 extends AbstractMessageType {
3771 constructor(method) {
3772 super(method, 1);
3773 }
3774}
3775exports.RequestType1 = RequestType1;
3776class RequestType2 extends AbstractMessageType {
3777 constructor(method) {
3778 super(method, 2);
3779 }
3780}
3781exports.RequestType2 = RequestType2;
3782class RequestType3 extends AbstractMessageType {
3783 constructor(method) {
3784 super(method, 3);
3785 }
3786}
3787exports.RequestType3 = RequestType3;
3788class RequestType4 extends AbstractMessageType {
3789 constructor(method) {
3790 super(method, 4);
3791 }
3792}
3793exports.RequestType4 = RequestType4;
3794class RequestType5 extends AbstractMessageType {
3795 constructor(method) {
3796 super(method, 5);
3797 }
3798}
3799exports.RequestType5 = RequestType5;
3800class RequestType6 extends AbstractMessageType {
3801 constructor(method) {
3802 super(method, 6);
3803 }
3804}
3805exports.RequestType6 = RequestType6;
3806class RequestType7 extends AbstractMessageType {
3807 constructor(method) {
3808 super(method, 7);
3809 }
3810}
3811exports.RequestType7 = RequestType7;
3812class RequestType8 extends AbstractMessageType {
3813 constructor(method) {
3814 super(method, 8);
3815 }
3816}
3817exports.RequestType8 = RequestType8;
3818class RequestType9 extends AbstractMessageType {
3819 constructor(method) {
3820 super(method, 9);
3821 }
3822}
3823exports.RequestType9 = RequestType9;
3824/**
3825 * The type parameter RO will be removed in the next major version
3826 * of the JSON RPC library since it is a LSP concept and doesn't
3827 * belong here. For now it is tagged as default never.
3828 */
3829class NotificationType extends AbstractMessageType {
3830 constructor(method) {
3831 super(method, 1);
3832 this._ = undefined;
3833 }
3834}
3835exports.NotificationType = NotificationType;
3836class NotificationType0 extends AbstractMessageType {
3837 constructor(method) {
3838 super(method, 0);
3839 }
3840}
3841exports.NotificationType0 = NotificationType0;
3842class NotificationType1 extends AbstractMessageType {
3843 constructor(method) {
3844 super(method, 1);
3845 }
3846}
3847exports.NotificationType1 = NotificationType1;
3848class NotificationType2 extends AbstractMessageType {
3849 constructor(method) {
3850 super(method, 2);
3851 }
3852}
3853exports.NotificationType2 = NotificationType2;
3854class NotificationType3 extends AbstractMessageType {
3855 constructor(method) {
3856 super(method, 3);
3857 }
3858}
3859exports.NotificationType3 = NotificationType3;
3860class NotificationType4 extends AbstractMessageType {
3861 constructor(method) {
3862 super(method, 4);
3863 }
3864}
3865exports.NotificationType4 = NotificationType4;
3866class NotificationType5 extends AbstractMessageType {
3867 constructor(method) {
3868 super(method, 5);
3869 }
3870}
3871exports.NotificationType5 = NotificationType5;
3872class NotificationType6 extends AbstractMessageType {
3873 constructor(method) {
3874 super(method, 6);
3875 }
3876}
3877exports.NotificationType6 = NotificationType6;
3878class NotificationType7 extends AbstractMessageType {
3879 constructor(method) {
3880 super(method, 7);
3881 }
3882}
3883exports.NotificationType7 = NotificationType7;
3884class NotificationType8 extends AbstractMessageType {
3885 constructor(method) {
3886 super(method, 8);
3887 }
3888}
3889exports.NotificationType8 = NotificationType8;
3890class NotificationType9 extends AbstractMessageType {
3891 constructor(method) {
3892 super(method, 9);
3893 }
3894}
3895exports.NotificationType9 = NotificationType9;
3896/**
3897 * Tests if the given message is a request message
3898 */
3899function isRequestMessage(message) {
3900 let candidate = message;
3901 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
3902}
3903exports.isRequestMessage = isRequestMessage;
3904/**
3905 * Tests if the given message is a notification message
3906 */
3907function isNotificationMessage(message) {
3908 let candidate = message;
3909 return candidate && is.string(candidate.method) && message.id === void 0;
3910}
3911exports.isNotificationMessage = isNotificationMessage;
3912/**
3913 * Tests if the given message is a response message
3914 */
3915function isResponseMessage(message) {
3916 let candidate = message;
3917 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
3918}
3919exports.isResponseMessage = isResponseMessage;
3920
3921
3922/***/ }),
3923
3924/***/ 12:
3925/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3926
3927"use strict";
3928/* --------------------------------------------------------------------------------------------
3929 * Copyright (c) Microsoft Corporation. All rights reserved.
3930 * Licensed under the MIT License. See License.txt in the project root for license information.
3931 * ------------------------------------------------------------------------------------------ */
3932
3933Object.defineProperty(exports, "__esModule", ({ value: true }));
3934const path_1 = __webpack_require__(13);
3935const os_1 = __webpack_require__(14);
3936const crypto_1 = __webpack_require__(15);
3937const net_1 = __webpack_require__(16);
3938const messageReader_1 = __webpack_require__(7);
3939const messageWriter_1 = __webpack_require__(9);
3940function generateRandomPipeName() {
3941 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
3942 if (process.platform === 'win32') {
3943 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
3944 }
3945 else {
3946 // Mac/Unix: use socket file
3947 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
3948 }
3949}
3950exports.generateRandomPipeName = generateRandomPipeName;
3951function createClientPipeTransport(pipeName, encoding = 'utf-8') {
3952 let connectResolve;
3953 let connected = new Promise((resolve, _reject) => {
3954 connectResolve = resolve;
3955 });
3956 return new Promise((resolve, reject) => {
3957 let server = net_1.createServer((socket) => {
3958 server.close();
3959 connectResolve([
3960 new messageReader_1.SocketMessageReader(socket, encoding),
3961 new messageWriter_1.SocketMessageWriter(socket, encoding)
3962 ]);
3963 });
3964 server.on('error', reject);
3965 server.listen(pipeName, () => {
3966 server.removeListener('error', reject);
3967 resolve({
3968 onConnected: () => { return connected; }
3969 });
3970 });
3971 });
3972}
3973exports.createClientPipeTransport = createClientPipeTransport;
3974function createServerPipeTransport(pipeName, encoding = 'utf-8') {
3975 const socket = net_1.createConnection(pipeName);
3976 return [
3977 new messageReader_1.SocketMessageReader(socket, encoding),
3978 new messageWriter_1.SocketMessageWriter(socket, encoding)
3979 ];
3980}
3981exports.createServerPipeTransport = createServerPipeTransport;
3982
3983
3984/***/ }),
3985
3986/***/ 17:
3987/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3988
3989"use strict";
3990/* --------------------------------------------------------------------------------------------
3991 * Copyright (c) Microsoft Corporation. All rights reserved.
3992 * Licensed under the MIT License. See License.txt in the project root for license information.
3993 * ------------------------------------------------------------------------------------------ */
3994
3995Object.defineProperty(exports, "__esModule", ({ value: true }));
3996const net_1 = __webpack_require__(16);
3997const messageReader_1 = __webpack_require__(7);
3998const messageWriter_1 = __webpack_require__(9);
3999function createClientSocketTransport(port, encoding = 'utf-8') {
4000 let connectResolve;
4001 let connected = new Promise((resolve, _reject) => {
4002 connectResolve = resolve;
4003 });
4004 return new Promise((resolve, reject) => {
4005 let server = net_1.createServer((socket) => {
4006 server.close();
4007 connectResolve([
4008 new messageReader_1.SocketMessageReader(socket, encoding),
4009 new messageWriter_1.SocketMessageWriter(socket, encoding)
4010 ]);
4011 });
4012 server.on('error', reject);
4013 server.listen(port, '127.0.0.1', () => {
4014 server.removeListener('error', reject);
4015 resolve({
4016 onConnected: () => { return connected; }
4017 });
4018 });
4019 });
4020}
4021exports.createClientSocketTransport = createClientSocketTransport;
4022function createServerSocketTransport(port, encoding = 'utf-8') {
4023 const socket = net_1.createConnection(port, '127.0.0.1');
4024 return [
4025 new messageReader_1.SocketMessageReader(socket, encoding),
4026 new messageWriter_1.SocketMessageWriter(socket, encoding)
4027 ];
4028}
4029exports.createServerSocketTransport = createServerSocketTransport;
4030
4031
4032/***/ }),
4033
4034/***/ 3:
4035/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4036
4037"use strict";
4038/* --------------------------------------------------------------------------------------------
4039 * Copyright (c) Microsoft Corporation. All rights reserved.
4040 * Licensed under the MIT License. See License.txt in the project root for license information.
4041 * ------------------------------------------------------------------------------------------ */
4042
4043function __export(m) {
4044 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4045}
4046Object.defineProperty(exports, "__esModule", ({ value: true }));
4047const vscode_jsonrpc_1 = __webpack_require__(4);
4048exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
4049exports.ResponseError = vscode_jsonrpc_1.ResponseError;
4050exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
4051exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
4052exports.Disposable = vscode_jsonrpc_1.Disposable;
4053exports.Event = vscode_jsonrpc_1.Event;
4054exports.Emitter = vscode_jsonrpc_1.Emitter;
4055exports.Trace = vscode_jsonrpc_1.Trace;
4056exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
4057exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
4058exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
4059exports.RequestType = vscode_jsonrpc_1.RequestType;
4060exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
4061exports.NotificationType = vscode_jsonrpc_1.NotificationType;
4062exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
4063exports.MessageReader = vscode_jsonrpc_1.MessageReader;
4064exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
4065exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
4066exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
4067exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
4068exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
4069exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
4070exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
4071exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
4072exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
4073exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
4074exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
4075exports.ProgressType = vscode_jsonrpc_1.ProgressType;
4076__export(__webpack_require__(18));
4077__export(__webpack_require__(19));
4078const callHierarchy = __webpack_require__(31);
4079const st = __webpack_require__(32);
4080var Proposed;
4081(function (Proposed) {
4082 let CallHierarchyPrepareRequest;
4083 (function (CallHierarchyPrepareRequest) {
4084 CallHierarchyPrepareRequest.method = callHierarchy.CallHierarchyPrepareRequest.method;
4085 CallHierarchyPrepareRequest.type = callHierarchy.CallHierarchyPrepareRequest.type;
4086 })(CallHierarchyPrepareRequest = Proposed.CallHierarchyPrepareRequest || (Proposed.CallHierarchyPrepareRequest = {}));
4087 let CallHierarchyIncomingCallsRequest;
4088 (function (CallHierarchyIncomingCallsRequest) {
4089 CallHierarchyIncomingCallsRequest.method = callHierarchy.CallHierarchyIncomingCallsRequest.method;
4090 CallHierarchyIncomingCallsRequest.type = callHierarchy.CallHierarchyIncomingCallsRequest.type;
4091 })(CallHierarchyIncomingCallsRequest = Proposed.CallHierarchyIncomingCallsRequest || (Proposed.CallHierarchyIncomingCallsRequest = {}));
4092 let CallHierarchyOutgoingCallsRequest;
4093 (function (CallHierarchyOutgoingCallsRequest) {
4094 CallHierarchyOutgoingCallsRequest.method = callHierarchy.CallHierarchyOutgoingCallsRequest.method;
4095 CallHierarchyOutgoingCallsRequest.type = callHierarchy.CallHierarchyOutgoingCallsRequest.type;
4096 })(CallHierarchyOutgoingCallsRequest = Proposed.CallHierarchyOutgoingCallsRequest || (Proposed.CallHierarchyOutgoingCallsRequest = {}));
4097 Proposed.SemanticTokenTypes = st.SemanticTokenTypes;
4098 Proposed.SemanticTokenModifiers = st.SemanticTokenModifiers;
4099 Proposed.SemanticTokens = st.SemanticTokens;
4100 let SemanticTokensRequest;
4101 (function (SemanticTokensRequest) {
4102 SemanticTokensRequest.method = st.SemanticTokensRequest.method;
4103 SemanticTokensRequest.type = st.SemanticTokensRequest.type;
4104 })(SemanticTokensRequest = Proposed.SemanticTokensRequest || (Proposed.SemanticTokensRequest = {}));
4105 let SemanticTokensEditsRequest;
4106 (function (SemanticTokensEditsRequest) {
4107 SemanticTokensEditsRequest.method = st.SemanticTokensEditsRequest.method;
4108 SemanticTokensEditsRequest.type = st.SemanticTokensEditsRequest.type;
4109 })(SemanticTokensEditsRequest = Proposed.SemanticTokensEditsRequest || (Proposed.SemanticTokensEditsRequest = {}));
4110 let SemanticTokensRangeRequest;
4111 (function (SemanticTokensRangeRequest) {
4112 SemanticTokensRangeRequest.method = st.SemanticTokensRangeRequest.method;
4113 SemanticTokensRangeRequest.type = st.SemanticTokensRangeRequest.type;
4114 })(SemanticTokensRangeRequest = Proposed.SemanticTokensRangeRequest || (Proposed.SemanticTokensRangeRequest = {}));
4115})(Proposed = exports.Proposed || (exports.Proposed = {}));
4116function createProtocolConnection(reader, writer, logger, strategy) {
4117 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
4118}
4119exports.createProtocolConnection = createProtocolConnection;
4120
4121
4122/***/ }),
4123
4124/***/ 21:
4125/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4126
4127"use strict";
4128/* --------------------------------------------------------------------------------------------
4129 * Copyright (c) Microsoft Corporation. All rights reserved.
4130 * Licensed under the MIT License. See License.txt in the project root for license information.
4131 * ------------------------------------------------------------------------------------------ */
4132
4133Object.defineProperty(exports, "__esModule", ({ value: true }));
4134const vscode_jsonrpc_1 = __webpack_require__(4);
4135class ProtocolRequestType0 extends vscode_jsonrpc_1.RequestType0 {
4136 constructor(method) {
4137 super(method);
4138 }
4139}
4140exports.ProtocolRequestType0 = ProtocolRequestType0;
4141class ProtocolRequestType extends vscode_jsonrpc_1.RequestType {
4142 constructor(method) {
4143 super(method);
4144 }
4145}
4146exports.ProtocolRequestType = ProtocolRequestType;
4147class ProtocolNotificationType extends vscode_jsonrpc_1.NotificationType {
4148 constructor(method) {
4149 super(method);
4150 }
4151}
4152exports.ProtocolNotificationType = ProtocolNotificationType;
4153class ProtocolNotificationType0 extends vscode_jsonrpc_1.NotificationType0 {
4154 constructor(method) {
4155 super(method);
4156 }
4157}
4158exports.ProtocolNotificationType0 = ProtocolNotificationType0;
4159
4160
4161/***/ }),
4162
4163/***/ 31:
4164/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4165
4166"use strict";
4167/* --------------------------------------------------------------------------------------------
4168 * Copyright (c) TypeFox and others. All rights reserved.
4169 * Licensed under the MIT License. See License.txt in the project root for license information.
4170 * ------------------------------------------------------------------------------------------ */
4171
4172Object.defineProperty(exports, "__esModule", ({ value: true }));
4173const messages_1 = __webpack_require__(21);
4174/**
4175 * A request to result a `CallHierarchyItem` in a document at a given position.
4176 * Can be used as an input to a incoming or outgoing call hierarchy.
4177 *
4178 * @since 3.16.0 - Proposed state
4179 */
4180var CallHierarchyPrepareRequest;
4181(function (CallHierarchyPrepareRequest) {
4182 CallHierarchyPrepareRequest.method = 'textDocument/prepareCallHierarchy';
4183 CallHierarchyPrepareRequest.type = new messages_1.ProtocolRequestType(CallHierarchyPrepareRequest.method);
4184})(CallHierarchyPrepareRequest = exports.CallHierarchyPrepareRequest || (exports.CallHierarchyPrepareRequest = {}));
4185/**
4186 * A request to resolve the incoming calls for a given `CallHierarchyItem`.
4187 *
4188 * @since 3.16.0 - Proposed state
4189 */
4190var CallHierarchyIncomingCallsRequest;
4191(function (CallHierarchyIncomingCallsRequest) {
4192 CallHierarchyIncomingCallsRequest.method = 'callHierarchy/incomingCalls';
4193 CallHierarchyIncomingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyIncomingCallsRequest.method);
4194})(CallHierarchyIncomingCallsRequest = exports.CallHierarchyIncomingCallsRequest || (exports.CallHierarchyIncomingCallsRequest = {}));
4195/**
4196 * A request to resolve the outgoing calls for a given `CallHierarchyItem`.
4197 *
4198 * @since 3.16.0 - Proposed state
4199 */
4200var CallHierarchyOutgoingCallsRequest;
4201(function (CallHierarchyOutgoingCallsRequest) {
4202 CallHierarchyOutgoingCallsRequest.method = 'callHierarchy/outgoingCalls';
4203 CallHierarchyOutgoingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyOutgoingCallsRequest.method);
4204})(CallHierarchyOutgoingCallsRequest = exports.CallHierarchyOutgoingCallsRequest || (exports.CallHierarchyOutgoingCallsRequest = {}));
4205
4206
4207/***/ }),
4208
4209/***/ 26:
4210/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4211
4212"use strict";
4213/* --------------------------------------------------------------------------------------------
4214 * Copyright (c) Microsoft Corporation. All rights reserved.
4215 * Licensed under the MIT License. See License.txt in the project root for license information.
4216 * ------------------------------------------------------------------------------------------ */
4217
4218Object.defineProperty(exports, "__esModule", ({ value: true }));
4219const vscode_jsonrpc_1 = __webpack_require__(4);
4220const messages_1 = __webpack_require__(21);
4221/**
4222 * A request to list all color symbols found in a given text document. The request's
4223 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
4224 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4225 * that resolves to such.
4226 */
4227var DocumentColorRequest;
4228(function (DocumentColorRequest) {
4229 DocumentColorRequest.method = 'textDocument/documentColor';
4230 DocumentColorRequest.type = new messages_1.ProtocolRequestType(DocumentColorRequest.method);
4231 /** @deprecated Use DocumentColorRequest.type */
4232 DocumentColorRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4233})(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
4234/**
4235 * A request to list all presentation for a color. The request's
4236 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
4237 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4238 * that resolves to such.
4239 */
4240var ColorPresentationRequest;
4241(function (ColorPresentationRequest) {
4242 ColorPresentationRequest.type = new messages_1.ProtocolRequestType('textDocument/colorPresentation');
4243})(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
4244
4245
4246/***/ }),
4247
4248/***/ 25:
4249/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4250
4251"use strict";
4252/* --------------------------------------------------------------------------------------------
4253 * Copyright (c) Microsoft Corporation. All rights reserved.
4254 * Licensed under the MIT License. See License.txt in the project root for license information.
4255 * ------------------------------------------------------------------------------------------ */
4256
4257Object.defineProperty(exports, "__esModule", ({ value: true }));
4258const messages_1 = __webpack_require__(21);
4259/**
4260 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
4261 * configuration setting.
4262 *
4263 * This pull model replaces the old push model were the client signaled configuration change via an
4264 * event. If the server still needs to react to configuration changes (since the server caches the
4265 * result of `workspace/configuration` requests) the server should register for an empty configuration
4266 * change event and empty the cache if such an event is received.
4267 */
4268var ConfigurationRequest;
4269(function (ConfigurationRequest) {
4270 ConfigurationRequest.type = new messages_1.ProtocolRequestType('workspace/configuration');
4271})(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
4272
4273
4274/***/ }),
4275
4276/***/ 28:
4277/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4278
4279"use strict";
4280/* --------------------------------------------------------------------------------------------
4281 * Copyright (c) Microsoft Corporation. All rights reserved.
4282 * Licensed under the MIT License. See License.txt in the project root for license information.
4283 * ------------------------------------------------------------------------------------------ */
4284
4285Object.defineProperty(exports, "__esModule", ({ value: true }));
4286const vscode_jsonrpc_1 = __webpack_require__(4);
4287const messages_1 = __webpack_require__(21);
4288// @ts-ignore: to avoid inlining LocatioLink as dynamic import
4289let __noDynamicImport;
4290/**
4291 * A request to resolve the type definition locations of a symbol at a given text
4292 * document position. The request's parameter is of type [TextDocumentPositioParams]
4293 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
4294 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
4295 * to such.
4296 */
4297var DeclarationRequest;
4298(function (DeclarationRequest) {
4299 DeclarationRequest.method = 'textDocument/declaration';
4300 DeclarationRequest.type = new messages_1.ProtocolRequestType(DeclarationRequest.method);
4301 /** @deprecated Use DeclarationRequest.type */
4302 DeclarationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4303})(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
4304
4305
4306/***/ }),
4307
4308/***/ 27:
4309/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4310
4311"use strict";
4312
4313/*---------------------------------------------------------------------------------------------
4314 * Copyright (c) Microsoft Corporation. All rights reserved.
4315 * Licensed under the MIT License. See License.txt in the project root for license information.
4316 *--------------------------------------------------------------------------------------------*/
4317Object.defineProperty(exports, "__esModule", ({ value: true }));
4318const vscode_jsonrpc_1 = __webpack_require__(4);
4319const messages_1 = __webpack_require__(21);
4320/**
4321 * Enum of known range kinds
4322 */
4323var FoldingRangeKind;
4324(function (FoldingRangeKind) {
4325 /**
4326 * Folding range for a comment
4327 */
4328 FoldingRangeKind["Comment"] = "comment";
4329 /**
4330 * Folding range for a imports or includes
4331 */
4332 FoldingRangeKind["Imports"] = "imports";
4333 /**
4334 * Folding range for a region (e.g. `#region`)
4335 */
4336 FoldingRangeKind["Region"] = "region";
4337})(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
4338/**
4339 * A request to provide folding ranges in a document. The request's
4340 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
4341 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
4342 * that resolves to such.
4343 */
4344var FoldingRangeRequest;
4345(function (FoldingRangeRequest) {
4346 FoldingRangeRequest.method = 'textDocument/foldingRange';
4347 FoldingRangeRequest.type = new messages_1.ProtocolRequestType(FoldingRangeRequest.method);
4348 /** @deprecated Use FoldingRangeRequest.type */
4349 FoldingRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4350})(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
4351
4352
4353/***/ }),
4354
4355/***/ 22:
4356/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4357
4358"use strict";
4359/* --------------------------------------------------------------------------------------------
4360 * Copyright (c) Microsoft Corporation. All rights reserved.
4361 * Licensed under the MIT License. See License.txt in the project root for license information.
4362 * ------------------------------------------------------------------------------------------ */
4363
4364Object.defineProperty(exports, "__esModule", ({ value: true }));
4365const vscode_jsonrpc_1 = __webpack_require__(4);
4366const messages_1 = __webpack_require__(21);
4367// @ts-ignore: to avoid inlining LocatioLink as dynamic import
4368let __noDynamicImport;
4369/**
4370 * A request to resolve the implementation locations of a symbol at a given text
4371 * document position. The request's parameter is of type [TextDocumentPositioParams]
4372 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
4373 * Thenable that resolves to such.
4374 */
4375var ImplementationRequest;
4376(function (ImplementationRequest) {
4377 ImplementationRequest.method = 'textDocument/implementation';
4378 ImplementationRequest.type = new messages_1.ProtocolRequestType(ImplementationRequest.method);
4379 /** @deprecated Use ImplementationRequest.type */
4380 ImplementationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4381})(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
4382
4383
4384/***/ }),
4385
4386/***/ 19:
4387/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4388
4389"use strict";
4390/* --------------------------------------------------------------------------------------------
4391 * Copyright (c) Microsoft Corporation. All rights reserved.
4392 * Licensed under the MIT License. See License.txt in the project root for license information.
4393 * ------------------------------------------------------------------------------------------ */
4394
4395Object.defineProperty(exports, "__esModule", ({ value: true }));
4396const Is = __webpack_require__(20);
4397const vscode_jsonrpc_1 = __webpack_require__(4);
4398const messages_1 = __webpack_require__(21);
4399const protocol_implementation_1 = __webpack_require__(22);
4400exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
4401const protocol_typeDefinition_1 = __webpack_require__(23);
4402exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
4403const protocol_workspaceFolders_1 = __webpack_require__(24);
4404exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
4405exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
4406const protocol_configuration_1 = __webpack_require__(25);
4407exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
4408const protocol_colorProvider_1 = __webpack_require__(26);
4409exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
4410exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
4411const protocol_foldingRange_1 = __webpack_require__(27);
4412exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
4413const protocol_declaration_1 = __webpack_require__(28);
4414exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
4415const protocol_selectionRange_1 = __webpack_require__(29);
4416exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
4417const protocol_progress_1 = __webpack_require__(30);
4418exports.WorkDoneProgress = protocol_progress_1.WorkDoneProgress;
4419exports.WorkDoneProgressCreateRequest = protocol_progress_1.WorkDoneProgressCreateRequest;
4420exports.WorkDoneProgressCancelNotification = protocol_progress_1.WorkDoneProgressCancelNotification;
4421// @ts-ignore: to avoid inlining LocatioLink as dynamic import
4422let __noDynamicImport;
4423/**
4424 * The DocumentFilter namespace provides helper functions to work with
4425 * [DocumentFilter](#DocumentFilter) literals.
4426 */
4427var DocumentFilter;
4428(function (DocumentFilter) {
4429 function is(value) {
4430 const candidate = value;
4431 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
4432 }
4433 DocumentFilter.is = is;
4434})(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
4435/**
4436 * The DocumentSelector namespace provides helper functions to work with
4437 * [DocumentSelector](#DocumentSelector)s.
4438 */
4439var DocumentSelector;
4440(function (DocumentSelector) {
4441 function is(value) {
4442 if (!Array.isArray(value)) {
4443 return false;
4444 }
4445 for (let elem of value) {
4446 if (!Is.string(elem) && !DocumentFilter.is(elem)) {
4447 return false;
4448 }
4449 }
4450 return true;
4451 }
4452 DocumentSelector.is = is;
4453})(DocumentSelector = exports.DocumentSelector || (exports.DocumentSelector = {}));
4454/**
4455 * The `client/registerCapability` request is sent from the server to the client to register a new capability
4456 * handler on the client side.
4457 */
4458var RegistrationRequest;
4459(function (RegistrationRequest) {
4460 RegistrationRequest.type = new messages_1.ProtocolRequestType('client/registerCapability');
4461})(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
4462/**
4463 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
4464 * handler on the client side.
4465 */
4466var UnregistrationRequest;
4467(function (UnregistrationRequest) {
4468 UnregistrationRequest.type = new messages_1.ProtocolRequestType('client/unregisterCapability');
4469})(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
4470var ResourceOperationKind;
4471(function (ResourceOperationKind) {
4472 /**
4473 * Supports creating new files and folders.
4474 */
4475 ResourceOperationKind.Create = 'create';
4476 /**
4477 * Supports renaming existing files and folders.
4478 */
4479 ResourceOperationKind.Rename = 'rename';
4480 /**
4481 * Supports deleting existing files and folders.
4482 */
4483 ResourceOperationKind.Delete = 'delete';
4484})(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
4485var FailureHandlingKind;
4486(function (FailureHandlingKind) {
4487 /**
4488 * Applying the workspace change is simply aborted if one of the changes provided
4489 * fails. All operations executed before the failing operation stay executed.
4490 */
4491 FailureHandlingKind.Abort = 'abort';
4492 /**
4493 * All operations are executed transactional. That means they either all
4494 * succeed or no changes at all are applied to the workspace.
4495 */
4496 FailureHandlingKind.Transactional = 'transactional';
4497 /**
4498 * If the workspace edit contains only textual file changes they are executed transactional.
4499 * If resource changes (create, rename or delete file) are part of the change the failure
4500 * handling startegy is abort.
4501 */
4502 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
4503 /**
4504 * The client tries to undo the operations already executed. But there is no
4505 * guarantee that this is succeeding.
4506 */
4507 FailureHandlingKind.Undo = 'undo';
4508})(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
4509/**
4510 * The StaticRegistrationOptions namespace provides helper functions to work with
4511 * [StaticRegistrationOptions](#StaticRegistrationOptions) literals.
4512 */
4513var StaticRegistrationOptions;
4514(function (StaticRegistrationOptions) {
4515 function hasId(value) {
4516 const candidate = value;
4517 return candidate && Is.string(candidate.id) && candidate.id.length > 0;
4518 }
4519 StaticRegistrationOptions.hasId = hasId;
4520})(StaticRegistrationOptions = exports.StaticRegistrationOptions || (exports.StaticRegistrationOptions = {}));
4521/**
4522 * The TextDocumentRegistrationOptions namespace provides helper functions to work with
4523 * [TextDocumentRegistrationOptions](#TextDocumentRegistrationOptions) literals.
4524 */
4525var TextDocumentRegistrationOptions;
4526(function (TextDocumentRegistrationOptions) {
4527 function is(value) {
4528 const candidate = value;
4529 return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
4530 }
4531 TextDocumentRegistrationOptions.is = is;
4532})(TextDocumentRegistrationOptions = exports.TextDocumentRegistrationOptions || (exports.TextDocumentRegistrationOptions = {}));
4533/**
4534 * The WorkDoneProgressOptions namespace provides helper functions to work with
4535 * [WorkDoneProgressOptions](#WorkDoneProgressOptions) literals.
4536 */
4537var WorkDoneProgressOptions;
4538(function (WorkDoneProgressOptions) {
4539 function is(value) {
4540 const candidate = value;
4541 return Is.objectLiteral(candidate) && (candidate.workDoneProgress === undefined || Is.boolean(candidate.workDoneProgress));
4542 }
4543 WorkDoneProgressOptions.is = is;
4544 function hasWorkDoneProgress(value) {
4545 const candidate = value;
4546 return candidate && Is.boolean(candidate.workDoneProgress);
4547 }
4548 WorkDoneProgressOptions.hasWorkDoneProgress = hasWorkDoneProgress;
4549})(WorkDoneProgressOptions = exports.WorkDoneProgressOptions || (exports.WorkDoneProgressOptions = {}));
4550/**
4551 * The initialize request is sent from the client to the server.
4552 * It is sent once as the request after starting up the server.
4553 * The requests parameter is of type [InitializeParams](#InitializeParams)
4554 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
4555 * resolves to such.
4556 */
4557var InitializeRequest;
4558(function (InitializeRequest) {
4559 InitializeRequest.type = new messages_1.ProtocolRequestType('initialize');
4560})(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
4561/**
4562 * Known error codes for an `InitializeError`;
4563 */
4564var InitializeError;
4565(function (InitializeError) {
4566 /**
4567 * If the protocol version provided by the client can't be handled by the server.
4568 * @deprecated This initialize error got replaced by client capabilities. There is
4569 * no version handshake in version 3.0x
4570 */
4571 InitializeError.unknownProtocolVersion = 1;
4572})(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
4573/**
4574 * The intialized notification is sent from the client to the
4575 * server after the client is fully initialized and the server
4576 * is allowed to send requests from the server to the client.
4577 */
4578var InitializedNotification;
4579(function (InitializedNotification) {
4580 InitializedNotification.type = new messages_1.ProtocolNotificationType('initialized');
4581})(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
4582//---- Shutdown Method ----
4583/**
4584 * A shutdown request is sent from the client to the server.
4585 * It is sent once when the client decides to shutdown the
4586 * server. The only notification that is sent after a shutdown request
4587 * is the exit event.
4588 */
4589var ShutdownRequest;
4590(function (ShutdownRequest) {
4591 ShutdownRequest.type = new messages_1.ProtocolRequestType0('shutdown');
4592})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
4593//---- Exit Notification ----
4594/**
4595 * The exit event is sent from the client to the server to
4596 * ask the server to exit its process.
4597 */
4598var ExitNotification;
4599(function (ExitNotification) {
4600 ExitNotification.type = new messages_1.ProtocolNotificationType0('exit');
4601})(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
4602/**
4603 * The configuration change notification is sent from the client to the server
4604 * when the client's configuration has changed. The notification contains
4605 * the changed configuration as defined by the language client.
4606 */
4607var DidChangeConfigurationNotification;
4608(function (DidChangeConfigurationNotification) {
4609 DidChangeConfigurationNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeConfiguration');
4610})(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
4611//---- Message show and log notifications ----
4612/**
4613 * The message type
4614 */
4615var MessageType;
4616(function (MessageType) {
4617 /**
4618 * An error message.
4619 */
4620 MessageType.Error = 1;
4621 /**
4622 * A warning message.
4623 */
4624 MessageType.Warning = 2;
4625 /**
4626 * An information message.
4627 */
4628 MessageType.Info = 3;
4629 /**
4630 * A log message.
4631 */
4632 MessageType.Log = 4;
4633})(MessageType = exports.MessageType || (exports.MessageType = {}));
4634/**
4635 * The show message notification is sent from a server to a client to ask
4636 * the client to display a particular message in the user interface.
4637 */
4638var ShowMessageNotification;
4639(function (ShowMessageNotification) {
4640 ShowMessageNotification.type = new messages_1.ProtocolNotificationType('window/showMessage');
4641})(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
4642/**
4643 * The show message request is sent from the server to the client to show a message
4644 * and a set of options actions to the user.
4645 */
4646var ShowMessageRequest;
4647(function (ShowMessageRequest) {
4648 ShowMessageRequest.type = new messages_1.ProtocolRequestType('window/showMessageRequest');
4649})(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
4650/**
4651 * The log message notification is sent from the server to the client to ask
4652 * the client to log a particular message.
4653 */
4654var LogMessageNotification;
4655(function (LogMessageNotification) {
4656 LogMessageNotification.type = new messages_1.ProtocolNotificationType('window/logMessage');
4657})(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
4658//---- Telemetry notification
4659/**
4660 * The telemetry event notification is sent from the server to the client to ask
4661 * the client to log telemetry data.
4662 */
4663var TelemetryEventNotification;
4664(function (TelemetryEventNotification) {
4665 TelemetryEventNotification.type = new messages_1.ProtocolNotificationType('telemetry/event');
4666})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
4667/**
4668 * Defines how the host (editor) should sync
4669 * document changes to the language server.
4670 */
4671var TextDocumentSyncKind;
4672(function (TextDocumentSyncKind) {
4673 /**
4674 * Documents should not be synced at all.
4675 */
4676 TextDocumentSyncKind.None = 0;
4677 /**
4678 * Documents are synced by always sending the full content
4679 * of the document.
4680 */
4681 TextDocumentSyncKind.Full = 1;
4682 /**
4683 * Documents are synced by sending the full content on open.
4684 * After that only incremental updates to the document are
4685 * send.
4686 */
4687 TextDocumentSyncKind.Incremental = 2;
4688})(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
4689/**
4690 * The document open notification is sent from the client to the server to signal
4691 * newly opened text documents. The document's truth is now managed by the client
4692 * and the server must not try to read the document's truth using the document's
4693 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
4694 * mean that its content is presented in an editor. An open notification must not
4695 * be sent more than once without a corresponding close notification send before.
4696 * This means open and close notification must be balanced and the max open count
4697 * is one.
4698 */
4699var DidOpenTextDocumentNotification;
4700(function (DidOpenTextDocumentNotification) {
4701 DidOpenTextDocumentNotification.method = 'textDocument/didOpen';
4702 DidOpenTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidOpenTextDocumentNotification.method);
4703})(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
4704/**
4705 * The document change notification is sent from the client to the server to signal
4706 * changes to a text document.
4707 */
4708var DidChangeTextDocumentNotification;
4709(function (DidChangeTextDocumentNotification) {
4710 DidChangeTextDocumentNotification.method = 'textDocument/didChange';
4711 DidChangeTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidChangeTextDocumentNotification.method);
4712})(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
4713/**
4714 * The document close notification is sent from the client to the server when
4715 * the document got closed in the client. The document's truth now exists where
4716 * the document's uri points to (e.g. if the document's uri is a file uri the
4717 * truth now exists on disk). As with the open notification the close notification
4718 * is about managing the document's content. Receiving a close notification
4719 * doesn't mean that the document was open in an editor before. A close
4720 * notification requires a previous open notification to be sent.
4721 */
4722var DidCloseTextDocumentNotification;
4723(function (DidCloseTextDocumentNotification) {
4724 DidCloseTextDocumentNotification.method = 'textDocument/didClose';
4725 DidCloseTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidCloseTextDocumentNotification.method);
4726})(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
4727/**
4728 * The document save notification is sent from the client to the server when
4729 * the document got saved in the client.
4730 */
4731var DidSaveTextDocumentNotification;
4732(function (DidSaveTextDocumentNotification) {
4733 DidSaveTextDocumentNotification.method = 'textDocument/didSave';
4734 DidSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidSaveTextDocumentNotification.method);
4735})(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
4736/**
4737 * Represents reasons why a text document is saved.
4738 */
4739var TextDocumentSaveReason;
4740(function (TextDocumentSaveReason) {
4741 /**
4742 * Manually triggered, e.g. by the user pressing save, by starting debugging,
4743 * or by an API call.
4744 */
4745 TextDocumentSaveReason.Manual = 1;
4746 /**
4747 * Automatic after a delay.
4748 */
4749 TextDocumentSaveReason.AfterDelay = 2;
4750 /**
4751 * When the editor lost focus.
4752 */
4753 TextDocumentSaveReason.FocusOut = 3;
4754})(TextDocumentSaveReason = exports.TextDocumentSaveReason || (exports.TextDocumentSaveReason = {}));
4755/**
4756 * A document will save notification is sent from the client to the server before
4757 * the document is actually saved.
4758 */
4759var WillSaveTextDocumentNotification;
4760(function (WillSaveTextDocumentNotification) {
4761 WillSaveTextDocumentNotification.method = 'textDocument/willSave';
4762 WillSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(WillSaveTextDocumentNotification.method);
4763})(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
4764/**
4765 * A document will save request is sent from the client to the server before
4766 * the document is actually saved. The request can return an array of TextEdits
4767 * which will be applied to the text document before it is saved. Please note that
4768 * clients might drop results if computing the text edits took too long or if a
4769 * server constantly fails on this request. This is done to keep the save fast and
4770 * reliable.
4771 */
4772var WillSaveTextDocumentWaitUntilRequest;
4773(function (WillSaveTextDocumentWaitUntilRequest) {
4774 WillSaveTextDocumentWaitUntilRequest.method = 'textDocument/willSaveWaitUntil';
4775 WillSaveTextDocumentWaitUntilRequest.type = new messages_1.ProtocolRequestType(WillSaveTextDocumentWaitUntilRequest.method);
4776})(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
4777/**
4778 * The watched files notification is sent from the client to the server when
4779 * the client detects changes to file watched by the language client.
4780 */
4781var DidChangeWatchedFilesNotification;
4782(function (DidChangeWatchedFilesNotification) {
4783 DidChangeWatchedFilesNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWatchedFiles');
4784})(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
4785/**
4786 * The file event type
4787 */
4788var FileChangeType;
4789(function (FileChangeType) {
4790 /**
4791 * The file got created.
4792 */
4793 FileChangeType.Created = 1;
4794 /**
4795 * The file got changed.
4796 */
4797 FileChangeType.Changed = 2;
4798 /**
4799 * The file got deleted.
4800 */
4801 FileChangeType.Deleted = 3;
4802})(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
4803var WatchKind;
4804(function (WatchKind) {
4805 /**
4806 * Interested in create events.
4807 */
4808 WatchKind.Create = 1;
4809 /**
4810 * Interested in change events
4811 */
4812 WatchKind.Change = 2;
4813 /**
4814 * Interested in delete events
4815 */
4816 WatchKind.Delete = 4;
4817})(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
4818/**
4819 * Diagnostics notification are sent from the server to the client to signal
4820 * results of validation runs.
4821 */
4822var PublishDiagnosticsNotification;
4823(function (PublishDiagnosticsNotification) {
4824 PublishDiagnosticsNotification.type = new messages_1.ProtocolNotificationType('textDocument/publishDiagnostics');
4825})(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
4826/**
4827 * How a completion was triggered
4828 */
4829var CompletionTriggerKind;
4830(function (CompletionTriggerKind) {
4831 /**
4832 * Completion was triggered by typing an identifier (24x7 code
4833 * complete), manual invocation (e.g Ctrl+Space) or via API.
4834 */
4835 CompletionTriggerKind.Invoked = 1;
4836 /**
4837 * Completion was triggered by a trigger character specified by
4838 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
4839 */
4840 CompletionTriggerKind.TriggerCharacter = 2;
4841 /**
4842 * Completion was re-triggered as current completion list is incomplete
4843 */
4844 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
4845})(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
4846/**
4847 * Request to request completion at a given text document position. The request's
4848 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
4849 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
4850 * or a Thenable that resolves to such.
4851 *
4852 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
4853 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
4854 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
4855 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
4856 */
4857var CompletionRequest;
4858(function (CompletionRequest) {
4859 CompletionRequest.method = 'textDocument/completion';
4860 CompletionRequest.type = new messages_1.ProtocolRequestType(CompletionRequest.method);
4861 /** @deprecated Use CompletionRequest.type */
4862 CompletionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4863})(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
4864/**
4865 * Request to resolve additional information for a given completion item.The request's
4866 * parameter is of type [CompletionItem](#CompletionItem) the response
4867 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
4868 */
4869var CompletionResolveRequest;
4870(function (CompletionResolveRequest) {
4871 CompletionResolveRequest.method = 'completionItem/resolve';
4872 CompletionResolveRequest.type = new messages_1.ProtocolRequestType(CompletionResolveRequest.method);
4873})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
4874/**
4875 * Request to request hover information at a given text document position. The request's
4876 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
4877 * type [Hover](#Hover) or a Thenable that resolves to such.
4878 */
4879var HoverRequest;
4880(function (HoverRequest) {
4881 HoverRequest.method = 'textDocument/hover';
4882 HoverRequest.type = new messages_1.ProtocolRequestType(HoverRequest.method);
4883})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
4884/**
4885 * How a signature help was triggered.
4886 *
4887 * @since 3.15.0
4888 */
4889var SignatureHelpTriggerKind;
4890(function (SignatureHelpTriggerKind) {
4891 /**
4892 * Signature help was invoked manually by the user or by a command.
4893 */
4894 SignatureHelpTriggerKind.Invoked = 1;
4895 /**
4896 * Signature help was triggered by a trigger character.
4897 */
4898 SignatureHelpTriggerKind.TriggerCharacter = 2;
4899 /**
4900 * Signature help was triggered by the cursor moving or by the document content changing.
4901 */
4902 SignatureHelpTriggerKind.ContentChange = 3;
4903})(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
4904var SignatureHelpRequest;
4905(function (SignatureHelpRequest) {
4906 SignatureHelpRequest.method = 'textDocument/signatureHelp';
4907 SignatureHelpRequest.type = new messages_1.ProtocolRequestType(SignatureHelpRequest.method);
4908})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
4909/**
4910 * A request to resolve the definition location of a symbol at a given text
4911 * document position. The request's parameter is of type [TextDocumentPosition]
4912 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
4913 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
4914 * to such.
4915 */
4916var DefinitionRequest;
4917(function (DefinitionRequest) {
4918 DefinitionRequest.method = 'textDocument/definition';
4919 DefinitionRequest.type = new messages_1.ProtocolRequestType(DefinitionRequest.method);
4920 /** @deprecated Use DefinitionRequest.type */
4921 DefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4922})(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
4923/**
4924 * A request to resolve project-wide references for the symbol denoted
4925 * by the given text document position. The request's parameter is of
4926 * type [ReferenceParams](#ReferenceParams) the response is of type
4927 * [Location[]](#Location) or a Thenable that resolves to such.
4928 */
4929var ReferencesRequest;
4930(function (ReferencesRequest) {
4931 ReferencesRequest.method = 'textDocument/references';
4932 ReferencesRequest.type = new messages_1.ProtocolRequestType(ReferencesRequest.method);
4933 /** @deprecated Use ReferencesRequest.type */
4934 ReferencesRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4935})(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
4936/**
4937 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
4938 * text document position. The request's parameter is of type [TextDocumentPosition]
4939 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
4940 * (#DocumentHighlight) or a Thenable that resolves to such.
4941 */
4942var DocumentHighlightRequest;
4943(function (DocumentHighlightRequest) {
4944 DocumentHighlightRequest.method = 'textDocument/documentHighlight';
4945 DocumentHighlightRequest.type = new messages_1.ProtocolRequestType(DocumentHighlightRequest.method);
4946 /** @deprecated Use DocumentHighlightRequest.type */
4947 DocumentHighlightRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4948})(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
4949/**
4950 * A request to list all symbols found in a given text document. The request's
4951 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
4952 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
4953 * that resolves to such.
4954 */
4955var DocumentSymbolRequest;
4956(function (DocumentSymbolRequest) {
4957 DocumentSymbolRequest.method = 'textDocument/documentSymbol';
4958 DocumentSymbolRequest.type = new messages_1.ProtocolRequestType(DocumentSymbolRequest.method);
4959 /** @deprecated Use DocumentSymbolRequest.type */
4960 DocumentSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4961})(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
4962/**
4963 * A request to provide commands for the given text document and range.
4964 */
4965var CodeActionRequest;
4966(function (CodeActionRequest) {
4967 CodeActionRequest.method = 'textDocument/codeAction';
4968 CodeActionRequest.type = new messages_1.ProtocolRequestType(CodeActionRequest.method);
4969 /** @deprecated Use CodeActionRequest.type */
4970 CodeActionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4971})(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
4972/**
4973 * A request to list project-wide symbols matching the query string given
4974 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
4975 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
4976 * resolves to such.
4977 */
4978var WorkspaceSymbolRequest;
4979(function (WorkspaceSymbolRequest) {
4980 WorkspaceSymbolRequest.method = 'workspace/symbol';
4981 WorkspaceSymbolRequest.type = new messages_1.ProtocolRequestType(WorkspaceSymbolRequest.method);
4982 /** @deprecated Use WorkspaceSymbolRequest.type */
4983 WorkspaceSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4984})(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
4985/**
4986 * A request to provide code lens for the given text document.
4987 */
4988var CodeLensRequest;
4989(function (CodeLensRequest) {
4990 CodeLensRequest.type = new messages_1.ProtocolRequestType('textDocument/codeLens');
4991 /** @deprecated Use CodeLensRequest.type */
4992 CodeLensRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4993})(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
4994/**
4995 * A request to resolve a command for a given code lens.
4996 */
4997var CodeLensResolveRequest;
4998(function (CodeLensResolveRequest) {
4999 CodeLensResolveRequest.type = new messages_1.ProtocolRequestType('codeLens/resolve');
5000})(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
5001/**
5002 * A request to provide document links
5003 */
5004var DocumentLinkRequest;
5005(function (DocumentLinkRequest) {
5006 DocumentLinkRequest.method = 'textDocument/documentLink';
5007 DocumentLinkRequest.type = new messages_1.ProtocolRequestType(DocumentLinkRequest.method);
5008 /** @deprecated Use DocumentLinkRequest.type */
5009 DocumentLinkRequest.resultType = new vscode_jsonrpc_1.ProgressType();
5010})(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
5011/**
5012 * Request to resolve additional information for a given document link. The request's
5013 * parameter is of type [DocumentLink](#DocumentLink) the response
5014 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
5015 */
5016var DocumentLinkResolveRequest;
5017(function (DocumentLinkResolveRequest) {
5018 DocumentLinkResolveRequest.type = new messages_1.ProtocolRequestType('documentLink/resolve');
5019})(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
5020/**
5021 * A request to to format a whole document.
5022 */
5023var DocumentFormattingRequest;
5024(function (DocumentFormattingRequest) {
5025 DocumentFormattingRequest.method = 'textDocument/formatting';
5026 DocumentFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentFormattingRequest.method);
5027})(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
5028/**
5029 * A request to to format a range in a document.
5030 */
5031var DocumentRangeFormattingRequest;
5032(function (DocumentRangeFormattingRequest) {
5033 DocumentRangeFormattingRequest.method = 'textDocument/rangeFormatting';
5034 DocumentRangeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentRangeFormattingRequest.method);
5035})(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
5036/**
5037 * A request to format a document on type.
5038 */
5039var DocumentOnTypeFormattingRequest;
5040(function (DocumentOnTypeFormattingRequest) {
5041 DocumentOnTypeFormattingRequest.method = 'textDocument/onTypeFormatting';
5042 DocumentOnTypeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentOnTypeFormattingRequest.method);
5043})(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
5044/**
5045 * A request to rename a symbol.
5046 */
5047var RenameRequest;
5048(function (RenameRequest) {
5049 RenameRequest.method = 'textDocument/rename';
5050 RenameRequest.type = new messages_1.ProtocolRequestType(RenameRequest.method);
5051})(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
5052/**
5053 * A request to test and perform the setup necessary for a rename.
5054 */
5055var PrepareRenameRequest;
5056(function (PrepareRenameRequest) {
5057 PrepareRenameRequest.method = 'textDocument/prepareRename';
5058 PrepareRenameRequest.type = new messages_1.ProtocolRequestType(PrepareRenameRequest.method);
5059})(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
5060/**
5061 * A request send from the client to the server to execute a command. The request might return
5062 * a workspace edit which the client will apply to the workspace.
5063 */
5064var ExecuteCommandRequest;
5065(function (ExecuteCommandRequest) {
5066 ExecuteCommandRequest.type = new messages_1.ProtocolRequestType('workspace/executeCommand');
5067})(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
5068/**
5069 * A request sent from the server to the client to modified certain resources.
5070 */
5071var ApplyWorkspaceEditRequest;
5072(function (ApplyWorkspaceEditRequest) {
5073 ApplyWorkspaceEditRequest.type = new messages_1.ProtocolRequestType('workspace/applyEdit');
5074})(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
5075
5076
5077/***/ }),
5078
5079/***/ 30:
5080/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5081
5082"use strict";
5083/* --------------------------------------------------------------------------------------------
5084 * Copyright (c) Microsoft Corporation. All rights reserved.
5085 * Licensed under the MIT License. See License.txt in the project root for license information.
5086 * ------------------------------------------------------------------------------------------ */
5087
5088Object.defineProperty(exports, "__esModule", ({ value: true }));
5089const vscode_jsonrpc_1 = __webpack_require__(4);
5090const messages_1 = __webpack_require__(21);
5091var WorkDoneProgress;
5092(function (WorkDoneProgress) {
5093 WorkDoneProgress.type = new vscode_jsonrpc_1.ProgressType();
5094})(WorkDoneProgress = exports.WorkDoneProgress || (exports.WorkDoneProgress = {}));
5095/**
5096 * The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
5097 * reporting from the server.
5098 */
5099var WorkDoneProgressCreateRequest;
5100(function (WorkDoneProgressCreateRequest) {
5101 WorkDoneProgressCreateRequest.type = new messages_1.ProtocolRequestType('window/workDoneProgress/create');
5102})(WorkDoneProgressCreateRequest = exports.WorkDoneProgressCreateRequest || (exports.WorkDoneProgressCreateRequest = {}));
5103/**
5104 * The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
5105 * initiated on the server side.
5106 */
5107var WorkDoneProgressCancelNotification;
5108(function (WorkDoneProgressCancelNotification) {
5109 WorkDoneProgressCancelNotification.type = new messages_1.ProtocolNotificationType('window/workDoneProgress/cancel');
5110})(WorkDoneProgressCancelNotification = exports.WorkDoneProgressCancelNotification || (exports.WorkDoneProgressCancelNotification = {}));
5111
5112
5113/***/ }),
5114
5115/***/ 29:
5116/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5117
5118"use strict";
5119
5120/*---------------------------------------------------------------------------------------------
5121 * Copyright (c) Microsoft Corporation. All rights reserved.
5122 * Licensed under the MIT License. See License.txt in the project root for license information.
5123 *--------------------------------------------------------------------------------------------*/
5124Object.defineProperty(exports, "__esModule", ({ value: true }));
5125const vscode_jsonrpc_1 = __webpack_require__(4);
5126const messages_1 = __webpack_require__(21);
5127/**
5128 * A request to provide selection ranges in a document. The request's
5129 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
5130 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
5131 * that resolves to such.
5132 */
5133var SelectionRangeRequest;
5134(function (SelectionRangeRequest) {
5135 SelectionRangeRequest.method = 'textDocument/selectionRange';
5136 SelectionRangeRequest.type = new messages_1.ProtocolRequestType(SelectionRangeRequest.method);
5137 /** @deprecated Use SelectionRangeRequest.type */
5138 SelectionRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
5139})(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
5140
5141
5142/***/ }),
5143
5144/***/ 32:
5145/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5146
5147"use strict";
5148/* --------------------------------------------------------------------------------------------
5149 * Copyright (c) Microsoft Corporation. All rights reserved.
5150 * Licensed under the MIT License. See License.txt in the project root for license information.
5151 * ------------------------------------------------------------------------------------------ */
5152
5153Object.defineProperty(exports, "__esModule", ({ value: true }));
5154const messages_1 = __webpack_require__(21);
5155/**
5156 * A set of predefined token types. This set is not fixed
5157 * an clients can specify additional token types via the
5158 * corresponding client capabilities.
5159 *
5160 * @since 3.16.0 - Proposed state
5161 */
5162var SemanticTokenTypes;
5163(function (SemanticTokenTypes) {
5164 SemanticTokenTypes["comment"] = "comment";
5165 SemanticTokenTypes["keyword"] = "keyword";
5166 SemanticTokenTypes["string"] = "string";
5167 SemanticTokenTypes["number"] = "number";
5168 SemanticTokenTypes["regexp"] = "regexp";
5169 SemanticTokenTypes["operator"] = "operator";
5170 SemanticTokenTypes["namespace"] = "namespace";
5171 SemanticTokenTypes["type"] = "type";
5172 SemanticTokenTypes["struct"] = "struct";
5173 SemanticTokenTypes["class"] = "class";
5174 SemanticTokenTypes["interface"] = "interface";
5175 SemanticTokenTypes["enum"] = "enum";
5176 SemanticTokenTypes["typeParameter"] = "typeParameter";
5177 SemanticTokenTypes["function"] = "function";
5178 SemanticTokenTypes["member"] = "member";
5179 SemanticTokenTypes["property"] = "property";
5180 SemanticTokenTypes["macro"] = "macro";
5181 SemanticTokenTypes["variable"] = "variable";
5182 SemanticTokenTypes["parameter"] = "parameter";
5183 SemanticTokenTypes["label"] = "label";
5184})(SemanticTokenTypes = exports.SemanticTokenTypes || (exports.SemanticTokenTypes = {}));
5185/**
5186 * A set of predefined token modifiers. This set is not fixed
5187 * an clients can specify additional token types via the
5188 * corresponding client capabilities.
5189 *
5190 * @since 3.16.0 - Proposed state
5191 */
5192var SemanticTokenModifiers;
5193(function (SemanticTokenModifiers) {
5194 SemanticTokenModifiers["documentation"] = "documentation";
5195 SemanticTokenModifiers["declaration"] = "declaration";
5196 SemanticTokenModifiers["definition"] = "definition";
5197 SemanticTokenModifiers["reference"] = "reference";
5198 SemanticTokenModifiers["static"] = "static";
5199 SemanticTokenModifiers["abstract"] = "abstract";
5200 SemanticTokenModifiers["deprecated"] = "deprecated";
5201 SemanticTokenModifiers["async"] = "async";
5202 SemanticTokenModifiers["volatile"] = "volatile";
5203 SemanticTokenModifiers["readonly"] = "readonly";
5204})(SemanticTokenModifiers = exports.SemanticTokenModifiers || (exports.SemanticTokenModifiers = {}));
5205/**
5206 * @since 3.16.0 - Proposed state
5207 */
5208var SemanticTokens;
5209(function (SemanticTokens) {
5210 function is(value) {
5211 const candidate = value;
5212 return candidate !== undefined && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
5213 Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
5214 }
5215 SemanticTokens.is = is;
5216})(SemanticTokens = exports.SemanticTokens || (exports.SemanticTokens = {}));
5217/**
5218 * @since 3.16.0 - Proposed state
5219 */
5220var SemanticTokensRequest;
5221(function (SemanticTokensRequest) {
5222 SemanticTokensRequest.method = 'textDocument/semanticTokens';
5223 SemanticTokensRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRequest.method);
5224})(SemanticTokensRequest = exports.SemanticTokensRequest || (exports.SemanticTokensRequest = {}));
5225/**
5226 * @since 3.16.0 - Proposed state
5227 */
5228var SemanticTokensEditsRequest;
5229(function (SemanticTokensEditsRequest) {
5230 SemanticTokensEditsRequest.method = 'textDocument/semanticTokens/edits';
5231 SemanticTokensEditsRequest.type = new messages_1.ProtocolRequestType(SemanticTokensEditsRequest.method);
5232})(SemanticTokensEditsRequest = exports.SemanticTokensEditsRequest || (exports.SemanticTokensEditsRequest = {}));
5233/**
5234 * @since 3.16.0 - Proposed state
5235 */
5236var SemanticTokensRangeRequest;
5237(function (SemanticTokensRangeRequest) {
5238 SemanticTokensRangeRequest.method = 'textDocument/semanticTokens/range';
5239 SemanticTokensRangeRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRangeRequest.method);
5240})(SemanticTokensRangeRequest = exports.SemanticTokensRangeRequest || (exports.SemanticTokensRangeRequest = {}));
5241
5242
5243/***/ }),
5244
5245/***/ 23:
5246/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5247
5248"use strict";
5249/* --------------------------------------------------------------------------------------------
5250 * Copyright (c) Microsoft Corporation. All rights reserved.
5251 * Licensed under the MIT License. See License.txt in the project root for license information.
5252 * ------------------------------------------------------------------------------------------ */
5253
5254Object.defineProperty(exports, "__esModule", ({ value: true }));
5255const vscode_jsonrpc_1 = __webpack_require__(4);
5256const messages_1 = __webpack_require__(21);
5257// @ts-ignore: to avoid inlining LocatioLink as dynamic import
5258let __noDynamicImport;
5259/**
5260 * A request to resolve the type definition locations of a symbol at a given text
5261 * document position. The request's parameter is of type [TextDocumentPositioParams]
5262 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
5263 * Thenable that resolves to such.
5264 */
5265var TypeDefinitionRequest;
5266(function (TypeDefinitionRequest) {
5267 TypeDefinitionRequest.method = 'textDocument/typeDefinition';
5268 TypeDefinitionRequest.type = new messages_1.ProtocolRequestType(TypeDefinitionRequest.method);
5269 /** @deprecated Use TypeDefinitionRequest.type */
5270 TypeDefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
5271})(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
5272
5273
5274/***/ }),
5275
5276/***/ 24:
5277/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5278
5279"use strict";
5280/* --------------------------------------------------------------------------------------------
5281 * Copyright (c) Microsoft Corporation. All rights reserved.
5282 * Licensed under the MIT License. See License.txt in the project root for license information.
5283 * ------------------------------------------------------------------------------------------ */
5284
5285Object.defineProperty(exports, "__esModule", ({ value: true }));
5286const messages_1 = __webpack_require__(21);
5287/**
5288 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
5289 */
5290var WorkspaceFoldersRequest;
5291(function (WorkspaceFoldersRequest) {
5292 WorkspaceFoldersRequest.type = new messages_1.ProtocolRequestType0('workspace/workspaceFolders');
5293})(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
5294/**
5295 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
5296 * folder configuration changes.
5297 */
5298var DidChangeWorkspaceFoldersNotification;
5299(function (DidChangeWorkspaceFoldersNotification) {
5300 DidChangeWorkspaceFoldersNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWorkspaceFolders');
5301})(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
5302
5303
5304/***/ }),
5305
5306/***/ 20:
5307/***/ ((__unused_webpack_module, exports) => {
5308
5309"use strict";
5310/* --------------------------------------------------------------------------------------------
5311 * Copyright (c) Microsoft Corporation. All rights reserved.
5312 * Licensed under the MIT License. See License.txt in the project root for license information.
5313 * ------------------------------------------------------------------------------------------ */
5314
5315Object.defineProperty(exports, "__esModule", ({ value: true }));
5316function boolean(value) {
5317 return value === true || value === false;
5318}
5319exports.boolean = boolean;
5320function string(value) {
5321 return typeof value === 'string' || value instanceof String;
5322}
5323exports.string = string;
5324function number(value) {
5325 return typeof value === 'number' || value instanceof Number;
5326}
5327exports.number = number;
5328function error(value) {
5329 return value instanceof Error;
5330}
5331exports.error = error;
5332function func(value) {
5333 return typeof value === 'function';
5334}
5335exports.func = func;
5336function array(value) {
5337 return Array.isArray(value);
5338}
5339exports.array = array;
5340function stringArray(value) {
5341 return array(value) && value.every(elem => string(elem));
5342}
5343exports.stringArray = stringArray;
5344function typedArray(value, check) {
5345 return Array.isArray(value) && value.every(check);
5346}
5347exports.typedArray = typedArray;
5348function objectLiteral(value) {
5349 // Strictly speaking class instances pass this check as well. Since the LSP
5350 // doesn't use classes we ignore this for now. If we do we need to add something
5351 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
5352 return value !== null && typeof value === 'object';
5353}
5354exports.objectLiteral = objectLiteral;
5355
5356
5357/***/ }),
5358
5359/***/ 18:
5360/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5361
5362"use strict";
5363__webpack_require__.r(__webpack_exports__);
5364/* harmony export */ __webpack_require__.d(__webpack_exports__, {
5365/* harmony export */ "Position": () => /* binding */ Position,
5366/* harmony export */ "Range": () => /* binding */ Range,
5367/* harmony export */ "Location": () => /* binding */ Location,
5368/* harmony export */ "LocationLink": () => /* binding */ LocationLink,
5369/* harmony export */ "Color": () => /* binding */ Color,
5370/* harmony export */ "ColorInformation": () => /* binding */ ColorInformation,
5371/* harmony export */ "ColorPresentation": () => /* binding */ ColorPresentation,
5372/* harmony export */ "FoldingRangeKind": () => /* binding */ FoldingRangeKind,
5373/* harmony export */ "FoldingRange": () => /* binding */ FoldingRange,
5374/* harmony export */ "DiagnosticRelatedInformation": () => /* binding */ DiagnosticRelatedInformation,
5375/* harmony export */ "DiagnosticSeverity": () => /* binding */ DiagnosticSeverity,
5376/* harmony export */ "DiagnosticTag": () => /* binding */ DiagnosticTag,
5377/* harmony export */ "Diagnostic": () => /* binding */ Diagnostic,
5378/* harmony export */ "Command": () => /* binding */ Command,
5379/* harmony export */ "TextEdit": () => /* binding */ TextEdit,
5380/* harmony export */ "TextDocumentEdit": () => /* binding */ TextDocumentEdit,
5381/* harmony export */ "CreateFile": () => /* binding */ CreateFile,
5382/* harmony export */ "RenameFile": () => /* binding */ RenameFile,
5383/* harmony export */ "DeleteFile": () => /* binding */ DeleteFile,
5384/* harmony export */ "WorkspaceEdit": () => /* binding */ WorkspaceEdit,
5385/* harmony export */ "WorkspaceChange": () => /* binding */ WorkspaceChange,
5386/* harmony export */ "TextDocumentIdentifier": () => /* binding */ TextDocumentIdentifier,
5387/* harmony export */ "VersionedTextDocumentIdentifier": () => /* binding */ VersionedTextDocumentIdentifier,
5388/* harmony export */ "TextDocumentItem": () => /* binding */ TextDocumentItem,
5389/* harmony export */ "MarkupKind": () => /* binding */ MarkupKind,
5390/* harmony export */ "MarkupContent": () => /* binding */ MarkupContent,
5391/* harmony export */ "CompletionItemKind": () => /* binding */ CompletionItemKind,
5392/* harmony export */ "InsertTextFormat": () => /* binding */ InsertTextFormat,
5393/* harmony export */ "CompletionItemTag": () => /* binding */ CompletionItemTag,
5394/* harmony export */ "CompletionItem": () => /* binding */ CompletionItem,
5395/* harmony export */ "CompletionList": () => /* binding */ CompletionList,
5396/* harmony export */ "MarkedString": () => /* binding */ MarkedString,
5397/* harmony export */ "Hover": () => /* binding */ Hover,
5398/* harmony export */ "ParameterInformation": () => /* binding */ ParameterInformation,
5399/* harmony export */ "SignatureInformation": () => /* binding */ SignatureInformation,
5400/* harmony export */ "DocumentHighlightKind": () => /* binding */ DocumentHighlightKind,
5401/* harmony export */ "DocumentHighlight": () => /* binding */ DocumentHighlight,
5402/* harmony export */ "SymbolKind": () => /* binding */ SymbolKind,
5403/* harmony export */ "SymbolTag": () => /* binding */ SymbolTag,
5404/* harmony export */ "SymbolInformation": () => /* binding */ SymbolInformation,
5405/* harmony export */ "DocumentSymbol": () => /* binding */ DocumentSymbol,
5406/* harmony export */ "CodeActionKind": () => /* binding */ CodeActionKind,
5407/* harmony export */ "CodeActionContext": () => /* binding */ CodeActionContext,
5408/* harmony export */ "CodeAction": () => /* binding */ CodeAction,
5409/* harmony export */ "CodeLens": () => /* binding */ CodeLens,
5410/* harmony export */ "FormattingOptions": () => /* binding */ FormattingOptions,
5411/* harmony export */ "DocumentLink": () => /* binding */ DocumentLink,
5412/* harmony export */ "SelectionRange": () => /* binding */ SelectionRange,
5413/* harmony export */ "EOL": () => /* binding */ EOL,
5414/* harmony export */ "TextDocument": () => /* binding */ TextDocument
5415/* harmony export */ });
5416/* --------------------------------------------------------------------------------------------
5417 * Copyright (c) Microsoft Corporation. All rights reserved.
5418 * Licensed under the MIT License. See License.txt in the project root for license information.
5419 * ------------------------------------------------------------------------------------------ */
5420
5421/**
5422 * The Position namespace provides helper functions to work with
5423 * [Position](#Position) literals.
5424 */
5425var Position;
5426(function (Position) {
5427 /**
5428 * Creates a new Position literal from the given line and character.
5429 * @param line The position's line.
5430 * @param character The position's character.
5431 */
5432 function create(line, character) {
5433 return { line: line, character: character };
5434 }
5435 Position.create = create;
5436 /**
5437 * Checks whether the given liternal conforms to the [Position](#Position) interface.
5438 */
5439 function is(value) {
5440 var candidate = value;
5441 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
5442 }
5443 Position.is = is;
5444})(Position || (Position = {}));
5445/**
5446 * The Range namespace provides helper functions to work with
5447 * [Range](#Range) literals.
5448 */
5449var Range;
5450(function (Range) {
5451 function create(one, two, three, four) {
5452 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
5453 return { start: Position.create(one, two), end: Position.create(three, four) };
5454 }
5455 else if (Position.is(one) && Position.is(two)) {
5456 return { start: one, end: two };
5457 }
5458 else {
5459 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
5460 }
5461 }
5462 Range.create = create;
5463 /**
5464 * Checks whether the given literal conforms to the [Range](#Range) interface.
5465 */
5466 function is(value) {
5467 var candidate = value;
5468 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
5469 }
5470 Range.is = is;
5471})(Range || (Range = {}));
5472/**
5473 * The Location namespace provides helper functions to work with
5474 * [Location](#Location) literals.
5475 */
5476var Location;
5477(function (Location) {
5478 /**
5479 * Creates a Location literal.
5480 * @param uri The location's uri.
5481 * @param range The location's range.
5482 */
5483 function create(uri, range) {
5484 return { uri: uri, range: range };
5485 }
5486 Location.create = create;
5487 /**
5488 * Checks whether the given literal conforms to the [Location](#Location) interface.
5489 */
5490 function is(value) {
5491 var candidate = value;
5492 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
5493 }
5494 Location.is = is;
5495})(Location || (Location = {}));
5496/**
5497 * The LocationLink namespace provides helper functions to work with
5498 * [LocationLink](#LocationLink) literals.
5499 */
5500var LocationLink;
5501(function (LocationLink) {
5502 /**
5503 * Creates a LocationLink literal.
5504 * @param targetUri The definition's uri.
5505 * @param targetRange The full range of the definition.
5506 * @param targetSelectionRange The span of the symbol definition at the target.
5507 * @param originSelectionRange The span of the symbol being defined in the originating source file.
5508 */
5509 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
5510 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
5511 }
5512 LocationLink.create = create;
5513 /**
5514 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
5515 */
5516 function is(value) {
5517 var candidate = value;
5518 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
5519 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
5520 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
5521 }
5522 LocationLink.is = is;
5523})(LocationLink || (LocationLink = {}));
5524/**
5525 * The Color namespace provides helper functions to work with
5526 * [Color](#Color) literals.
5527 */
5528var Color;
5529(function (Color) {
5530 /**
5531 * Creates a new Color literal.
5532 */
5533 function create(red, green, blue, alpha) {
5534 return {
5535 red: red,
5536 green: green,
5537 blue: blue,
5538 alpha: alpha,
5539 };
5540 }
5541 Color.create = create;
5542 /**
5543 * Checks whether the given literal conforms to the [Color](#Color) interface.
5544 */
5545 function is(value) {
5546 var candidate = value;
5547 return Is.number(candidate.red)
5548 && Is.number(candidate.green)
5549 && Is.number(candidate.blue)
5550 && Is.number(candidate.alpha);
5551 }
5552 Color.is = is;
5553})(Color || (Color = {}));
5554/**
5555 * The ColorInformation namespace provides helper functions to work with
5556 * [ColorInformation](#ColorInformation) literals.
5557 */
5558var ColorInformation;
5559(function (ColorInformation) {
5560 /**
5561 * Creates a new ColorInformation literal.
5562 */
5563 function create(range, color) {
5564 return {
5565 range: range,
5566 color: color,
5567 };
5568 }
5569 ColorInformation.create = create;
5570 /**
5571 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
5572 */
5573 function is(value) {
5574 var candidate = value;
5575 return Range.is(candidate.range) && Color.is(candidate.color);
5576 }
5577 ColorInformation.is = is;
5578})(ColorInformation || (ColorInformation = {}));
5579/**
5580 * The Color namespace provides helper functions to work with
5581 * [ColorPresentation](#ColorPresentation) literals.
5582 */
5583var ColorPresentation;
5584(function (ColorPresentation) {
5585 /**
5586 * Creates a new ColorInformation literal.
5587 */
5588 function create(label, textEdit, additionalTextEdits) {
5589 return {
5590 label: label,
5591 textEdit: textEdit,
5592 additionalTextEdits: additionalTextEdits,
5593 };
5594 }
5595 ColorPresentation.create = create;
5596 /**
5597 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
5598 */
5599 function is(value) {
5600 var candidate = value;
5601 return Is.string(candidate.label)
5602 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
5603 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
5604 }
5605 ColorPresentation.is = is;
5606})(ColorPresentation || (ColorPresentation = {}));
5607/**
5608 * Enum of known range kinds
5609 */
5610var FoldingRangeKind;
5611(function (FoldingRangeKind) {
5612 /**
5613 * Folding range for a comment
5614 */
5615 FoldingRangeKind["Comment"] = "comment";
5616 /**
5617 * Folding range for a imports or includes
5618 */
5619 FoldingRangeKind["Imports"] = "imports";
5620 /**
5621 * Folding range for a region (e.g. `#region`)
5622 */
5623 FoldingRangeKind["Region"] = "region";
5624})(FoldingRangeKind || (FoldingRangeKind = {}));
5625/**
5626 * The folding range namespace provides helper functions to work with
5627 * [FoldingRange](#FoldingRange) literals.
5628 */
5629var FoldingRange;
5630(function (FoldingRange) {
5631 /**
5632 * Creates a new FoldingRange literal.
5633 */
5634 function create(startLine, endLine, startCharacter, endCharacter, kind) {
5635 var result = {
5636 startLine: startLine,
5637 endLine: endLine
5638 };
5639 if (Is.defined(startCharacter)) {
5640 result.startCharacter = startCharacter;
5641 }
5642 if (Is.defined(endCharacter)) {
5643 result.endCharacter = endCharacter;
5644 }
5645 if (Is.defined(kind)) {
5646 result.kind = kind;
5647 }
5648 return result;
5649 }
5650 FoldingRange.create = create;
5651 /**
5652 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
5653 */
5654 function is(value) {
5655 var candidate = value;
5656 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
5657 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
5658 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
5659 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
5660 }
5661 FoldingRange.is = is;
5662})(FoldingRange || (FoldingRange = {}));
5663/**
5664 * The DiagnosticRelatedInformation namespace provides helper functions to work with
5665 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
5666 */
5667var DiagnosticRelatedInformation;
5668(function (DiagnosticRelatedInformation) {
5669 /**
5670 * Creates a new DiagnosticRelatedInformation literal.
5671 */
5672 function create(location, message) {
5673 return {
5674 location: location,
5675 message: message
5676 };
5677 }
5678 DiagnosticRelatedInformation.create = create;
5679 /**
5680 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
5681 */
5682 function is(value) {
5683 var candidate = value;
5684 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
5685 }
5686 DiagnosticRelatedInformation.is = is;
5687})(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
5688/**
5689 * The diagnostic's severity.
5690 */
5691var DiagnosticSeverity;
5692(function (DiagnosticSeverity) {
5693 /**
5694 * Reports an error.
5695 */
5696 DiagnosticSeverity.Error = 1;
5697 /**
5698 * Reports a warning.
5699 */
5700 DiagnosticSeverity.Warning = 2;
5701 /**
5702 * Reports an information.
5703 */
5704 DiagnosticSeverity.Information = 3;
5705 /**
5706 * Reports a hint.
5707 */
5708 DiagnosticSeverity.Hint = 4;
5709})(DiagnosticSeverity || (DiagnosticSeverity = {}));
5710/**
5711 * The diagnostic tags.
5712 *
5713 * @since 3.15.0
5714 */
5715var DiagnosticTag;
5716(function (DiagnosticTag) {
5717 /**
5718 * Unused or unnecessary code.
5719 *
5720 * Clients are allowed to render diagnostics with this tag faded out instead of having
5721 * an error squiggle.
5722 */
5723 DiagnosticTag.Unnecessary = 1;
5724 /**
5725 * Deprecated or obsolete code.
5726 *
5727 * Clients are allowed to rendered diagnostics with this tag strike through.
5728 */
5729 DiagnosticTag.Deprecated = 2;
5730})(DiagnosticTag || (DiagnosticTag = {}));
5731/**
5732 * The Diagnostic namespace provides helper functions to work with
5733 * [Diagnostic](#Diagnostic) literals.
5734 */
5735var Diagnostic;
5736(function (Diagnostic) {
5737 /**
5738 * Creates a new Diagnostic literal.
5739 */
5740 function create(range, message, severity, code, source, relatedInformation) {
5741 var result = { range: range, message: message };
5742 if (Is.defined(severity)) {
5743 result.severity = severity;
5744 }
5745 if (Is.defined(code)) {
5746 result.code = code;
5747 }
5748 if (Is.defined(source)) {
5749 result.source = source;
5750 }
5751 if (Is.defined(relatedInformation)) {
5752 result.relatedInformation = relatedInformation;
5753 }
5754 return result;
5755 }
5756 Diagnostic.create = create;
5757 /**
5758 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
5759 */
5760 function is(value) {
5761 var candidate = value;
5762 return Is.defined(candidate)
5763 && Range.is(candidate.range)
5764 && Is.string(candidate.message)
5765 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
5766 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
5767 && (Is.string(candidate.source) || Is.undefined(candidate.source))
5768 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
5769 }
5770 Diagnostic.is = is;
5771})(Diagnostic || (Diagnostic = {}));
5772/**
5773 * The Command namespace provides helper functions to work with
5774 * [Command](#Command) literals.
5775 */
5776var Command;
5777(function (Command) {
5778 /**
5779 * Creates a new Command literal.
5780 */
5781 function create(title, command) {
5782 var args = [];
5783 for (var _i = 2; _i < arguments.length; _i++) {
5784 args[_i - 2] = arguments[_i];
5785 }
5786 var result = { title: title, command: command };
5787 if (Is.defined(args) && args.length > 0) {
5788 result.arguments = args;
5789 }
5790 return result;
5791 }
5792 Command.create = create;
5793 /**
5794 * Checks whether the given literal conforms to the [Command](#Command) interface.
5795 */
5796 function is(value) {
5797 var candidate = value;
5798 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
5799 }
5800 Command.is = is;
5801})(Command || (Command = {}));
5802/**
5803 * The TextEdit namespace provides helper function to create replace,
5804 * insert and delete edits more easily.
5805 */
5806var TextEdit;
5807(function (TextEdit) {
5808 /**
5809 * Creates a replace text edit.
5810 * @param range The range of text to be replaced.
5811 * @param newText The new text.
5812 */
5813 function replace(range, newText) {
5814 return { range: range, newText: newText };
5815 }
5816 TextEdit.replace = replace;
5817 /**
5818 * Creates a insert text edit.
5819 * @param position The position to insert the text at.
5820 * @param newText The text to be inserted.
5821 */
5822 function insert(position, newText) {
5823 return { range: { start: position, end: position }, newText: newText };
5824 }
5825 TextEdit.insert = insert;
5826 /**
5827 * Creates a delete text edit.
5828 * @param range The range of text to be deleted.
5829 */
5830 function del(range) {
5831 return { range: range, newText: '' };
5832 }
5833 TextEdit.del = del;
5834 function is(value) {
5835 var candidate = value;
5836 return Is.objectLiteral(candidate)
5837 && Is.string(candidate.newText)
5838 && Range.is(candidate.range);
5839 }
5840 TextEdit.is = is;
5841})(TextEdit || (TextEdit = {}));
5842/**
5843 * The TextDocumentEdit namespace provides helper function to create
5844 * an edit that manipulates a text document.
5845 */
5846var TextDocumentEdit;
5847(function (TextDocumentEdit) {
5848 /**
5849 * Creates a new `TextDocumentEdit`
5850 */
5851 function create(textDocument, edits) {
5852 return { textDocument: textDocument, edits: edits };
5853 }
5854 TextDocumentEdit.create = create;
5855 function is(value) {
5856 var candidate = value;
5857 return Is.defined(candidate)
5858 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
5859 && Array.isArray(candidate.edits);
5860 }
5861 TextDocumentEdit.is = is;
5862})(TextDocumentEdit || (TextDocumentEdit = {}));
5863var CreateFile;
5864(function (CreateFile) {
5865 function create(uri, options) {
5866 var result = {
5867 kind: 'create',
5868 uri: uri
5869 };
5870 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
5871 result.options = options;
5872 }
5873 return result;
5874 }
5875 CreateFile.create = create;
5876 function is(value) {
5877 var candidate = value;
5878 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
5879 (candidate.options === void 0 ||
5880 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
5881 }
5882 CreateFile.is = is;
5883})(CreateFile || (CreateFile = {}));
5884var RenameFile;
5885(function (RenameFile) {
5886 function create(oldUri, newUri, options) {
5887 var result = {
5888 kind: 'rename',
5889 oldUri: oldUri,
5890 newUri: newUri
5891 };
5892 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
5893 result.options = options;
5894 }
5895 return result;
5896 }
5897 RenameFile.create = create;
5898 function is(value) {
5899 var candidate = value;
5900 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
5901 (candidate.options === void 0 ||
5902 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
5903 }
5904 RenameFile.is = is;
5905})(RenameFile || (RenameFile = {}));
5906var DeleteFile;
5907(function (DeleteFile) {
5908 function create(uri, options) {
5909 var result = {
5910 kind: 'delete',
5911 uri: uri
5912 };
5913 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
5914 result.options = options;
5915 }
5916 return result;
5917 }
5918 DeleteFile.create = create;
5919 function is(value) {
5920 var candidate = value;
5921 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
5922 (candidate.options === void 0 ||
5923 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
5924 }
5925 DeleteFile.is = is;
5926})(DeleteFile || (DeleteFile = {}));
5927var WorkspaceEdit;
5928(function (WorkspaceEdit) {
5929 function is(value) {
5930 var candidate = value;
5931 return candidate &&
5932 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
5933 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
5934 if (Is.string(change.kind)) {
5935 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
5936 }
5937 else {
5938 return TextDocumentEdit.is(change);
5939 }
5940 }));
5941 }
5942 WorkspaceEdit.is = is;
5943})(WorkspaceEdit || (WorkspaceEdit = {}));
5944var TextEditChangeImpl = /** @class */ (function () {
5945 function TextEditChangeImpl(edits) {
5946 this.edits = edits;
5947 }
5948 TextEditChangeImpl.prototype.insert = function (position, newText) {
5949 this.edits.push(TextEdit.insert(position, newText));
5950 };
5951 TextEditChangeImpl.prototype.replace = function (range, newText) {
5952 this.edits.push(TextEdit.replace(range, newText));
5953 };
5954 TextEditChangeImpl.prototype.delete = function (range) {
5955 this.edits.push(TextEdit.del(range));
5956 };
5957 TextEditChangeImpl.prototype.add = function (edit) {
5958 this.edits.push(edit);
5959 };
5960 TextEditChangeImpl.prototype.all = function () {
5961 return this.edits;
5962 };
5963 TextEditChangeImpl.prototype.clear = function () {
5964 this.edits.splice(0, this.edits.length);
5965 };
5966 return TextEditChangeImpl;
5967}());
5968/**
5969 * A workspace change helps constructing changes to a workspace.
5970 */
5971var WorkspaceChange = /** @class */ (function () {
5972 function WorkspaceChange(workspaceEdit) {
5973 var _this = this;
5974 this._textEditChanges = Object.create(null);
5975 if (workspaceEdit) {
5976 this._workspaceEdit = workspaceEdit;
5977 if (workspaceEdit.documentChanges) {
5978 workspaceEdit.documentChanges.forEach(function (change) {
5979 if (TextDocumentEdit.is(change)) {
5980 var textEditChange = new TextEditChangeImpl(change.edits);
5981 _this._textEditChanges[change.textDocument.uri] = textEditChange;
5982 }
5983 });
5984 }
5985 else if (workspaceEdit.changes) {
5986 Object.keys(workspaceEdit.changes).forEach(function (key) {
5987 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
5988 _this._textEditChanges[key] = textEditChange;
5989 });
5990 }
5991 }
5992 }
5993 Object.defineProperty(WorkspaceChange.prototype, "edit", {
5994 /**
5995 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
5996 * use to be returned from a workspace edit operation like rename.
5997 */
5998 get: function () {
5999 return this._workspaceEdit;
6000 },
6001 enumerable: true,
6002 configurable: true
6003 });
6004 WorkspaceChange.prototype.getTextEditChange = function (key) {
6005 if (VersionedTextDocumentIdentifier.is(key)) {
6006 if (!this._workspaceEdit) {
6007 this._workspaceEdit = {
6008 documentChanges: []
6009 };
6010 }
6011 if (!this._workspaceEdit.documentChanges) {
6012 throw new Error('Workspace edit is not configured for document changes.');
6013 }
6014 var textDocument = key;
6015 var result = this._textEditChanges[textDocument.uri];
6016 if (!result) {
6017 var edits = [];
6018 var textDocumentEdit = {
6019 textDocument: textDocument,
6020 edits: edits
6021 };
6022 this._workspaceEdit.documentChanges.push(textDocumentEdit);
6023 result = new TextEditChangeImpl(edits);
6024 this._textEditChanges[textDocument.uri] = result;
6025 }
6026 return result;
6027 }
6028 else {
6029 if (!this._workspaceEdit) {
6030 this._workspaceEdit = {
6031 changes: Object.create(null)
6032 };
6033 }
6034 if (!this._workspaceEdit.changes) {
6035 throw new Error('Workspace edit is not configured for normal text edit changes.');
6036 }
6037 var result = this._textEditChanges[key];
6038 if (!result) {
6039 var edits = [];
6040 this._workspaceEdit.changes[key] = edits;
6041 result = new TextEditChangeImpl(edits);
6042 this._textEditChanges[key] = result;
6043 }
6044 return result;
6045 }
6046 };
6047 WorkspaceChange.prototype.createFile = function (uri, options) {
6048 this.checkDocumentChanges();
6049 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
6050 };
6051 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
6052 this.checkDocumentChanges();
6053 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
6054 };
6055 WorkspaceChange.prototype.deleteFile = function (uri, options) {
6056 this.checkDocumentChanges();
6057 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
6058 };
6059 WorkspaceChange.prototype.checkDocumentChanges = function () {
6060 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
6061 throw new Error('Workspace edit is not configured for document changes.');
6062 }
6063 };
6064 return WorkspaceChange;
6065}());
6066
6067/**
6068 * The TextDocumentIdentifier namespace provides helper functions to work with
6069 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
6070 */
6071var TextDocumentIdentifier;
6072(function (TextDocumentIdentifier) {
6073 /**
6074 * Creates a new TextDocumentIdentifier literal.
6075 * @param uri The document's uri.
6076 */
6077 function create(uri) {
6078 return { uri: uri };
6079 }
6080 TextDocumentIdentifier.create = create;
6081 /**
6082 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
6083 */
6084 function is(value) {
6085 var candidate = value;
6086 return Is.defined(candidate) && Is.string(candidate.uri);
6087 }
6088 TextDocumentIdentifier.is = is;
6089})(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
6090/**
6091 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
6092 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
6093 */
6094var VersionedTextDocumentIdentifier;
6095(function (VersionedTextDocumentIdentifier) {
6096 /**
6097 * Creates a new VersionedTextDocumentIdentifier literal.
6098 * @param uri The document's uri.
6099 * @param uri The document's text.
6100 */
6101 function create(uri, version) {
6102 return { uri: uri, version: version };
6103 }
6104 VersionedTextDocumentIdentifier.create = create;
6105 /**
6106 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
6107 */
6108 function is(value) {
6109 var candidate = value;
6110 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
6111 }
6112 VersionedTextDocumentIdentifier.is = is;
6113})(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
6114/**
6115 * The TextDocumentItem namespace provides helper functions to work with
6116 * [TextDocumentItem](#TextDocumentItem) literals.
6117 */
6118var TextDocumentItem;
6119(function (TextDocumentItem) {
6120 /**
6121 * Creates a new TextDocumentItem literal.
6122 * @param uri The document's uri.
6123 * @param languageId The document's language identifier.
6124 * @param version The document's version number.
6125 * @param text The document's text.
6126 */
6127 function create(uri, languageId, version, text) {
6128 return { uri: uri, languageId: languageId, version: version, text: text };
6129 }
6130 TextDocumentItem.create = create;
6131 /**
6132 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
6133 */
6134 function is(value) {
6135 var candidate = value;
6136 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
6137 }
6138 TextDocumentItem.is = is;
6139})(TextDocumentItem || (TextDocumentItem = {}));
6140/**
6141 * Describes the content type that a client supports in various
6142 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
6143 *
6144 * Please note that `MarkupKinds` must not start with a `$`. This kinds
6145 * are reserved for internal usage.
6146 */
6147var MarkupKind;
6148(function (MarkupKind) {
6149 /**
6150 * Plain text is supported as a content format
6151 */
6152 MarkupKind.PlainText = 'plaintext';
6153 /**
6154 * Markdown is supported as a content format
6155 */
6156 MarkupKind.Markdown = 'markdown';
6157})(MarkupKind || (MarkupKind = {}));
6158(function (MarkupKind) {
6159 /**
6160 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
6161 */
6162 function is(value) {
6163 var candidate = value;
6164 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
6165 }
6166 MarkupKind.is = is;
6167})(MarkupKind || (MarkupKind = {}));
6168var MarkupContent;
6169(function (MarkupContent) {
6170 /**
6171 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
6172 */
6173 function is(value) {
6174 var candidate = value;
6175 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
6176 }
6177 MarkupContent.is = is;
6178})(MarkupContent || (MarkupContent = {}));
6179/**
6180 * The kind of a completion entry.
6181 */
6182var CompletionItemKind;
6183(function (CompletionItemKind) {
6184 CompletionItemKind.Text = 1;
6185 CompletionItemKind.Method = 2;
6186 CompletionItemKind.Function = 3;
6187 CompletionItemKind.Constructor = 4;
6188 CompletionItemKind.Field = 5;
6189 CompletionItemKind.Variable = 6;
6190 CompletionItemKind.Class = 7;
6191 CompletionItemKind.Interface = 8;
6192 CompletionItemKind.Module = 9;
6193 CompletionItemKind.Property = 10;
6194 CompletionItemKind.Unit = 11;
6195 CompletionItemKind.Value = 12;
6196 CompletionItemKind.Enum = 13;
6197 CompletionItemKind.Keyword = 14;
6198 CompletionItemKind.Snippet = 15;
6199 CompletionItemKind.Color = 16;
6200 CompletionItemKind.File = 17;
6201 CompletionItemKind.Reference = 18;
6202 CompletionItemKind.Folder = 19;
6203 CompletionItemKind.EnumMember = 20;
6204 CompletionItemKind.Constant = 21;
6205 CompletionItemKind.Struct = 22;
6206 CompletionItemKind.Event = 23;
6207 CompletionItemKind.Operator = 24;
6208 CompletionItemKind.TypeParameter = 25;
6209})(CompletionItemKind || (CompletionItemKind = {}));
6210/**
6211 * Defines whether the insert text in a completion item should be interpreted as
6212 * plain text or a snippet.
6213 */
6214var InsertTextFormat;
6215(function (InsertTextFormat) {
6216 /**
6217 * The primary text to be inserted is treated as a plain string.
6218 */
6219 InsertTextFormat.PlainText = 1;
6220 /**
6221 * The primary text to be inserted is treated as a snippet.
6222 *
6223 * A snippet can define tab stops and placeholders with `$1`, `$2`
6224 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
6225 * the end of the snippet. Placeholders with equal identifiers are linked,
6226 * that is typing in one will update others too.
6227 *
6228 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
6229 */
6230 InsertTextFormat.Snippet = 2;
6231})(InsertTextFormat || (InsertTextFormat = {}));
6232/**
6233 * Completion item tags are extra annotations that tweak the rendering of a completion
6234 * item.
6235 *
6236 * @since 3.15.0
6237 */
6238var CompletionItemTag;
6239(function (CompletionItemTag) {
6240 /**
6241 * Render a completion as obsolete, usually using a strike-out.
6242 */
6243 CompletionItemTag.Deprecated = 1;
6244})(CompletionItemTag || (CompletionItemTag = {}));
6245/**
6246 * The CompletionItem namespace provides functions to deal with
6247 * completion items.
6248 */
6249var CompletionItem;
6250(function (CompletionItem) {
6251 /**
6252 * Create a completion item and seed it with a label.
6253 * @param label The completion item's label
6254 */
6255 function create(label) {
6256 return { label: label };
6257 }
6258 CompletionItem.create = create;
6259})(CompletionItem || (CompletionItem = {}));
6260/**
6261 * The CompletionList namespace provides functions to deal with
6262 * completion lists.
6263 */
6264var CompletionList;
6265(function (CompletionList) {
6266 /**
6267 * Creates a new completion list.
6268 *
6269 * @param items The completion items.
6270 * @param isIncomplete The list is not complete.
6271 */
6272 function create(items, isIncomplete) {
6273 return { items: items ? items : [], isIncomplete: !!isIncomplete };
6274 }
6275 CompletionList.create = create;
6276})(CompletionList || (CompletionList = {}));
6277var MarkedString;
6278(function (MarkedString) {
6279 /**
6280 * Creates a marked string from plain text.
6281 *
6282 * @param plainText The plain text.
6283 */
6284 function fromPlainText(plainText) {
6285 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
6286 }
6287 MarkedString.fromPlainText = fromPlainText;
6288 /**
6289 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
6290 */
6291 function is(value) {
6292 var candidate = value;
6293 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
6294 }
6295 MarkedString.is = is;
6296})(MarkedString || (MarkedString = {}));
6297var Hover;
6298(function (Hover) {
6299 /**
6300 * Checks whether the given value conforms to the [Hover](#Hover) interface.
6301 */
6302 function is(value) {
6303 var candidate = value;
6304 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
6305 MarkedString.is(candidate.contents) ||
6306 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
6307 }
6308 Hover.is = is;
6309})(Hover || (Hover = {}));
6310/**
6311 * The ParameterInformation namespace provides helper functions to work with
6312 * [ParameterInformation](#ParameterInformation) literals.
6313 */
6314var ParameterInformation;
6315(function (ParameterInformation) {
6316 /**
6317 * Creates a new parameter information literal.
6318 *
6319 * @param label A label string.
6320 * @param documentation A doc string.
6321 */
6322 function create(label, documentation) {
6323 return documentation ? { label: label, documentation: documentation } : { label: label };
6324 }
6325 ParameterInformation.create = create;
6326})(ParameterInformation || (ParameterInformation = {}));
6327/**
6328 * The SignatureInformation namespace provides helper functions to work with
6329 * [SignatureInformation](#SignatureInformation) literals.
6330 */
6331var SignatureInformation;
6332(function (SignatureInformation) {
6333 function create(label, documentation) {
6334 var parameters = [];
6335 for (var _i = 2; _i < arguments.length; _i++) {
6336 parameters[_i - 2] = arguments[_i];
6337 }
6338 var result = { label: label };
6339 if (Is.defined(documentation)) {
6340 result.documentation = documentation;
6341 }
6342 if (Is.defined(parameters)) {
6343 result.parameters = parameters;
6344 }
6345 else {
6346 result.parameters = [];
6347 }
6348 return result;
6349 }
6350 SignatureInformation.create = create;
6351})(SignatureInformation || (SignatureInformation = {}));
6352/**
6353 * A document highlight kind.
6354 */
6355var DocumentHighlightKind;
6356(function (DocumentHighlightKind) {
6357 /**
6358 * A textual occurrence.
6359 */
6360 DocumentHighlightKind.Text = 1;
6361 /**
6362 * Read-access of a symbol, like reading a variable.
6363 */
6364 DocumentHighlightKind.Read = 2;
6365 /**
6366 * Write-access of a symbol, like writing to a variable.
6367 */
6368 DocumentHighlightKind.Write = 3;
6369})(DocumentHighlightKind || (DocumentHighlightKind = {}));
6370/**
6371 * DocumentHighlight namespace to provide helper functions to work with
6372 * [DocumentHighlight](#DocumentHighlight) literals.
6373 */
6374var DocumentHighlight;
6375(function (DocumentHighlight) {
6376 /**
6377 * Create a DocumentHighlight object.
6378 * @param range The range the highlight applies to.
6379 */
6380 function create(range, kind) {
6381 var result = { range: range };
6382 if (Is.number(kind)) {
6383 result.kind = kind;
6384 }
6385 return result;
6386 }
6387 DocumentHighlight.create = create;
6388})(DocumentHighlight || (DocumentHighlight = {}));
6389/**
6390 * A symbol kind.
6391 */
6392var SymbolKind;
6393(function (SymbolKind) {
6394 SymbolKind.File = 1;
6395 SymbolKind.Module = 2;
6396 SymbolKind.Namespace = 3;
6397 SymbolKind.Package = 4;
6398 SymbolKind.Class = 5;
6399 SymbolKind.Method = 6;
6400 SymbolKind.Property = 7;
6401 SymbolKind.Field = 8;
6402 SymbolKind.Constructor = 9;
6403 SymbolKind.Enum = 10;
6404 SymbolKind.Interface = 11;
6405 SymbolKind.Function = 12;
6406 SymbolKind.Variable = 13;
6407 SymbolKind.Constant = 14;
6408 SymbolKind.String = 15;
6409 SymbolKind.Number = 16;
6410 SymbolKind.Boolean = 17;
6411 SymbolKind.Array = 18;
6412 SymbolKind.Object = 19;
6413 SymbolKind.Key = 20;
6414 SymbolKind.Null = 21;
6415 SymbolKind.EnumMember = 22;
6416 SymbolKind.Struct = 23;
6417 SymbolKind.Event = 24;
6418 SymbolKind.Operator = 25;
6419 SymbolKind.TypeParameter = 26;
6420})(SymbolKind || (SymbolKind = {}));
6421/**
6422 * Symbol tags are extra annotations that tweak the rendering of a symbol.
6423 * @since 3.15
6424 */
6425var SymbolTag;
6426(function (SymbolTag) {
6427 /**
6428 * Render a symbol as obsolete, usually using a strike-out.
6429 */
6430 SymbolTag.Deprecated = 1;
6431})(SymbolTag || (SymbolTag = {}));
6432var SymbolInformation;
6433(function (SymbolInformation) {
6434 /**
6435 * Creates a new symbol information literal.
6436 *
6437 * @param name The name of the symbol.
6438 * @param kind The kind of the symbol.
6439 * @param range The range of the location of the symbol.
6440 * @param uri The resource of the location of symbol, defaults to the current document.
6441 * @param containerName The name of the symbol containing the symbol.
6442 */
6443 function create(name, kind, range, uri, containerName) {
6444 var result = {
6445 name: name,
6446 kind: kind,
6447 location: { uri: uri, range: range }
6448 };
6449 if (containerName) {
6450 result.containerName = containerName;
6451 }
6452 return result;
6453 }
6454 SymbolInformation.create = create;
6455})(SymbolInformation || (SymbolInformation = {}));
6456var DocumentSymbol;
6457(function (DocumentSymbol) {
6458 /**
6459 * Creates a new symbol information literal.
6460 *
6461 * @param name The name of the symbol.
6462 * @param detail The detail of the symbol.
6463 * @param kind The kind of the symbol.
6464 * @param range The range of the symbol.
6465 * @param selectionRange The selectionRange of the symbol.
6466 * @param children Children of the symbol.
6467 */
6468 function create(name, detail, kind, range, selectionRange, children) {
6469 var result = {
6470 name: name,
6471 detail: detail,
6472 kind: kind,
6473 range: range,
6474 selectionRange: selectionRange
6475 };
6476 if (children !== void 0) {
6477 result.children = children;
6478 }
6479 return result;
6480 }
6481 DocumentSymbol.create = create;
6482 /**
6483 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
6484 */
6485 function is(value) {
6486 var candidate = value;
6487 return candidate &&
6488 Is.string(candidate.name) && Is.number(candidate.kind) &&
6489 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
6490 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
6491 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
6492 (candidate.children === void 0 || Array.isArray(candidate.children));
6493 }
6494 DocumentSymbol.is = is;
6495})(DocumentSymbol || (DocumentSymbol = {}));
6496/**
6497 * A set of predefined code action kinds
6498 */
6499var CodeActionKind;
6500(function (CodeActionKind) {
6501 /**
6502 * Empty kind.
6503 */
6504 CodeActionKind.Empty = '';
6505 /**
6506 * Base kind for quickfix actions: 'quickfix'
6507 */
6508 CodeActionKind.QuickFix = 'quickfix';
6509 /**
6510 * Base kind for refactoring actions: 'refactor'
6511 */
6512 CodeActionKind.Refactor = 'refactor';
6513 /**
6514 * Base kind for refactoring extraction actions: 'refactor.extract'
6515 *
6516 * Example extract actions:
6517 *
6518 * - Extract method
6519 * - Extract function
6520 * - Extract variable
6521 * - Extract interface from class
6522 * - ...
6523 */
6524 CodeActionKind.RefactorExtract = 'refactor.extract';
6525 /**
6526 * Base kind for refactoring inline actions: 'refactor.inline'
6527 *
6528 * Example inline actions:
6529 *
6530 * - Inline function
6531 * - Inline variable
6532 * - Inline constant
6533 * - ...
6534 */
6535 CodeActionKind.RefactorInline = 'refactor.inline';
6536 /**
6537 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
6538 *
6539 * Example rewrite actions:
6540 *
6541 * - Convert JavaScript function to class
6542 * - Add or remove parameter
6543 * - Encapsulate field
6544 * - Make method static
6545 * - Move method to base class
6546 * - ...
6547 */
6548 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
6549 /**
6550 * Base kind for source actions: `source`
6551 *
6552 * Source code actions apply to the entire file.
6553 */
6554 CodeActionKind.Source = 'source';
6555 /**
6556 * Base kind for an organize imports source action: `source.organizeImports`
6557 */
6558 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
6559 /**
6560 * Base kind for auto-fix source actions: `source.fixAll`.
6561 *
6562 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
6563 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
6564 *
6565 * @since 3.15.0
6566 */
6567 CodeActionKind.SourceFixAll = 'source.fixAll';
6568})(CodeActionKind || (CodeActionKind = {}));
6569/**
6570 * The CodeActionContext namespace provides helper functions to work with
6571 * [CodeActionContext](#CodeActionContext) literals.
6572 */
6573var CodeActionContext;
6574(function (CodeActionContext) {
6575 /**
6576 * Creates a new CodeActionContext literal.
6577 */
6578 function create(diagnostics, only) {
6579 var result = { diagnostics: diagnostics };
6580 if (only !== void 0 && only !== null) {
6581 result.only = only;
6582 }
6583 return result;
6584 }
6585 CodeActionContext.create = create;
6586 /**
6587 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
6588 */
6589 function is(value) {
6590 var candidate = value;
6591 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
6592 }
6593 CodeActionContext.is = is;
6594})(CodeActionContext || (CodeActionContext = {}));
6595var CodeAction;
6596(function (CodeAction) {
6597 function create(title, commandOrEdit, kind) {
6598 var result = { title: title };
6599 if (Command.is(commandOrEdit)) {
6600 result.command = commandOrEdit;
6601 }
6602 else {
6603 result.edit = commandOrEdit;
6604 }
6605 if (kind !== void 0) {
6606 result.kind = kind;
6607 }
6608 return result;
6609 }
6610 CodeAction.create = create;
6611 function is(value) {
6612 var candidate = value;
6613 return candidate && Is.string(candidate.title) &&
6614 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
6615 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
6616 (candidate.edit !== void 0 || candidate.command !== void 0) &&
6617 (candidate.command === void 0 || Command.is(candidate.command)) &&
6618 (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) &&
6619 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
6620 }
6621 CodeAction.is = is;
6622})(CodeAction || (CodeAction = {}));
6623/**
6624 * The CodeLens namespace provides helper functions to work with
6625 * [CodeLens](#CodeLens) literals.
6626 */
6627var CodeLens;
6628(function (CodeLens) {
6629 /**
6630 * Creates a new CodeLens literal.
6631 */
6632 function create(range, data) {
6633 var result = { range: range };
6634 if (Is.defined(data)) {
6635 result.data = data;
6636 }
6637 return result;
6638 }
6639 CodeLens.create = create;
6640 /**
6641 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
6642 */
6643 function is(value) {
6644 var candidate = value;
6645 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
6646 }
6647 CodeLens.is = is;
6648})(CodeLens || (CodeLens = {}));
6649/**
6650 * The FormattingOptions namespace provides helper functions to work with
6651 * [FormattingOptions](#FormattingOptions) literals.
6652 */
6653var FormattingOptions;
6654(function (FormattingOptions) {
6655 /**
6656 * Creates a new FormattingOptions literal.
6657 */
6658 function create(tabSize, insertSpaces) {
6659 return { tabSize: tabSize, insertSpaces: insertSpaces };
6660 }
6661 FormattingOptions.create = create;
6662 /**
6663 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
6664 */
6665 function is(value) {
6666 var candidate = value;
6667 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
6668 }
6669 FormattingOptions.is = is;
6670})(FormattingOptions || (FormattingOptions = {}));
6671/**
6672 * The DocumentLink namespace provides helper functions to work with
6673 * [DocumentLink](#DocumentLink) literals.
6674 */
6675var DocumentLink;
6676(function (DocumentLink) {
6677 /**
6678 * Creates a new DocumentLink literal.
6679 */
6680 function create(range, target, data) {
6681 return { range: range, target: target, data: data };
6682 }
6683 DocumentLink.create = create;
6684 /**
6685 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
6686 */
6687 function is(value) {
6688 var candidate = value;
6689 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
6690 }
6691 DocumentLink.is = is;
6692})(DocumentLink || (DocumentLink = {}));
6693/**
6694 * The SelectionRange namespace provides helper function to work with
6695 * SelectionRange literals.
6696 */
6697var SelectionRange;
6698(function (SelectionRange) {
6699 /**
6700 * Creates a new SelectionRange
6701 * @param range the range.
6702 * @param parent an optional parent.
6703 */
6704 function create(range, parent) {
6705 return { range: range, parent: parent };
6706 }
6707 SelectionRange.create = create;
6708 function is(value) {
6709 var candidate = value;
6710 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
6711 }
6712 SelectionRange.is = is;
6713})(SelectionRange || (SelectionRange = {}));
6714var EOL = ['\n', '\r\n', '\r'];
6715/**
6716 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
6717 */
6718var TextDocument;
6719(function (TextDocument) {
6720 /**
6721 * Creates a new ITextDocument literal from the given uri and content.
6722 * @param uri The document's uri.
6723 * @param languageId The document's language Id.
6724 * @param content The document's content.
6725 */
6726 function create(uri, languageId, version, content) {
6727 return new FullTextDocument(uri, languageId, version, content);
6728 }
6729 TextDocument.create = create;
6730 /**
6731 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
6732 */
6733 function is(value) {
6734 var candidate = value;
6735 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
6736 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
6737 }
6738 TextDocument.is = is;
6739 function applyEdits(document, edits) {
6740 var text = document.getText();
6741 var sortedEdits = mergeSort(edits, function (a, b) {
6742 var diff = a.range.start.line - b.range.start.line;
6743 if (diff === 0) {
6744 return a.range.start.character - b.range.start.character;
6745 }
6746 return diff;
6747 });
6748 var lastModifiedOffset = text.length;
6749 for (var i = sortedEdits.length - 1; i >= 0; i--) {
6750 var e = sortedEdits[i];
6751 var startOffset = document.offsetAt(e.range.start);
6752 var endOffset = document.offsetAt(e.range.end);
6753 if (endOffset <= lastModifiedOffset) {
6754 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
6755 }
6756 else {
6757 throw new Error('Overlapping edit');
6758 }
6759 lastModifiedOffset = startOffset;
6760 }
6761 return text;
6762 }
6763 TextDocument.applyEdits = applyEdits;
6764 function mergeSort(data, compare) {
6765 if (data.length <= 1) {
6766 // sorted
6767 return data;
6768 }
6769 var p = (data.length / 2) | 0;
6770 var left = data.slice(0, p);
6771 var right = data.slice(p);
6772 mergeSort(left, compare);
6773 mergeSort(right, compare);
6774 var leftIdx = 0;
6775 var rightIdx = 0;
6776 var i = 0;
6777 while (leftIdx < left.length && rightIdx < right.length) {
6778 var ret = compare(left[leftIdx], right[rightIdx]);
6779 if (ret <= 0) {
6780 // smaller_equal -> take left to preserve order
6781 data[i++] = left[leftIdx++];
6782 }
6783 else {
6784 // greater -> take right
6785 data[i++] = right[rightIdx++];
6786 }
6787 }
6788 while (leftIdx < left.length) {
6789 data[i++] = left[leftIdx++];
6790 }
6791 while (rightIdx < right.length) {
6792 data[i++] = right[rightIdx++];
6793 }
6794 return data;
6795 }
6796})(TextDocument || (TextDocument = {}));
6797var FullTextDocument = /** @class */ (function () {
6798 function FullTextDocument(uri, languageId, version, content) {
6799 this._uri = uri;
6800 this._languageId = languageId;
6801 this._version = version;
6802 this._content = content;
6803 this._lineOffsets = undefined;
6804 }
6805 Object.defineProperty(FullTextDocument.prototype, "uri", {
6806 get: function () {
6807 return this._uri;
6808 },
6809 enumerable: true,
6810 configurable: true
6811 });
6812 Object.defineProperty(FullTextDocument.prototype, "languageId", {
6813 get: function () {
6814 return this._languageId;
6815 },
6816 enumerable: true,
6817 configurable: true
6818 });
6819 Object.defineProperty(FullTextDocument.prototype, "version", {
6820 get: function () {
6821 return this._version;
6822 },
6823 enumerable: true,
6824 configurable: true
6825 });
6826 FullTextDocument.prototype.getText = function (range) {
6827 if (range) {
6828 var start = this.offsetAt(range.start);
6829 var end = this.offsetAt(range.end);
6830 return this._content.substring(start, end);
6831 }
6832 return this._content;
6833 };
6834 FullTextDocument.prototype.update = function (event, version) {
6835 this._content = event.text;
6836 this._version = version;
6837 this._lineOffsets = undefined;
6838 };
6839 FullTextDocument.prototype.getLineOffsets = function () {
6840 if (this._lineOffsets === undefined) {
6841 var lineOffsets = [];
6842 var text = this._content;
6843 var isLineStart = true;
6844 for (var i = 0; i < text.length; i++) {
6845 if (isLineStart) {
6846 lineOffsets.push(i);
6847 isLineStart = false;
6848 }
6849 var ch = text.charAt(i);
6850 isLineStart = (ch === '\r' || ch === '\n');
6851 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
6852 i++;
6853 }
6854 }
6855 if (isLineStart && text.length > 0) {
6856 lineOffsets.push(text.length);
6857 }
6858 this._lineOffsets = lineOffsets;
6859 }
6860 return this._lineOffsets;
6861 };
6862 FullTextDocument.prototype.positionAt = function (offset) {
6863 offset = Math.max(Math.min(offset, this._content.length), 0);
6864 var lineOffsets = this.getLineOffsets();
6865 var low = 0, high = lineOffsets.length;
6866 if (high === 0) {
6867 return Position.create(0, offset);
6868 }
6869 while (low < high) {
6870 var mid = Math.floor((low + high) / 2);
6871 if (lineOffsets[mid] > offset) {
6872 high = mid;
6873 }
6874 else {
6875 low = mid + 1;
6876 }
6877 }
6878 // low is the least x for which the line offset is larger than the current offset
6879 // or array.length if no line offset is larger than the current offset
6880 var line = low - 1;
6881 return Position.create(line, offset - lineOffsets[line]);
6882 };
6883 FullTextDocument.prototype.offsetAt = function (position) {
6884 var lineOffsets = this.getLineOffsets();
6885 if (position.line >= lineOffsets.length) {
6886 return this._content.length;
6887 }
6888 else if (position.line < 0) {
6889 return 0;
6890 }
6891 var lineOffset = lineOffsets[position.line];
6892 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
6893 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
6894 };
6895 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
6896 get: function () {
6897 return this.getLineOffsets().length;
6898 },
6899 enumerable: true,
6900 configurable: true
6901 });
6902 return FullTextDocument;
6903}());
6904var Is;
6905(function (Is) {
6906 var toString = Object.prototype.toString;
6907 function defined(value) {
6908 return typeof value !== 'undefined';
6909 }
6910 Is.defined = defined;
6911 function undefined(value) {
6912 return typeof value === 'undefined';
6913 }
6914 Is.undefined = undefined;
6915 function boolean(value) {
6916 return value === true || value === false;
6917 }
6918 Is.boolean = boolean;
6919 function string(value) {
6920 return toString.call(value) === '[object String]';
6921 }
6922 Is.string = string;
6923 function number(value) {
6924 return toString.call(value) === '[object Number]';
6925 }
6926 Is.number = number;
6927 function func(value) {
6928 return toString.call(value) === '[object Function]';
6929 }
6930 Is.func = func;
6931 function objectLiteral(value) {
6932 // Strictly speaking class instances pass this check as well. Since the LSP
6933 // doesn't use classes we ignore this for now. If we do we need to add something
6934 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
6935 return value !== null && typeof value === 'object';
6936 }
6937 Is.objectLiteral = objectLiteral;
6938 function typedArray(value, check) {
6939 return Array.isArray(value) && value.every(check);
6940 }
6941 Is.typedArray = typedArray;
6942})(Is || (Is = {}));
6943
6944
6945/***/ }),
6946
6947/***/ 42:
6948/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6949
6950"use strict";
6951/* --------------------------------------------------------------------------------------------
6952 * Copyright (c) Microsoft Corporation. All rights reserved.
6953 * Licensed under the MIT License. See License.txt in the project root for license information.
6954 * ------------------------------------------------------------------------------------------ */
6955
6956Object.defineProperty(exports, "__esModule", ({ value: true }));
6957const vscode_languageserver_protocol_1 = __webpack_require__(3);
6958exports.CallHierarchyFeature = (Base) => {
6959 return class extends Base {
6960 get callHierarchy() {
6961 return {
6962 onPrepare: (handler) => {
6963 this.connection.onRequest(vscode_languageserver_protocol_1.Proposed.CallHierarchyPrepareRequest.type, (params, cancel) => {
6964 return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
6965 });
6966 },
6967 onIncomingCalls: (handler) => {
6968 const type = vscode_languageserver_protocol_1.Proposed.CallHierarchyIncomingCallsRequest.type;
6969 this.connection.onRequest(type, (params, cancel) => {
6970 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
6971 });
6972 },
6973 onOutgoingCalls: (handler) => {
6974 const type = vscode_languageserver_protocol_1.Proposed.CallHierarchyOutgoingCallsRequest.type;
6975 this.connection.onRequest(type, (params, cancel) => {
6976 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
6977 });
6978 }
6979 };
6980 }
6981 };
6982};
6983//# sourceMappingURL=callHierarchy.proposed.js.map
6984
6985/***/ }),
6986
6987/***/ 33:
6988/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6989
6990"use strict";
6991/* --------------------------------------------------------------------------------------------
6992 * Copyright (c) Microsoft Corporation. All rights reserved.
6993 * Licensed under the MIT License. See License.txt in the project root for license information.
6994 * ------------------------------------------------------------------------------------------ */
6995
6996Object.defineProperty(exports, "__esModule", ({ value: true }));
6997const vscode_languageserver_protocol_1 = __webpack_require__(3);
6998const Is = __webpack_require__(34);
6999exports.ConfigurationFeature = (Base) => {
7000 return class extends Base {
7001 getConfiguration(arg) {
7002 if (!arg) {
7003 return this._getConfiguration({});
7004 }
7005 else if (Is.string(arg)) {
7006 return this._getConfiguration({ section: arg });
7007 }
7008 else {
7009 return this._getConfiguration(arg);
7010 }
7011 }
7012 _getConfiguration(arg) {
7013 let params = {
7014 items: Array.isArray(arg) ? arg : [arg]
7015 };
7016 return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {
7017 return Array.isArray(arg) ? result : result[0];
7018 });
7019 }
7020 };
7021};
7022//# sourceMappingURL=configuration.js.map
7023
7024/***/ }),
7025
7026/***/ 38:
7027/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7028
7029"use strict";
7030/* --------------------------------------------------------------------------------------------
7031 * Copyright (c) Microsoft Corporation. All rights reserved.
7032 * Licensed under the MIT License. See License.txt in the project root for license information.
7033 * ------------------------------------------------------------------------------------------ */
7034
7035Object.defineProperty(exports, "__esModule", ({ value: true }));
7036const url = __webpack_require__(39);
7037const path = __webpack_require__(13);
7038const fs = __webpack_require__(40);
7039const child_process_1 = __webpack_require__(41);
7040/**
7041 * @deprecated Use the `vscode-uri` npm module which provides a more
7042 * complete implementation of handling VS Code URIs.
7043 */
7044function uriToFilePath(uri) {
7045 let parsed = url.parse(uri);
7046 if (parsed.protocol !== 'file:' || !parsed.path) {
7047 return undefined;
7048 }
7049 let segments = parsed.path.split('/');
7050 for (var i = 0, len = segments.length; i < len; i++) {
7051 segments[i] = decodeURIComponent(segments[i]);
7052 }
7053 if (process.platform === 'win32' && segments.length > 1) {
7054 let first = segments[0];
7055 let second = segments[1];
7056 // Do we have a drive letter and we started with a / which is the
7057 // case if the first segement is empty (see split above)
7058 if (first.length === 0 && second.length > 1 && second[1] === ':') {
7059 // Remove first slash
7060 segments.shift();
7061 }
7062 }
7063 return path.normalize(segments.join('/'));
7064}
7065exports.uriToFilePath = uriToFilePath;
7066function isWindows() {
7067 return process.platform === 'win32';
7068}
7069function resolve(moduleName, nodePath, cwd, tracer) {
7070 const nodePathKey = 'NODE_PATH';
7071 const app = [
7072 'var p = process;',
7073 'p.on(\'message\',function(m){',
7074 'if(m.c===\'e\'){',
7075 'p.exit(0);',
7076 '}',
7077 'else if(m.c===\'rs\'){',
7078 'try{',
7079 'var r=require.resolve(m.a);',
7080 'p.send({c:\'r\',s:true,r:r});',
7081 '}',
7082 'catch(err){',
7083 'p.send({c:\'r\',s:false});',
7084 '}',
7085 '}',
7086 '});'
7087 ].join('');
7088 return new Promise((resolve, reject) => {
7089 let env = process.env;
7090 let newEnv = Object.create(null);
7091 Object.keys(env).forEach(key => newEnv[key] = env[key]);
7092 if (nodePath && fs.existsSync(nodePath) /* see issue 545 */) {
7093 if (newEnv[nodePathKey]) {
7094 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
7095 }
7096 else {
7097 newEnv[nodePathKey] = nodePath;
7098 }
7099 if (tracer) {
7100 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
7101 }
7102 }
7103 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
7104 try {
7105 let cp = child_process_1.fork('', [], {
7106 cwd: cwd,
7107 env: newEnv,
7108 execArgv: ['-e', app]
7109 });
7110 if (cp.pid === void 0) {
7111 reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
7112 return;
7113 }
7114 cp.on('error', (error) => {
7115 reject(error);
7116 });
7117 cp.on('message', (message) => {
7118 if (message.c === 'r') {
7119 cp.send({ c: 'e' });
7120 if (message.s) {
7121 resolve(message.r);
7122 }
7123 else {
7124 reject(new Error(`Failed to resolve module: ${moduleName}`));
7125 }
7126 }
7127 });
7128 let message = {
7129 c: 'rs',
7130 a: moduleName
7131 };
7132 cp.send(message);
7133 }
7134 catch (error) {
7135 reject(error);
7136 }
7137 });
7138}
7139exports.resolve = resolve;
7140/**
7141 * Resolve the global npm package path.
7142 * @deprecated Since this depends on the used package manager and their version the best is that servers
7143 * implement this themselves since they know best what kind of package managers to support.
7144 * @param tracer the tracer to use
7145 */
7146function resolveGlobalNodePath(tracer) {
7147 let npmCommand = 'npm';
7148 const env = Object.create(null);
7149 Object.keys(process.env).forEach(key => env[key] = process.env[key]);
7150 env['NO_UPDATE_NOTIFIER'] = 'true';
7151 const options = {
7152 encoding: 'utf8',
7153 env
7154 };
7155 if (isWindows()) {
7156 npmCommand = 'npm.cmd';
7157 options.shell = true;
7158 }
7159 let handler = () => { };
7160 try {
7161 process.on('SIGPIPE', handler);
7162 let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;
7163 if (!stdout) {
7164 if (tracer) {
7165 tracer(`'npm config get prefix' didn't return a value.`);
7166 }
7167 return undefined;
7168 }
7169 let prefix = stdout.trim();
7170 if (tracer) {
7171 tracer(`'npm config get prefix' value is: ${prefix}`);
7172 }
7173 if (prefix.length > 0) {
7174 if (isWindows()) {
7175 return path.join(prefix, 'node_modules');
7176 }
7177 else {
7178 return path.join(prefix, 'lib', 'node_modules');
7179 }
7180 }
7181 return undefined;
7182 }
7183 catch (err) {
7184 return undefined;
7185 }
7186 finally {
7187 process.removeListener('SIGPIPE', handler);
7188 }
7189}
7190exports.resolveGlobalNodePath = resolveGlobalNodePath;
7191/*
7192 * Resolve the global yarn pakage path.
7193 * @deprecated Since this depends on the used package manager and their version the best is that servers
7194 * implement this themselves since they know best what kind of package managers to support.
7195 * @param tracer the tracer to use
7196 */
7197function resolveGlobalYarnPath(tracer) {
7198 let yarnCommand = 'yarn';
7199 let options = {
7200 encoding: 'utf8'
7201 };
7202 if (isWindows()) {
7203 yarnCommand = 'yarn.cmd';
7204 options.shell = true;
7205 }
7206 let handler = () => { };
7207 try {
7208 process.on('SIGPIPE', handler);
7209 let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);
7210 let stdout = results.stdout;
7211 if (!stdout) {
7212 if (tracer) {
7213 tracer(`'yarn global dir' didn't return a value.`);
7214 if (results.stderr) {
7215 tracer(results.stderr);
7216 }
7217 }
7218 return undefined;
7219 }
7220 let lines = stdout.trim().split(/\r?\n/);
7221 for (let line of lines) {
7222 try {
7223 let yarn = JSON.parse(line);
7224 if (yarn.type === 'log') {
7225 return path.join(yarn.data, 'node_modules');
7226 }
7227 }
7228 catch (e) {
7229 // Do nothing. Ignore the line
7230 }
7231 }
7232 return undefined;
7233 }
7234 catch (err) {
7235 return undefined;
7236 }
7237 finally {
7238 process.removeListener('SIGPIPE', handler);
7239 }
7240}
7241exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
7242var FileSystem;
7243(function (FileSystem) {
7244 let _isCaseSensitive = undefined;
7245 function isCaseSensitive() {
7246 if (_isCaseSensitive !== void 0) {
7247 return _isCaseSensitive;
7248 }
7249 if (process.platform === 'win32') {
7250 _isCaseSensitive = false;
7251 }
7252 else {
7253 // convert current file name to upper case / lower case and check if file exists
7254 // (guards against cases when name is already all uppercase or lowercase)
7255 _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
7256 }
7257 return _isCaseSensitive;
7258 }
7259 FileSystem.isCaseSensitive = isCaseSensitive;
7260 function isParent(parent, child) {
7261 if (isCaseSensitive()) {
7262 return path.normalize(child).indexOf(path.normalize(parent)) === 0;
7263 }
7264 else {
7265 return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) === 0;
7266 }
7267 }
7268 FileSystem.isParent = isParent;
7269})(FileSystem = exports.FileSystem || (exports.FileSystem = {}));
7270function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
7271 if (nodePath) {
7272 if (!path.isAbsolute(nodePath)) {
7273 nodePath = path.join(workspaceRoot, nodePath);
7274 }
7275 return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
7276 if (FileSystem.isParent(nodePath, value)) {
7277 return value;
7278 }
7279 else {
7280 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
7281 }
7282 }).then(undefined, (_error) => {
7283 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
7284 });
7285 }
7286 else {
7287 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
7288 }
7289}
7290exports.resolveModulePath = resolveModulePath;
7291//# sourceMappingURL=files.js.map
7292
7293/***/ }),
7294
7295/***/ 2:
7296/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7297
7298"use strict";
7299/* --------------------------------------------------------------------------------------------
7300 * Copyright (c) Microsoft Corporation. All rights reserved.
7301 * Licensed under the MIT License. See License.txt in the project root for license information.
7302 * ------------------------------------------------------------------------------------------ */
7303/// <reference path="../typings/thenable.d.ts" />
7304
7305function __export(m) {
7306 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
7307}
7308Object.defineProperty(exports, "__esModule", ({ value: true }));
7309const vscode_languageserver_protocol_1 = __webpack_require__(3);
7310exports.Event = vscode_languageserver_protocol_1.Event;
7311const configuration_1 = __webpack_require__(33);
7312const workspaceFolders_1 = __webpack_require__(35);
7313const progress_1 = __webpack_require__(36);
7314const Is = __webpack_require__(34);
7315const UUID = __webpack_require__(37);
7316// ------------- Reexport the API surface of the language worker API ----------------------
7317__export(__webpack_require__(3));
7318const fm = __webpack_require__(38);
7319var Files;
7320(function (Files) {
7321 Files.uriToFilePath = fm.uriToFilePath;
7322 Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
7323 Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
7324 Files.resolve = fm.resolve;
7325 Files.resolveModulePath = fm.resolveModulePath;
7326})(Files = exports.Files || (exports.Files = {}));
7327let shutdownReceived = false;
7328let exitTimer = undefined;
7329function setupExitTimer() {
7330 const argName = '--clientProcessId';
7331 function runTimer(value) {
7332 try {
7333 let processId = parseInt(value);
7334 if (!isNaN(processId)) {
7335 exitTimer = setInterval(() => {
7336 try {
7337 process.kill(processId, 0);
7338 }
7339 catch (ex) {
7340 // Parent process doesn't exist anymore. Exit the server.
7341 process.exit(shutdownReceived ? 0 : 1);
7342 }
7343 }, 3000);
7344 }
7345 }
7346 catch (e) {
7347 // Ignore errors;
7348 }
7349 }
7350 for (let i = 2; i < process.argv.length; i++) {
7351 let arg = process.argv[i];
7352 if (arg === argName && i + 1 < process.argv.length) {
7353 runTimer(process.argv[i + 1]);
7354 return;
7355 }
7356 else {
7357 let args = arg.split('=');
7358 if (args[0] === argName) {
7359 runTimer(args[1]);
7360 }
7361 }
7362 }
7363}
7364setupExitTimer();
7365function null2Undefined(value) {
7366 if (value === null) {
7367 return void 0;
7368 }
7369 return value;
7370}
7371/**
7372 * A manager for simple text documents
7373 */
7374class TextDocuments {
7375 /**
7376 * Create a new text document manager.
7377 */
7378 constructor(configuration) {
7379 this._documents = Object.create(null);
7380 this._configuration = configuration;
7381 this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
7382 this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
7383 this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
7384 this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
7385 this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
7386 }
7387 /**
7388 * An event that fires when a text document managed by this manager
7389 * has been opened or the content changes.
7390 */
7391 get onDidChangeContent() {
7392 return this._onDidChangeContent.event;
7393 }
7394 /**
7395 * An event that fires when a text document managed by this manager
7396 * has been opened.
7397 */
7398 get onDidOpen() {
7399 return this._onDidOpen.event;
7400 }
7401 /**
7402 * An event that fires when a text document managed by this manager
7403 * will be saved.
7404 */
7405 get onWillSave() {
7406 return this._onWillSave.event;
7407 }
7408 /**
7409 * Sets a handler that will be called if a participant wants to provide
7410 * edits during a text document save.
7411 */
7412 onWillSaveWaitUntil(handler) {
7413 this._willSaveWaitUntil = handler;
7414 }
7415 /**
7416 * An event that fires when a text document managed by this manager
7417 * has been saved.
7418 */
7419 get onDidSave() {
7420 return this._onDidSave.event;
7421 }
7422 /**
7423 * An event that fires when a text document managed by this manager
7424 * has been closed.
7425 */
7426 get onDidClose() {
7427 return this._onDidClose.event;
7428 }
7429 /**
7430 * Returns the document for the given URI. Returns undefined if
7431 * the document is not mananged by this instance.
7432 *
7433 * @param uri The text document's URI to retrieve.
7434 * @return the text document or `undefined`.
7435 */
7436 get(uri) {
7437 return this._documents[uri];
7438 }
7439 /**
7440 * Returns all text documents managed by this instance.
7441 *
7442 * @return all text documents.
7443 */
7444 all() {
7445 return Object.keys(this._documents).map(key => this._documents[key]);
7446 }
7447 /**
7448 * Returns the URIs of all text documents managed by this instance.
7449 *
7450 * @return the URI's of all text documents.
7451 */
7452 keys() {
7453 return Object.keys(this._documents);
7454 }
7455 /**
7456 * Listens for `low level` notification on the given connection to
7457 * update the text documents managed by this instance.
7458 *
7459 * @param connection The connection to listen on.
7460 */
7461 listen(connection) {
7462 connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
7463 connection.onDidOpenTextDocument((event) => {
7464 let td = event.textDocument;
7465 let document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
7466 this._documents[td.uri] = document;
7467 let toFire = Object.freeze({ document });
7468 this._onDidOpen.fire(toFire);
7469 this._onDidChangeContent.fire(toFire);
7470 });
7471 connection.onDidChangeTextDocument((event) => {
7472 let td = event.textDocument;
7473 let changes = event.contentChanges;
7474 if (changes.length === 0) {
7475 return;
7476 }
7477 let document = this._documents[td.uri];
7478 const { version } = td;
7479 if (version === null || version === void 0) {
7480 throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
7481 }
7482 document = this._configuration.update(document, changes, version);
7483 this._documents[td.uri] = document;
7484 this._onDidChangeContent.fire(Object.freeze({ document }));
7485 });
7486 connection.onDidCloseTextDocument((event) => {
7487 let document = this._documents[event.textDocument.uri];
7488 if (document) {
7489 delete this._documents[event.textDocument.uri];
7490 this._onDidClose.fire(Object.freeze({ document }));
7491 }
7492 });
7493 connection.onWillSaveTextDocument((event) => {
7494 let document = this._documents[event.textDocument.uri];
7495 if (document) {
7496 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
7497 }
7498 });
7499 connection.onWillSaveTextDocumentWaitUntil((event, token) => {
7500 let document = this._documents[event.textDocument.uri];
7501 if (document && this._willSaveWaitUntil) {
7502 return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);
7503 }
7504 else {
7505 return [];
7506 }
7507 });
7508 connection.onDidSaveTextDocument((event) => {
7509 let document = this._documents[event.textDocument.uri];
7510 if (document) {
7511 this._onDidSave.fire(Object.freeze({ document }));
7512 }
7513 });
7514 }
7515}
7516exports.TextDocuments = TextDocuments;
7517/**
7518 * Helps tracking error message. Equal occurences of the same
7519 * message are only stored once. This class is for example
7520 * useful if text documents are validated in a loop and equal
7521 * error message should be folded into one.
7522 */
7523class ErrorMessageTracker {
7524 constructor() {
7525 this._messages = Object.create(null);
7526 }
7527 /**
7528 * Add a message to the tracker.
7529 *
7530 * @param message The message to add.
7531 */
7532 add(message) {
7533 let count = this._messages[message];
7534 if (!count) {
7535 count = 0;
7536 }
7537 count++;
7538 this._messages[message] = count;
7539 }
7540 /**
7541 * Send all tracked messages to the connection's window.
7542 *
7543 * @param connection The connection established between client and server.
7544 */
7545 sendErrors(connection) {
7546 Object.keys(this._messages).forEach(message => {
7547 connection.window.showErrorMessage(message);
7548 });
7549 }
7550}
7551exports.ErrorMessageTracker = ErrorMessageTracker;
7552class RemoteConsoleImpl {
7553 constructor() {
7554 }
7555 rawAttach(connection) {
7556 this._rawConnection = connection;
7557 }
7558 attach(connection) {
7559 this._connection = connection;
7560 }
7561 get connection() {
7562 if (!this._connection) {
7563 throw new Error('Remote is not attached to a connection yet.');
7564 }
7565 return this._connection;
7566 }
7567 fillServerCapabilities(_capabilities) {
7568 }
7569 initialize(_capabilities) {
7570 }
7571 error(message) {
7572 this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
7573 }
7574 warn(message) {
7575 this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
7576 }
7577 info(message) {
7578 this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
7579 }
7580 log(message) {
7581 this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
7582 }
7583 send(type, message) {
7584 if (this._rawConnection) {
7585 this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });
7586 }
7587 }
7588}
7589class _RemoteWindowImpl {
7590 constructor() {
7591 }
7592 attach(connection) {
7593 this._connection = connection;
7594 }
7595 get connection() {
7596 if (!this._connection) {
7597 throw new Error('Remote is not attached to a connection yet.');
7598 }
7599 return this._connection;
7600 }
7601 initialize(_capabilities) {
7602 }
7603 fillServerCapabilities(_capabilities) {
7604 }
7605 showErrorMessage(message, ...actions) {
7606 let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };
7607 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
7608 }
7609 showWarningMessage(message, ...actions) {
7610 let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };
7611 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
7612 }
7613 showInformationMessage(message, ...actions) {
7614 let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };
7615 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
7616 }
7617}
7618const RemoteWindowImpl = progress_1.ProgressFeature(_RemoteWindowImpl);
7619var BulkRegistration;
7620(function (BulkRegistration) {
7621 /**
7622 * Creates a new bulk registration.
7623 * @return an empty bulk registration.
7624 */
7625 function create() {
7626 return new BulkRegistrationImpl();
7627 }
7628 BulkRegistration.create = create;
7629})(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));
7630class BulkRegistrationImpl {
7631 constructor() {
7632 this._registrations = [];
7633 this._registered = new Set();
7634 }
7635 add(type, registerOptions) {
7636 const method = Is.string(type) ? type : type.method;
7637 if (this._registered.has(method)) {
7638 throw new Error(`${method} is already added to this registration`);
7639 }
7640 const id = UUID.generateUuid();
7641 this._registrations.push({
7642 id: id,
7643 method: method,
7644 registerOptions: registerOptions || {}
7645 });
7646 this._registered.add(method);
7647 }
7648 asRegistrationParams() {
7649 return {
7650 registrations: this._registrations
7651 };
7652 }
7653}
7654var BulkUnregistration;
7655(function (BulkUnregistration) {
7656 function create() {
7657 return new BulkUnregistrationImpl(undefined, []);
7658 }
7659 BulkUnregistration.create = create;
7660})(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));
7661class BulkUnregistrationImpl {
7662 constructor(_connection, unregistrations) {
7663 this._connection = _connection;
7664 this._unregistrations = new Map();
7665 unregistrations.forEach(unregistration => {
7666 this._unregistrations.set(unregistration.method, unregistration);
7667 });
7668 }
7669 get isAttached() {
7670 return !!this._connection;
7671 }
7672 attach(connection) {
7673 this._connection = connection;
7674 }
7675 add(unregistration) {
7676 this._unregistrations.set(unregistration.method, unregistration);
7677 }
7678 dispose() {
7679 let unregistrations = [];
7680 for (let unregistration of this._unregistrations.values()) {
7681 unregistrations.push(unregistration);
7682 }
7683 let params = {
7684 unregisterations: unregistrations
7685 };
7686 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
7687 this._connection.console.info(`Bulk unregistration failed.`);
7688 });
7689 }
7690 disposeSingle(arg) {
7691 const method = Is.string(arg) ? arg : arg.method;
7692 const unregistration = this._unregistrations.get(method);
7693 if (!unregistration) {
7694 return false;
7695 }
7696 let params = {
7697 unregisterations: [unregistration]
7698 };
7699 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
7700 this._unregistrations.delete(method);
7701 }, (_error) => {
7702 this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);
7703 });
7704 return true;
7705 }
7706}
7707class RemoteClientImpl {
7708 attach(connection) {
7709 this._connection = connection;
7710 }
7711 get connection() {
7712 if (!this._connection) {
7713 throw new Error('Remote is not attached to a connection yet.');
7714 }
7715 return this._connection;
7716 }
7717 initialize(_capabilities) {
7718 }
7719 fillServerCapabilities(_capabilities) {
7720 }
7721 register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
7722 if (typeOrRegistrations instanceof BulkRegistrationImpl) {
7723 return this.registerMany(typeOrRegistrations);
7724 }
7725 else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
7726 return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
7727 }
7728 else {
7729 return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
7730 }
7731 }
7732 registerSingle1(unregistration, type, registerOptions) {
7733 const method = Is.string(type) ? type : type.method;
7734 const id = UUID.generateUuid();
7735 let params = {
7736 registrations: [{ id, method, registerOptions: registerOptions || {} }]
7737 };
7738 if (!unregistration.isAttached) {
7739 unregistration.attach(this._connection);
7740 }
7741 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
7742 unregistration.add({ id: id, method: method });
7743 return unregistration;
7744 }, (_error) => {
7745 this.connection.console.info(`Registering request handler for ${method} failed.`);
7746 return Promise.reject(_error);
7747 });
7748 }
7749 registerSingle2(type, registerOptions) {
7750 const method = Is.string(type) ? type : type.method;
7751 const id = UUID.generateUuid();
7752 let params = {
7753 registrations: [{ id, method, registerOptions: registerOptions || {} }]
7754 };
7755 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
7756 return vscode_languageserver_protocol_1.Disposable.create(() => {
7757 this.unregisterSingle(id, method);
7758 });
7759 }, (_error) => {
7760 this.connection.console.info(`Registering request handler for ${method} failed.`);
7761 return Promise.reject(_error);
7762 });
7763 }
7764 unregisterSingle(id, method) {
7765 let params = {
7766 unregisterations: [{ id, method }]
7767 };
7768 return this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
7769 this.connection.console.info(`Unregistering request handler for ${id} failed.`);
7770 });
7771 }
7772 registerMany(registrations) {
7773 let params = registrations.asRegistrationParams();
7774 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
7775 return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
7776 }, (_error) => {
7777 this.connection.console.info(`Bulk registration failed.`);
7778 return Promise.reject(_error);
7779 });
7780 }
7781}
7782class _RemoteWorkspaceImpl {
7783 constructor() {
7784 }
7785 attach(connection) {
7786 this._connection = connection;
7787 }
7788 get connection() {
7789 if (!this._connection) {
7790 throw new Error('Remote is not attached to a connection yet.');
7791 }
7792 return this._connection;
7793 }
7794 initialize(_capabilities) {
7795 }
7796 fillServerCapabilities(_capabilities) {
7797 }
7798 applyEdit(paramOrEdit) {
7799 function isApplyWorkspaceEditParams(value) {
7800 return value && !!value.edit;
7801 }
7802 let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
7803 return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
7804 }
7805}
7806const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));
7807class TelemetryImpl {
7808 constructor() {
7809 }
7810 attach(connection) {
7811 this._connection = connection;
7812 }
7813 get connection() {
7814 if (!this._connection) {
7815 throw new Error('Remote is not attached to a connection yet.');
7816 }
7817 return this._connection;
7818 }
7819 initialize(_capabilities) {
7820 }
7821 fillServerCapabilities(_capabilities) {
7822 }
7823 logEvent(data) {
7824 this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
7825 }
7826}
7827class TracerImpl {
7828 constructor() {
7829 this._trace = vscode_languageserver_protocol_1.Trace.Off;
7830 }
7831 attach(connection) {
7832 this._connection = connection;
7833 }
7834 get connection() {
7835 if (!this._connection) {
7836 throw new Error('Remote is not attached to a connection yet.');
7837 }
7838 return this._connection;
7839 }
7840 initialize(_capabilities) {
7841 }
7842 fillServerCapabilities(_capabilities) {
7843 }
7844 set trace(value) {
7845 this._trace = value;
7846 }
7847 log(message, verbose) {
7848 if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
7849 return;
7850 }
7851 this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
7852 message: message,
7853 verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
7854 });
7855 }
7856}
7857class LanguagesImpl {
7858 constructor() {
7859 }
7860 attach(connection) {
7861 this._connection = connection;
7862 }
7863 get connection() {
7864 if (!this._connection) {
7865 throw new Error('Remote is not attached to a connection yet.');
7866 }
7867 return this._connection;
7868 }
7869 initialize(_capabilities) {
7870 }
7871 fillServerCapabilities(_capabilities) {
7872 }
7873 attachWorkDoneProgress(params) {
7874 return progress_1.attachWorkDone(this.connection, params);
7875 }
7876 attachPartialResultProgress(_type, params) {
7877 return progress_1.attachPartialResult(this.connection, params);
7878 }
7879}
7880exports.LanguagesImpl = LanguagesImpl;
7881function combineConsoleFeatures(one, two) {
7882 return function (Base) {
7883 return two(one(Base));
7884 };
7885}
7886exports.combineConsoleFeatures = combineConsoleFeatures;
7887function combineTelemetryFeatures(one, two) {
7888 return function (Base) {
7889 return two(one(Base));
7890 };
7891}
7892exports.combineTelemetryFeatures = combineTelemetryFeatures;
7893function combineTracerFeatures(one, two) {
7894 return function (Base) {
7895 return two(one(Base));
7896 };
7897}
7898exports.combineTracerFeatures = combineTracerFeatures;
7899function combineClientFeatures(one, two) {
7900 return function (Base) {
7901 return two(one(Base));
7902 };
7903}
7904exports.combineClientFeatures = combineClientFeatures;
7905function combineWindowFeatures(one, two) {
7906 return function (Base) {
7907 return two(one(Base));
7908 };
7909}
7910exports.combineWindowFeatures = combineWindowFeatures;
7911function combineWorkspaceFeatures(one, two) {
7912 return function (Base) {
7913 return two(one(Base));
7914 };
7915}
7916exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
7917function combineLanguagesFeatures(one, two) {
7918 return function (Base) {
7919 return two(one(Base));
7920 };
7921}
7922exports.combineLanguagesFeatures = combineLanguagesFeatures;
7923function combineFeatures(one, two) {
7924 function combine(one, two, func) {
7925 if (one && two) {
7926 return func(one, two);
7927 }
7928 else if (one) {
7929 return one;
7930 }
7931 else {
7932 return two;
7933 }
7934 }
7935 let result = {
7936 __brand: 'features',
7937 console: combine(one.console, two.console, combineConsoleFeatures),
7938 tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
7939 telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
7940 client: combine(one.client, two.client, combineClientFeatures),
7941 window: combine(one.window, two.window, combineWindowFeatures),
7942 workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)
7943 };
7944 return result;
7945}
7946exports.combineFeatures = combineFeatures;
7947function createConnection(arg1, arg2, arg3, arg4) {
7948 let factories;
7949 let input;
7950 let output;
7951 let strategy;
7952 if (arg1 !== void 0 && arg1.__brand === 'features') {
7953 factories = arg1;
7954 arg1 = arg2;
7955 arg2 = arg3;
7956 arg3 = arg4;
7957 }
7958 if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {
7959 strategy = arg1;
7960 }
7961 else {
7962 input = arg1;
7963 output = arg2;
7964 strategy = arg3;
7965 }
7966 return _createConnection(input, output, strategy, factories);
7967}
7968exports.createConnection = createConnection;
7969function _createConnection(input, output, strategy, factories) {
7970 if (!input && !output && process.argv.length > 2) {
7971 let port = void 0;
7972 let pipeName = void 0;
7973 let argv = process.argv.slice(2);
7974 for (let i = 0; i < argv.length; i++) {
7975 let arg = argv[i];
7976 if (arg === '--node-ipc') {
7977 input = new vscode_languageserver_protocol_1.IPCMessageReader(process);
7978 output = new vscode_languageserver_protocol_1.IPCMessageWriter(process);
7979 break;
7980 }
7981 else if (arg === '--stdio') {
7982 input = process.stdin;
7983 output = process.stdout;
7984 break;
7985 }
7986 else if (arg === '--socket') {
7987 port = parseInt(argv[i + 1]);
7988 break;
7989 }
7990 else if (arg === '--pipe') {
7991 pipeName = argv[i + 1];
7992 break;
7993 }
7994 else {
7995 var args = arg.split('=');
7996 if (args[0] === '--socket') {
7997 port = parseInt(args[1]);
7998 break;
7999 }
8000 else if (args[0] === '--pipe') {
8001 pipeName = args[1];
8002 break;
8003 }
8004 }
8005 }
8006 if (port) {
8007 let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);
8008 input = transport[0];
8009 output = transport[1];
8010 }
8011 else if (pipeName) {
8012 let transport = vscode_languageserver_protocol_1.createServerPipeTransport(pipeName);
8013 input = transport[0];
8014 output = transport[1];
8015 }
8016 }
8017 var commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
8018 if (!input) {
8019 throw new Error('Connection input stream is not set. ' + commandLineMessage);
8020 }
8021 if (!output) {
8022 throw new Error('Connection output stream is not set. ' + commandLineMessage);
8023 }
8024 // Backwards compatibility
8025 if (Is.func(input.read) && Is.func(input.on)) {
8026 let inputStream = input;
8027 inputStream.on('end', () => {
8028 process.exit(shutdownReceived ? 0 : 1);
8029 });
8030 inputStream.on('close', () => {
8031 process.exit(shutdownReceived ? 0 : 1);
8032 });
8033 }
8034 const logger = (factories && factories.console ? new (factories.console(RemoteConsoleImpl))() : new RemoteConsoleImpl());
8035 const connection = vscode_languageserver_protocol_1.createProtocolConnection(input, output, logger, strategy);
8036 logger.rawAttach(connection);
8037 const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());
8038 const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());
8039 const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());
8040 const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());
8041 const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());
8042 const languages = (factories && factories.languages ? new (factories.languages(LanguagesImpl))() : new LanguagesImpl());
8043 const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages];
8044 function asPromise(value) {
8045 if (value instanceof Promise) {
8046 return value;
8047 }
8048 else if (Is.thenable(value)) {
8049 return new Promise((resolve, reject) => {
8050 value.then((resolved) => resolve(resolved), (error) => reject(error));
8051 });
8052 }
8053 else {
8054 return Promise.resolve(value);
8055 }
8056 }
8057 let shutdownHandler = undefined;
8058 let initializeHandler = undefined;
8059 let exitHandler = undefined;
8060 let protocolConnection = {
8061 listen: () => connection.listen(),
8062 sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
8063 onRequest: (type, handler) => connection.onRequest(type, handler),
8064 sendNotification: (type, param) => {
8065 const method = Is.string(type) ? type : type.method;
8066 if (arguments.length === 1) {
8067 connection.sendNotification(method);
8068 }
8069 else {
8070 connection.sendNotification(method, param);
8071 }
8072 },
8073 onNotification: (type, handler) => connection.onNotification(type, handler),
8074 onProgress: connection.onProgress,
8075 sendProgress: connection.sendProgress,
8076 onInitialize: (handler) => initializeHandler = handler,
8077 onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
8078 onShutdown: (handler) => shutdownHandler = handler,
8079 onExit: (handler) => exitHandler = handler,
8080 get console() { return logger; },
8081 get telemetry() { return telemetry; },
8082 get tracer() { return tracer; },
8083 get client() { return client; },
8084 get window() { return remoteWindow; },
8085 get workspace() { return workspace; },
8086 get languages() { return languages; },
8087 onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
8088 onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
8089 __textDocumentSync: undefined,
8090 onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
8091 onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
8092 onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
8093 onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
8094 onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
8095 onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
8096 sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
8097 onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, (params, cancel) => {
8098 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
8099 }),
8100 onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
8101 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8102 }),
8103 onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
8104 onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
8105 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
8106 }),
8107 onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
8108 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8109 }),
8110 onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
8111 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8112 }),
8113 onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
8114 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8115 }),
8116 onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
8117 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8118 }),
8119 onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
8120 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8121 }),
8122 onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
8123 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8124 }),
8125 onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
8126 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8127 }),
8128 onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
8129 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8130 }),
8131 onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
8132 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8133 }),
8134 onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
8135 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8136 }),
8137 onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, (params, cancel) => {
8138 return handler(params, cancel);
8139 }),
8140 onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
8141 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
8142 }),
8143 onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
8144 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
8145 }),
8146 onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, (params, cancel) => {
8147 return handler(params, cancel);
8148 }),
8149 onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, (params, cancel) => {
8150 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
8151 }),
8152 onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, (params, cancel) => {
8153 return handler(params, cancel);
8154 }),
8155 onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, (params, cancel) => {
8156 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8157 }),
8158 onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, (params, cancel) => {
8159 return handler(params, cancel);
8160 }),
8161 onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
8162 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8163 }),
8164 onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
8165 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8166 }),
8167 onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
8168 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8169 }),
8170 onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
8171 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
8172 }),
8173 onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
8174 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
8175 }),
8176 dispose: () => connection.dispose()
8177 };
8178 for (let remote of allRemotes) {
8179 remote.attach(protocolConnection);
8180 }
8181 connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
8182 const processId = params.processId;
8183 if (Is.number(processId) && exitTimer === void 0) {
8184 // We received a parent process id. Set up a timer to periodically check
8185 // if the parent is still alive.
8186 setInterval(() => {
8187 try {
8188 process.kill(processId, 0);
8189 }
8190 catch (ex) {
8191 // Parent process doesn't exist anymore. Exit the server.
8192 process.exit(shutdownReceived ? 0 : 1);
8193 }
8194 }, 3000);
8195 }
8196 if (Is.string(params.trace)) {
8197 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
8198 }
8199 for (let remote of allRemotes) {
8200 remote.initialize(params.capabilities);
8201 }
8202 if (initializeHandler) {
8203 let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token, progress_1.attachWorkDone(connection, params), undefined);
8204 return asPromise(result).then((value) => {
8205 if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
8206 return value;
8207 }
8208 let result = value;
8209 if (!result) {
8210 result = { capabilities: {} };
8211 }
8212 let capabilities = result.capabilities;
8213 if (!capabilities) {
8214 capabilities = {};
8215 result.capabilities = capabilities;
8216 }
8217 if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {
8218 capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
8219 }
8220 else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
8221 capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
8222 }
8223 for (let remote of allRemotes) {
8224 remote.fillServerCapabilities(capabilities);
8225 }
8226 return result;
8227 });
8228 }
8229 else {
8230 let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };
8231 for (let remote of allRemotes) {
8232 remote.fillServerCapabilities(result.capabilities);
8233 }
8234 return result;
8235 }
8236 });
8237 connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
8238 shutdownReceived = true;
8239 if (shutdownHandler) {
8240 return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
8241 }
8242 else {
8243 return undefined;
8244 }
8245 });
8246 connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
8247 try {
8248 if (exitHandler) {
8249 exitHandler();
8250 }
8251 }
8252 finally {
8253 if (shutdownReceived) {
8254 process.exit(0);
8255 }
8256 else {
8257 process.exit(1);
8258 }
8259 }
8260 });
8261 connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
8262 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
8263 });
8264 return protocolConnection;
8265}
8266// Export the protocol currently in proposed state.
8267const callHierarchy_proposed_1 = __webpack_require__(42);
8268const st = __webpack_require__(43);
8269var ProposedFeatures;
8270(function (ProposedFeatures) {
8271 ProposedFeatures.all = {
8272 __brand: 'features',
8273 languages: combineLanguagesFeatures(callHierarchy_proposed_1.CallHierarchyFeature, st.SemanticTokensFeature)
8274 };
8275 ProposedFeatures.SemanticTokensBuilder = st.SemanticTokensBuilder;
8276})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
8277//# sourceMappingURL=main.js.map
8278
8279/***/ }),
8280
8281/***/ 36:
8282/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8283
8284"use strict";
8285/* --------------------------------------------------------------------------------------------
8286 * Copyright (c) Microsoft Corporation. All rights reserved.
8287 * Licensed under the MIT License. See License.txt in the project root for license information.
8288 * ------------------------------------------------------------------------------------------ */
8289
8290Object.defineProperty(exports, "__esModule", ({ value: true }));
8291const vscode_languageserver_protocol_1 = __webpack_require__(3);
8292const uuid_1 = __webpack_require__(37);
8293class WorkDoneProgressImpl {
8294 constructor(_connection, _token) {
8295 this._connection = _connection;
8296 this._token = _token;
8297 WorkDoneProgressImpl.Instances.set(this._token, this);
8298 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
8299 }
8300 get token() {
8301 return this._source.token;
8302 }
8303 begin(title, percentage, message, cancellable) {
8304 let param = {
8305 kind: 'begin',
8306 title,
8307 percentage,
8308 message,
8309 cancellable
8310 };
8311 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
8312 }
8313 report(arg0, arg1) {
8314 let param = {
8315 kind: 'report'
8316 };
8317 if (typeof arg0 === 'number') {
8318 param.percentage = arg0;
8319 if (arg1 !== undefined) {
8320 param.message = arg1;
8321 }
8322 }
8323 else {
8324 param.message = arg0;
8325 }
8326 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
8327 }
8328 done() {
8329 WorkDoneProgressImpl.Instances.delete(this._token);
8330 this._source.dispose();
8331 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, { kind: 'end' });
8332 }
8333 cancel() {
8334 this._source.cancel();
8335 }
8336}
8337WorkDoneProgressImpl.Instances = new Map();
8338class NullProgress {
8339 constructor() {
8340 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
8341 }
8342 get token() {
8343 return this._source.token;
8344 }
8345 begin() {
8346 }
8347 report() {
8348 }
8349 done() {
8350 }
8351}
8352function attachWorkDone(connection, params) {
8353 if (params === undefined || params.workDoneToken === undefined) {
8354 return new NullProgress();
8355 }
8356 const token = params.workDoneToken;
8357 delete params.workDoneToken;
8358 return new WorkDoneProgressImpl(connection, token);
8359}
8360exports.attachWorkDone = attachWorkDone;
8361exports.ProgressFeature = (Base) => {
8362 return class extends Base {
8363 initialize(capabilities) {
8364 var _a;
8365 if (((_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.window) === null || _a === void 0 ? void 0 : _a.workDoneProgress) === true) {
8366 this._progressSupported = true;
8367 this.connection.onNotification(vscode_languageserver_protocol_1.WorkDoneProgressCancelNotification.type, (params) => {
8368 let progress = WorkDoneProgressImpl.Instances.get(params.token);
8369 if (progress !== undefined) {
8370 progress.cancel();
8371 }
8372 });
8373 }
8374 }
8375 attachWorkDoneProgress(token) {
8376 if (token === undefined) {
8377 return new NullProgress();
8378 }
8379 else {
8380 return new WorkDoneProgressImpl(this.connection, token);
8381 }
8382 }
8383 createWorkDoneProgress() {
8384 if (this._progressSupported) {
8385 const token = uuid_1.generateUuid();
8386 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkDoneProgressCreateRequest.type, { token }).then(() => {
8387 const result = new WorkDoneProgressImpl(this.connection, token);
8388 return result;
8389 });
8390 }
8391 else {
8392 return Promise.resolve(new NullProgress());
8393 }
8394 }
8395 };
8396};
8397var ResultProgress;
8398(function (ResultProgress) {
8399 ResultProgress.type = new vscode_languageserver_protocol_1.ProgressType();
8400})(ResultProgress || (ResultProgress = {}));
8401class ResultProgressImpl {
8402 constructor(_connection, _token) {
8403 this._connection = _connection;
8404 this._token = _token;
8405 }
8406 report(data) {
8407 this._connection.sendProgress(ResultProgress.type, this._token, data);
8408 }
8409}
8410function attachPartialResult(connection, params) {
8411 if (params === undefined || params.partialResultToken === undefined) {
8412 return undefined;
8413 }
8414 const token = params.partialResultToken;
8415 delete params.partialResultToken;
8416 return new ResultProgressImpl(connection, token);
8417}
8418exports.attachPartialResult = attachPartialResult;
8419//# sourceMappingURL=progress.js.map
8420
8421/***/ }),
8422
8423/***/ 43:
8424/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8425
8426"use strict";
8427/* --------------------------------------------------------------------------------------------
8428 * Copyright (c) Microsoft Corporation. All rights reserved.
8429 * Licensed under the MIT License. See License.txt in the project root for license information.
8430 * ------------------------------------------------------------------------------------------ */
8431
8432Object.defineProperty(exports, "__esModule", ({ value: true }));
8433const vscode_languageserver_protocol_1 = __webpack_require__(3);
8434exports.SemanticTokensFeature = (Base) => {
8435 return class extends Base {
8436 get semanticTokens() {
8437 return {
8438 on: (handler) => {
8439 const type = vscode_languageserver_protocol_1.Proposed.SemanticTokensRequest.type;
8440 this.connection.onRequest(type, (params, cancel) => {
8441 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
8442 });
8443 },
8444 onEdits: (handler) => {
8445 const type = vscode_languageserver_protocol_1.Proposed.SemanticTokensEditsRequest.type;
8446 this.connection.onRequest(type, (params, cancel) => {
8447 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
8448 });
8449 },
8450 onRange: (handler) => {
8451 const type = vscode_languageserver_protocol_1.Proposed.SemanticTokensRangeRequest.type;
8452 this.connection.onRequest(type, (params, cancel) => {
8453 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
8454 });
8455 }
8456 };
8457 }
8458 };
8459};
8460class SemanticTokensBuilder {
8461 constructor() {
8462 this._prevData = undefined;
8463 this.initialize();
8464 }
8465 initialize() {
8466 this._id = Date.now();
8467 this._prevLine = 0;
8468 this._prevChar = 0;
8469 this._data = [];
8470 this._dataLen = 0;
8471 }
8472 push(line, char, length, tokenType, tokenModifiers) {
8473 let pushLine = line;
8474 let pushChar = char;
8475 if (this._dataLen > 0) {
8476 pushLine -= this._prevLine;
8477 if (pushLine === 0) {
8478 pushChar -= this._prevChar;
8479 }
8480 }
8481 this._data[this._dataLen++] = pushLine;
8482 this._data[this._dataLen++] = pushChar;
8483 this._data[this._dataLen++] = length;
8484 this._data[this._dataLen++] = tokenType;
8485 this._data[this._dataLen++] = tokenModifiers;
8486 this._prevLine = line;
8487 this._prevChar = char;
8488 }
8489 get id() {
8490 return this._id.toString();
8491 }
8492 previousResult(id) {
8493 if (this.id === id) {
8494 this._prevData = this._data;
8495 }
8496 this.initialize();
8497 }
8498 build() {
8499 this._prevData = undefined;
8500 return {
8501 resultId: this.id,
8502 data: this._data
8503 };
8504 }
8505 canBuildEdits() {
8506 return this._prevData !== undefined;
8507 }
8508 buildEdits() {
8509 if (this._prevData !== undefined) {
8510 const prevDataLength = this._prevData.length;
8511 const dataLength = this._data.length;
8512 let startIndex = 0;
8513 while (startIndex < dataLength && startIndex < prevDataLength && this._prevData[startIndex] === this._data[startIndex]) {
8514 startIndex++;
8515 }
8516 if (startIndex < dataLength && startIndex < prevDataLength) {
8517 // Find end index
8518 let endIndex = 0;
8519 while (endIndex < dataLength && endIndex < prevDataLength && this._prevData[prevDataLength - 1 - endIndex] === this._data[dataLength - 1 - endIndex]) {
8520 endIndex++;
8521 }
8522 const newData = this._data.slice(startIndex, dataLength - endIndex);
8523 const result = {
8524 resultId: this.id,
8525 edits: [
8526 { start: startIndex, deleteCount: prevDataLength - endIndex - startIndex, data: newData }
8527 ]
8528 };
8529 return result;
8530 }
8531 else if (startIndex < dataLength) {
8532 return { resultId: this.id, edits: [
8533 { start: startIndex, deleteCount: 0, data: this._data.slice(startIndex) }
8534 ] };
8535 }
8536 else if (startIndex < prevDataLength) {
8537 return { resultId: this.id, edits: [
8538 { start: startIndex, deleteCount: prevDataLength - startIndex }
8539 ] };
8540 }
8541 else {
8542 return { resultId: this.id, edits: [] };
8543 }
8544 }
8545 else {
8546 return this.build();
8547 }
8548 }
8549}
8550exports.SemanticTokensBuilder = SemanticTokensBuilder;
8551//# sourceMappingURL=sematicTokens.proposed.js.map
8552
8553/***/ }),
8554
8555/***/ 34:
8556/***/ ((__unused_webpack_module, exports) => {
8557
8558"use strict";
8559/* --------------------------------------------------------------------------------------------
8560 * Copyright (c) Microsoft Corporation. All rights reserved.
8561 * Licensed under the MIT License. See License.txt in the project root for license information.
8562 * ------------------------------------------------------------------------------------------ */
8563
8564Object.defineProperty(exports, "__esModule", ({ value: true }));
8565function boolean(value) {
8566 return value === true || value === false;
8567}
8568exports.boolean = boolean;
8569function string(value) {
8570 return typeof value === 'string' || value instanceof String;
8571}
8572exports.string = string;
8573function number(value) {
8574 return typeof value === 'number' || value instanceof Number;
8575}
8576exports.number = number;
8577function error(value) {
8578 return value instanceof Error;
8579}
8580exports.error = error;
8581function func(value) {
8582 return typeof value === 'function';
8583}
8584exports.func = func;
8585function array(value) {
8586 return Array.isArray(value);
8587}
8588exports.array = array;
8589function stringArray(value) {
8590 return array(value) && value.every(elem => string(elem));
8591}
8592exports.stringArray = stringArray;
8593function typedArray(value, check) {
8594 return Array.isArray(value) && value.every(check);
8595}
8596exports.typedArray = typedArray;
8597function thenable(value) {
8598 return value && func(value.then);
8599}
8600exports.thenable = thenable;
8601//# sourceMappingURL=is.js.map
8602
8603/***/ }),
8604
8605/***/ 37:
8606/***/ ((__unused_webpack_module, exports) => {
8607
8608"use strict";
8609/*---------------------------------------------------------------------------------------------
8610 * Copyright (c) Microsoft Corporation. All rights reserved.
8611 * Licensed under the MIT License. See License.txt in the project root for license information.
8612 *--------------------------------------------------------------------------------------------*/
8613
8614Object.defineProperty(exports, "__esModule", ({ value: true }));
8615class ValueUUID {
8616 constructor(_value) {
8617 this._value = _value;
8618 // empty
8619 }
8620 asHex() {
8621 return this._value;
8622 }
8623 equals(other) {
8624 return this.asHex() === other.asHex();
8625 }
8626}
8627class V4UUID extends ValueUUID {
8628 constructor() {
8629 super([
8630 V4UUID._randomHex(),
8631 V4UUID._randomHex(),
8632 V4UUID._randomHex(),
8633 V4UUID._randomHex(),
8634 V4UUID._randomHex(),
8635 V4UUID._randomHex(),
8636 V4UUID._randomHex(),
8637 V4UUID._randomHex(),
8638 '-',
8639 V4UUID._randomHex(),
8640 V4UUID._randomHex(),
8641 V4UUID._randomHex(),
8642 V4UUID._randomHex(),
8643 '-',
8644 '4',
8645 V4UUID._randomHex(),
8646 V4UUID._randomHex(),
8647 V4UUID._randomHex(),
8648 '-',
8649 V4UUID._oneOf(V4UUID._timeHighBits),
8650 V4UUID._randomHex(),
8651 V4UUID._randomHex(),
8652 V4UUID._randomHex(),
8653 '-',
8654 V4UUID._randomHex(),
8655 V4UUID._randomHex(),
8656 V4UUID._randomHex(),
8657 V4UUID._randomHex(),
8658 V4UUID._randomHex(),
8659 V4UUID._randomHex(),
8660 V4UUID._randomHex(),
8661 V4UUID._randomHex(),
8662 V4UUID._randomHex(),
8663 V4UUID._randomHex(),
8664 V4UUID._randomHex(),
8665 V4UUID._randomHex(),
8666 ].join(''));
8667 }
8668 static _oneOf(array) {
8669 return array[Math.floor(array.length * Math.random())];
8670 }
8671 static _randomHex() {
8672 return V4UUID._oneOf(V4UUID._chars);
8673 }
8674}
8675V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
8676V4UUID._timeHighBits = ['8', '9', 'a', 'b'];
8677/**
8678 * An empty UUID that contains only zeros.
8679 */
8680exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');
8681function v4() {
8682 return new V4UUID();
8683}
8684exports.v4 = v4;
8685const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8686function isUUID(value) {
8687 return _UUIDPattern.test(value);
8688}
8689exports.isUUID = isUUID;
8690/**
8691 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
8692 * @param value A uuid string.
8693 */
8694function parse(value) {
8695 if (!isUUID(value)) {
8696 throw new Error('invalid uuid');
8697 }
8698 return new ValueUUID(value);
8699}
8700exports.parse = parse;
8701function generateUuid() {
8702 return v4().asHex();
8703}
8704exports.generateUuid = generateUuid;
8705//# sourceMappingURL=uuid.js.map
8706
8707/***/ }),
8708
8709/***/ 35:
8710/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8711
8712"use strict";
8713/* --------------------------------------------------------------------------------------------
8714 * Copyright (c) Microsoft Corporation. All rights reserved.
8715 * Licensed under the MIT License. See License.txt in the project root for license information.
8716 * ------------------------------------------------------------------------------------------ */
8717
8718Object.defineProperty(exports, "__esModule", ({ value: true }));
8719const vscode_languageserver_protocol_1 = __webpack_require__(3);
8720exports.WorkspaceFoldersFeature = (Base) => {
8721 return class extends Base {
8722 initialize(capabilities) {
8723 let workspaceCapabilities = capabilities.workspace;
8724 if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {
8725 this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();
8726 this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {
8727 this._onDidChangeWorkspaceFolders.fire(params.event);
8728 });
8729 }
8730 }
8731 getWorkspaceFolders() {
8732 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
8733 }
8734 get onDidChangeWorkspaceFolders() {
8735 if (!this._onDidChangeWorkspaceFolders) {
8736 throw new Error('Client doesn\'t support sending workspace folder change events.');
8737 }
8738 if (!this._unregistration) {
8739 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
8740 }
8741 return this._onDidChangeWorkspaceFolders.event;
8742 }
8743 };
8744};
8745//# sourceMappingURL=workspaceFolders.js.map
8746
8747/***/ }),
8748
8749/***/ 52:
8750/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8751
8752/* module decorator */ module = __webpack_require__.nmd(module);
8753//!/usr/bin/env nodejs
8754// usage: nodejs vimlparser.js [--neovim] foo.vim
8755
8756var fs = __webpack_require__(40);
8757var util = __webpack_require__(48);
8758
8759function main() {
8760 var neovim = false;
8761 var fpath = ''
8762 var args = process.argv;
8763 if (args.length == 4) {
8764 if (args[2] == '--neovim') {
8765 neovim = true;
8766 }
8767 fpath = args[3];
8768 } else if (args.length == 3) {
8769 neovim = false;
8770 fpath = args[2]
8771 }
8772 var r = new StringReader(viml_readfile(fpath));
8773 var p = new VimLParser(neovim);
8774 var c = new Compiler();
8775 try {
8776 var lines = c.compile(p.parse(r));
8777 for (var i in lines) {
8778 process.stdout.write(lines[i] + "\n");
8779 }
8780 } catch (e) {
8781 process.stdout.write(e + '\n');
8782 }
8783}
8784
8785var pat_vim2js = {
8786 "[0-9a-zA-Z]" : "[0-9a-zA-Z]",
8787 "[@*!=><&~#]" : "[@*!=><&~#]",
8788 "\\<ARGOPT\\>" : "\\bARGOPT\\b",
8789 "\\<BANG\\>" : "\\bBANG\\b",
8790 "\\<EDITCMD\\>" : "\\bEDITCMD\\b",
8791 "\\<NOTRLCOM\\>" : "\\bNOTRLCOM\\b",
8792 "\\<TRLBAR\\>" : "\\bTRLBAR\\b",
8793 "\\<USECTRLV\\>" : "\\bUSECTRLV\\b",
8794 "\\<USERCMD\\>" : "\\bUSERCMD\\b",
8795 "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>" : "\\b(XFILE|FILES|FILE1)\\b",
8796 "\\S" : "\\S",
8797 "\\a" : "[A-Za-z]",
8798 "\\d" : "\\d",
8799 "\\h" : "[A-Za-z_]",
8800 "\\s" : "\\s",
8801 "\\v^d%[elete][lp]$" : "^d(elete|elet|ele|el|e)[lp]$",
8802 "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])" : "^s(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])",
8803 "\\w" : "[0-9A-Za-z_]",
8804 "\\w\\|[:#]" : "[0-9A-Za-z_]|[:#]",
8805 "\\x" : "[0-9A-Fa-f]",
8806 "^++" : "^\+\+",
8807 "^++bad=\\(keep\\|drop\\|.\\)\\>" : "^\\+\\+bad=(keep|drop|.)\\b",
8808 "^++bad=drop" : "^\\+\\+bad=drop",
8809 "^++bad=keep" : "^\\+\\+bad=keep",
8810 "^++bin\\>" : "^\\+\\+bin\\b",
8811 "^++edit\\>" : "^\\+\\+edit\\b",
8812 "^++enc=\\S" : "^\\+\\+enc=\\S",
8813 "^++encoding=\\S" : "^\\+\\+encoding=\\S",
8814 "^++ff=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+ff=(dos|unix|mac)\\b",
8815 "^++fileformat=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+fileformat=(dos|unix|mac)\\b",
8816 "^++nobin\\>" : "^\\+\\+nobin\\b",
8817 "^[A-Z]" : "^[A-Z]",
8818 "^\\$\\w\\+" : "^\\$[0-9A-Za-z_]+",
8819 "^\\(!\\|global\\|vglobal\\)$" : "^(!|global|vglobal)$",
8820 "^\\(WHILE\\|FOR\\)$" : "^(WHILE|FOR)$",
8821 "^\\(vimgrep\\|vimgrepadd\\|lvimgrep\\|lvimgrepadd\\)$" : "^(vimgrep|vimgrepadd|lvimgrep|lvimgrepadd)$",
8822 "^\\d" : "^\\d",
8823 "^\\h" : "^[A-Za-z_]",
8824 "^\\s" : "^\\s",
8825 "^\\s*\\\\" : "^\\s*\\\\",
8826 "^[ \\t]$" : "^[ \\t]$",
8827 "^[A-Za-z]$" : "^[A-Za-z]$",
8828 "^[0-9A-Za-z]$" : "^[0-9A-Za-z]$",
8829 "^[0-9]$" : "^[0-9]$",
8830 "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$",
8831 "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$",
8832 "^[A-Za-z_]$" : "^[A-Za-z_]$",
8833 "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$",
8834 "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$",
8835 "^[A-Z]$" : "^[A-Z]$",
8836 "^[a-z]$" : "^[a-z]$",
8837 "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$",
8838 "^[0-7]$" : "^[0-7]$",
8839 "^[0-9A-Fa-f][0-9A-Fa-f]$" : "^[0-9A-Fa-f][0-9A-Fa-f]$",
8840 "^\\.[0-9A-Fa-f]$" : "^\\.[0-9A-Fa-f]$",
8841 "^[0-9A-Fa-f][^0-9A-Fa-f]$" : "^[0-9A-Fa-f][^0-9A-Fa-f]$",
8842}
8843
8844function viml_add(lst, item) {
8845 lst.push(item);
8846}
8847
8848function viml_call(func, args) {
8849 return func.apply(null, args);
8850}
8851
8852function viml_char2nr(c) {
8853 return c.charCodeAt(0);
8854}
8855
8856function viml_empty(obj) {
8857 return obj.length == 0;
8858}
8859
8860function viml_equalci(a, b) {
8861 return a.toLowerCase() == b.toLowerCase();
8862}
8863
8864function viml_eqreg(s, reg) {
8865 var mx = new RegExp(pat_vim2js[reg]);
8866 return mx.exec(s) != null;
8867}
8868
8869function viml_eqregh(s, reg) {
8870 var mx = new RegExp(pat_vim2js[reg]);
8871 return mx.exec(s) != null;
8872}
8873
8874function viml_eqregq(s, reg) {
8875 var mx = new RegExp(pat_vim2js[reg], "i");
8876 return mx.exec(s) != null;
8877}
8878
8879function viml_escape(s, chars) {
8880 var r = '';
8881 for (var i = 0; i < s.length; ++i) {
8882 if (chars.indexOf(s.charAt(i)) != -1) {
8883 r = r + "\\" + s.charAt(i);
8884 } else {
8885 r = r + s.charAt(i);
8886 }
8887 }
8888 return r;
8889}
8890
8891function viml_extend(obj, item) {
8892 obj.push.apply(obj, item);
8893}
8894
8895function viml_insert(lst, item) {
8896 var idx = arguments.length >= 3 ? arguments[2] : 0;
8897 lst.splice(0, 0, item);
8898}
8899
8900function viml_join(lst, sep) {
8901 return lst.join(sep);
8902}
8903
8904function viml_keys(obj) {
8905 return Object.keys(obj);
8906}
8907
8908function viml_len(obj) {
8909 if (typeof obj === 'string') {
8910 var len = 0;
8911 for (var i = 0; i < obj.length; i++) {
8912 var c = obj.charCodeAt(i);
8913 len += c < 128 ? 1 : ((c > 127) && (c < 2048)) ? 2 : 3;
8914 }
8915 return len;
8916 }
8917 return obj.length;
8918}
8919
8920function viml_printf() {
8921 var a000 = Array.prototype.slice.call(arguments, 0);
8922 if (a000.length == 1) {
8923 return a000[0];
8924 } else {
8925 return util.format.apply(null, a000);
8926 }
8927}
8928
8929function viml_range(start) {
8930 var end = arguments.length >= 2 ? arguments[1] : null;
8931 if (end == null) {
8932 var x = [];
8933 for (var i = 0; i < start; ++i) {
8934 x.push(i);
8935 }
8936 return x;
8937 } else {
8938 var x = []
8939 for (var i = start; i <= end; ++i) {
8940 x.push(i);
8941 }
8942 return x;
8943 }
8944}
8945
8946function viml_readfile(path) {
8947 // FIXME: newline?
8948 return fs.readFileSync(path, 'utf-8').split(/\r\n|\r|\n/);
8949}
8950
8951function viml_remove(lst, idx) {
8952 lst.splice(idx, 1);
8953}
8954
8955function viml_split(s, sep) {
8956 if (sep == "\\zs") {
8957 return s.split("");
8958 }
8959 throw "NotImplemented";
8960}
8961
8962function viml_str2nr(s) {
8963 var base = arguments.length >= 2 ? arguments[1] : 10;
8964 return parseInt(s, base);
8965}
8966
8967function viml_string(obj) {
8968 return obj.toString();
8969}
8970
8971function viml_has_key(obj, key) {
8972 return obj[key] !== undefined;
8973}
8974
8975function viml_stridx(a, b) {
8976 return a.indexOf(b);
8977}
8978
8979var NIL = [];
8980var TRUE = 1;
8981var FALSE = 0;
8982var NODE_TOPLEVEL = 1;
8983var NODE_COMMENT = 2;
8984var NODE_EXCMD = 3;
8985var NODE_FUNCTION = 4;
8986var NODE_ENDFUNCTION = 5;
8987var NODE_DELFUNCTION = 6;
8988var NODE_RETURN = 7;
8989var NODE_EXCALL = 8;
8990var NODE_LET = 9;
8991var NODE_UNLET = 10;
8992var NODE_LOCKVAR = 11;
8993var NODE_UNLOCKVAR = 12;
8994var NODE_IF = 13;
8995var NODE_ELSEIF = 14;
8996var NODE_ELSE = 15;
8997var NODE_ENDIF = 16;
8998var NODE_WHILE = 17;
8999var NODE_ENDWHILE = 18;
9000var NODE_FOR = 19;
9001var NODE_ENDFOR = 20;
9002var NODE_CONTINUE = 21;
9003var NODE_BREAK = 22;
9004var NODE_TRY = 23;
9005var NODE_CATCH = 24;
9006var NODE_FINALLY = 25;
9007var NODE_ENDTRY = 26;
9008var NODE_THROW = 27;
9009var NODE_ECHO = 28;
9010var NODE_ECHON = 29;
9011var NODE_ECHOHL = 30;
9012var NODE_ECHOMSG = 31;
9013var NODE_ECHOERR = 32;
9014var NODE_EXECUTE = 33;
9015var NODE_TERNARY = 34;
9016var NODE_OR = 35;
9017var NODE_AND = 36;
9018var NODE_EQUAL = 37;
9019var NODE_EQUALCI = 38;
9020var NODE_EQUALCS = 39;
9021var NODE_NEQUAL = 40;
9022var NODE_NEQUALCI = 41;
9023var NODE_NEQUALCS = 42;
9024var NODE_GREATER = 43;
9025var NODE_GREATERCI = 44;
9026var NODE_GREATERCS = 45;
9027var NODE_GEQUAL = 46;
9028var NODE_GEQUALCI = 47;
9029var NODE_GEQUALCS = 48;
9030var NODE_SMALLER = 49;
9031var NODE_SMALLERCI = 50;
9032var NODE_SMALLERCS = 51;
9033var NODE_SEQUAL = 52;
9034var NODE_SEQUALCI = 53;
9035var NODE_SEQUALCS = 54;
9036var NODE_MATCH = 55;
9037var NODE_MATCHCI = 56;
9038var NODE_MATCHCS = 57;
9039var NODE_NOMATCH = 58;
9040var NODE_NOMATCHCI = 59;
9041var NODE_NOMATCHCS = 60;
9042var NODE_IS = 61;
9043var NODE_ISCI = 62;
9044var NODE_ISCS = 63;
9045var NODE_ISNOT = 64;
9046var NODE_ISNOTCI = 65;
9047var NODE_ISNOTCS = 66;
9048var NODE_ADD = 67;
9049var NODE_SUBTRACT = 68;
9050var NODE_CONCAT = 69;
9051var NODE_MULTIPLY = 70;
9052var NODE_DIVIDE = 71;
9053var NODE_REMAINDER = 72;
9054var NODE_NOT = 73;
9055var NODE_MINUS = 74;
9056var NODE_PLUS = 75;
9057var NODE_SUBSCRIPT = 76;
9058var NODE_SLICE = 77;
9059var NODE_CALL = 78;
9060var NODE_DOT = 79;
9061var NODE_NUMBER = 80;
9062var NODE_STRING = 81;
9063var NODE_LIST = 82;
9064var NODE_DICT = 83;
9065var NODE_OPTION = 85;
9066var NODE_IDENTIFIER = 86;
9067var NODE_CURLYNAME = 87;
9068var NODE_ENV = 88;
9069var NODE_REG = 89;
9070var NODE_CURLYNAMEPART = 90;
9071var NODE_CURLYNAMEEXPR = 91;
9072var NODE_LAMBDA = 92;
9073var NODE_BLOB = 93;
9074var NODE_CONST = 94;
9075var NODE_EVAL = 95;
9076var NODE_HEREDOC = 96;
9077var NODE_METHOD = 97;
9078var TOKEN_EOF = 1;
9079var TOKEN_EOL = 2;
9080var TOKEN_SPACE = 3;
9081var TOKEN_OROR = 4;
9082var TOKEN_ANDAND = 5;
9083var TOKEN_EQEQ = 6;
9084var TOKEN_EQEQCI = 7;
9085var TOKEN_EQEQCS = 8;
9086var TOKEN_NEQ = 9;
9087var TOKEN_NEQCI = 10;
9088var TOKEN_NEQCS = 11;
9089var TOKEN_GT = 12;
9090var TOKEN_GTCI = 13;
9091var TOKEN_GTCS = 14;
9092var TOKEN_GTEQ = 15;
9093var TOKEN_GTEQCI = 16;
9094var TOKEN_GTEQCS = 17;
9095var TOKEN_LT = 18;
9096var TOKEN_LTCI = 19;
9097var TOKEN_LTCS = 20;
9098var TOKEN_LTEQ = 21;
9099var TOKEN_LTEQCI = 22;
9100var TOKEN_LTEQCS = 23;
9101var TOKEN_MATCH = 24;
9102var TOKEN_MATCHCI = 25;
9103var TOKEN_MATCHCS = 26;
9104var TOKEN_NOMATCH = 27;
9105var TOKEN_NOMATCHCI = 28;
9106var TOKEN_NOMATCHCS = 29;
9107var TOKEN_IS = 30;
9108var TOKEN_ISCI = 31;
9109var TOKEN_ISCS = 32;
9110var TOKEN_ISNOT = 33;
9111var TOKEN_ISNOTCI = 34;
9112var TOKEN_ISNOTCS = 35;
9113var TOKEN_PLUS = 36;
9114var TOKEN_MINUS = 37;
9115var TOKEN_DOT = 38;
9116var TOKEN_STAR = 39;
9117var TOKEN_SLASH = 40;
9118var TOKEN_PERCENT = 41;
9119var TOKEN_NOT = 42;
9120var TOKEN_QUESTION = 43;
9121var TOKEN_COLON = 44;
9122var TOKEN_POPEN = 45;
9123var TOKEN_PCLOSE = 46;
9124var TOKEN_SQOPEN = 47;
9125var TOKEN_SQCLOSE = 48;
9126var TOKEN_COPEN = 49;
9127var TOKEN_CCLOSE = 50;
9128var TOKEN_COMMA = 51;
9129var TOKEN_NUMBER = 52;
9130var TOKEN_SQUOTE = 53;
9131var TOKEN_DQUOTE = 54;
9132var TOKEN_OPTION = 55;
9133var TOKEN_IDENTIFIER = 56;
9134var TOKEN_ENV = 57;
9135var TOKEN_REG = 58;
9136var TOKEN_EQ = 59;
9137var TOKEN_OR = 60;
9138var TOKEN_SEMICOLON = 61;
9139var TOKEN_BACKTICK = 62;
9140var TOKEN_DOTDOTDOT = 63;
9141var TOKEN_SHARP = 64;
9142var TOKEN_ARROW = 65;
9143var TOKEN_BLOB = 66;
9144var TOKEN_LITCOPEN = 67;
9145var TOKEN_DOTDOT = 68;
9146var TOKEN_HEREDOC = 69;
9147var MAX_FUNC_ARGS = 20;
9148function isalpha(c) {
9149 return viml_eqregh(c, "^[A-Za-z]$");
9150}
9151
9152function isalnum(c) {
9153 return viml_eqregh(c, "^[0-9A-Za-z]$");
9154}
9155
9156function isdigit(c) {
9157 return viml_eqregh(c, "^[0-9]$");
9158}
9159
9160function isodigit(c) {
9161 return viml_eqregh(c, "^[0-7]$");
9162}
9163
9164function isxdigit(c) {
9165 return viml_eqregh(c, "^[0-9A-Fa-f]$");
9166}
9167
9168function iswordc(c) {
9169 return viml_eqregh(c, "^[0-9A-Za-z_]$");
9170}
9171
9172function iswordc1(c) {
9173 return viml_eqregh(c, "^[A-Za-z_]$");
9174}
9175
9176function iswhite(c) {
9177 return viml_eqregh(c, "^[ \\t]$");
9178}
9179
9180function isnamec(c) {
9181 return viml_eqregh(c, "^[0-9A-Za-z_:#]$");
9182}
9183
9184function isnamec1(c) {
9185 return viml_eqregh(c, "^[A-Za-z_]$");
9186}
9187
9188function isargname(s) {
9189 return viml_eqregh(s, "^[A-Za-z_][0-9A-Za-z_]*$");
9190}
9191
9192function isvarname(s) {
9193 return viml_eqregh(s, "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$");
9194}
9195
9196// FIXME:
9197function isidc(c) {
9198 return viml_eqregh(c, "^[0-9A-Za-z_]$");
9199}
9200
9201function isupper(c) {
9202 return viml_eqregh(c, "^[A-Z]$");
9203}
9204
9205function islower(c) {
9206 return viml_eqregh(c, "^[a-z]$");
9207}
9208
9209function ExArg() {
9210 var ea = {};
9211 ea.forceit = FALSE;
9212 ea.addr_count = 0;
9213 ea.line1 = 0;
9214 ea.line2 = 0;
9215 ea.flags = 0;
9216 ea.do_ecmd_cmd = "";
9217 ea.do_ecmd_lnum = 0;
9218 ea.append = 0;
9219 ea.usefilter = FALSE;
9220 ea.amount = 0;
9221 ea.regname = 0;
9222 ea.force_bin = 0;
9223 ea.read_edit = 0;
9224 ea.force_ff = 0;
9225 ea.force_enc = 0;
9226 ea.bad_char = 0;
9227 ea.linepos = {};
9228 ea.cmdpos = [];
9229 ea.argpos = [];
9230 ea.cmd = {};
9231 ea.modifiers = [];
9232 ea.range = [];
9233 ea.argopt = {};
9234 ea.argcmd = {};
9235 return ea;
9236}
9237
9238// struct node {
9239// int type
9240// pos pos
9241// node left
9242// node right
9243// node cond
9244// node rest
9245// node[] list
9246// node[] rlist
9247// node[] default_args
9248// node[] body
9249// string op
9250// string str
9251// int depth
9252// variant value
9253// }
9254// TOPLEVEL .body
9255// COMMENT .str
9256// EXCMD .ea .str
9257// FUNCTION .ea .body .left .rlist .default_args .attr .endfunction
9258// ENDFUNCTION .ea
9259// DELFUNCTION .ea .left
9260// RETURN .ea .left
9261// EXCALL .ea .left
9262// LET .ea .op .left .list .rest .right
9263// CONST .ea .op .left .list .rest .right
9264// UNLET .ea .list
9265// LOCKVAR .ea .depth .list
9266// UNLOCKVAR .ea .depth .list
9267// IF .ea .body .cond .elseif .else .endif
9268// ELSEIF .ea .body .cond
9269// ELSE .ea .body
9270// ENDIF .ea
9271// WHILE .ea .body .cond .endwhile
9272// ENDWHILE .ea
9273// FOR .ea .body .left .list .rest .right .endfor
9274// ENDFOR .ea
9275// CONTINUE .ea
9276// BREAK .ea
9277// TRY .ea .body .catch .finally .endtry
9278// CATCH .ea .body .pattern
9279// FINALLY .ea .body
9280// ENDTRY .ea
9281// THROW .ea .left
9282// EVAL .ea .left
9283// ECHO .ea .list
9284// ECHON .ea .list
9285// ECHOHL .ea .str
9286// ECHOMSG .ea .list
9287// ECHOERR .ea .list
9288// EXECUTE .ea .list
9289// TERNARY .cond .left .right
9290// OR .left .right
9291// AND .left .right
9292// EQUAL .left .right
9293// EQUALCI .left .right
9294// EQUALCS .left .right
9295// NEQUAL .left .right
9296// NEQUALCI .left .right
9297// NEQUALCS .left .right
9298// GREATER .left .right
9299// GREATERCI .left .right
9300// GREATERCS .left .right
9301// GEQUAL .left .right
9302// GEQUALCI .left .right
9303// GEQUALCS .left .right
9304// SMALLER .left .right
9305// SMALLERCI .left .right
9306// SMALLERCS .left .right
9307// SEQUAL .left .right
9308// SEQUALCI .left .right
9309// SEQUALCS .left .right
9310// MATCH .left .right
9311// MATCHCI .left .right
9312// MATCHCS .left .right
9313// NOMATCH .left .right
9314// NOMATCHCI .left .right
9315// NOMATCHCS .left .right
9316// IS .left .right
9317// ISCI .left .right
9318// ISCS .left .right
9319// ISNOT .left .right
9320// ISNOTCI .left .right
9321// ISNOTCS .left .right
9322// ADD .left .right
9323// SUBTRACT .left .right
9324// CONCAT .left .right
9325// MULTIPLY .left .right
9326// DIVIDE .left .right
9327// REMAINDER .left .right
9328// NOT .left
9329// MINUS .left
9330// PLUS .left
9331// SUBSCRIPT .left .right
9332// SLICE .left .rlist
9333// METHOD .left .right
9334// CALL .left .rlist
9335// DOT .left .right
9336// NUMBER .value
9337// STRING .value
9338// LIST .value
9339// DICT .value
9340// BLOB .value
9341// NESTING .left
9342// OPTION .value
9343// IDENTIFIER .value
9344// CURLYNAME .value
9345// ENV .value
9346// REG .value
9347// CURLYNAMEPART .value
9348// CURLYNAMEEXPR .value
9349// LAMBDA .rlist .left
9350// HEREDOC .rlist .op .body
9351function Node(type) {
9352 return {"type":type};
9353}
9354
9355function Err(msg, pos) {
9356 return viml_printf("vimlparser: %s: line %d col %d", msg, pos.lnum, pos.col);
9357}
9358
9359function VimLParser() { this.__init__.apply(this, arguments); }
9360VimLParser.prototype.__init__ = function() {
9361 var a000 = Array.prototype.slice.call(arguments, 0);
9362 if (viml_len(a000) > 0) {
9363 this.neovim = a000[0];
9364 }
9365 else {
9366 this.neovim = 0;
9367 }
9368 this.find_command_cache = {};
9369}
9370
9371VimLParser.prototype.push_context = function(node) {
9372 viml_insert(this.context, node);
9373}
9374
9375VimLParser.prototype.pop_context = function() {
9376 viml_remove(this.context, 0);
9377}
9378
9379VimLParser.prototype.find_context = function(type) {
9380 var i = 0;
9381 var __c3 = this.context;
9382 for (var __i3 = 0; __i3 < __c3.length; ++__i3) {
9383 var node = __c3[__i3];
9384 if (node.type == type) {
9385 return i;
9386 }
9387 i += 1;
9388 }
9389 return -1;
9390}
9391
9392VimLParser.prototype.add_node = function(node) {
9393 viml_add(this.context[0].body, node);
9394}
9395
9396VimLParser.prototype.check_missing_endfunction = function(ends, pos) {
9397 if (this.context[0].type == NODE_FUNCTION) {
9398 throw Err(viml_printf("E126: Missing :endfunction: %s", ends), pos);
9399 }
9400}
9401
9402VimLParser.prototype.check_missing_endif = function(ends, pos) {
9403 if (this.context[0].type == NODE_IF || this.context[0].type == NODE_ELSEIF || this.context[0].type == NODE_ELSE) {
9404 throw Err(viml_printf("E171: Missing :endif: %s", ends), pos);
9405 }
9406}
9407
9408VimLParser.prototype.check_missing_endtry = function(ends, pos) {
9409 if (this.context[0].type == NODE_TRY || this.context[0].type == NODE_CATCH || this.context[0].type == NODE_FINALLY) {
9410 throw Err(viml_printf("E600: Missing :endtry: %s", ends), pos);
9411 }
9412}
9413
9414VimLParser.prototype.check_missing_endwhile = function(ends, pos) {
9415 if (this.context[0].type == NODE_WHILE) {
9416 throw Err(viml_printf("E170: Missing :endwhile: %s", ends), pos);
9417 }
9418}
9419
9420VimLParser.prototype.check_missing_endfor = function(ends, pos) {
9421 if (this.context[0].type == NODE_FOR) {
9422 throw Err(viml_printf("E170: Missing :endfor: %s", ends), pos);
9423 }
9424}
9425
9426VimLParser.prototype.parse = function(reader) {
9427 this.reader = reader;
9428 this.context = [];
9429 var toplevel = Node(NODE_TOPLEVEL);
9430 toplevel.pos = this.reader.getpos();
9431 toplevel.body = [];
9432 this.push_context(toplevel);
9433 while (this.reader.peek() != "<EOF>") {
9434 this.parse_one_cmd();
9435 }
9436 this.check_missing_endfunction("TOPLEVEL", this.reader.getpos());
9437 this.check_missing_endif("TOPLEVEL", this.reader.getpos());
9438 this.check_missing_endtry("TOPLEVEL", this.reader.getpos());
9439 this.check_missing_endwhile("TOPLEVEL", this.reader.getpos());
9440 this.check_missing_endfor("TOPLEVEL", this.reader.getpos());
9441 this.pop_context();
9442 return toplevel;
9443}
9444
9445VimLParser.prototype.parse_one_cmd = function() {
9446 this.ea = ExArg();
9447 if (this.reader.peekn(2) == "#!") {
9448 this.parse_hashbang();
9449 this.reader.get();
9450 return;
9451 }
9452 this.reader.skip_white_and_colon();
9453 if (this.reader.peekn(1) == "") {
9454 this.reader.get();
9455 return;
9456 }
9457 if (this.reader.peekn(1) == "\"") {
9458 this.parse_comment();
9459 this.reader.get();
9460 return;
9461 }
9462 this.ea.linepos = this.reader.getpos();
9463 this.parse_command_modifiers();
9464 this.parse_range();
9465 this.parse_command();
9466 this.parse_trail();
9467}
9468
9469// FIXME:
9470VimLParser.prototype.parse_command_modifiers = function() {
9471 var modifiers = [];
9472 while (TRUE) {
9473 var pos = this.reader.tell();
9474 var d = "";
9475 if (isdigit(this.reader.peekn(1))) {
9476 var d = this.reader.read_digit();
9477 this.reader.skip_white();
9478 }
9479 var k = this.reader.read_alpha();
9480 var c = this.reader.peekn(1);
9481 this.reader.skip_white();
9482 if (viml_stridx("aboveleft", k) == 0 && viml_len(k) >= 3) {
9483 // abo\%[veleft]
9484 viml_add(modifiers, {"name":"aboveleft"});
9485 }
9486 else if (viml_stridx("belowright", k) == 0 && viml_len(k) >= 3) {
9487 // bel\%[owright]
9488 viml_add(modifiers, {"name":"belowright"});
9489 }
9490 else if (viml_stridx("browse", k) == 0 && viml_len(k) >= 3) {
9491 // bro\%[wse]
9492 viml_add(modifiers, {"name":"browse"});
9493 }
9494 else if (viml_stridx("botright", k) == 0 && viml_len(k) >= 2) {
9495 // bo\%[tright]
9496 viml_add(modifiers, {"name":"botright"});
9497 }
9498 else if (viml_stridx("confirm", k) == 0 && viml_len(k) >= 4) {
9499 // conf\%[irm]
9500 viml_add(modifiers, {"name":"confirm"});
9501 }
9502 else if (viml_stridx("keepmarks", k) == 0 && viml_len(k) >= 3) {
9503 // kee\%[pmarks]
9504 viml_add(modifiers, {"name":"keepmarks"});
9505 }
9506 else if (viml_stridx("keepalt", k) == 0 && viml_len(k) >= 5) {
9507 // keepa\%[lt]
9508 viml_add(modifiers, {"name":"keepalt"});
9509 }
9510 else if (viml_stridx("keepjumps", k) == 0 && viml_len(k) >= 5) {
9511 // keepj\%[umps]
9512 viml_add(modifiers, {"name":"keepjumps"});
9513 }
9514 else if (viml_stridx("keeppatterns", k) == 0 && viml_len(k) >= 5) {
9515 // keepp\%[atterns]
9516 viml_add(modifiers, {"name":"keeppatterns"});
9517 }
9518 else if (viml_stridx("hide", k) == 0 && viml_len(k) >= 3) {
9519 // hid\%[e]
9520 if (this.ends_excmds(c)) {
9521 break;
9522 }
9523 viml_add(modifiers, {"name":"hide"});
9524 }
9525 else if (viml_stridx("lockmarks", k) == 0 && viml_len(k) >= 3) {
9526 // loc\%[kmarks]
9527 viml_add(modifiers, {"name":"lockmarks"});
9528 }
9529 else if (viml_stridx("leftabove", k) == 0 && viml_len(k) >= 5) {
9530 // lefta\%[bove]
9531 viml_add(modifiers, {"name":"leftabove"});
9532 }
9533 else if (viml_stridx("noautocmd", k) == 0 && viml_len(k) >= 3) {
9534 // noa\%[utocmd]
9535 viml_add(modifiers, {"name":"noautocmd"});
9536 }
9537 else if (viml_stridx("noswapfile", k) == 0 && viml_len(k) >= 3) {
9538 // :nos\%[wapfile]
9539 viml_add(modifiers, {"name":"noswapfile"});
9540 }
9541 else if (viml_stridx("rightbelow", k) == 0 && viml_len(k) >= 6) {
9542 // rightb\%[elow]
9543 viml_add(modifiers, {"name":"rightbelow"});
9544 }
9545 else if (viml_stridx("sandbox", k) == 0 && viml_len(k) >= 3) {
9546 // san\%[dbox]
9547 viml_add(modifiers, {"name":"sandbox"});
9548 }
9549 else if (viml_stridx("silent", k) == 0 && viml_len(k) >= 3) {
9550 // sil\%[ent]
9551 if (c == "!") {
9552 this.reader.get();
9553 viml_add(modifiers, {"name":"silent", "bang":1});
9554 }
9555 else {
9556 viml_add(modifiers, {"name":"silent", "bang":0});
9557 }
9558 }
9559 else if (k == "tab") {
9560 // tab
9561 if (d != "") {
9562 viml_add(modifiers, {"name":"tab", "count":viml_str2nr(d, 10)});
9563 }
9564 else {
9565 viml_add(modifiers, {"name":"tab"});
9566 }
9567 }
9568 else if (viml_stridx("topleft", k) == 0 && viml_len(k) >= 2) {
9569 // to\%[pleft]
9570 viml_add(modifiers, {"name":"topleft"});
9571 }
9572 else if (viml_stridx("unsilent", k) == 0 && viml_len(k) >= 3) {
9573 // uns\%[ilent]
9574 viml_add(modifiers, {"name":"unsilent"});
9575 }
9576 else if (viml_stridx("vertical", k) == 0 && viml_len(k) >= 4) {
9577 // vert\%[ical]
9578 viml_add(modifiers, {"name":"vertical"});
9579 }
9580 else if (viml_stridx("verbose", k) == 0 && viml_len(k) >= 4) {
9581 // verb\%[ose]
9582 if (d != "") {
9583 viml_add(modifiers, {"name":"verbose", "count":viml_str2nr(d, 10)});
9584 }
9585 else {
9586 viml_add(modifiers, {"name":"verbose", "count":1});
9587 }
9588 }
9589 else {
9590 this.reader.seek_set(pos);
9591 break;
9592 }
9593 }
9594 this.ea.modifiers = modifiers;
9595}
9596
9597// FIXME:
9598VimLParser.prototype.parse_range = function() {
9599 var tokens = [];
9600 while (TRUE) {
9601 while (TRUE) {
9602 this.reader.skip_white();
9603 var c = this.reader.peekn(1);
9604 if (c == "") {
9605 break;
9606 }
9607 if (c == ".") {
9608 viml_add(tokens, this.reader.getn(1));
9609 }
9610 else if (c == "$") {
9611 viml_add(tokens, this.reader.getn(1));
9612 }
9613 else if (c == "'") {
9614 this.reader.getn(1);
9615 var m = this.reader.getn(1);
9616 if (m == "") {
9617 break;
9618 }
9619 viml_add(tokens, "'" + m);
9620 }
9621 else if (c == "/") {
9622 this.reader.getn(1);
9623 var __tmp = this.parse_pattern(c);
9624 var pattern = __tmp[0];
9625 var _ = __tmp[1];
9626 viml_add(tokens, pattern);
9627 }
9628 else if (c == "?") {
9629 this.reader.getn(1);
9630 var __tmp = this.parse_pattern(c);
9631 var pattern = __tmp[0];
9632 var _ = __tmp[1];
9633 viml_add(tokens, pattern);
9634 }
9635 else if (c == "\\") {
9636 var m = this.reader.p(1);
9637 if (m == "&" || m == "?" || m == "/") {
9638 this.reader.seek_cur(2);
9639 viml_add(tokens, "\\" + m);
9640 }
9641 else {
9642 throw Err("E10: \\\\ should be followed by /, ? or &", this.reader.getpos());
9643 }
9644 }
9645 else if (isdigit(c)) {
9646 viml_add(tokens, this.reader.read_digit());
9647 }
9648 while (TRUE) {
9649 this.reader.skip_white();
9650 if (this.reader.peekn(1) == "") {
9651 break;
9652 }
9653 var n = this.reader.read_integer();
9654 if (n == "") {
9655 break;
9656 }
9657 viml_add(tokens, n);
9658 }
9659 if (this.reader.p(0) != "/" && this.reader.p(0) != "?") {
9660 break;
9661 }
9662 }
9663 if (this.reader.peekn(1) == "%") {
9664 viml_add(tokens, this.reader.getn(1));
9665 }
9666 else if (this.reader.peekn(1) == "*") {
9667 // && &cpoptions !~ '\*'
9668 viml_add(tokens, this.reader.getn(1));
9669 }
9670 if (this.reader.peekn(1) == ";") {
9671 viml_add(tokens, this.reader.getn(1));
9672 continue;
9673 }
9674 else if (this.reader.peekn(1) == ",") {
9675 viml_add(tokens, this.reader.getn(1));
9676 continue;
9677 }
9678 break;
9679 }
9680 this.ea.range = tokens;
9681}
9682
9683// FIXME:
9684VimLParser.prototype.parse_pattern = function(delimiter) {
9685 var pattern = "";
9686 var endc = "";
9687 var inbracket = 0;
9688 while (TRUE) {
9689 var c = this.reader.getn(1);
9690 if (c == "") {
9691 break;
9692 }
9693 if (c == delimiter && inbracket == 0) {
9694 var endc = c;
9695 break;
9696 }
9697 pattern += c;
9698 if (c == "\\") {
9699 var c = this.reader.peekn(1);
9700 if (c == "") {
9701 throw Err("E682: Invalid search pattern or delimiter", this.reader.getpos());
9702 }
9703 this.reader.getn(1);
9704 pattern += c;
9705 }
9706 else if (c == "[") {
9707 inbracket += 1;
9708 }
9709 else if (c == "]") {
9710 inbracket -= 1;
9711 }
9712 }
9713 return [pattern, endc];
9714}
9715
9716VimLParser.prototype.parse_command = function() {
9717 this.reader.skip_white_and_colon();
9718 this.ea.cmdpos = this.reader.getpos();
9719 if (this.reader.peekn(1) == "" || this.reader.peekn(1) == "\"") {
9720 if (!viml_empty(this.ea.modifiers) || !viml_empty(this.ea.range)) {
9721 this.parse_cmd_modifier_range();
9722 }
9723 return;
9724 }
9725 this.ea.cmd = this.find_command();
9726 if (this.ea.cmd === NIL) {
9727 this.reader.setpos(this.ea.cmdpos);
9728 throw Err(viml_printf("E492: Not an editor command: %s", this.reader.peekline()), this.ea.cmdpos);
9729 }
9730 if (this.reader.peekn(1) == "!" && this.ea.cmd.name != "substitute" && this.ea.cmd.name != "smagic" && this.ea.cmd.name != "snomagic") {
9731 this.reader.getn(1);
9732 this.ea.forceit = TRUE;
9733 }
9734 else {
9735 this.ea.forceit = FALSE;
9736 }
9737 if (!viml_eqregh(this.ea.cmd.flags, "\\<BANG\\>") && this.ea.forceit && !viml_eqregh(this.ea.cmd.flags, "\\<USERCMD\\>")) {
9738 throw Err("E477: No ! allowed", this.ea.cmdpos);
9739 }
9740 if (this.ea.cmd.name != "!") {
9741 this.reader.skip_white();
9742 }
9743 this.ea.argpos = this.reader.getpos();
9744 if (viml_eqregh(this.ea.cmd.flags, "\\<ARGOPT\\>")) {
9745 this.parse_argopt();
9746 }
9747 if (this.ea.cmd.name == "write" || this.ea.cmd.name == "update") {
9748 if (this.reader.p(0) == ">") {
9749 if (this.reader.p(1) != ">") {
9750 throw Err("E494: Use w or w>>", this.ea.cmdpos);
9751 }
9752 this.reader.seek_cur(2);
9753 this.reader.skip_white();
9754 this.ea.append = 1;
9755 }
9756 else if (this.reader.peekn(1) == "!" && this.ea.cmd.name == "write") {
9757 this.reader.getn(1);
9758 this.ea.usefilter = TRUE;
9759 }
9760 }
9761 if (this.ea.cmd.name == "read") {
9762 if (this.ea.forceit) {
9763 this.ea.usefilter = TRUE;
9764 this.ea.forceit = FALSE;
9765 }
9766 else if (this.reader.peekn(1) == "!") {
9767 this.reader.getn(1);
9768 this.ea.usefilter = TRUE;
9769 }
9770 }
9771 if (this.ea.cmd.name == "<" || this.ea.cmd.name == ">") {
9772 this.ea.amount = 1;
9773 while (this.reader.peekn(1) == this.ea.cmd.name) {
9774 this.reader.getn(1);
9775 this.ea.amount += 1;
9776 }
9777 this.reader.skip_white();
9778 }
9779 if (viml_eqregh(this.ea.cmd.flags, "\\<EDITCMD\\>") && !this.ea.usefilter) {
9780 this.parse_argcmd();
9781 }
9782 this._parse_command(this.ea.cmd.parser);
9783}
9784
9785// TODO: self[a:parser]
9786VimLParser.prototype._parse_command = function(parser) {
9787 if (parser == "parse_cmd_append") {
9788 this.parse_cmd_append();
9789 }
9790 else if (parser == "parse_cmd_break") {
9791 this.parse_cmd_break();
9792 }
9793 else if (parser == "parse_cmd_call") {
9794 this.parse_cmd_call();
9795 }
9796 else if (parser == "parse_cmd_catch") {
9797 this.parse_cmd_catch();
9798 }
9799 else if (parser == "parse_cmd_common") {
9800 this.parse_cmd_common();
9801 }
9802 else if (parser == "parse_cmd_continue") {
9803 this.parse_cmd_continue();
9804 }
9805 else if (parser == "parse_cmd_delfunction") {
9806 this.parse_cmd_delfunction();
9807 }
9808 else if (parser == "parse_cmd_echo") {
9809 this.parse_cmd_echo();
9810 }
9811 else if (parser == "parse_cmd_echoerr") {
9812 this.parse_cmd_echoerr();
9813 }
9814 else if (parser == "parse_cmd_echohl") {
9815 this.parse_cmd_echohl();
9816 }
9817 else if (parser == "parse_cmd_echomsg") {
9818 this.parse_cmd_echomsg();
9819 }
9820 else if (parser == "parse_cmd_echon") {
9821 this.parse_cmd_echon();
9822 }
9823 else if (parser == "parse_cmd_else") {
9824 this.parse_cmd_else();
9825 }
9826 else if (parser == "parse_cmd_elseif") {
9827 this.parse_cmd_elseif();
9828 }
9829 else if (parser == "parse_cmd_endfor") {
9830 this.parse_cmd_endfor();
9831 }
9832 else if (parser == "parse_cmd_endfunction") {
9833 this.parse_cmd_endfunction();
9834 }
9835 else if (parser == "parse_cmd_endif") {
9836 this.parse_cmd_endif();
9837 }
9838 else if (parser == "parse_cmd_endtry") {
9839 this.parse_cmd_endtry();
9840 }
9841 else if (parser == "parse_cmd_endwhile") {
9842 this.parse_cmd_endwhile();
9843 }
9844 else if (parser == "parse_cmd_execute") {
9845 this.parse_cmd_execute();
9846 }
9847 else if (parser == "parse_cmd_finally") {
9848 this.parse_cmd_finally();
9849 }
9850 else if (parser == "parse_cmd_finish") {
9851 this.parse_cmd_finish();
9852 }
9853 else if (parser == "parse_cmd_for") {
9854 this.parse_cmd_for();
9855 }
9856 else if (parser == "parse_cmd_function") {
9857 this.parse_cmd_function();
9858 }
9859 else if (parser == "parse_cmd_if") {
9860 this.parse_cmd_if();
9861 }
9862 else if (parser == "parse_cmd_insert") {
9863 this.parse_cmd_insert();
9864 }
9865 else if (parser == "parse_cmd_let") {
9866 this.parse_cmd_let();
9867 }
9868 else if (parser == "parse_cmd_const") {
9869 this.parse_cmd_const();
9870 }
9871 else if (parser == "parse_cmd_loadkeymap") {
9872 this.parse_cmd_loadkeymap();
9873 }
9874 else if (parser == "parse_cmd_lockvar") {
9875 this.parse_cmd_lockvar();
9876 }
9877 else if (parser == "parse_cmd_lua") {
9878 this.parse_cmd_lua();
9879 }
9880 else if (parser == "parse_cmd_modifier_range") {
9881 this.parse_cmd_modifier_range();
9882 }
9883 else if (parser == "parse_cmd_mzscheme") {
9884 this.parse_cmd_mzscheme();
9885 }
9886 else if (parser == "parse_cmd_perl") {
9887 this.parse_cmd_perl();
9888 }
9889 else if (parser == "parse_cmd_python") {
9890 this.parse_cmd_python();
9891 }
9892 else if (parser == "parse_cmd_python3") {
9893 this.parse_cmd_python3();
9894 }
9895 else if (parser == "parse_cmd_return") {
9896 this.parse_cmd_return();
9897 }
9898 else if (parser == "parse_cmd_ruby") {
9899 this.parse_cmd_ruby();
9900 }
9901 else if (parser == "parse_cmd_tcl") {
9902 this.parse_cmd_tcl();
9903 }
9904 else if (parser == "parse_cmd_throw") {
9905 this.parse_cmd_throw();
9906 }
9907 else if (parser == "parse_cmd_eval") {
9908 this.parse_cmd_eval();
9909 }
9910 else if (parser == "parse_cmd_try") {
9911 this.parse_cmd_try();
9912 }
9913 else if (parser == "parse_cmd_unlet") {
9914 this.parse_cmd_unlet();
9915 }
9916 else if (parser == "parse_cmd_unlockvar") {
9917 this.parse_cmd_unlockvar();
9918 }
9919 else if (parser == "parse_cmd_usercmd") {
9920 this.parse_cmd_usercmd();
9921 }
9922 else if (parser == "parse_cmd_while") {
9923 this.parse_cmd_while();
9924 }
9925 else if (parser == "parse_wincmd") {
9926 this.parse_wincmd();
9927 }
9928 else if (parser == "parse_cmd_syntax") {
9929 this.parse_cmd_syntax();
9930 }
9931 else {
9932 throw viml_printf("unknown parser: %s", viml_string(parser));
9933 }
9934}
9935
9936VimLParser.prototype.find_command = function() {
9937 var c = this.reader.peekn(1);
9938 var name = "";
9939 if (c == "k") {
9940 this.reader.getn(1);
9941 var name = "k";
9942 }
9943 else if (c == "s" && viml_eqregh(this.reader.peekn(5), "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])")) {
9944 this.reader.getn(1);
9945 var name = "substitute";
9946 }
9947 else if (viml_eqregh(c, "[@*!=><&~#]")) {
9948 this.reader.getn(1);
9949 var name = c;
9950 }
9951 else if (this.reader.peekn(2) == "py") {
9952 var name = this.reader.read_alnum();
9953 }
9954 else {
9955 var pos = this.reader.tell();
9956 var name = this.reader.read_alpha();
9957 if (name != "del" && viml_eqregh(name, "\\v^d%[elete][lp]$")) {
9958 this.reader.seek_set(pos);
9959 var name = this.reader.getn(viml_len(name) - 1);
9960 }
9961 }
9962 if (name == "") {
9963 return NIL;
9964 }
9965 if (viml_has_key(this.find_command_cache, name)) {
9966 return this.find_command_cache[name];
9967 }
9968 var cmd = NIL;
9969 var __c4 = this.builtin_commands;
9970 for (var __i4 = 0; __i4 < __c4.length; ++__i4) {
9971 var x = __c4[__i4];
9972 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
9973 delete cmd;
9974 var cmd = x;
9975 break;
9976 }
9977 }
9978 if (this.neovim) {
9979 var __c5 = this.neovim_additional_commands;
9980 for (var __i5 = 0; __i5 < __c5.length; ++__i5) {
9981 var x = __c5[__i5];
9982 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
9983 delete cmd;
9984 var cmd = x;
9985 break;
9986 }
9987 }
9988 var __c6 = this.neovim_removed_commands;
9989 for (var __i6 = 0; __i6 < __c6.length; ++__i6) {
9990 var x = __c6[__i6];
9991 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
9992 delete cmd;
9993 var cmd = NIL;
9994 break;
9995 }
9996 }
9997 }
9998 // FIXME: user defined command
9999 if ((cmd === NIL || cmd.name == "Print") && viml_eqregh(name, "^[A-Z]")) {
10000 name += this.reader.read_alnum();
10001 delete cmd;
10002 var cmd = {"name":name, "flags":"USERCMD", "parser":"parse_cmd_usercmd"};
10003 }
10004 this.find_command_cache[name] = cmd;
10005 return cmd;
10006}
10007
10008// TODO:
10009VimLParser.prototype.parse_hashbang = function() {
10010 this.reader.getn(-1);
10011}
10012
10013// TODO:
10014// ++opt=val
10015VimLParser.prototype.parse_argopt = function() {
10016 while (this.reader.p(0) == "+" && this.reader.p(1) == "+") {
10017 var s = this.reader.peekn(20);
10018 if (viml_eqregh(s, "^++bin\\>")) {
10019 this.reader.getn(5);
10020 this.ea.force_bin = 1;
10021 }
10022 else if (viml_eqregh(s, "^++nobin\\>")) {
10023 this.reader.getn(7);
10024 this.ea.force_bin = 2;
10025 }
10026 else if (viml_eqregh(s, "^++edit\\>")) {
10027 this.reader.getn(6);
10028 this.ea.read_edit = 1;
10029 }
10030 else if (viml_eqregh(s, "^++ff=\\(dos\\|unix\\|mac\\)\\>")) {
10031 this.reader.getn(5);
10032 this.ea.force_ff = this.reader.read_alpha();
10033 }
10034 else if (viml_eqregh(s, "^++fileformat=\\(dos\\|unix\\|mac\\)\\>")) {
10035 this.reader.getn(13);
10036 this.ea.force_ff = this.reader.read_alpha();
10037 }
10038 else if (viml_eqregh(s, "^++enc=\\S")) {
10039 this.reader.getn(6);
10040 this.ea.force_enc = this.reader.read_nonwhite();
10041 }
10042 else if (viml_eqregh(s, "^++encoding=\\S")) {
10043 this.reader.getn(11);
10044 this.ea.force_enc = this.reader.read_nonwhite();
10045 }
10046 else if (viml_eqregh(s, "^++bad=\\(keep\\|drop\\|.\\)\\>")) {
10047 this.reader.getn(6);
10048 if (viml_eqregh(s, "^++bad=keep")) {
10049 this.ea.bad_char = this.reader.getn(4);
10050 }
10051 else if (viml_eqregh(s, "^++bad=drop")) {
10052 this.ea.bad_char = this.reader.getn(4);
10053 }
10054 else {
10055 this.ea.bad_char = this.reader.getn(1);
10056 }
10057 }
10058 else if (viml_eqregh(s, "^++")) {
10059 throw Err("E474: Invalid Argument", this.reader.getpos());
10060 }
10061 else {
10062 break;
10063 }
10064 this.reader.skip_white();
10065 }
10066}
10067
10068// TODO:
10069// +command
10070VimLParser.prototype.parse_argcmd = function() {
10071 if (this.reader.peekn(1) == "+") {
10072 this.reader.getn(1);
10073 if (this.reader.peekn(1) == " ") {
10074 this.ea.do_ecmd_cmd = "$";
10075 }
10076 else {
10077 this.ea.do_ecmd_cmd = this.read_cmdarg();
10078 }
10079 }
10080}
10081
10082VimLParser.prototype.read_cmdarg = function() {
10083 var r = "";
10084 while (TRUE) {
10085 var c = this.reader.peekn(1);
10086 if (c == "" || iswhite(c)) {
10087 break;
10088 }
10089 this.reader.getn(1);
10090 if (c == "\\") {
10091 var c = this.reader.getn(1);
10092 }
10093 r += c;
10094 }
10095 return r;
10096}
10097
10098VimLParser.prototype.parse_comment = function() {
10099 var npos = this.reader.getpos();
10100 var c = this.reader.get();
10101 if (c != "\"") {
10102 throw Err(viml_printf("unexpected character: %s", c), npos);
10103 }
10104 var node = Node(NODE_COMMENT);
10105 node.pos = npos;
10106 node.str = this.reader.getn(-1);
10107 this.add_node(node);
10108}
10109
10110VimLParser.prototype.parse_trail = function() {
10111 this.reader.skip_white();
10112 var c = this.reader.peek();
10113 if (c == "<EOF>") {
10114 // pass
10115 }
10116 else if (c == "<EOL>") {
10117 this.reader.get();
10118 }
10119 else if (c == "|") {
10120 this.reader.get();
10121 }
10122 else if (c == "\"") {
10123 this.parse_comment();
10124 this.reader.get();
10125 }
10126 else {
10127 throw Err(viml_printf("E488: Trailing characters: %s", c), this.reader.getpos());
10128 }
10129}
10130
10131// modifier or range only command line
10132VimLParser.prototype.parse_cmd_modifier_range = function() {
10133 var node = Node(NODE_EXCMD);
10134 node.pos = this.ea.cmdpos;
10135 node.ea = this.ea;
10136 node.str = this.reader.getstr(this.ea.linepos, this.reader.getpos());
10137 this.add_node(node);
10138}
10139
10140// TODO:
10141VimLParser.prototype.parse_cmd_common = function() {
10142 var end = this.reader.getpos();
10143 if (viml_eqregh(this.ea.cmd.flags, "\\<TRLBAR\\>") && !this.ea.usefilter) {
10144 var end = this.separate_nextcmd();
10145 }
10146 else if (this.ea.cmd.name == "!" || this.ea.cmd.name == "global" || this.ea.cmd.name == "vglobal" || this.ea.usefilter) {
10147 while (TRUE) {
10148 var end = this.reader.getpos();
10149 if (this.reader.getn(1) == "") {
10150 break;
10151 }
10152 }
10153 }
10154 else {
10155 while (TRUE) {
10156 var end = this.reader.getpos();
10157 if (this.reader.getn(1) == "") {
10158 break;
10159 }
10160 }
10161 }
10162 var node = Node(NODE_EXCMD);
10163 node.pos = this.ea.cmdpos;
10164 node.ea = this.ea;
10165 node.str = this.reader.getstr(this.ea.linepos, end);
10166 this.add_node(node);
10167}
10168
10169VimLParser.prototype.separate_nextcmd = function() {
10170 if (this.ea.cmd.name == "vimgrep" || this.ea.cmd.name == "vimgrepadd" || this.ea.cmd.name == "lvimgrep" || this.ea.cmd.name == "lvimgrepadd") {
10171 this.skip_vimgrep_pat();
10172 }
10173 var pc = "";
10174 var end = this.reader.getpos();
10175 var nospend = end;
10176 while (TRUE) {
10177 var end = this.reader.getpos();
10178 if (!iswhite(pc)) {
10179 var nospend = end;
10180 }
10181 var c = this.reader.peek();
10182 if (c == "<EOF>" || c == "<EOL>") {
10183 break;
10184 }
10185 else if (c == "\x16") {
10186 // <C-V>
10187 this.reader.get();
10188 var end = this.reader.getpos();
10189 var nospend = this.reader.getpos();
10190 var c = this.reader.peek();
10191 if (c == "<EOF>" || c == "<EOL>") {
10192 break;
10193 }
10194 this.reader.get();
10195 }
10196 else if (this.reader.peekn(2) == "`=" && viml_eqregh(this.ea.cmd.flags, "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>")) {
10197 this.reader.getn(2);
10198 this.parse_expr();
10199 var c = this.reader.peekn(1);
10200 if (c != "`") {
10201 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
10202 }
10203 this.reader.getn(1);
10204 }
10205 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 != "@")) {
10206 var has_cpo_bar = FALSE;
10207 // &cpoptions =~ 'b'
10208 if ((!has_cpo_bar || !viml_eqregh(this.ea.cmd.flags, "\\<USECTRLV\\>")) && pc == "\\") {
10209 this.reader.get();
10210 }
10211 else {
10212 break;
10213 }
10214 }
10215 else {
10216 this.reader.get();
10217 }
10218 var pc = c;
10219 }
10220 if (!viml_eqregh(this.ea.cmd.flags, "\\<NOTRLCOM\\>")) {
10221 var end = nospend;
10222 }
10223 return end;
10224}
10225
10226// FIXME
10227VimLParser.prototype.skip_vimgrep_pat = function() {
10228 if (this.reader.peekn(1) == "") {
10229 // pass
10230 }
10231 else if (isidc(this.reader.peekn(1))) {
10232 // :vimgrep pattern fname
10233 this.reader.read_nonwhite();
10234 }
10235 else {
10236 // :vimgrep /pattern/[g][j] fname
10237 var c = this.reader.getn(1);
10238 var __tmp = this.parse_pattern(c);
10239 var _ = __tmp[0];
10240 var endc = __tmp[1];
10241 if (c != endc) {
10242 return;
10243 }
10244 while (this.reader.p(0) == "g" || this.reader.p(0) == "j") {
10245 this.reader.getn(1);
10246 }
10247 }
10248}
10249
10250VimLParser.prototype.parse_cmd_append = function() {
10251 this.reader.setpos(this.ea.linepos);
10252 var cmdline = this.reader.readline();
10253 var lines = [cmdline];
10254 var m = ".";
10255 while (TRUE) {
10256 if (this.reader.peek() == "<EOF>") {
10257 break;
10258 }
10259 var line = this.reader.getn(-1);
10260 viml_add(lines, line);
10261 if (line == m) {
10262 break;
10263 }
10264 this.reader.get();
10265 }
10266 var node = Node(NODE_EXCMD);
10267 node.pos = this.ea.cmdpos;
10268 node.ea = this.ea;
10269 node.str = viml_join(lines, "\n");
10270 this.add_node(node);
10271}
10272
10273VimLParser.prototype.parse_cmd_insert = function() {
10274 this.parse_cmd_append();
10275}
10276
10277VimLParser.prototype.parse_cmd_loadkeymap = function() {
10278 this.reader.setpos(this.ea.linepos);
10279 var cmdline = this.reader.readline();
10280 var lines = [cmdline];
10281 while (TRUE) {
10282 if (this.reader.peek() == "<EOF>") {
10283 break;
10284 }
10285 var line = this.reader.readline();
10286 viml_add(lines, line);
10287 }
10288 var node = Node(NODE_EXCMD);
10289 node.pos = this.ea.cmdpos;
10290 node.ea = this.ea;
10291 node.str = viml_join(lines, "\n");
10292 this.add_node(node);
10293}
10294
10295VimLParser.prototype.parse_cmd_lua = function() {
10296 var lines = [];
10297 this.reader.skip_white();
10298 if (this.reader.peekn(2) == "<<") {
10299 this.reader.getn(2);
10300 this.reader.skip_white();
10301 var m = this.reader.readline();
10302 if (m == "") {
10303 var m = ".";
10304 }
10305 this.reader.setpos(this.ea.linepos);
10306 var cmdline = this.reader.getn(-1);
10307 var lines = [cmdline];
10308 this.reader.get();
10309 while (TRUE) {
10310 if (this.reader.peek() == "<EOF>") {
10311 break;
10312 }
10313 var line = this.reader.getn(-1);
10314 viml_add(lines, line);
10315 if (line == m) {
10316 break;
10317 }
10318 this.reader.get();
10319 }
10320 }
10321 else {
10322 this.reader.setpos(this.ea.linepos);
10323 var cmdline = this.reader.getn(-1);
10324 var lines = [cmdline];
10325 }
10326 var node = Node(NODE_EXCMD);
10327 node.pos = this.ea.cmdpos;
10328 node.ea = this.ea;
10329 node.str = viml_join(lines, "\n");
10330 this.add_node(node);
10331}
10332
10333VimLParser.prototype.parse_cmd_mzscheme = function() {
10334 this.parse_cmd_lua();
10335}
10336
10337VimLParser.prototype.parse_cmd_perl = function() {
10338 this.parse_cmd_lua();
10339}
10340
10341VimLParser.prototype.parse_cmd_python = function() {
10342 this.parse_cmd_lua();
10343}
10344
10345VimLParser.prototype.parse_cmd_python3 = function() {
10346 this.parse_cmd_lua();
10347}
10348
10349VimLParser.prototype.parse_cmd_ruby = function() {
10350 this.parse_cmd_lua();
10351}
10352
10353VimLParser.prototype.parse_cmd_tcl = function() {
10354 this.parse_cmd_lua();
10355}
10356
10357VimLParser.prototype.parse_cmd_finish = function() {
10358 this.parse_cmd_common();
10359 if (this.context[0].type == NODE_TOPLEVEL) {
10360 this.reader.seek_end(0);
10361 }
10362}
10363
10364// FIXME
10365VimLParser.prototype.parse_cmd_usercmd = function() {
10366 this.parse_cmd_common();
10367}
10368
10369VimLParser.prototype.parse_cmd_function = function() {
10370 var pos = this.reader.tell();
10371 this.reader.skip_white();
10372 // :function
10373 if (this.ends_excmds(this.reader.peek())) {
10374 this.reader.seek_set(pos);
10375 this.parse_cmd_common();
10376 return;
10377 }
10378 // :function /pattern
10379 if (this.reader.peekn(1) == "/") {
10380 this.reader.seek_set(pos);
10381 this.parse_cmd_common();
10382 return;
10383 }
10384 var left = this.parse_lvalue_func();
10385 this.reader.skip_white();
10386 if (left.type == NODE_IDENTIFIER) {
10387 var s = left.value;
10388 var ss = viml_split(s, "\\zs");
10389 if (ss[0] != "<" && ss[0] != "_" && !isupper(ss[0]) && viml_stridx(s, ":") == -1 && viml_stridx(s, "#") == -1) {
10390 throw Err(viml_printf("E128: Function name must start with a capital or contain a colon: %s", s), left.pos);
10391 }
10392 }
10393 // :function {name}
10394 if (this.reader.peekn(1) != "(") {
10395 this.reader.seek_set(pos);
10396 this.parse_cmd_common();
10397 return;
10398 }
10399 // :function[!] {name}([arguments]) [range] [abort] [dict] [closure]
10400 var node = Node(NODE_FUNCTION);
10401 node.pos = this.ea.cmdpos;
10402 node.body = [];
10403 node.ea = this.ea;
10404 node.left = left;
10405 node.rlist = [];
10406 node.default_args = [];
10407 node.attr = {"range":0, "abort":0, "dict":0, "closure":0};
10408 node.endfunction = NIL;
10409 this.reader.getn(1);
10410 var tokenizer = new ExprTokenizer(this.reader);
10411 if (tokenizer.peek().type == TOKEN_PCLOSE) {
10412 tokenizer.get();
10413 }
10414 else {
10415 var named = {};
10416 while (TRUE) {
10417 var varnode = Node(NODE_IDENTIFIER);
10418 var token = tokenizer.get();
10419 if (token.type == TOKEN_IDENTIFIER) {
10420 if (!isargname(token.value) || token.value == "firstline" || token.value == "lastline") {
10421 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
10422 }
10423 else if (viml_has_key(named, token.value)) {
10424 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
10425 }
10426 named[token.value] = 1;
10427 varnode.pos = token.pos;
10428 varnode.value = token.value;
10429 viml_add(node.rlist, varnode);
10430 if (tokenizer.peek().type == TOKEN_EQ) {
10431 tokenizer.get();
10432 viml_add(node.default_args, this.parse_expr());
10433 }
10434 else if (viml_len(node.default_args) > 0) {
10435 throw Err("E989: Non-default argument follows default argument", varnode.pos);
10436 }
10437 // XXX: Vim doesn't skip white space before comma. F(a ,b) => E475
10438 if (iswhite(this.reader.p(0)) && tokenizer.peek().type == TOKEN_COMMA) {
10439 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
10440 }
10441 var token = tokenizer.get();
10442 if (token.type == TOKEN_COMMA) {
10443 // XXX: Vim allows last comma. F(a, b, ) => OK
10444 if (tokenizer.peek().type == TOKEN_PCLOSE) {
10445 tokenizer.get();
10446 break;
10447 }
10448 }
10449 else if (token.type == TOKEN_PCLOSE) {
10450 break;
10451 }
10452 else {
10453 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10454 }
10455 }
10456 else if (token.type == TOKEN_DOTDOTDOT) {
10457 varnode.pos = token.pos;
10458 varnode.value = token.value;
10459 viml_add(node.rlist, varnode);
10460 var token = tokenizer.get();
10461 if (token.type == TOKEN_PCLOSE) {
10462 break;
10463 }
10464 else {
10465 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10466 }
10467 }
10468 else {
10469 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10470 }
10471 }
10472 }
10473 while (TRUE) {
10474 this.reader.skip_white();
10475 var epos = this.reader.getpos();
10476 var key = this.reader.read_alpha();
10477 if (key == "") {
10478 break;
10479 }
10480 else if (key == "range") {
10481 node.attr.range = TRUE;
10482 }
10483 else if (key == "abort") {
10484 node.attr.abort = TRUE;
10485 }
10486 else if (key == "dict") {
10487 node.attr.dict = TRUE;
10488 }
10489 else if (key == "closure") {
10490 node.attr.closure = TRUE;
10491 }
10492 else {
10493 throw Err(viml_printf("unexpected token: %s", key), epos);
10494 }
10495 }
10496 this.add_node(node);
10497 this.push_context(node);
10498}
10499
10500VimLParser.prototype.parse_cmd_endfunction = function() {
10501 this.check_missing_endif("ENDFUNCTION", this.ea.cmdpos);
10502 this.check_missing_endtry("ENDFUNCTION", this.ea.cmdpos);
10503 this.check_missing_endwhile("ENDFUNCTION", this.ea.cmdpos);
10504 this.check_missing_endfor("ENDFUNCTION", this.ea.cmdpos);
10505 if (this.context[0].type != NODE_FUNCTION) {
10506 throw Err("E193: :endfunction not inside a function", this.ea.cmdpos);
10507 }
10508 this.reader.getn(-1);
10509 var node = Node(NODE_ENDFUNCTION);
10510 node.pos = this.ea.cmdpos;
10511 node.ea = this.ea;
10512 this.context[0].endfunction = node;
10513 this.pop_context();
10514}
10515
10516VimLParser.prototype.parse_cmd_delfunction = function() {
10517 var node = Node(NODE_DELFUNCTION);
10518 node.pos = this.ea.cmdpos;
10519 node.ea = this.ea;
10520 node.left = this.parse_lvalue_func();
10521 this.add_node(node);
10522}
10523
10524VimLParser.prototype.parse_cmd_return = function() {
10525 if (this.find_context(NODE_FUNCTION) == -1) {
10526 throw Err("E133: :return not inside a function", this.ea.cmdpos);
10527 }
10528 var node = Node(NODE_RETURN);
10529 node.pos = this.ea.cmdpos;
10530 node.ea = this.ea;
10531 node.left = NIL;
10532 this.reader.skip_white();
10533 var c = this.reader.peek();
10534 if (c == "\"" || !this.ends_excmds(c)) {
10535 node.left = this.parse_expr();
10536 }
10537 this.add_node(node);
10538}
10539
10540VimLParser.prototype.parse_cmd_call = function() {
10541 var node = Node(NODE_EXCALL);
10542 node.pos = this.ea.cmdpos;
10543 node.ea = this.ea;
10544 this.reader.skip_white();
10545 var c = this.reader.peek();
10546 if (this.ends_excmds(c)) {
10547 throw Err("E471: Argument required", this.reader.getpos());
10548 }
10549 node.left = this.parse_expr();
10550 if (node.left.type != NODE_CALL) {
10551 throw Err("Not a function call", node.left.pos);
10552 }
10553 this.add_node(node);
10554}
10555
10556VimLParser.prototype.parse_heredoc = function() {
10557 var node = Node(NODE_HEREDOC);
10558 node.pos = this.ea.cmdpos;
10559 node.op = "";
10560 node.rlist = [];
10561 node.body = [];
10562 while (TRUE) {
10563 this.reader.skip_white();
10564 var key = this.reader.read_word();
10565 if (key == "") {
10566 break;
10567 }
10568 if (!islower(key[0])) {
10569 node.op = key;
10570 break;
10571 }
10572 else {
10573 viml_add(node.rlist, key);
10574 }
10575 }
10576 if (node.op == "") {
10577 throw Err("E172: Missing marker", this.reader.getpos());
10578 }
10579 this.parse_trail();
10580 while (TRUE) {
10581 if (this.reader.peek() == "<EOF>") {
10582 break;
10583 }
10584 var line = this.reader.getn(-1);
10585 if (line == node.op) {
10586 return node;
10587 }
10588 viml_add(node.body, line);
10589 this.reader.get();
10590 }
10591 throw Err(viml_printf("E990: Missing end marker '%s'", node.op), this.reader.getpos());
10592}
10593
10594VimLParser.prototype.parse_cmd_let = function() {
10595 var pos = this.reader.tell();
10596 this.reader.skip_white();
10597 // :let
10598 if (this.ends_excmds(this.reader.peek())) {
10599 this.reader.seek_set(pos);
10600 this.parse_cmd_common();
10601 return;
10602 }
10603 var lhs = this.parse_letlhs();
10604 this.reader.skip_white();
10605 var s1 = this.reader.peekn(1);
10606 var s2 = this.reader.peekn(2);
10607 // TODO check scriptversion?
10608 if (s2 == "..") {
10609 var s2 = this.reader.peekn(3);
10610 }
10611 else if (s2 == "=<") {
10612 var s2 = this.reader.peekn(3);
10613 }
10614 // :let {var-name} ..
10615 if (this.ends_excmds(s1) || s2 != "+=" && s2 != "-=" && s2 != ".=" && s2 != "..=" && s2 != "*=" && s2 != "/=" && s2 != "%=" && s2 != "=<<" && s1 != "=") {
10616 this.reader.seek_set(pos);
10617 this.parse_cmd_common();
10618 return;
10619 }
10620 // :let left op right
10621 var node = Node(NODE_LET);
10622 node.pos = this.ea.cmdpos;
10623 node.ea = this.ea;
10624 node.op = "";
10625 node.left = lhs.left;
10626 node.list = lhs.list;
10627 node.rest = lhs.rest;
10628 node.right = NIL;
10629 if (s2 == "+=" || s2 == "-=" || s2 == ".=" || s2 == "..=" || s2 == "*=" || s2 == "/=" || s2 == "%=") {
10630 this.reader.getn(viml_len(s2));
10631 node.op = s2;
10632 }
10633 else if (s2 == "=<<") {
10634 this.reader.getn(viml_len(s2));
10635 this.reader.skip_white();
10636 node.op = s2;
10637 node.right = this.parse_heredoc();
10638 this.add_node(node);
10639 return;
10640 }
10641 else if (s1 == "=") {
10642 this.reader.getn(1);
10643 node.op = s1;
10644 }
10645 else {
10646 throw "NOT REACHED";
10647 }
10648 node.right = this.parse_expr();
10649 this.add_node(node);
10650}
10651
10652VimLParser.prototype.parse_cmd_const = function() {
10653 var pos = this.reader.tell();
10654 this.reader.skip_white();
10655 // :const
10656 if (this.ends_excmds(this.reader.peek())) {
10657 this.reader.seek_set(pos);
10658 this.parse_cmd_common();
10659 return;
10660 }
10661 var lhs = this.parse_constlhs();
10662 this.reader.skip_white();
10663 var s1 = this.reader.peekn(1);
10664 // :const {var-name}
10665 if (this.ends_excmds(s1) || s1 != "=") {
10666 this.reader.seek_set(pos);
10667 this.parse_cmd_common();
10668 return;
10669 }
10670 // :const left op right
10671 var node = Node(NODE_CONST);
10672 node.pos = this.ea.cmdpos;
10673 node.ea = this.ea;
10674 this.reader.getn(1);
10675 node.op = s1;
10676 node.left = lhs.left;
10677 node.list = lhs.list;
10678 node.rest = lhs.rest;
10679 node.right = this.parse_expr();
10680 this.add_node(node);
10681}
10682
10683VimLParser.prototype.parse_cmd_unlet = function() {
10684 var node = Node(NODE_UNLET);
10685 node.pos = this.ea.cmdpos;
10686 node.ea = this.ea;
10687 node.list = this.parse_lvaluelist();
10688 this.add_node(node);
10689}
10690
10691VimLParser.prototype.parse_cmd_lockvar = function() {
10692 var node = Node(NODE_LOCKVAR);
10693 node.pos = this.ea.cmdpos;
10694 node.ea = this.ea;
10695 node.depth = NIL;
10696 node.list = [];
10697 this.reader.skip_white();
10698 if (isdigit(this.reader.peekn(1))) {
10699 node.depth = viml_str2nr(this.reader.read_digit(), 10);
10700 }
10701 node.list = this.parse_lvaluelist();
10702 this.add_node(node);
10703}
10704
10705VimLParser.prototype.parse_cmd_unlockvar = function() {
10706 var node = Node(NODE_UNLOCKVAR);
10707 node.pos = this.ea.cmdpos;
10708 node.ea = this.ea;
10709 node.depth = NIL;
10710 node.list = [];
10711 this.reader.skip_white();
10712 if (isdigit(this.reader.peekn(1))) {
10713 node.depth = viml_str2nr(this.reader.read_digit(), 10);
10714 }
10715 node.list = this.parse_lvaluelist();
10716 this.add_node(node);
10717}
10718
10719VimLParser.prototype.parse_cmd_if = function() {
10720 var node = Node(NODE_IF);
10721 node.pos = this.ea.cmdpos;
10722 node.body = [];
10723 node.ea = this.ea;
10724 node.cond = this.parse_expr();
10725 node.elseif = [];
10726 node._else = NIL;
10727 node.endif = NIL;
10728 this.add_node(node);
10729 this.push_context(node);
10730}
10731
10732VimLParser.prototype.parse_cmd_elseif = function() {
10733 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
10734 throw Err("E582: :elseif without :if", this.ea.cmdpos);
10735 }
10736 if (this.context[0].type != NODE_IF) {
10737 this.pop_context();
10738 }
10739 var node = Node(NODE_ELSEIF);
10740 node.pos = this.ea.cmdpos;
10741 node.body = [];
10742 node.ea = this.ea;
10743 node.cond = this.parse_expr();
10744 viml_add(this.context[0].elseif, node);
10745 this.push_context(node);
10746}
10747
10748VimLParser.prototype.parse_cmd_else = function() {
10749 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
10750 throw Err("E581: :else without :if", this.ea.cmdpos);
10751 }
10752 if (this.context[0].type != NODE_IF) {
10753 this.pop_context();
10754 }
10755 var node = Node(NODE_ELSE);
10756 node.pos = this.ea.cmdpos;
10757 node.body = [];
10758 node.ea = this.ea;
10759 this.context[0]._else = node;
10760 this.push_context(node);
10761}
10762
10763VimLParser.prototype.parse_cmd_endif = function() {
10764 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF && this.context[0].type != NODE_ELSE) {
10765 throw Err("E580: :endif without :if", this.ea.cmdpos);
10766 }
10767 if (this.context[0].type != NODE_IF) {
10768 this.pop_context();
10769 }
10770 var node = Node(NODE_ENDIF);
10771 node.pos = this.ea.cmdpos;
10772 node.ea = this.ea;
10773 this.context[0].endif = node;
10774 this.pop_context();
10775}
10776
10777VimLParser.prototype.parse_cmd_while = function() {
10778 var node = Node(NODE_WHILE);
10779 node.pos = this.ea.cmdpos;
10780 node.body = [];
10781 node.ea = this.ea;
10782 node.cond = this.parse_expr();
10783 node.endwhile = NIL;
10784 this.add_node(node);
10785 this.push_context(node);
10786}
10787
10788VimLParser.prototype.parse_cmd_endwhile = function() {
10789 if (this.context[0].type != NODE_WHILE) {
10790 throw Err("E588: :endwhile without :while", this.ea.cmdpos);
10791 }
10792 var node = Node(NODE_ENDWHILE);
10793 node.pos = this.ea.cmdpos;
10794 node.ea = this.ea;
10795 this.context[0].endwhile = node;
10796 this.pop_context();
10797}
10798
10799VimLParser.prototype.parse_cmd_for = function() {
10800 var node = Node(NODE_FOR);
10801 node.pos = this.ea.cmdpos;
10802 node.body = [];
10803 node.ea = this.ea;
10804 node.left = NIL;
10805 node.right = NIL;
10806 node.endfor = NIL;
10807 var lhs = this.parse_letlhs();
10808 node.left = lhs.left;
10809 node.list = lhs.list;
10810 node.rest = lhs.rest;
10811 this.reader.skip_white();
10812 var epos = this.reader.getpos();
10813 if (this.reader.read_alpha() != "in") {
10814 throw Err("Missing \"in\" after :for", epos);
10815 }
10816 node.right = this.parse_expr();
10817 this.add_node(node);
10818 this.push_context(node);
10819}
10820
10821VimLParser.prototype.parse_cmd_endfor = function() {
10822 if (this.context[0].type != NODE_FOR) {
10823 throw Err("E588: :endfor without :for", this.ea.cmdpos);
10824 }
10825 var node = Node(NODE_ENDFOR);
10826 node.pos = this.ea.cmdpos;
10827 node.ea = this.ea;
10828 this.context[0].endfor = node;
10829 this.pop_context();
10830}
10831
10832VimLParser.prototype.parse_cmd_continue = function() {
10833 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
10834 throw Err("E586: :continue without :while or :for", this.ea.cmdpos);
10835 }
10836 var node = Node(NODE_CONTINUE);
10837 node.pos = this.ea.cmdpos;
10838 node.ea = this.ea;
10839 this.add_node(node);
10840}
10841
10842VimLParser.prototype.parse_cmd_break = function() {
10843 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
10844 throw Err("E587: :break without :while or :for", this.ea.cmdpos);
10845 }
10846 var node = Node(NODE_BREAK);
10847 node.pos = this.ea.cmdpos;
10848 node.ea = this.ea;
10849 this.add_node(node);
10850}
10851
10852VimLParser.prototype.parse_cmd_try = function() {
10853 var node = Node(NODE_TRY);
10854 node.pos = this.ea.cmdpos;
10855 node.body = [];
10856 node.ea = this.ea;
10857 node.catch = [];
10858 node._finally = NIL;
10859 node.endtry = NIL;
10860 this.add_node(node);
10861 this.push_context(node);
10862}
10863
10864VimLParser.prototype.parse_cmd_catch = function() {
10865 if (this.context[0].type == NODE_FINALLY) {
10866 throw Err("E604: :catch after :finally", this.ea.cmdpos);
10867 }
10868 else if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
10869 throw Err("E603: :catch without :try", this.ea.cmdpos);
10870 }
10871 if (this.context[0].type != NODE_TRY) {
10872 this.pop_context();
10873 }
10874 var node = Node(NODE_CATCH);
10875 node.pos = this.ea.cmdpos;
10876 node.body = [];
10877 node.ea = this.ea;
10878 node.pattern = NIL;
10879 this.reader.skip_white();
10880 if (!this.ends_excmds(this.reader.peek())) {
10881 var __tmp = this.parse_pattern(this.reader.get());
10882 node.pattern = __tmp[0];
10883 var _ = __tmp[1];
10884 }
10885 viml_add(this.context[0].catch, node);
10886 this.push_context(node);
10887}
10888
10889VimLParser.prototype.parse_cmd_finally = function() {
10890 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
10891 throw Err("E606: :finally without :try", this.ea.cmdpos);
10892 }
10893 if (this.context[0].type != NODE_TRY) {
10894 this.pop_context();
10895 }
10896 var node = Node(NODE_FINALLY);
10897 node.pos = this.ea.cmdpos;
10898 node.body = [];
10899 node.ea = this.ea;
10900 this.context[0]._finally = node;
10901 this.push_context(node);
10902}
10903
10904VimLParser.prototype.parse_cmd_endtry = function() {
10905 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH && this.context[0].type != NODE_FINALLY) {
10906 throw Err("E602: :endtry without :try", this.ea.cmdpos);
10907 }
10908 if (this.context[0].type != NODE_TRY) {
10909 this.pop_context();
10910 }
10911 var node = Node(NODE_ENDTRY);
10912 node.pos = this.ea.cmdpos;
10913 node.ea = this.ea;
10914 this.context[0].endtry = node;
10915 this.pop_context();
10916}
10917
10918VimLParser.prototype.parse_cmd_throw = function() {
10919 var node = Node(NODE_THROW);
10920 node.pos = this.ea.cmdpos;
10921 node.ea = this.ea;
10922 node.left = this.parse_expr();
10923 this.add_node(node);
10924}
10925
10926VimLParser.prototype.parse_cmd_eval = function() {
10927 var node = Node(NODE_EVAL);
10928 node.pos = this.ea.cmdpos;
10929 node.ea = this.ea;
10930 node.left = this.parse_expr();
10931 this.add_node(node);
10932}
10933
10934VimLParser.prototype.parse_cmd_echo = function() {
10935 var node = Node(NODE_ECHO);
10936 node.pos = this.ea.cmdpos;
10937 node.ea = this.ea;
10938 node.list = this.parse_exprlist();
10939 this.add_node(node);
10940}
10941
10942VimLParser.prototype.parse_cmd_echon = function() {
10943 var node = Node(NODE_ECHON);
10944 node.pos = this.ea.cmdpos;
10945 node.ea = this.ea;
10946 node.list = this.parse_exprlist();
10947 this.add_node(node);
10948}
10949
10950VimLParser.prototype.parse_cmd_echohl = function() {
10951 var node = Node(NODE_ECHOHL);
10952 node.pos = this.ea.cmdpos;
10953 node.ea = this.ea;
10954 node.str = "";
10955 while (!this.ends_excmds(this.reader.peek())) {
10956 node.str += this.reader.get();
10957 }
10958 this.add_node(node);
10959}
10960
10961VimLParser.prototype.parse_cmd_echomsg = function() {
10962 var node = Node(NODE_ECHOMSG);
10963 node.pos = this.ea.cmdpos;
10964 node.ea = this.ea;
10965 node.list = this.parse_exprlist();
10966 this.add_node(node);
10967}
10968
10969VimLParser.prototype.parse_cmd_echoerr = function() {
10970 var node = Node(NODE_ECHOERR);
10971 node.pos = this.ea.cmdpos;
10972 node.ea = this.ea;
10973 node.list = this.parse_exprlist();
10974 this.add_node(node);
10975}
10976
10977VimLParser.prototype.parse_cmd_execute = function() {
10978 var node = Node(NODE_EXECUTE);
10979 node.pos = this.ea.cmdpos;
10980 node.ea = this.ea;
10981 node.list = this.parse_exprlist();
10982 this.add_node(node);
10983}
10984
10985VimLParser.prototype.parse_expr = function() {
10986 return new ExprParser(this.reader).parse();
10987}
10988
10989VimLParser.prototype.parse_exprlist = function() {
10990 var list = [];
10991 while (TRUE) {
10992 this.reader.skip_white();
10993 var c = this.reader.peek();
10994 if (c != "\"" && this.ends_excmds(c)) {
10995 break;
10996 }
10997 var node = this.parse_expr();
10998 viml_add(list, node);
10999 }
11000 return list;
11001}
11002
11003VimLParser.prototype.parse_lvalue_func = function() {
11004 var p = new LvalueParser(this.reader);
11005 var node = p.parse();
11006 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) {
11007 return node;
11008 }
11009 throw Err("Invalid Expression", node.pos);
11010}
11011
11012// FIXME:
11013VimLParser.prototype.parse_lvalue = function() {
11014 var p = new LvalueParser(this.reader);
11015 var node = p.parse();
11016 if (node.type == NODE_IDENTIFIER) {
11017 if (!isvarname(node.value)) {
11018 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
11019 }
11020 }
11021 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) {
11022 return node;
11023 }
11024 throw Err("Invalid Expression", node.pos);
11025}
11026
11027// TODO: merge with s:VimLParser.parse_lvalue()
11028VimLParser.prototype.parse_constlvalue = function() {
11029 var p = new LvalueParser(this.reader);
11030 var node = p.parse();
11031 if (node.type == NODE_IDENTIFIER) {
11032 if (!isvarname(node.value)) {
11033 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
11034 }
11035 }
11036 if (node.type == NODE_IDENTIFIER || node.type == NODE_CURLYNAME) {
11037 return node;
11038 }
11039 else if (node.type == NODE_SUBSCRIPT || node.type == NODE_SLICE || node.type == NODE_DOT) {
11040 throw Err("E996: Cannot lock a list or dict", node.pos);
11041 }
11042 else if (node.type == NODE_OPTION) {
11043 throw Err("E996: Cannot lock an option", node.pos);
11044 }
11045 else if (node.type == NODE_ENV) {
11046 throw Err("E996: Cannot lock an environment variable", node.pos);
11047 }
11048 else if (node.type == NODE_REG) {
11049 throw Err("E996: Cannot lock a register", node.pos);
11050 }
11051 throw Err("Invalid Expression", node.pos);
11052}
11053
11054VimLParser.prototype.parse_lvaluelist = function() {
11055 var list = [];
11056 var node = this.parse_expr();
11057 viml_add(list, node);
11058 while (TRUE) {
11059 this.reader.skip_white();
11060 if (this.ends_excmds(this.reader.peek())) {
11061 break;
11062 }
11063 var node = this.parse_lvalue();
11064 viml_add(list, node);
11065 }
11066 return list;
11067}
11068
11069// FIXME:
11070VimLParser.prototype.parse_letlhs = function() {
11071 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
11072 var tokenizer = new ExprTokenizer(this.reader);
11073 if (tokenizer.peek().type == TOKEN_SQOPEN) {
11074 tokenizer.get();
11075 lhs.list = [];
11076 while (TRUE) {
11077 var node = this.parse_lvalue();
11078 viml_add(lhs.list, node);
11079 var token = tokenizer.get();
11080 if (token.type == TOKEN_SQCLOSE) {
11081 break;
11082 }
11083 else if (token.type == TOKEN_COMMA) {
11084 continue;
11085 }
11086 else if (token.type == TOKEN_SEMICOLON) {
11087 var node = this.parse_lvalue();
11088 lhs.rest = node;
11089 var token = tokenizer.get();
11090 if (token.type == TOKEN_SQCLOSE) {
11091 break;
11092 }
11093 else {
11094 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
11095 }
11096 }
11097 else {
11098 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
11099 }
11100 }
11101 }
11102 else {
11103 lhs.left = this.parse_lvalue();
11104 }
11105 return lhs;
11106}
11107
11108// TODO: merge with s:VimLParser.parse_letlhs() ?
11109VimLParser.prototype.parse_constlhs = function() {
11110 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
11111 var tokenizer = new ExprTokenizer(this.reader);
11112 if (tokenizer.peek().type == TOKEN_SQOPEN) {
11113 tokenizer.get();
11114 lhs.list = [];
11115 while (TRUE) {
11116 var node = this.parse_lvalue();
11117 viml_add(lhs.list, node);
11118 var token = tokenizer.get();
11119 if (token.type == TOKEN_SQCLOSE) {
11120 break;
11121 }
11122 else if (token.type == TOKEN_COMMA) {
11123 continue;
11124 }
11125 else if (token.type == TOKEN_SEMICOLON) {
11126 var node = this.parse_lvalue();
11127 lhs.rest = node;
11128 var token = tokenizer.get();
11129 if (token.type == TOKEN_SQCLOSE) {
11130 break;
11131 }
11132 else {
11133 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
11134 }
11135 }
11136 else {
11137 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
11138 }
11139 }
11140 }
11141 else {
11142 lhs.left = this.parse_constlvalue();
11143 }
11144 return lhs;
11145}
11146
11147VimLParser.prototype.ends_excmds = function(c) {
11148 return c == "" || c == "|" || c == "\"" || c == "<EOF>" || c == "<EOL>";
11149}
11150
11151// FIXME: validate argument
11152VimLParser.prototype.parse_wincmd = function() {
11153 var c = this.reader.getn(1);
11154 if (c == "") {
11155 throw Err("E471: Argument required", this.reader.getpos());
11156 }
11157 else if (c == "g" || c == "\x07") {
11158 // <C-G>
11159 var c2 = this.reader.getn(1);
11160 if (c2 == "" || iswhite(c2)) {
11161 throw Err("E474: Invalid Argument", this.reader.getpos());
11162 }
11163 }
11164 var end = this.reader.getpos();
11165 this.reader.skip_white();
11166 if (!this.ends_excmds(this.reader.peek())) {
11167 throw Err("E474: Invalid Argument", this.reader.getpos());
11168 }
11169 var node = Node(NODE_EXCMD);
11170 node.pos = this.ea.cmdpos;
11171 node.ea = this.ea;
11172 node.str = this.reader.getstr(this.ea.linepos, end);
11173 this.add_node(node);
11174}
11175
11176// FIXME: validate argument
11177VimLParser.prototype.parse_cmd_syntax = function() {
11178 var end = this.reader.getpos();
11179 while (TRUE) {
11180 var end = this.reader.getpos();
11181 var c = this.reader.peek();
11182 if (c == "/" || c == "'" || c == "\"") {
11183 this.reader.getn(1);
11184 this.parse_pattern(c);
11185 }
11186 else if (c == "=") {
11187 this.reader.getn(1);
11188 this.parse_pattern(" ");
11189 }
11190 else if (this.ends_excmds(c)) {
11191 break;
11192 }
11193 this.reader.getn(1);
11194 }
11195 var node = Node(NODE_EXCMD);
11196 node.pos = this.ea.cmdpos;
11197 node.ea = this.ea;
11198 node.str = this.reader.getstr(this.ea.linepos, end);
11199 this.add_node(node);
11200}
11201
11202VimLParser.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"}];
11203VimLParser.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"}];
11204// To find new builtin_commands, run the below script.
11205// $ scripts/update_builtin_commands.sh /path/to/vim/src/ex_cmds.h
11206VimLParser.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"}];
11207// To find new builtin_functions, run the below script.
11208// $ scripts/update_builtin_functions.sh /path/to/vim/src/evalfunc.c
11209VimLParser.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"}];
11210function ExprTokenizer() { this.__init__.apply(this, arguments); }
11211ExprTokenizer.prototype.__init__ = function(reader) {
11212 this.reader = reader;
11213 this.cache = {};
11214}
11215
11216ExprTokenizer.prototype.token = function(type, value, pos) {
11217 return {"type":type, "value":value, "pos":pos};
11218}
11219
11220ExprTokenizer.prototype.peek = function() {
11221 var pos = this.reader.tell();
11222 var r = this.get();
11223 this.reader.seek_set(pos);
11224 return r;
11225}
11226
11227ExprTokenizer.prototype.get = function() {
11228 // FIXME: remove dirty hack
11229 if (viml_has_key(this.cache, this.reader.tell())) {
11230 var x = this.cache[this.reader.tell()];
11231 this.reader.seek_set(x[0]);
11232 return x[1];
11233 }
11234 var pos = this.reader.tell();
11235 this.reader.skip_white();
11236 var r = this.get2();
11237 this.cache[pos] = [this.reader.tell(), r];
11238 return r;
11239}
11240
11241ExprTokenizer.prototype.get2 = function() {
11242 var r = this.reader;
11243 var pos = r.getpos();
11244 var c = r.peek();
11245 if (c == "<EOF>") {
11246 return this.token(TOKEN_EOF, c, pos);
11247 }
11248 else if (c == "<EOL>") {
11249 r.seek_cur(1);
11250 return this.token(TOKEN_EOL, c, pos);
11251 }
11252 else if (iswhite(c)) {
11253 var s = r.read_white();
11254 return this.token(TOKEN_SPACE, s, pos);
11255 }
11256 else if (c == "0" && (r.p(1) == "X" || r.p(1) == "x") && isxdigit(r.p(2))) {
11257 var s = r.getn(3);
11258 s += r.read_xdigit();
11259 return this.token(TOKEN_NUMBER, s, pos);
11260 }
11261 else if (c == "0" && (r.p(1) == "B" || r.p(1) == "b") && (r.p(2) == "0" || r.p(2) == "1")) {
11262 var s = r.getn(3);
11263 s += r.read_bdigit();
11264 return this.token(TOKEN_NUMBER, s, pos);
11265 }
11266 else if (c == "0" && (r.p(1) == "Z" || r.p(1) == "z") && r.p(2) != ".") {
11267 var s = r.getn(2);
11268 s += r.read_blob();
11269 return this.token(TOKEN_BLOB, s, pos);
11270 }
11271 else if (isdigit(c)) {
11272 var s = r.read_digit();
11273 if (r.p(0) == "." && isdigit(r.p(1))) {
11274 s += r.getn(1);
11275 s += r.read_digit();
11276 if ((r.p(0) == "E" || r.p(0) == "e") && (isdigit(r.p(1)) || (r.p(1) == "-" || r.p(1) == "+") && isdigit(r.p(2)))) {
11277 s += r.getn(2);
11278 s += r.read_digit();
11279 }
11280 }
11281 return this.token(TOKEN_NUMBER, s, pos);
11282 }
11283 else if (c == "i" && r.p(1) == "s" && !isidc(r.p(2))) {
11284 if (r.p(2) == "?") {
11285 r.seek_cur(3);
11286 return this.token(TOKEN_ISCI, "is?", pos);
11287 }
11288 else if (r.p(2) == "#") {
11289 r.seek_cur(3);
11290 return this.token(TOKEN_ISCS, "is#", pos);
11291 }
11292 else {
11293 r.seek_cur(2);
11294 return this.token(TOKEN_IS, "is", pos);
11295 }
11296 }
11297 else if (c == "i" && r.p(1) == "s" && r.p(2) == "n" && r.p(3) == "o" && r.p(4) == "t" && !isidc(r.p(5))) {
11298 if (r.p(5) == "?") {
11299 r.seek_cur(6);
11300 return this.token(TOKEN_ISNOTCI, "isnot?", pos);
11301 }
11302 else if (r.p(5) == "#") {
11303 r.seek_cur(6);
11304 return this.token(TOKEN_ISNOTCS, "isnot#", pos);
11305 }
11306 else {
11307 r.seek_cur(5);
11308 return this.token(TOKEN_ISNOT, "isnot", pos);
11309 }
11310 }
11311 else if (isnamec1(c)) {
11312 var s = r.read_name();
11313 return this.token(TOKEN_IDENTIFIER, s, pos);
11314 }
11315 else if (c == "|" && r.p(1) == "|") {
11316 r.seek_cur(2);
11317 return this.token(TOKEN_OROR, "||", pos);
11318 }
11319 else if (c == "&" && r.p(1) == "&") {
11320 r.seek_cur(2);
11321 return this.token(TOKEN_ANDAND, "&&", pos);
11322 }
11323 else if (c == "=" && r.p(1) == "=") {
11324 if (r.p(2) == "?") {
11325 r.seek_cur(3);
11326 return this.token(TOKEN_EQEQCI, "==?", pos);
11327 }
11328 else if (r.p(2) == "#") {
11329 r.seek_cur(3);
11330 return this.token(TOKEN_EQEQCS, "==#", pos);
11331 }
11332 else {
11333 r.seek_cur(2);
11334 return this.token(TOKEN_EQEQ, "==", pos);
11335 }
11336 }
11337 else if (c == "!" && r.p(1) == "=") {
11338 if (r.p(2) == "?") {
11339 r.seek_cur(3);
11340 return this.token(TOKEN_NEQCI, "!=?", pos);
11341 }
11342 else if (r.p(2) == "#") {
11343 r.seek_cur(3);
11344 return this.token(TOKEN_NEQCS, "!=#", pos);
11345 }
11346 else {
11347 r.seek_cur(2);
11348 return this.token(TOKEN_NEQ, "!=", pos);
11349 }
11350 }
11351 else if (c == ">" && r.p(1) == "=") {
11352 if (r.p(2) == "?") {
11353 r.seek_cur(3);
11354 return this.token(TOKEN_GTEQCI, ">=?", pos);
11355 }
11356 else if (r.p(2) == "#") {
11357 r.seek_cur(3);
11358 return this.token(TOKEN_GTEQCS, ">=#", pos);
11359 }
11360 else {
11361 r.seek_cur(2);
11362 return this.token(TOKEN_GTEQ, ">=", pos);
11363 }
11364 }
11365 else if (c == "<" && r.p(1) == "=") {
11366 if (r.p(2) == "?") {
11367 r.seek_cur(3);
11368 return this.token(TOKEN_LTEQCI, "<=?", pos);
11369 }
11370 else if (r.p(2) == "#") {
11371 r.seek_cur(3);
11372 return this.token(TOKEN_LTEQCS, "<=#", pos);
11373 }
11374 else {
11375 r.seek_cur(2);
11376 return this.token(TOKEN_LTEQ, "<=", pos);
11377 }
11378 }
11379 else if (c == "=" && r.p(1) == "~") {
11380 if (r.p(2) == "?") {
11381 r.seek_cur(3);
11382 return this.token(TOKEN_MATCHCI, "=~?", pos);
11383 }
11384 else if (r.p(2) == "#") {
11385 r.seek_cur(3);
11386 return this.token(TOKEN_MATCHCS, "=~#", pos);
11387 }
11388 else {
11389 r.seek_cur(2);
11390 return this.token(TOKEN_MATCH, "=~", pos);
11391 }
11392 }
11393 else if (c == "!" && r.p(1) == "~") {
11394 if (r.p(2) == "?") {
11395 r.seek_cur(3);
11396 return this.token(TOKEN_NOMATCHCI, "!~?", pos);
11397 }
11398 else if (r.p(2) == "#") {
11399 r.seek_cur(3);
11400 return this.token(TOKEN_NOMATCHCS, "!~#", pos);
11401 }
11402 else {
11403 r.seek_cur(2);
11404 return this.token(TOKEN_NOMATCH, "!~", pos);
11405 }
11406 }
11407 else if (c == ">") {
11408 if (r.p(1) == "?") {
11409 r.seek_cur(2);
11410 return this.token(TOKEN_GTCI, ">?", pos);
11411 }
11412 else if (r.p(1) == "#") {
11413 r.seek_cur(2);
11414 return this.token(TOKEN_GTCS, ">#", pos);
11415 }
11416 else {
11417 r.seek_cur(1);
11418 return this.token(TOKEN_GT, ">", pos);
11419 }
11420 }
11421 else if (c == "<") {
11422 if (r.p(1) == "?") {
11423 r.seek_cur(2);
11424 return this.token(TOKEN_LTCI, "<?", pos);
11425 }
11426 else if (r.p(1) == "#") {
11427 r.seek_cur(2);
11428 return this.token(TOKEN_LTCS, "<#", pos);
11429 }
11430 else {
11431 r.seek_cur(1);
11432 return this.token(TOKEN_LT, "<", pos);
11433 }
11434 }
11435 else if (c == "+") {
11436 r.seek_cur(1);
11437 return this.token(TOKEN_PLUS, "+", pos);
11438 }
11439 else if (c == "-") {
11440 if (r.p(1) == ">") {
11441 r.seek_cur(2);
11442 return this.token(TOKEN_ARROW, "->", pos);
11443 }
11444 else {
11445 r.seek_cur(1);
11446 return this.token(TOKEN_MINUS, "-", pos);
11447 }
11448 }
11449 else if (c == ".") {
11450 if (r.p(1) == "." && r.p(2) == ".") {
11451 r.seek_cur(3);
11452 return this.token(TOKEN_DOTDOTDOT, "...", pos);
11453 }
11454 else if (r.p(1) == ".") {
11455 r.seek_cur(2);
11456 return this.token(TOKEN_DOTDOT, "..", pos);
11457 // TODO check scriptversion?
11458 }
11459 else {
11460 r.seek_cur(1);
11461 return this.token(TOKEN_DOT, ".", pos);
11462 // TODO check scriptversion?
11463 }
11464 }
11465 else if (c == "*") {
11466 r.seek_cur(1);
11467 return this.token(TOKEN_STAR, "*", pos);
11468 }
11469 else if (c == "/") {
11470 r.seek_cur(1);
11471 return this.token(TOKEN_SLASH, "/", pos);
11472 }
11473 else if (c == "%") {
11474 r.seek_cur(1);
11475 return this.token(TOKEN_PERCENT, "%", pos);
11476 }
11477 else if (c == "!") {
11478 r.seek_cur(1);
11479 return this.token(TOKEN_NOT, "!", pos);
11480 }
11481 else if (c == "?") {
11482 r.seek_cur(1);
11483 return this.token(TOKEN_QUESTION, "?", pos);
11484 }
11485 else if (c == ":") {
11486 r.seek_cur(1);
11487 return this.token(TOKEN_COLON, ":", pos);
11488 }
11489 else if (c == "#") {
11490 if (r.p(1) == "{") {
11491 r.seek_cur(2);
11492 return this.token(TOKEN_LITCOPEN, "#{", pos);
11493 }
11494 else {
11495 r.seek_cur(1);
11496 return this.token(TOKEN_SHARP, "#", pos);
11497 }
11498 }
11499 else if (c == "(") {
11500 r.seek_cur(1);
11501 return this.token(TOKEN_POPEN, "(", pos);
11502 }
11503 else if (c == ")") {
11504 r.seek_cur(1);
11505 return this.token(TOKEN_PCLOSE, ")", pos);
11506 }
11507 else if (c == "[") {
11508 r.seek_cur(1);
11509 return this.token(TOKEN_SQOPEN, "[", pos);
11510 }
11511 else if (c == "]") {
11512 r.seek_cur(1);
11513 return this.token(TOKEN_SQCLOSE, "]", pos);
11514 }
11515 else if (c == "{") {
11516 r.seek_cur(1);
11517 return this.token(TOKEN_COPEN, "{", pos);
11518 }
11519 else if (c == "}") {
11520 r.seek_cur(1);
11521 return this.token(TOKEN_CCLOSE, "}", pos);
11522 }
11523 else if (c == ",") {
11524 r.seek_cur(1);
11525 return this.token(TOKEN_COMMA, ",", pos);
11526 }
11527 else if (c == "'") {
11528 r.seek_cur(1);
11529 return this.token(TOKEN_SQUOTE, "'", pos);
11530 }
11531 else if (c == "\"") {
11532 r.seek_cur(1);
11533 return this.token(TOKEN_DQUOTE, "\"", pos);
11534 }
11535 else if (c == "$") {
11536 var s = r.getn(1);
11537 s += r.read_word();
11538 return this.token(TOKEN_ENV, s, pos);
11539 }
11540 else if (c == "@") {
11541 // @<EOL> is treated as @"
11542 return this.token(TOKEN_REG, r.getn(2), pos);
11543 }
11544 else if (c == "&") {
11545 var s = "";
11546 if ((r.p(1) == "g" || r.p(1) == "l") && r.p(2) == ":") {
11547 var s = r.getn(3) + r.read_word();
11548 }
11549 else {
11550 var s = r.getn(1) + r.read_word();
11551 }
11552 return this.token(TOKEN_OPTION, s, pos);
11553 }
11554 else if (c == "=") {
11555 r.seek_cur(1);
11556 return this.token(TOKEN_EQ, "=", pos);
11557 }
11558 else if (c == "|") {
11559 r.seek_cur(1);
11560 return this.token(TOKEN_OR, "|", pos);
11561 }
11562 else if (c == ";") {
11563 r.seek_cur(1);
11564 return this.token(TOKEN_SEMICOLON, ";", pos);
11565 }
11566 else if (c == "`") {
11567 r.seek_cur(1);
11568 return this.token(TOKEN_BACKTICK, "`", pos);
11569 }
11570 else {
11571 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
11572 }
11573}
11574
11575ExprTokenizer.prototype.get_sstring = function() {
11576 this.reader.skip_white();
11577 var c = this.reader.p(0);
11578 if (c != "'") {
11579 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
11580 }
11581 this.reader.seek_cur(1);
11582 var s = "";
11583 while (TRUE) {
11584 var c = this.reader.p(0);
11585 if (c == "<EOF>" || c == "<EOL>") {
11586 throw Err("unexpected EOL", this.reader.getpos());
11587 }
11588 else if (c == "'") {
11589 this.reader.seek_cur(1);
11590 if (this.reader.p(0) == "'") {
11591 this.reader.seek_cur(1);
11592 s += "''";
11593 }
11594 else {
11595 break;
11596 }
11597 }
11598 else {
11599 this.reader.seek_cur(1);
11600 s += c;
11601 }
11602 }
11603 return s;
11604}
11605
11606ExprTokenizer.prototype.get_dstring = function() {
11607 this.reader.skip_white();
11608 var c = this.reader.p(0);
11609 if (c != "\"") {
11610 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
11611 }
11612 this.reader.seek_cur(1);
11613 var s = "";
11614 while (TRUE) {
11615 var c = this.reader.p(0);
11616 if (c == "<EOF>" || c == "<EOL>") {
11617 throw Err("unexpectd EOL", this.reader.getpos());
11618 }
11619 else if (c == "\"") {
11620 this.reader.seek_cur(1);
11621 break;
11622 }
11623 else if (c == "\\") {
11624 this.reader.seek_cur(1);
11625 s += c;
11626 var c = this.reader.p(0);
11627 if (c == "<EOF>" || c == "<EOL>") {
11628 throw Err("ExprTokenizer: unexpected EOL", this.reader.getpos());
11629 }
11630 this.reader.seek_cur(1);
11631 s += c;
11632 }
11633 else {
11634 this.reader.seek_cur(1);
11635 s += c;
11636 }
11637 }
11638 return s;
11639}
11640
11641ExprTokenizer.prototype.parse_dict_literal_key = function() {
11642 this.reader.skip_white();
11643 var c = this.reader.peek();
11644 if (!isalnum(c) && c != "_" && c != "-") {
11645 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
11646 }
11647 var node = Node(NODE_STRING);
11648 var s = c;
11649 this.reader.seek_cur(1);
11650 node.pos = this.reader.getpos();
11651 while (TRUE) {
11652 var c = this.reader.p(0);
11653 if (c == "<EOF>" || c == "<EOL>") {
11654 throw Err("unexpectd EOL", this.reader.getpos());
11655 }
11656 if (!isalnum(c) && c != "_" && c != "-") {
11657 break;
11658 }
11659 this.reader.seek_cur(1);
11660 s += c;
11661 }
11662 node.value = "'" + s + "'";
11663 return node;
11664}
11665
11666function ExprParser() { this.__init__.apply(this, arguments); }
11667ExprParser.prototype.__init__ = function(reader) {
11668 this.reader = reader;
11669 this.tokenizer = new ExprTokenizer(reader);
11670}
11671
11672ExprParser.prototype.parse = function() {
11673 return this.parse_expr1();
11674}
11675
11676// expr1: expr2 ? expr1 : expr1
11677ExprParser.prototype.parse_expr1 = function() {
11678 var left = this.parse_expr2();
11679 var pos = this.reader.tell();
11680 var token = this.tokenizer.get();
11681 if (token.type == TOKEN_QUESTION) {
11682 var node = Node(NODE_TERNARY);
11683 node.pos = token.pos;
11684 node.cond = left;
11685 node.left = this.parse_expr1();
11686 var token = this.tokenizer.get();
11687 if (token.type != TOKEN_COLON) {
11688 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11689 }
11690 node.right = this.parse_expr1();
11691 var left = node;
11692 }
11693 else {
11694 this.reader.seek_set(pos);
11695 }
11696 return left;
11697}
11698
11699// expr2: expr3 || expr3 ..
11700ExprParser.prototype.parse_expr2 = function() {
11701 var left = this.parse_expr3();
11702 while (TRUE) {
11703 var pos = this.reader.tell();
11704 var token = this.tokenizer.get();
11705 if (token.type == TOKEN_OROR) {
11706 var node = Node(NODE_OR);
11707 node.pos = token.pos;
11708 node.left = left;
11709 node.right = this.parse_expr3();
11710 var left = node;
11711 }
11712 else {
11713 this.reader.seek_set(pos);
11714 break;
11715 }
11716 }
11717 return left;
11718}
11719
11720// expr3: expr4 && expr4
11721ExprParser.prototype.parse_expr3 = function() {
11722 var left = this.parse_expr4();
11723 while (TRUE) {
11724 var pos = this.reader.tell();
11725 var token = this.tokenizer.get();
11726 if (token.type == TOKEN_ANDAND) {
11727 var node = Node(NODE_AND);
11728 node.pos = token.pos;
11729 node.left = left;
11730 node.right = this.parse_expr4();
11731 var left = node;
11732 }
11733 else {
11734 this.reader.seek_set(pos);
11735 break;
11736 }
11737 }
11738 return left;
11739}
11740
11741// expr4: expr5 == expr5
11742// expr5 != expr5
11743// expr5 > expr5
11744// expr5 >= expr5
11745// expr5 < expr5
11746// expr5 <= expr5
11747// expr5 =~ expr5
11748// expr5 !~ expr5
11749//
11750// expr5 ==? expr5
11751// expr5 ==# expr5
11752// etc.
11753//
11754// expr5 is expr5
11755// expr5 isnot expr5
11756ExprParser.prototype.parse_expr4 = function() {
11757 var left = this.parse_expr5();
11758 var pos = this.reader.tell();
11759 var token = this.tokenizer.get();
11760 if (token.type == TOKEN_EQEQ) {
11761 var node = Node(NODE_EQUAL);
11762 node.pos = token.pos;
11763 node.left = left;
11764 node.right = this.parse_expr5();
11765 var left = node;
11766 }
11767 else if (token.type == TOKEN_EQEQCI) {
11768 var node = Node(NODE_EQUALCI);
11769 node.pos = token.pos;
11770 node.left = left;
11771 node.right = this.parse_expr5();
11772 var left = node;
11773 }
11774 else if (token.type == TOKEN_EQEQCS) {
11775 var node = Node(NODE_EQUALCS);
11776 node.pos = token.pos;
11777 node.left = left;
11778 node.right = this.parse_expr5();
11779 var left = node;
11780 }
11781 else if (token.type == TOKEN_NEQ) {
11782 var node = Node(NODE_NEQUAL);
11783 node.pos = token.pos;
11784 node.left = left;
11785 node.right = this.parse_expr5();
11786 var left = node;
11787 }
11788 else if (token.type == TOKEN_NEQCI) {
11789 var node = Node(NODE_NEQUALCI);
11790 node.pos = token.pos;
11791 node.left = left;
11792 node.right = this.parse_expr5();
11793 var left = node;
11794 }
11795 else if (token.type == TOKEN_NEQCS) {
11796 var node = Node(NODE_NEQUALCS);
11797 node.pos = token.pos;
11798 node.left = left;
11799 node.right = this.parse_expr5();
11800 var left = node;
11801 }
11802 else if (token.type == TOKEN_GT) {
11803 var node = Node(NODE_GREATER);
11804 node.pos = token.pos;
11805 node.left = left;
11806 node.right = this.parse_expr5();
11807 var left = node;
11808 }
11809 else if (token.type == TOKEN_GTCI) {
11810 var node = Node(NODE_GREATERCI);
11811 node.pos = token.pos;
11812 node.left = left;
11813 node.right = this.parse_expr5();
11814 var left = node;
11815 }
11816 else if (token.type == TOKEN_GTCS) {
11817 var node = Node(NODE_GREATERCS);
11818 node.pos = token.pos;
11819 node.left = left;
11820 node.right = this.parse_expr5();
11821 var left = node;
11822 }
11823 else if (token.type == TOKEN_GTEQ) {
11824 var node = Node(NODE_GEQUAL);
11825 node.pos = token.pos;
11826 node.left = left;
11827 node.right = this.parse_expr5();
11828 var left = node;
11829 }
11830 else if (token.type == TOKEN_GTEQCI) {
11831 var node = Node(NODE_GEQUALCI);
11832 node.pos = token.pos;
11833 node.left = left;
11834 node.right = this.parse_expr5();
11835 var left = node;
11836 }
11837 else if (token.type == TOKEN_GTEQCS) {
11838 var node = Node(NODE_GEQUALCS);
11839 node.pos = token.pos;
11840 node.left = left;
11841 node.right = this.parse_expr5();
11842 var left = node;
11843 }
11844 else if (token.type == TOKEN_LT) {
11845 var node = Node(NODE_SMALLER);
11846 node.pos = token.pos;
11847 node.left = left;
11848 node.right = this.parse_expr5();
11849 var left = node;
11850 }
11851 else if (token.type == TOKEN_LTCI) {
11852 var node = Node(NODE_SMALLERCI);
11853 node.pos = token.pos;
11854 node.left = left;
11855 node.right = this.parse_expr5();
11856 var left = node;
11857 }
11858 else if (token.type == TOKEN_LTCS) {
11859 var node = Node(NODE_SMALLERCS);
11860 node.pos = token.pos;
11861 node.left = left;
11862 node.right = this.parse_expr5();
11863 var left = node;
11864 }
11865 else if (token.type == TOKEN_LTEQ) {
11866 var node = Node(NODE_SEQUAL);
11867 node.pos = token.pos;
11868 node.left = left;
11869 node.right = this.parse_expr5();
11870 var left = node;
11871 }
11872 else if (token.type == TOKEN_LTEQCI) {
11873 var node = Node(NODE_SEQUALCI);
11874 node.pos = token.pos;
11875 node.left = left;
11876 node.right = this.parse_expr5();
11877 var left = node;
11878 }
11879 else if (token.type == TOKEN_LTEQCS) {
11880 var node = Node(NODE_SEQUALCS);
11881 node.pos = token.pos;
11882 node.left = left;
11883 node.right = this.parse_expr5();
11884 var left = node;
11885 }
11886 else if (token.type == TOKEN_MATCH) {
11887 var node = Node(NODE_MATCH);
11888 node.pos = token.pos;
11889 node.left = left;
11890 node.right = this.parse_expr5();
11891 var left = node;
11892 }
11893 else if (token.type == TOKEN_MATCHCI) {
11894 var node = Node(NODE_MATCHCI);
11895 node.pos = token.pos;
11896 node.left = left;
11897 node.right = this.parse_expr5();
11898 var left = node;
11899 }
11900 else if (token.type == TOKEN_MATCHCS) {
11901 var node = Node(NODE_MATCHCS);
11902 node.pos = token.pos;
11903 node.left = left;
11904 node.right = this.parse_expr5();
11905 var left = node;
11906 }
11907 else if (token.type == TOKEN_NOMATCH) {
11908 var node = Node(NODE_NOMATCH);
11909 node.pos = token.pos;
11910 node.left = left;
11911 node.right = this.parse_expr5();
11912 var left = node;
11913 }
11914 else if (token.type == TOKEN_NOMATCHCI) {
11915 var node = Node(NODE_NOMATCHCI);
11916 node.pos = token.pos;
11917 node.left = left;
11918 node.right = this.parse_expr5();
11919 var left = node;
11920 }
11921 else if (token.type == TOKEN_NOMATCHCS) {
11922 var node = Node(NODE_NOMATCHCS);
11923 node.pos = token.pos;
11924 node.left = left;
11925 node.right = this.parse_expr5();
11926 var left = node;
11927 }
11928 else if (token.type == TOKEN_IS) {
11929 var node = Node(NODE_IS);
11930 node.pos = token.pos;
11931 node.left = left;
11932 node.right = this.parse_expr5();
11933 var left = node;
11934 }
11935 else if (token.type == TOKEN_ISCI) {
11936 var node = Node(NODE_ISCI);
11937 node.pos = token.pos;
11938 node.left = left;
11939 node.right = this.parse_expr5();
11940 var left = node;
11941 }
11942 else if (token.type == TOKEN_ISCS) {
11943 var node = Node(NODE_ISCS);
11944 node.pos = token.pos;
11945 node.left = left;
11946 node.right = this.parse_expr5();
11947 var left = node;
11948 }
11949 else if (token.type == TOKEN_ISNOT) {
11950 var node = Node(NODE_ISNOT);
11951 node.pos = token.pos;
11952 node.left = left;
11953 node.right = this.parse_expr5();
11954 var left = node;
11955 }
11956 else if (token.type == TOKEN_ISNOTCI) {
11957 var node = Node(NODE_ISNOTCI);
11958 node.pos = token.pos;
11959 node.left = left;
11960 node.right = this.parse_expr5();
11961 var left = node;
11962 }
11963 else if (token.type == TOKEN_ISNOTCS) {
11964 var node = Node(NODE_ISNOTCS);
11965 node.pos = token.pos;
11966 node.left = left;
11967 node.right = this.parse_expr5();
11968 var left = node;
11969 }
11970 else {
11971 this.reader.seek_set(pos);
11972 }
11973 return left;
11974}
11975
11976// expr5: expr6 + expr6 ..
11977// expr6 - expr6 ..
11978// expr6 . expr6 ..
11979// expr6 .. expr6 ..
11980ExprParser.prototype.parse_expr5 = function() {
11981 var left = this.parse_expr6();
11982 while (TRUE) {
11983 var pos = this.reader.tell();
11984 var token = this.tokenizer.get();
11985 if (token.type == TOKEN_PLUS) {
11986 var node = Node(NODE_ADD);
11987 node.pos = token.pos;
11988 node.left = left;
11989 node.right = this.parse_expr6();
11990 var left = node;
11991 }
11992 else if (token.type == TOKEN_MINUS) {
11993 var node = Node(NODE_SUBTRACT);
11994 node.pos = token.pos;
11995 node.left = left;
11996 node.right = this.parse_expr6();
11997 var left = node;
11998 }
11999 else if (token.type == TOKEN_DOTDOT) {
12000 // TODO check scriptversion?
12001 var node = Node(NODE_CONCAT);
12002 node.pos = token.pos;
12003 node.left = left;
12004 node.right = this.parse_expr6();
12005 var left = node;
12006 }
12007 else if (token.type == TOKEN_DOT) {
12008 // TODO check scriptversion?
12009 var node = Node(NODE_CONCAT);
12010 node.pos = token.pos;
12011 node.left = left;
12012 node.right = this.parse_expr6();
12013 var left = node;
12014 }
12015 else {
12016 this.reader.seek_set(pos);
12017 break;
12018 }
12019 }
12020 return left;
12021}
12022
12023// expr6: expr7 * expr7 ..
12024// expr7 / expr7 ..
12025// expr7 % expr7 ..
12026ExprParser.prototype.parse_expr6 = function() {
12027 var left = this.parse_expr7();
12028 while (TRUE) {
12029 var pos = this.reader.tell();
12030 var token = this.tokenizer.get();
12031 if (token.type == TOKEN_STAR) {
12032 var node = Node(NODE_MULTIPLY);
12033 node.pos = token.pos;
12034 node.left = left;
12035 node.right = this.parse_expr7();
12036 var left = node;
12037 }
12038 else if (token.type == TOKEN_SLASH) {
12039 var node = Node(NODE_DIVIDE);
12040 node.pos = token.pos;
12041 node.left = left;
12042 node.right = this.parse_expr7();
12043 var left = node;
12044 }
12045 else if (token.type == TOKEN_PERCENT) {
12046 var node = Node(NODE_REMAINDER);
12047 node.pos = token.pos;
12048 node.left = left;
12049 node.right = this.parse_expr7();
12050 var left = node;
12051 }
12052 else {
12053 this.reader.seek_set(pos);
12054 break;
12055 }
12056 }
12057 return left;
12058}
12059
12060// expr7: ! expr7
12061// - expr7
12062// + expr7
12063ExprParser.prototype.parse_expr7 = function() {
12064 var pos = this.reader.tell();
12065 var token = this.tokenizer.get();
12066 if (token.type == TOKEN_NOT) {
12067 var node = Node(NODE_NOT);
12068 node.pos = token.pos;
12069 node.left = this.parse_expr7();
12070 return node;
12071 }
12072 else if (token.type == TOKEN_MINUS) {
12073 var node = Node(NODE_MINUS);
12074 node.pos = token.pos;
12075 node.left = this.parse_expr7();
12076 return node;
12077 }
12078 else if (token.type == TOKEN_PLUS) {
12079 var node = Node(NODE_PLUS);
12080 node.pos = token.pos;
12081 node.left = this.parse_expr7();
12082 return node;
12083 }
12084 else {
12085 this.reader.seek_set(pos);
12086 var node = this.parse_expr8();
12087 return node;
12088 }
12089}
12090
12091// expr8: expr8[expr1]
12092// expr8[expr1 : expr1]
12093// expr8.name
12094// expr8->name(expr1, ...)
12095// expr8->s:user_func(expr1, ...)
12096// expr8->{lambda}(expr1, ...)
12097// expr8(expr1, ...)
12098ExprParser.prototype.parse_expr8 = function() {
12099 var left = this.parse_expr9();
12100 while (TRUE) {
12101 var pos = this.reader.tell();
12102 var c = this.reader.peek();
12103 var token = this.tokenizer.get();
12104 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
12105 var npos = token.pos;
12106 if (this.tokenizer.peek().type == TOKEN_COLON) {
12107 this.tokenizer.get();
12108 var node = Node(NODE_SLICE);
12109 node.pos = npos;
12110 node.left = left;
12111 node.rlist = [NIL, NIL];
12112 var token = this.tokenizer.peek();
12113 if (token.type != TOKEN_SQCLOSE) {
12114 node.rlist[1] = this.parse_expr1();
12115 }
12116 var token = this.tokenizer.get();
12117 if (token.type != TOKEN_SQCLOSE) {
12118 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12119 }
12120 var left = node;
12121 }
12122 else {
12123 var right = this.parse_expr1();
12124 if (this.tokenizer.peek().type == TOKEN_COLON) {
12125 this.tokenizer.get();
12126 var node = Node(NODE_SLICE);
12127 node.pos = npos;
12128 node.left = left;
12129 node.rlist = [right, NIL];
12130 var token = this.tokenizer.peek();
12131 if (token.type != TOKEN_SQCLOSE) {
12132 node.rlist[1] = this.parse_expr1();
12133 }
12134 var token = this.tokenizer.get();
12135 if (token.type != TOKEN_SQCLOSE) {
12136 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12137 }
12138 var left = node;
12139 }
12140 else {
12141 var node = Node(NODE_SUBSCRIPT);
12142 node.pos = npos;
12143 node.left = left;
12144 node.right = right;
12145 var token = this.tokenizer.get();
12146 if (token.type != TOKEN_SQCLOSE) {
12147 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12148 }
12149 var left = node;
12150 }
12151 }
12152 delete node;
12153 }
12154 else if (token.type == TOKEN_ARROW) {
12155 var funcname_or_lambda = this.parse_expr9();
12156 var token = this.tokenizer.get();
12157 if (token.type != TOKEN_POPEN) {
12158 throw Err("E107: Missing parentheses: lambda", token.pos);
12159 }
12160 var right = Node(NODE_CALL);
12161 right.pos = token.pos;
12162 right.left = funcname_or_lambda;
12163 right.rlist = this.parse_rlist();
12164 var node = Node(NODE_METHOD);
12165 node.pos = token.pos;
12166 node.left = left;
12167 node.right = right;
12168 var left = node;
12169 delete node;
12170 }
12171 else if (token.type == TOKEN_POPEN) {
12172 var node = Node(NODE_CALL);
12173 node.pos = token.pos;
12174 node.left = left;
12175 node.rlist = this.parse_rlist();
12176 var left = node;
12177 delete node;
12178 }
12179 else if (!iswhite(c) && token.type == TOKEN_DOT) {
12180 // TODO check scriptversion?
12181 var node = this.parse_dot(token, left);
12182 if (node === NIL) {
12183 this.reader.seek_set(pos);
12184 break;
12185 }
12186 var left = node;
12187 delete node;
12188 }
12189 else {
12190 this.reader.seek_set(pos);
12191 break;
12192 }
12193 }
12194 return left;
12195}
12196
12197ExprParser.prototype.parse_rlist = function() {
12198 var rlist = [];
12199 var token = this.tokenizer.peek();
12200 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
12201 this.tokenizer.get();
12202 }
12203 else {
12204 while (TRUE) {
12205 viml_add(rlist, this.parse_expr1());
12206 var token = this.tokenizer.get();
12207 if (token.type == TOKEN_COMMA) {
12208 // XXX: Vim allows foo(a, b, ). Lint should warn it.
12209 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
12210 this.tokenizer.get();
12211 break;
12212 }
12213 }
12214 else if (token.type == TOKEN_PCLOSE) {
12215 break;
12216 }
12217 else {
12218 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12219 }
12220 }
12221 }
12222 if (viml_len(rlist) > MAX_FUNC_ARGS) {
12223 // TODO: funcname E740: Too many arguments for function: %s
12224 throw Err("E740: Too many arguments for function", token.pos);
12225 }
12226 return rlist;
12227}
12228
12229// expr9: number
12230// "string"
12231// 'string'
12232// [expr1, ...]
12233// {expr1: expr1, ...}
12234// #{literal_key1: expr1, ...}
12235// {args -> expr1}
12236// &option
12237// (expr1)
12238// variable
12239// var{ria}ble
12240// $VAR
12241// @r
12242// function(expr1, ...)
12243// func{ti}on(expr1, ...)
12244ExprParser.prototype.parse_expr9 = function() {
12245 var pos = this.reader.tell();
12246 var token = this.tokenizer.get();
12247 var node = Node(-1);
12248 if (token.type == TOKEN_NUMBER) {
12249 var node = Node(NODE_NUMBER);
12250 node.pos = token.pos;
12251 node.value = token.value;
12252 }
12253 else if (token.type == TOKEN_BLOB) {
12254 var node = Node(NODE_BLOB);
12255 node.pos = token.pos;
12256 node.value = token.value;
12257 }
12258 else if (token.type == TOKEN_DQUOTE) {
12259 this.reader.seek_set(pos);
12260 var node = Node(NODE_STRING);
12261 node.pos = token.pos;
12262 node.value = "\"" + this.tokenizer.get_dstring() + "\"";
12263 }
12264 else if (token.type == TOKEN_SQUOTE) {
12265 this.reader.seek_set(pos);
12266 var node = Node(NODE_STRING);
12267 node.pos = token.pos;
12268 node.value = "'" + this.tokenizer.get_sstring() + "'";
12269 }
12270 else if (token.type == TOKEN_SQOPEN) {
12271 var node = Node(NODE_LIST);
12272 node.pos = token.pos;
12273 node.value = [];
12274 var token = this.tokenizer.peek();
12275 if (token.type == TOKEN_SQCLOSE) {
12276 this.tokenizer.get();
12277 }
12278 else {
12279 while (TRUE) {
12280 viml_add(node.value, this.parse_expr1());
12281 var token = this.tokenizer.peek();
12282 if (token.type == TOKEN_COMMA) {
12283 this.tokenizer.get();
12284 if (this.tokenizer.peek().type == TOKEN_SQCLOSE) {
12285 this.tokenizer.get();
12286 break;
12287 }
12288 }
12289 else if (token.type == TOKEN_SQCLOSE) {
12290 this.tokenizer.get();
12291 break;
12292 }
12293 else {
12294 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12295 }
12296 }
12297 }
12298 }
12299 else if (token.type == TOKEN_COPEN || token.type == TOKEN_LITCOPEN) {
12300 var is_litdict = token.type == TOKEN_LITCOPEN;
12301 var savepos = this.reader.tell();
12302 var nodepos = token.pos;
12303 var token = this.tokenizer.get();
12304 var lambda = token.type == TOKEN_ARROW;
12305 if (!lambda && !(token.type == TOKEN_SQUOTE || token.type == TOKEN_DQUOTE)) {
12306 // if the token type is stirng, we cannot peek next token and we can
12307 // assume it's not lambda.
12308 var token2 = this.tokenizer.peek();
12309 var lambda = token2.type == TOKEN_ARROW || token2.type == TOKEN_COMMA;
12310 }
12311 // fallback to dict or {expr} if true
12312 var fallback = FALSE;
12313 if (lambda) {
12314 // lambda {token,...} {->...} {token->...}
12315 var node = Node(NODE_LAMBDA);
12316 node.pos = nodepos;
12317 node.rlist = [];
12318 var named = {};
12319 while (TRUE) {
12320 if (token.type == TOKEN_ARROW) {
12321 break;
12322 }
12323 else if (token.type == TOKEN_IDENTIFIER) {
12324 if (!isargname(token.value)) {
12325 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
12326 }
12327 else if (viml_has_key(named, token.value)) {
12328 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
12329 }
12330 named[token.value] = 1;
12331 var varnode = Node(NODE_IDENTIFIER);
12332 varnode.pos = token.pos;
12333 varnode.value = token.value;
12334 // XXX: Vim doesn't skip white space before comma. {a ,b -> ...} => E475
12335 if (iswhite(this.reader.p(0)) && this.tokenizer.peek().type == TOKEN_COMMA) {
12336 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
12337 }
12338 var token = this.tokenizer.get();
12339 viml_add(node.rlist, varnode);
12340 if (token.type == TOKEN_COMMA) {
12341 // XXX: Vim allows last comma. {a, b, -> ...} => OK
12342 var token = this.tokenizer.peek();
12343 if (token.type == TOKEN_ARROW) {
12344 this.tokenizer.get();
12345 break;
12346 }
12347 }
12348 else if (token.type == TOKEN_ARROW) {
12349 break;
12350 }
12351 else {
12352 throw Err(viml_printf("unexpected token: %s, type: %d", token.value, token.type), token.pos);
12353 }
12354 }
12355 else if (token.type == TOKEN_DOTDOTDOT) {
12356 var varnode = Node(NODE_IDENTIFIER);
12357 varnode.pos = token.pos;
12358 varnode.value = token.value;
12359 viml_add(node.rlist, varnode);
12360 var token = this.tokenizer.peek();
12361 if (token.type == TOKEN_ARROW) {
12362 this.tokenizer.get();
12363 break;
12364 }
12365 else {
12366 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12367 }
12368 }
12369 else {
12370 var fallback = TRUE;
12371 break;
12372 }
12373 var token = this.tokenizer.get();
12374 }
12375 if (!fallback) {
12376 node.left = this.parse_expr1();
12377 var token = this.tokenizer.get();
12378 if (token.type != TOKEN_CCLOSE) {
12379 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12380 }
12381 return node;
12382 }
12383 }
12384 // dict
12385 var node = Node(NODE_DICT);
12386 node.pos = nodepos;
12387 node.value = [];
12388 this.reader.seek_set(savepos);
12389 var token = this.tokenizer.peek();
12390 if (token.type == TOKEN_CCLOSE) {
12391 this.tokenizer.get();
12392 return node;
12393 }
12394 while (1) {
12395 var key = is_litdict ? this.tokenizer.parse_dict_literal_key() : this.parse_expr1();
12396 var token = this.tokenizer.get();
12397 if (token.type == TOKEN_CCLOSE) {
12398 if (!viml_empty(node.value)) {
12399 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12400 }
12401 this.reader.seek_set(pos);
12402 var node = this.parse_identifier();
12403 break;
12404 }
12405 if (token.type != TOKEN_COLON) {
12406 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12407 }
12408 var val = this.parse_expr1();
12409 viml_add(node.value, [key, val]);
12410 var token = this.tokenizer.get();
12411 if (token.type == TOKEN_COMMA) {
12412 if (this.tokenizer.peek().type == TOKEN_CCLOSE) {
12413 this.tokenizer.get();
12414 break;
12415 }
12416 }
12417 else if (token.type == TOKEN_CCLOSE) {
12418 break;
12419 }
12420 else {
12421 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12422 }
12423 }
12424 return node;
12425 }
12426 else if (token.type == TOKEN_POPEN) {
12427 var node = this.parse_expr1();
12428 var token = this.tokenizer.get();
12429 if (token.type != TOKEN_PCLOSE) {
12430 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12431 }
12432 }
12433 else if (token.type == TOKEN_OPTION) {
12434 var node = Node(NODE_OPTION);
12435 node.pos = token.pos;
12436 node.value = token.value;
12437 }
12438 else if (token.type == TOKEN_IDENTIFIER) {
12439 this.reader.seek_set(pos);
12440 var node = this.parse_identifier();
12441 }
12442 else if (FALSE && (token.type == TOKEN_COLON || token.type == TOKEN_SHARP)) {
12443 // XXX: no parse error but invalid expression
12444 this.reader.seek_set(pos);
12445 var node = this.parse_identifier();
12446 }
12447 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
12448 this.reader.seek_set(pos);
12449 var node = this.parse_identifier();
12450 }
12451 else if (token.type == TOKEN_IS || token.type == TOKEN_ISCS || token.type == TOKEN_ISNOT || token.type == TOKEN_ISNOTCS) {
12452 this.reader.seek_set(pos);
12453 var node = this.parse_identifier();
12454 }
12455 else if (token.type == TOKEN_ENV) {
12456 var node = Node(NODE_ENV);
12457 node.pos = token.pos;
12458 node.value = token.value;
12459 }
12460 else if (token.type == TOKEN_REG) {
12461 var node = Node(NODE_REG);
12462 node.pos = token.pos;
12463 node.value = token.value;
12464 }
12465 else {
12466 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12467 }
12468 return node;
12469}
12470
12471// SUBSCRIPT or CONCAT
12472// dict "." [0-9A-Za-z_]+ => (subscript dict key)
12473// str "." expr6 => (concat str expr6)
12474ExprParser.prototype.parse_dot = function(token, left) {
12475 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) {
12476 return NIL;
12477 }
12478 if (!iswordc(this.reader.p(0))) {
12479 return NIL;
12480 }
12481 var pos = this.reader.getpos();
12482 var name = this.reader.read_word();
12483 if (isnamec(this.reader.p(0))) {
12484 // XXX: foo is str => ok, foo is obj => invalid expression
12485 // foo.s:bar or foo.bar#baz
12486 return NIL;
12487 }
12488 var node = Node(NODE_DOT);
12489 node.pos = token.pos;
12490 node.left = left;
12491 node.right = Node(NODE_IDENTIFIER);
12492 node.right.pos = pos;
12493 node.right.value = name;
12494 return node;
12495}
12496
12497// CONCAT
12498// str ".." expr6 => (concat str expr6)
12499ExprParser.prototype.parse_concat = function(token, left) {
12500 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) {
12501 return NIL;
12502 }
12503 if (!iswordc(this.reader.p(0))) {
12504 return NIL;
12505 }
12506 var pos = this.reader.getpos();
12507 var name = this.reader.read_word();
12508 if (isnamec(this.reader.p(0))) {
12509 // XXX: foo is str => ok, foo is obj => invalid expression
12510 // foo.s:bar or foo.bar#baz
12511 return NIL;
12512 }
12513 var node = Node(NODE_CONCAT);
12514 node.pos = token.pos;
12515 node.left = left;
12516 node.right = Node(NODE_IDENTIFIER);
12517 node.right.pos = pos;
12518 node.right.value = name;
12519 return node;
12520}
12521
12522ExprParser.prototype.parse_identifier = function() {
12523 this.reader.skip_white();
12524 var npos = this.reader.getpos();
12525 var curly_parts = this.parse_curly_parts();
12526 if (viml_len(curly_parts) == 1 && curly_parts[0].type == NODE_CURLYNAMEPART) {
12527 var node = Node(NODE_IDENTIFIER);
12528 node.pos = npos;
12529 node.value = curly_parts[0].value;
12530 return node;
12531 }
12532 else {
12533 var node = Node(NODE_CURLYNAME);
12534 node.pos = npos;
12535 node.value = curly_parts;
12536 return node;
12537 }
12538}
12539
12540ExprParser.prototype.parse_curly_parts = function() {
12541 var curly_parts = [];
12542 var c = this.reader.peek();
12543 var pos = this.reader.getpos();
12544 if (c == "<" && viml_equalci(this.reader.peekn(5), "<SID>")) {
12545 var name = this.reader.getn(5);
12546 var node = Node(NODE_CURLYNAMEPART);
12547 node.curly = FALSE;
12548 // Keep backword compatibility for the curly attribute
12549 node.pos = pos;
12550 node.value = name;
12551 viml_add(curly_parts, node);
12552 }
12553 while (TRUE) {
12554 var c = this.reader.peek();
12555 if (isnamec(c)) {
12556 var pos = this.reader.getpos();
12557 var name = this.reader.read_name();
12558 var node = Node(NODE_CURLYNAMEPART);
12559 node.curly = FALSE;
12560 // Keep backword compatibility for the curly attribute
12561 node.pos = pos;
12562 node.value = name;
12563 viml_add(curly_parts, node);
12564 }
12565 else if (c == "{") {
12566 this.reader.get();
12567 var pos = this.reader.getpos();
12568 var node = Node(NODE_CURLYNAMEEXPR);
12569 node.curly = TRUE;
12570 // Keep backword compatibility for the curly attribute
12571 node.pos = pos;
12572 node.value = this.parse_expr1();
12573 viml_add(curly_parts, node);
12574 this.reader.skip_white();
12575 var c = this.reader.p(0);
12576 if (c != "}") {
12577 throw Err(viml_printf("unexpected token: %s", c), this.reader.getpos());
12578 }
12579 this.reader.seek_cur(1);
12580 }
12581 else {
12582 break;
12583 }
12584 }
12585 return curly_parts;
12586}
12587
12588function LvalueParser() { ExprParser.apply(this, arguments); this.__init__.apply(this, arguments); }
12589LvalueParser.prototype = Object.create(ExprParser.prototype);
12590LvalueParser.prototype.parse = function() {
12591 return this.parse_lv8();
12592}
12593
12594// expr8: expr8[expr1]
12595// expr8[expr1 : expr1]
12596// expr8.name
12597LvalueParser.prototype.parse_lv8 = function() {
12598 var left = this.parse_lv9();
12599 while (TRUE) {
12600 var pos = this.reader.tell();
12601 var c = this.reader.peek();
12602 var token = this.tokenizer.get();
12603 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
12604 var npos = token.pos;
12605 var node = Node(-1);
12606 if (this.tokenizer.peek().type == TOKEN_COLON) {
12607 this.tokenizer.get();
12608 var node = Node(NODE_SLICE);
12609 node.pos = npos;
12610 node.left = left;
12611 node.rlist = [NIL, NIL];
12612 var token = this.tokenizer.peek();
12613 if (token.type != TOKEN_SQCLOSE) {
12614 node.rlist[1] = this.parse_expr1();
12615 }
12616 var token = this.tokenizer.get();
12617 if (token.type != TOKEN_SQCLOSE) {
12618 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12619 }
12620 }
12621 else {
12622 var right = this.parse_expr1();
12623 if (this.tokenizer.peek().type == TOKEN_COLON) {
12624 this.tokenizer.get();
12625 var node = Node(NODE_SLICE);
12626 node.pos = npos;
12627 node.left = left;
12628 node.rlist = [right, NIL];
12629 var token = this.tokenizer.peek();
12630 if (token.type != TOKEN_SQCLOSE) {
12631 node.rlist[1] = this.parse_expr1();
12632 }
12633 var token = this.tokenizer.get();
12634 if (token.type != TOKEN_SQCLOSE) {
12635 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12636 }
12637 }
12638 else {
12639 var node = Node(NODE_SUBSCRIPT);
12640 node.pos = npos;
12641 node.left = left;
12642 node.right = right;
12643 var token = this.tokenizer.get();
12644 if (token.type != TOKEN_SQCLOSE) {
12645 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12646 }
12647 }
12648 }
12649 var left = node;
12650 delete node;
12651 }
12652 else if (!iswhite(c) && token.type == TOKEN_DOT) {
12653 var node = this.parse_dot(token, left);
12654 if (node === NIL) {
12655 this.reader.seek_set(pos);
12656 break;
12657 }
12658 var left = node;
12659 delete node;
12660 }
12661 else {
12662 this.reader.seek_set(pos);
12663 break;
12664 }
12665 }
12666 return left;
12667}
12668
12669// expr9: &option
12670// variable
12671// var{ria}ble
12672// $VAR
12673// @r
12674LvalueParser.prototype.parse_lv9 = function() {
12675 var pos = this.reader.tell();
12676 var token = this.tokenizer.get();
12677 var node = Node(-1);
12678 if (token.type == TOKEN_COPEN) {
12679 this.reader.seek_set(pos);
12680 var node = this.parse_identifier();
12681 }
12682 else if (token.type == TOKEN_OPTION) {
12683 var node = Node(NODE_OPTION);
12684 node.pos = token.pos;
12685 node.value = token.value;
12686 }
12687 else if (token.type == TOKEN_IDENTIFIER) {
12688 this.reader.seek_set(pos);
12689 var node = this.parse_identifier();
12690 }
12691 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
12692 this.reader.seek_set(pos);
12693 var node = this.parse_identifier();
12694 }
12695 else if (token.type == TOKEN_ENV) {
12696 var node = Node(NODE_ENV);
12697 node.pos = token.pos;
12698 node.value = token.value;
12699 }
12700 else if (token.type == TOKEN_REG) {
12701 var node = Node(NODE_REG);
12702 node.pos = token.pos;
12703 node.pos = token.pos;
12704 node.value = token.value;
12705 }
12706 else {
12707 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
12708 }
12709 return node;
12710}
12711
12712function StringReader() { this.__init__.apply(this, arguments); }
12713StringReader.prototype.__init__ = function(lines) {
12714 this.buf = [];
12715 this.pos = [];
12716 var lnum = 0;
12717 var offset = 0;
12718 while (lnum < viml_len(lines)) {
12719 var col = 0;
12720 var __c7 = viml_split(lines[lnum], "\\zs");
12721 for (var __i7 = 0; __i7 < __c7.length; ++__i7) {
12722 var c = __c7[__i7];
12723 viml_add(this.buf, c);
12724 viml_add(this.pos, [lnum + 1, col + 1, offset]);
12725 col += viml_len(c);
12726 offset += viml_len(c);
12727 }
12728 while (lnum + 1 < viml_len(lines) && viml_eqregh(lines[lnum + 1], "^\\s*\\\\")) {
12729 var skip = TRUE;
12730 var col = 0;
12731 var __c8 = viml_split(lines[lnum + 1], "\\zs");
12732 for (var __i8 = 0; __i8 < __c8.length; ++__i8) {
12733 var c = __c8[__i8];
12734 if (skip) {
12735 if (c == "\\") {
12736 var skip = FALSE;
12737 }
12738 }
12739 else {
12740 viml_add(this.buf, c);
12741 viml_add(this.pos, [lnum + 2, col + 1, offset]);
12742 }
12743 col += viml_len(c);
12744 offset += viml_len(c);
12745 }
12746 lnum += 1;
12747 offset += 1;
12748 }
12749 viml_add(this.buf, "<EOL>");
12750 viml_add(this.pos, [lnum + 1, col + 1, offset]);
12751 lnum += 1;
12752 offset += 1;
12753 }
12754 // for <EOF>
12755 viml_add(this.pos, [lnum + 1, 0, offset]);
12756 this.i = 0;
12757}
12758
12759StringReader.prototype.eof = function() {
12760 return this.i >= viml_len(this.buf);
12761}
12762
12763StringReader.prototype.tell = function() {
12764 return this.i;
12765}
12766
12767StringReader.prototype.seek_set = function(i) {
12768 this.i = i;
12769}
12770
12771StringReader.prototype.seek_cur = function(i) {
12772 this.i = this.i + i;
12773}
12774
12775StringReader.prototype.seek_end = function(i) {
12776 this.i = viml_len(this.buf) + i;
12777}
12778
12779StringReader.prototype.p = function(i) {
12780 if (this.i >= viml_len(this.buf)) {
12781 return "<EOF>";
12782 }
12783 return this.buf[this.i + i];
12784}
12785
12786StringReader.prototype.peek = function() {
12787 if (this.i >= viml_len(this.buf)) {
12788 return "<EOF>";
12789 }
12790 return this.buf[this.i];
12791}
12792
12793StringReader.prototype.get = function() {
12794 if (this.i >= viml_len(this.buf)) {
12795 return "<EOF>";
12796 }
12797 this.i += 1;
12798 return this.buf[this.i - 1];
12799}
12800
12801StringReader.prototype.peekn = function(n) {
12802 var pos = this.tell();
12803 var r = this.getn(n);
12804 this.seek_set(pos);
12805 return r;
12806}
12807
12808StringReader.prototype.getn = function(n) {
12809 var r = "";
12810 var j = 0;
12811 while (this.i < viml_len(this.buf) && (n < 0 || j < n)) {
12812 var c = this.buf[this.i];
12813 if (c == "<EOL>") {
12814 break;
12815 }
12816 r += c;
12817 this.i += 1;
12818 j += 1;
12819 }
12820 return r;
12821}
12822
12823StringReader.prototype.peekline = function() {
12824 return this.peekn(-1);
12825}
12826
12827StringReader.prototype.readline = function() {
12828 var r = this.getn(-1);
12829 this.get();
12830 return r;
12831}
12832
12833StringReader.prototype.getstr = function(begin, end) {
12834 var r = "";
12835 var __c9 = viml_range(begin.i, end.i - 1);
12836 for (var __i9 = 0; __i9 < __c9.length; ++__i9) {
12837 var i = __c9[__i9];
12838 if (i >= viml_len(this.buf)) {
12839 break;
12840 }
12841 var c = this.buf[i];
12842 if (c == "<EOL>") {
12843 var c = "\n";
12844 }
12845 r += c;
12846 }
12847 return r;
12848}
12849
12850StringReader.prototype.getpos = function() {
12851 var __tmp = this.pos[this.i];
12852 var lnum = __tmp[0];
12853 var col = __tmp[1];
12854 var offset = __tmp[2];
12855 return {"i":this.i, "lnum":lnum, "col":col, "offset":offset};
12856}
12857
12858StringReader.prototype.setpos = function(pos) {
12859 this.i = pos.i;
12860}
12861
12862StringReader.prototype.read_alpha = function() {
12863 var r = "";
12864 while (isalpha(this.peekn(1))) {
12865 r += this.getn(1);
12866 }
12867 return r;
12868}
12869
12870StringReader.prototype.read_alnum = function() {
12871 var r = "";
12872 while (isalnum(this.peekn(1))) {
12873 r += this.getn(1);
12874 }
12875 return r;
12876}
12877
12878StringReader.prototype.read_digit = function() {
12879 var r = "";
12880 while (isdigit(this.peekn(1))) {
12881 r += this.getn(1);
12882 }
12883 return r;
12884}
12885
12886StringReader.prototype.read_odigit = function() {
12887 var r = "";
12888 while (isodigit(this.peekn(1))) {
12889 r += this.getn(1);
12890 }
12891 return r;
12892}
12893
12894StringReader.prototype.read_blob = function() {
12895 var r = "";
12896 while (1) {
12897 var s = this.peekn(2);
12898 if (viml_eqregh(s, "^[0-9A-Fa-f][0-9A-Fa-f]$")) {
12899 r += this.getn(2);
12900 }
12901 else if (viml_eqregh(s, "^\\.[0-9A-Fa-f]$")) {
12902 r += this.getn(1);
12903 }
12904 else if (viml_eqregh(s, "^[0-9A-Fa-f][^0-9A-Fa-f]$")) {
12905 throw Err("E973: Blob literal should have an even number of hex characters:" + s, this.getpos());
12906 }
12907 else {
12908 break;
12909 }
12910 }
12911 return r;
12912}
12913
12914StringReader.prototype.read_xdigit = function() {
12915 var r = "";
12916 while (isxdigit(this.peekn(1))) {
12917 r += this.getn(1);
12918 }
12919 return r;
12920}
12921
12922StringReader.prototype.read_bdigit = function() {
12923 var r = "";
12924 while (this.peekn(1) == "0" || this.peekn(1) == "1") {
12925 r += this.getn(1);
12926 }
12927 return r;
12928}
12929
12930StringReader.prototype.read_integer = function() {
12931 var r = "";
12932 var c = this.peekn(1);
12933 if (c == "-" || c == "+") {
12934 var r = this.getn(1);
12935 }
12936 return r + this.read_digit();
12937}
12938
12939StringReader.prototype.read_word = function() {
12940 var r = "";
12941 while (iswordc(this.peekn(1))) {
12942 r += this.getn(1);
12943 }
12944 return r;
12945}
12946
12947StringReader.prototype.read_white = function() {
12948 var r = "";
12949 while (iswhite(this.peekn(1))) {
12950 r += this.getn(1);
12951 }
12952 return r;
12953}
12954
12955StringReader.prototype.read_nonwhite = function() {
12956 var r = "";
12957 var ch = this.peekn(1);
12958 while (!iswhite(ch) && ch != "") {
12959 r += this.getn(1);
12960 var ch = this.peekn(1);
12961 }
12962 return r;
12963}
12964
12965StringReader.prototype.read_name = function() {
12966 var r = "";
12967 while (isnamec(this.peekn(1))) {
12968 r += this.getn(1);
12969 }
12970 return r;
12971}
12972
12973StringReader.prototype.skip_white = function() {
12974 while (iswhite(this.peekn(1))) {
12975 this.seek_cur(1);
12976 }
12977}
12978
12979StringReader.prototype.skip_white_and_colon = function() {
12980 while (TRUE) {
12981 var c = this.peekn(1);
12982 if (!iswhite(c) && c != ":") {
12983 break;
12984 }
12985 this.seek_cur(1);
12986 }
12987}
12988
12989function Compiler() { this.__init__.apply(this, arguments); }
12990Compiler.prototype.__init__ = function() {
12991 this.indent = [""];
12992 this.lines = [];
12993}
12994
12995Compiler.prototype.out = function() {
12996 var a000 = Array.prototype.slice.call(arguments, 0);
12997 if (viml_len(a000) == 1) {
12998 if (a000[0][0] == ")") {
12999 this.lines[this.lines.length - 1] += a000[0];
13000 }
13001 else {
13002 viml_add(this.lines, this.indent[0] + a000[0]);
13003 }
13004 }
13005 else {
13006 viml_add(this.lines, this.indent[0] + viml_printf.apply(null, a000));
13007 }
13008}
13009
13010Compiler.prototype.incindent = function(s) {
13011 viml_insert(this.indent, this.indent[0] + s);
13012}
13013
13014Compiler.prototype.decindent = function() {
13015 viml_remove(this.indent, 0);
13016}
13017
13018Compiler.prototype.compile = function(node) {
13019 if (node.type == NODE_TOPLEVEL) {
13020 return this.compile_toplevel(node);
13021 }
13022 else if (node.type == NODE_COMMENT) {
13023 this.compile_comment(node);
13024 return NIL;
13025 }
13026 else if (node.type == NODE_EXCMD) {
13027 this.compile_excmd(node);
13028 return NIL;
13029 }
13030 else if (node.type == NODE_FUNCTION) {
13031 this.compile_function(node);
13032 return NIL;
13033 }
13034 else if (node.type == NODE_DELFUNCTION) {
13035 this.compile_delfunction(node);
13036 return NIL;
13037 }
13038 else if (node.type == NODE_RETURN) {
13039 this.compile_return(node);
13040 return NIL;
13041 }
13042 else if (node.type == NODE_EXCALL) {
13043 this.compile_excall(node);
13044 return NIL;
13045 }
13046 else if (node.type == NODE_EVAL) {
13047 this.compile_eval(node);
13048 return NIL;
13049 }
13050 else if (node.type == NODE_LET) {
13051 this.compile_let(node);
13052 return NIL;
13053 }
13054 else if (node.type == NODE_CONST) {
13055 this.compile_const(node);
13056 return NIL;
13057 }
13058 else if (node.type == NODE_UNLET) {
13059 this.compile_unlet(node);
13060 return NIL;
13061 }
13062 else if (node.type == NODE_LOCKVAR) {
13063 this.compile_lockvar(node);
13064 return NIL;
13065 }
13066 else if (node.type == NODE_UNLOCKVAR) {
13067 this.compile_unlockvar(node);
13068 return NIL;
13069 }
13070 else if (node.type == NODE_IF) {
13071 this.compile_if(node);
13072 return NIL;
13073 }
13074 else if (node.type == NODE_WHILE) {
13075 this.compile_while(node);
13076 return NIL;
13077 }
13078 else if (node.type == NODE_FOR) {
13079 this.compile_for(node);
13080 return NIL;
13081 }
13082 else if (node.type == NODE_CONTINUE) {
13083 this.compile_continue(node);
13084 return NIL;
13085 }
13086 else if (node.type == NODE_BREAK) {
13087 this.compile_break(node);
13088 return NIL;
13089 }
13090 else if (node.type == NODE_TRY) {
13091 this.compile_try(node);
13092 return NIL;
13093 }
13094 else if (node.type == NODE_THROW) {
13095 this.compile_throw(node);
13096 return NIL;
13097 }
13098 else if (node.type == NODE_ECHO) {
13099 this.compile_echo(node);
13100 return NIL;
13101 }
13102 else if (node.type == NODE_ECHON) {
13103 this.compile_echon(node);
13104 return NIL;
13105 }
13106 else if (node.type == NODE_ECHOHL) {
13107 this.compile_echohl(node);
13108 return NIL;
13109 }
13110 else if (node.type == NODE_ECHOMSG) {
13111 this.compile_echomsg(node);
13112 return NIL;
13113 }
13114 else if (node.type == NODE_ECHOERR) {
13115 this.compile_echoerr(node);
13116 return NIL;
13117 }
13118 else if (node.type == NODE_EXECUTE) {
13119 this.compile_execute(node);
13120 return NIL;
13121 }
13122 else if (node.type == NODE_TERNARY) {
13123 return this.compile_ternary(node);
13124 }
13125 else if (node.type == NODE_OR) {
13126 return this.compile_or(node);
13127 }
13128 else if (node.type == NODE_AND) {
13129 return this.compile_and(node);
13130 }
13131 else if (node.type == NODE_EQUAL) {
13132 return this.compile_equal(node);
13133 }
13134 else if (node.type == NODE_EQUALCI) {
13135 return this.compile_equalci(node);
13136 }
13137 else if (node.type == NODE_EQUALCS) {
13138 return this.compile_equalcs(node);
13139 }
13140 else if (node.type == NODE_NEQUAL) {
13141 return this.compile_nequal(node);
13142 }
13143 else if (node.type == NODE_NEQUALCI) {
13144 return this.compile_nequalci(node);
13145 }
13146 else if (node.type == NODE_NEQUALCS) {
13147 return this.compile_nequalcs(node);
13148 }
13149 else if (node.type == NODE_GREATER) {
13150 return this.compile_greater(node);
13151 }
13152 else if (node.type == NODE_GREATERCI) {
13153 return this.compile_greaterci(node);
13154 }
13155 else if (node.type == NODE_GREATERCS) {
13156 return this.compile_greatercs(node);
13157 }
13158 else if (node.type == NODE_GEQUAL) {
13159 return this.compile_gequal(node);
13160 }
13161 else if (node.type == NODE_GEQUALCI) {
13162 return this.compile_gequalci(node);
13163 }
13164 else if (node.type == NODE_GEQUALCS) {
13165 return this.compile_gequalcs(node);
13166 }
13167 else if (node.type == NODE_SMALLER) {
13168 return this.compile_smaller(node);
13169 }
13170 else if (node.type == NODE_SMALLERCI) {
13171 return this.compile_smallerci(node);
13172 }
13173 else if (node.type == NODE_SMALLERCS) {
13174 return this.compile_smallercs(node);
13175 }
13176 else if (node.type == NODE_SEQUAL) {
13177 return this.compile_sequal(node);
13178 }
13179 else if (node.type == NODE_SEQUALCI) {
13180 return this.compile_sequalci(node);
13181 }
13182 else if (node.type == NODE_SEQUALCS) {
13183 return this.compile_sequalcs(node);
13184 }
13185 else if (node.type == NODE_MATCH) {
13186 return this.compile_match(node);
13187 }
13188 else if (node.type == NODE_MATCHCI) {
13189 return this.compile_matchci(node);
13190 }
13191 else if (node.type == NODE_MATCHCS) {
13192 return this.compile_matchcs(node);
13193 }
13194 else if (node.type == NODE_NOMATCH) {
13195 return this.compile_nomatch(node);
13196 }
13197 else if (node.type == NODE_NOMATCHCI) {
13198 return this.compile_nomatchci(node);
13199 }
13200 else if (node.type == NODE_NOMATCHCS) {
13201 return this.compile_nomatchcs(node);
13202 }
13203 else if (node.type == NODE_IS) {
13204 return this.compile_is(node);
13205 }
13206 else if (node.type == NODE_ISCI) {
13207 return this.compile_isci(node);
13208 }
13209 else if (node.type == NODE_ISCS) {
13210 return this.compile_iscs(node);
13211 }
13212 else if (node.type == NODE_ISNOT) {
13213 return this.compile_isnot(node);
13214 }
13215 else if (node.type == NODE_ISNOTCI) {
13216 return this.compile_isnotci(node);
13217 }
13218 else if (node.type == NODE_ISNOTCS) {
13219 return this.compile_isnotcs(node);
13220 }
13221 else if (node.type == NODE_ADD) {
13222 return this.compile_add(node);
13223 }
13224 else if (node.type == NODE_SUBTRACT) {
13225 return this.compile_subtract(node);
13226 }
13227 else if (node.type == NODE_CONCAT) {
13228 return this.compile_concat(node);
13229 }
13230 else if (node.type == NODE_MULTIPLY) {
13231 return this.compile_multiply(node);
13232 }
13233 else if (node.type == NODE_DIVIDE) {
13234 return this.compile_divide(node);
13235 }
13236 else if (node.type == NODE_REMAINDER) {
13237 return this.compile_remainder(node);
13238 }
13239 else if (node.type == NODE_NOT) {
13240 return this.compile_not(node);
13241 }
13242 else if (node.type == NODE_PLUS) {
13243 return this.compile_plus(node);
13244 }
13245 else if (node.type == NODE_MINUS) {
13246 return this.compile_minus(node);
13247 }
13248 else if (node.type == NODE_SUBSCRIPT) {
13249 return this.compile_subscript(node);
13250 }
13251 else if (node.type == NODE_SLICE) {
13252 return this.compile_slice(node);
13253 }
13254 else if (node.type == NODE_DOT) {
13255 return this.compile_dot(node);
13256 }
13257 else if (node.type == NODE_METHOD) {
13258 return this.compile_method(node);
13259 }
13260 else if (node.type == NODE_CALL) {
13261 return this.compile_call(node);
13262 }
13263 else if (node.type == NODE_NUMBER) {
13264 return this.compile_number(node);
13265 }
13266 else if (node.type == NODE_BLOB) {
13267 return this.compile_blob(node);
13268 }
13269 else if (node.type == NODE_STRING) {
13270 return this.compile_string(node);
13271 }
13272 else if (node.type == NODE_LIST) {
13273 return this.compile_list(node);
13274 }
13275 else if (node.type == NODE_DICT) {
13276 return this.compile_dict(node);
13277 }
13278 else if (node.type == NODE_OPTION) {
13279 return this.compile_option(node);
13280 }
13281 else if (node.type == NODE_IDENTIFIER) {
13282 return this.compile_identifier(node);
13283 }
13284 else if (node.type == NODE_CURLYNAME) {
13285 return this.compile_curlyname(node);
13286 }
13287 else if (node.type == NODE_ENV) {
13288 return this.compile_env(node);
13289 }
13290 else if (node.type == NODE_REG) {
13291 return this.compile_reg(node);
13292 }
13293 else if (node.type == NODE_CURLYNAMEPART) {
13294 return this.compile_curlynamepart(node);
13295 }
13296 else if (node.type == NODE_CURLYNAMEEXPR) {
13297 return this.compile_curlynameexpr(node);
13298 }
13299 else if (node.type == NODE_LAMBDA) {
13300 return this.compile_lambda(node);
13301 }
13302 else if (node.type == NODE_HEREDOC) {
13303 return this.compile_heredoc(node);
13304 }
13305 else {
13306 throw viml_printf("Compiler: unknown node: %s", viml_string(node));
13307 }
13308 return NIL;
13309}
13310
13311Compiler.prototype.compile_body = function(body) {
13312 var __c10 = body;
13313 for (var __i10 = 0; __i10 < __c10.length; ++__i10) {
13314 var node = __c10[__i10];
13315 this.compile(node);
13316 }
13317}
13318
13319Compiler.prototype.compile_toplevel = function(node) {
13320 this.compile_body(node.body);
13321 return this.lines;
13322}
13323
13324Compiler.prototype.compile_comment = function(node) {
13325 this.out(";%s", node.str);
13326}
13327
13328Compiler.prototype.compile_excmd = function(node) {
13329 this.out("(excmd \"%s\")", viml_escape(node.str, "\\\""));
13330}
13331
13332Compiler.prototype.compile_function = function(node) {
13333 var left = this.compile(node.left);
13334 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
13335 var default_args = node.default_args.map((function(vval) { return this.compile(vval); }).bind(this));
13336 if (!viml_empty(rlist)) {
13337 var remaining = FALSE;
13338 if (rlist[rlist.length - 1] == "...") {
13339 viml_remove(rlist, -1);
13340 var remaining = TRUE;
13341 }
13342 var __c11 = viml_range(viml_len(rlist));
13343 for (var __i11 = 0; __i11 < __c11.length; ++__i11) {
13344 var i = __c11[__i11];
13345 if (i < viml_len(rlist) - viml_len(default_args)) {
13346 left += viml_printf(" %s", rlist[i]);
13347 }
13348 else {
13349 left += viml_printf(" (%s %s)", rlist[i], default_args[i + viml_len(default_args) - viml_len(rlist)]);
13350 }
13351 }
13352 if (remaining) {
13353 left += " . ...";
13354 }
13355 }
13356 this.out("(function (%s)", left);
13357 this.incindent(" ");
13358 this.compile_body(node.body);
13359 this.out(")");
13360 this.decindent();
13361}
13362
13363Compiler.prototype.compile_delfunction = function(node) {
13364 this.out("(delfunction %s)", this.compile(node.left));
13365}
13366
13367Compiler.prototype.compile_return = function(node) {
13368 if (node.left === NIL) {
13369 this.out("(return)");
13370 }
13371 else {
13372 this.out("(return %s)", this.compile(node.left));
13373 }
13374}
13375
13376Compiler.prototype.compile_excall = function(node) {
13377 this.out("(call %s)", this.compile(node.left));
13378}
13379
13380Compiler.prototype.compile_eval = function(node) {
13381 this.out("(eval %s)", this.compile(node.left));
13382}
13383
13384Compiler.prototype.compile_let = function(node) {
13385 var left = "";
13386 if (node.left !== NIL) {
13387 var left = this.compile(node.left);
13388 }
13389 else {
13390 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
13391 if (node.rest !== NIL) {
13392 left += " . " + this.compile(node.rest);
13393 }
13394 var left = "(" + left + ")";
13395 }
13396 var right = this.compile(node.right);
13397 this.out("(let %s %s %s)", node.op, left, right);
13398}
13399
13400// TODO: merge with s:Compiler.compile_let() ?
13401Compiler.prototype.compile_const = function(node) {
13402 var left = "";
13403 if (node.left !== NIL) {
13404 var left = this.compile(node.left);
13405 }
13406 else {
13407 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
13408 if (node.rest !== NIL) {
13409 left += " . " + this.compile(node.rest);
13410 }
13411 var left = "(" + left + ")";
13412 }
13413 var right = this.compile(node.right);
13414 this.out("(const %s %s %s)", node.op, left, right);
13415}
13416
13417Compiler.prototype.compile_unlet = function(node) {
13418 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13419 this.out("(unlet %s)", viml_join(list, " "));
13420}
13421
13422Compiler.prototype.compile_lockvar = function(node) {
13423 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13424 if (node.depth === NIL) {
13425 this.out("(lockvar %s)", viml_join(list, " "));
13426 }
13427 else {
13428 this.out("(lockvar %s %s)", node.depth, viml_join(list, " "));
13429 }
13430}
13431
13432Compiler.prototype.compile_unlockvar = function(node) {
13433 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13434 if (node.depth === NIL) {
13435 this.out("(unlockvar %s)", viml_join(list, " "));
13436 }
13437 else {
13438 this.out("(unlockvar %s %s)", node.depth, viml_join(list, " "));
13439 }
13440}
13441
13442Compiler.prototype.compile_if = function(node) {
13443 this.out("(if %s", this.compile(node.cond));
13444 this.incindent(" ");
13445 this.compile_body(node.body);
13446 this.decindent();
13447 var __c12 = node.elseif;
13448 for (var __i12 = 0; __i12 < __c12.length; ++__i12) {
13449 var enode = __c12[__i12];
13450 this.out(" elseif %s", this.compile(enode.cond));
13451 this.incindent(" ");
13452 this.compile_body(enode.body);
13453 this.decindent();
13454 }
13455 if (node._else !== NIL) {
13456 this.out(" else");
13457 this.incindent(" ");
13458 this.compile_body(node._else.body);
13459 this.decindent();
13460 }
13461 this.incindent(" ");
13462 this.out(")");
13463 this.decindent();
13464}
13465
13466Compiler.prototype.compile_while = function(node) {
13467 this.out("(while %s", this.compile(node.cond));
13468 this.incindent(" ");
13469 this.compile_body(node.body);
13470 this.out(")");
13471 this.decindent();
13472}
13473
13474Compiler.prototype.compile_for = function(node) {
13475 var left = "";
13476 if (node.left !== NIL) {
13477 var left = this.compile(node.left);
13478 }
13479 else {
13480 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
13481 if (node.rest !== NIL) {
13482 left += " . " + this.compile(node.rest);
13483 }
13484 var left = "(" + left + ")";
13485 }
13486 var right = this.compile(node.right);
13487 this.out("(for %s %s", left, right);
13488 this.incindent(" ");
13489 this.compile_body(node.body);
13490 this.out(")");
13491 this.decindent();
13492}
13493
13494Compiler.prototype.compile_continue = function(node) {
13495 this.out("(continue)");
13496}
13497
13498Compiler.prototype.compile_break = function(node) {
13499 this.out("(break)");
13500}
13501
13502Compiler.prototype.compile_try = function(node) {
13503 this.out("(try");
13504 this.incindent(" ");
13505 this.compile_body(node.body);
13506 var __c13 = node.catch;
13507 for (var __i13 = 0; __i13 < __c13.length; ++__i13) {
13508 var cnode = __c13[__i13];
13509 if (cnode.pattern !== NIL) {
13510 this.decindent();
13511 this.out(" catch /%s/", cnode.pattern);
13512 this.incindent(" ");
13513 this.compile_body(cnode.body);
13514 }
13515 else {
13516 this.decindent();
13517 this.out(" catch");
13518 this.incindent(" ");
13519 this.compile_body(cnode.body);
13520 }
13521 }
13522 if (node._finally !== NIL) {
13523 this.decindent();
13524 this.out(" finally");
13525 this.incindent(" ");
13526 this.compile_body(node._finally.body);
13527 }
13528 this.out(")");
13529 this.decindent();
13530}
13531
13532Compiler.prototype.compile_throw = function(node) {
13533 this.out("(throw %s)", this.compile(node.left));
13534}
13535
13536Compiler.prototype.compile_echo = function(node) {
13537 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13538 this.out("(echo %s)", viml_join(list, " "));
13539}
13540
13541Compiler.prototype.compile_echon = function(node) {
13542 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13543 this.out("(echon %s)", viml_join(list, " "));
13544}
13545
13546Compiler.prototype.compile_echohl = function(node) {
13547 this.out("(echohl \"%s\")", viml_escape(node.str, "\\\""));
13548}
13549
13550Compiler.prototype.compile_echomsg = function(node) {
13551 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13552 this.out("(echomsg %s)", viml_join(list, " "));
13553}
13554
13555Compiler.prototype.compile_echoerr = function(node) {
13556 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13557 this.out("(echoerr %s)", viml_join(list, " "));
13558}
13559
13560Compiler.prototype.compile_execute = function(node) {
13561 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
13562 this.out("(execute %s)", viml_join(list, " "));
13563}
13564
13565Compiler.prototype.compile_ternary = function(node) {
13566 return viml_printf("(?: %s %s %s)", this.compile(node.cond), this.compile(node.left), this.compile(node.right));
13567}
13568
13569Compiler.prototype.compile_or = function(node) {
13570 return viml_printf("(|| %s %s)", this.compile(node.left), this.compile(node.right));
13571}
13572
13573Compiler.prototype.compile_and = function(node) {
13574 return viml_printf("(&& %s %s)", this.compile(node.left), this.compile(node.right));
13575}
13576
13577Compiler.prototype.compile_equal = function(node) {
13578 return viml_printf("(== %s %s)", this.compile(node.left), this.compile(node.right));
13579}
13580
13581Compiler.prototype.compile_equalci = function(node) {
13582 return viml_printf("(==? %s %s)", this.compile(node.left), this.compile(node.right));
13583}
13584
13585Compiler.prototype.compile_equalcs = function(node) {
13586 return viml_printf("(==# %s %s)", this.compile(node.left), this.compile(node.right));
13587}
13588
13589Compiler.prototype.compile_nequal = function(node) {
13590 return viml_printf("(!= %s %s)", this.compile(node.left), this.compile(node.right));
13591}
13592
13593Compiler.prototype.compile_nequalci = function(node) {
13594 return viml_printf("(!=? %s %s)", this.compile(node.left), this.compile(node.right));
13595}
13596
13597Compiler.prototype.compile_nequalcs = function(node) {
13598 return viml_printf("(!=# %s %s)", this.compile(node.left), this.compile(node.right));
13599}
13600
13601Compiler.prototype.compile_greater = function(node) {
13602 return viml_printf("(> %s %s)", this.compile(node.left), this.compile(node.right));
13603}
13604
13605Compiler.prototype.compile_greaterci = function(node) {
13606 return viml_printf("(>? %s %s)", this.compile(node.left), this.compile(node.right));
13607}
13608
13609Compiler.prototype.compile_greatercs = function(node) {
13610 return viml_printf("(># %s %s)", this.compile(node.left), this.compile(node.right));
13611}
13612
13613Compiler.prototype.compile_gequal = function(node) {
13614 return viml_printf("(>= %s %s)", this.compile(node.left), this.compile(node.right));
13615}
13616
13617Compiler.prototype.compile_gequalci = function(node) {
13618 return viml_printf("(>=? %s %s)", this.compile(node.left), this.compile(node.right));
13619}
13620
13621Compiler.prototype.compile_gequalcs = function(node) {
13622 return viml_printf("(>=# %s %s)", this.compile(node.left), this.compile(node.right));
13623}
13624
13625Compiler.prototype.compile_smaller = function(node) {
13626 return viml_printf("(< %s %s)", this.compile(node.left), this.compile(node.right));
13627}
13628
13629Compiler.prototype.compile_smallerci = function(node) {
13630 return viml_printf("(<? %s %s)", this.compile(node.left), this.compile(node.right));
13631}
13632
13633Compiler.prototype.compile_smallercs = function(node) {
13634 return viml_printf("(<# %s %s)", this.compile(node.left), this.compile(node.right));
13635}
13636
13637Compiler.prototype.compile_sequal = function(node) {
13638 return viml_printf("(<= %s %s)", this.compile(node.left), this.compile(node.right));
13639}
13640
13641Compiler.prototype.compile_sequalci = function(node) {
13642 return viml_printf("(<=? %s %s)", this.compile(node.left), this.compile(node.right));
13643}
13644
13645Compiler.prototype.compile_sequalcs = function(node) {
13646 return viml_printf("(<=# %s %s)", this.compile(node.left), this.compile(node.right));
13647}
13648
13649Compiler.prototype.compile_match = function(node) {
13650 return viml_printf("(=~ %s %s)", this.compile(node.left), this.compile(node.right));
13651}
13652
13653Compiler.prototype.compile_matchci = function(node) {
13654 return viml_printf("(=~? %s %s)", this.compile(node.left), this.compile(node.right));
13655}
13656
13657Compiler.prototype.compile_matchcs = function(node) {
13658 return viml_printf("(=~# %s %s)", this.compile(node.left), this.compile(node.right));
13659}
13660
13661Compiler.prototype.compile_nomatch = function(node) {
13662 return viml_printf("(!~ %s %s)", this.compile(node.left), this.compile(node.right));
13663}
13664
13665Compiler.prototype.compile_nomatchci = function(node) {
13666 return viml_printf("(!~? %s %s)", this.compile(node.left), this.compile(node.right));
13667}
13668
13669Compiler.prototype.compile_nomatchcs = function(node) {
13670 return viml_printf("(!~# %s %s)", this.compile(node.left), this.compile(node.right));
13671}
13672
13673Compiler.prototype.compile_is = function(node) {
13674 return viml_printf("(is %s %s)", this.compile(node.left), this.compile(node.right));
13675}
13676
13677Compiler.prototype.compile_isci = function(node) {
13678 return viml_printf("(is? %s %s)", this.compile(node.left), this.compile(node.right));
13679}
13680
13681Compiler.prototype.compile_iscs = function(node) {
13682 return viml_printf("(is# %s %s)", this.compile(node.left), this.compile(node.right));
13683}
13684
13685Compiler.prototype.compile_isnot = function(node) {
13686 return viml_printf("(isnot %s %s)", this.compile(node.left), this.compile(node.right));
13687}
13688
13689Compiler.prototype.compile_isnotci = function(node) {
13690 return viml_printf("(isnot? %s %s)", this.compile(node.left), this.compile(node.right));
13691}
13692
13693Compiler.prototype.compile_isnotcs = function(node) {
13694 return viml_printf("(isnot# %s %s)", this.compile(node.left), this.compile(node.right));
13695}
13696
13697Compiler.prototype.compile_add = function(node) {
13698 return viml_printf("(+ %s %s)", this.compile(node.left), this.compile(node.right));
13699}
13700
13701Compiler.prototype.compile_subtract = function(node) {
13702 return viml_printf("(- %s %s)", this.compile(node.left), this.compile(node.right));
13703}
13704
13705Compiler.prototype.compile_concat = function(node) {
13706 return viml_printf("(concat %s %s)", this.compile(node.left), this.compile(node.right));
13707}
13708
13709Compiler.prototype.compile_multiply = function(node) {
13710 return viml_printf("(* %s %s)", this.compile(node.left), this.compile(node.right));
13711}
13712
13713Compiler.prototype.compile_divide = function(node) {
13714 return viml_printf("(/ %s %s)", this.compile(node.left), this.compile(node.right));
13715}
13716
13717Compiler.prototype.compile_remainder = function(node) {
13718 return viml_printf("(%% %s %s)", this.compile(node.left), this.compile(node.right));
13719}
13720
13721Compiler.prototype.compile_not = function(node) {
13722 return viml_printf("(! %s)", this.compile(node.left));
13723}
13724
13725Compiler.prototype.compile_plus = function(node) {
13726 return viml_printf("(+ %s)", this.compile(node.left));
13727}
13728
13729Compiler.prototype.compile_minus = function(node) {
13730 return viml_printf("(- %s)", this.compile(node.left));
13731}
13732
13733Compiler.prototype.compile_subscript = function(node) {
13734 return viml_printf("(subscript %s %s)", this.compile(node.left), this.compile(node.right));
13735}
13736
13737Compiler.prototype.compile_slice = function(node) {
13738 var r0 = node.rlist[0] === NIL ? "nil" : this.compile(node.rlist[0]);
13739 var r1 = node.rlist[1] === NIL ? "nil" : this.compile(node.rlist[1]);
13740 return viml_printf("(slice %s %s %s)", this.compile(node.left), r0, r1);
13741}
13742
13743Compiler.prototype.compile_dot = function(node) {
13744 return viml_printf("(dot %s %s)", this.compile(node.left), this.compile(node.right));
13745}
13746
13747Compiler.prototype.compile_method = function(node) {
13748 return viml_printf("(method %s %s)", this.compile(node.left), this.compile(node.right));
13749}
13750
13751Compiler.prototype.compile_call = function(node) {
13752 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
13753 if (viml_empty(rlist)) {
13754 return viml_printf("(%s)", this.compile(node.left));
13755 }
13756 else {
13757 return viml_printf("(%s %s)", this.compile(node.left), viml_join(rlist, " "));
13758 }
13759}
13760
13761Compiler.prototype.compile_number = function(node) {
13762 return node.value;
13763}
13764
13765Compiler.prototype.compile_blob = function(node) {
13766 return node.value;
13767}
13768
13769Compiler.prototype.compile_string = function(node) {
13770 return node.value;
13771}
13772
13773Compiler.prototype.compile_list = function(node) {
13774 var value = node.value.map((function(vval) { return this.compile(vval); }).bind(this));
13775 if (viml_empty(value)) {
13776 return "(list)";
13777 }
13778 else {
13779 return viml_printf("(list %s)", viml_join(value, " "));
13780 }
13781}
13782
13783Compiler.prototype.compile_dict = function(node) {
13784 var value = node.value.map((function(vval) { return "(" + this.compile(vval[0]) + " " + this.compile(vval[1]) + ")"; }).bind(this));
13785 if (viml_empty(value)) {
13786 return "(dict)";
13787 }
13788 else {
13789 return viml_printf("(dict %s)", viml_join(value, " "));
13790 }
13791}
13792
13793Compiler.prototype.compile_option = function(node) {
13794 return node.value;
13795}
13796
13797Compiler.prototype.compile_identifier = function(node) {
13798 return node.value;
13799}
13800
13801Compiler.prototype.compile_curlyname = function(node) {
13802 return viml_join(node.value.map((function(vval) { return this.compile(vval); }).bind(this)), "");
13803}
13804
13805Compiler.prototype.compile_env = function(node) {
13806 return node.value;
13807}
13808
13809Compiler.prototype.compile_reg = function(node) {
13810 return node.value;
13811}
13812
13813Compiler.prototype.compile_curlynamepart = function(node) {
13814 return node.value;
13815}
13816
13817Compiler.prototype.compile_curlynameexpr = function(node) {
13818 return "{" + this.compile(node.value) + "}";
13819}
13820
13821Compiler.prototype.escape_string = function(str) {
13822 var m = {"\n":"\\n", "\t":"\\t", "\r":"\\r"};
13823 var out = "\"";
13824 var __c14 = viml_range(viml_len(str));
13825 for (var __i14 = 0; __i14 < __c14.length; ++__i14) {
13826 var i = __c14[__i14];
13827 var c = str[i];
13828 if (viml_has_key(m, c)) {
13829 out += m[c];
13830 }
13831 else {
13832 out += c;
13833 }
13834 }
13835 out += "\"";
13836 return out;
13837}
13838
13839Compiler.prototype.compile_lambda = function(node) {
13840 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
13841 return viml_printf("(lambda (%s) %s)", viml_join(rlist, " "), this.compile(node.left));
13842}
13843
13844Compiler.prototype.compile_heredoc = function(node) {
13845 if (viml_empty(node.rlist)) {
13846 var rlist = "(list)";
13847 }
13848 else {
13849 var rlist = "(list " + viml_join(node.rlist.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
13850 }
13851 if (viml_empty(node.body)) {
13852 var body = "(list)";
13853 }
13854 else {
13855 var body = "(list " + viml_join(node.body.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
13856 }
13857 var op = this.escape_string(node.op);
13858 return viml_printf("(heredoc %s %s %s)", rlist, op, body);
13859}
13860
13861// TODO: under construction
13862function RegexpParser() { this.__init__.apply(this, arguments); }
13863RegexpParser.prototype.RE_VERY_NOMAGIC = 1;
13864RegexpParser.prototype.RE_NOMAGIC = 2;
13865RegexpParser.prototype.RE_MAGIC = 3;
13866RegexpParser.prototype.RE_VERY_MAGIC = 4;
13867RegexpParser.prototype.__init__ = function(reader, cmd, delim) {
13868 this.reader = reader;
13869 this.cmd = cmd;
13870 this.delim = delim;
13871 this.reg_magic = this.RE_MAGIC;
13872}
13873
13874RegexpParser.prototype.isend = function(c) {
13875 return c == "<EOF>" || c == "<EOL>" || c == this.delim;
13876}
13877
13878RegexpParser.prototype.parse_regexp = function() {
13879 var prevtoken = "";
13880 var ntoken = "";
13881 var ret = [];
13882 if (this.reader.peekn(4) == "\\%#=") {
13883 var epos = this.reader.getpos();
13884 var token = this.reader.getn(5);
13885 if (token != "\\%#=0" && token != "\\%#=1" && token != "\\%#=2") {
13886 throw Err("E864: \\%#= can only be followed by 0, 1, or 2", epos);
13887 }
13888 viml_add(ret, token);
13889 }
13890 while (!this.isend(this.reader.peek())) {
13891 var prevtoken = ntoken;
13892 var __tmp = this.get_token();
13893 var token = __tmp[0];
13894 var ntoken = __tmp[1];
13895 if (ntoken == "\\m") {
13896 this.reg_magic = this.RE_MAGIC;
13897 }
13898 else if (ntoken == "\\M") {
13899 this.reg_magic = this.RE_NOMAGIC;
13900 }
13901 else if (ntoken == "\\v") {
13902 this.reg_magic = this.RE_VERY_MAGIC;
13903 }
13904 else if (ntoken == "\\V") {
13905 this.reg_magic = this.RE_VERY_NOMAGIC;
13906 }
13907 else if (ntoken == "\\*") {
13908 // '*' is not magic as the very first character.
13909 if (prevtoken == "" || prevtoken == "\\^" || prevtoken == "\\&" || prevtoken == "\\|" || prevtoken == "\\(") {
13910 var ntoken = "*";
13911 }
13912 }
13913 else if (ntoken == "\\^") {
13914 // '^' is only magic as the very first character.
13915 if (this.reg_magic != this.RE_VERY_MAGIC && prevtoken != "" && prevtoken != "\\&" && prevtoken != "\\|" && prevtoken != "\\n" && prevtoken != "\\(" && prevtoken != "\\%(") {
13916 var ntoken = "^";
13917 }
13918 }
13919 else if (ntoken == "\\$") {
13920 // '$' is only magic as the very last character
13921 var pos = this.reader.tell();
13922 if (this.reg_magic != this.RE_VERY_MAGIC) {
13923 while (!this.isend(this.reader.peek())) {
13924 var __tmp = this.get_token();
13925 var t = __tmp[0];
13926 var n = __tmp[1];
13927 // XXX: Vim doesn't check \v and \V?
13928 if (n == "\\c" || n == "\\C" || n == "\\m" || n == "\\M" || n == "\\Z") {
13929 continue;
13930 }
13931 if (n != "\\|" && n != "\\&" && n != "\\n" && n != "\\)") {
13932 var ntoken = "$";
13933 }
13934 break;
13935 }
13936 }
13937 this.reader.seek_set(pos);
13938 }
13939 else if (ntoken == "\\?") {
13940 // '?' is literal in '?' command.
13941 if (this.cmd == "?") {
13942 var ntoken = "?";
13943 }
13944 }
13945 viml_add(ret, ntoken);
13946 }
13947 return ret;
13948}
13949
13950// @return [actual_token, normalized_token]
13951RegexpParser.prototype.get_token = function() {
13952 if (this.reg_magic == this.RE_VERY_MAGIC) {
13953 return this.get_token_very_magic();
13954 }
13955 else if (this.reg_magic == this.RE_MAGIC) {
13956 return this.get_token_magic();
13957 }
13958 else if (this.reg_magic == this.RE_NOMAGIC) {
13959 return this.get_token_nomagic();
13960 }
13961 else if (this.reg_magic == this.RE_VERY_NOMAGIC) {
13962 return this.get_token_very_nomagic();
13963 }
13964}
13965
13966RegexpParser.prototype.get_token_very_magic = function() {
13967 if (this.isend(this.reader.peek())) {
13968 return ["<END>", "<END>"];
13969 }
13970 var c = this.reader.get();
13971 if (c == "\\") {
13972 return this.get_token_backslash_common();
13973 }
13974 else if (c == "*") {
13975 return ["*", "\\*"];
13976 }
13977 else if (c == "+") {
13978 return ["+", "\\+"];
13979 }
13980 else if (c == "=") {
13981 return ["=", "\\="];
13982 }
13983 else if (c == "?") {
13984 return ["?", "\\?"];
13985 }
13986 else if (c == "{") {
13987 return this.get_token_brace("{");
13988 }
13989 else if (c == "@") {
13990 return this.get_token_at("@");
13991 }
13992 else if (c == "^") {
13993 return ["^", "\\^"];
13994 }
13995 else if (c == "$") {
13996 return ["$", "\\$"];
13997 }
13998 else if (c == ".") {
13999 return [".", "\\."];
14000 }
14001 else if (c == "<") {
14002 return ["<", "\\<"];
14003 }
14004 else if (c == ">") {
14005 return [">", "\\>"];
14006 }
14007 else if (c == "%") {
14008 return this.get_token_percent("%");
14009 }
14010 else if (c == "[") {
14011 return this.get_token_sq("[");
14012 }
14013 else if (c == "~") {
14014 return ["~", "\\~"];
14015 }
14016 else if (c == "|") {
14017 return ["|", "\\|"];
14018 }
14019 else if (c == "&") {
14020 return ["&", "\\&"];
14021 }
14022 else if (c == "(") {
14023 return ["(", "\\("];
14024 }
14025 else if (c == ")") {
14026 return [")", "\\)"];
14027 }
14028 return [c, c];
14029}
14030
14031RegexpParser.prototype.get_token_magic = function() {
14032 if (this.isend(this.reader.peek())) {
14033 return ["<END>", "<END>"];
14034 }
14035 var c = this.reader.get();
14036 if (c == "\\") {
14037 var pos = this.reader.tell();
14038 var c = this.reader.get();
14039 if (c == "+") {
14040 return ["\\+", "\\+"];
14041 }
14042 else if (c == "=") {
14043 return ["\\=", "\\="];
14044 }
14045 else if (c == "?") {
14046 return ["\\?", "\\?"];
14047 }
14048 else if (c == "{") {
14049 return this.get_token_brace("\\{");
14050 }
14051 else if (c == "@") {
14052 return this.get_token_at("\\@");
14053 }
14054 else if (c == "<") {
14055 return ["\\<", "\\<"];
14056 }
14057 else if (c == ">") {
14058 return ["\\>", "\\>"];
14059 }
14060 else if (c == "%") {
14061 return this.get_token_percent("\\%");
14062 }
14063 else if (c == "|") {
14064 return ["\\|", "\\|"];
14065 }
14066 else if (c == "&") {
14067 return ["\\&", "\\&"];
14068 }
14069 else if (c == "(") {
14070 return ["\\(", "\\("];
14071 }
14072 else if (c == ")") {
14073 return ["\\)", "\\)"];
14074 }
14075 this.reader.seek_set(pos);
14076 return this.get_token_backslash_common();
14077 }
14078 else if (c == "*") {
14079 return ["*", "\\*"];
14080 }
14081 else if (c == "^") {
14082 return ["^", "\\^"];
14083 }
14084 else if (c == "$") {
14085 return ["$", "\\$"];
14086 }
14087 else if (c == ".") {
14088 return [".", "\\."];
14089 }
14090 else if (c == "[") {
14091 return this.get_token_sq("[");
14092 }
14093 else if (c == "~") {
14094 return ["~", "\\~"];
14095 }
14096 return [c, c];
14097}
14098
14099RegexpParser.prototype.get_token_nomagic = function() {
14100 if (this.isend(this.reader.peek())) {
14101 return ["<END>", "<END>"];
14102 }
14103 var c = this.reader.get();
14104 if (c == "\\") {
14105 var pos = this.reader.tell();
14106 var c = this.reader.get();
14107 if (c == "*") {
14108 return ["\\*", "\\*"];
14109 }
14110 else if (c == "+") {
14111 return ["\\+", "\\+"];
14112 }
14113 else if (c == "=") {
14114 return ["\\=", "\\="];
14115 }
14116 else if (c == "?") {
14117 return ["\\?", "\\?"];
14118 }
14119 else if (c == "{") {
14120 return this.get_token_brace("\\{");
14121 }
14122 else if (c == "@") {
14123 return this.get_token_at("\\@");
14124 }
14125 else if (c == ".") {
14126 return ["\\.", "\\."];
14127 }
14128 else if (c == "<") {
14129 return ["\\<", "\\<"];
14130 }
14131 else if (c == ">") {
14132 return ["\\>", "\\>"];
14133 }
14134 else if (c == "%") {
14135 return this.get_token_percent("\\%");
14136 }
14137 else if (c == "~") {
14138 return ["\\~", "\\^"];
14139 }
14140 else if (c == "[") {
14141 return this.get_token_sq("\\[");
14142 }
14143 else if (c == "|") {
14144 return ["\\|", "\\|"];
14145 }
14146 else if (c == "&") {
14147 return ["\\&", "\\&"];
14148 }
14149 else if (c == "(") {
14150 return ["\\(", "\\("];
14151 }
14152 else if (c == ")") {
14153 return ["\\)", "\\)"];
14154 }
14155 this.reader.seek_set(pos);
14156 return this.get_token_backslash_common();
14157 }
14158 else if (c == "^") {
14159 return ["^", "\\^"];
14160 }
14161 else if (c == "$") {
14162 return ["$", "\\$"];
14163 }
14164 return [c, c];
14165}
14166
14167RegexpParser.prototype.get_token_very_nomagic = function() {
14168 if (this.isend(this.reader.peek())) {
14169 return ["<END>", "<END>"];
14170 }
14171 var c = this.reader.get();
14172 if (c == "\\") {
14173 var pos = this.reader.tell();
14174 var c = this.reader.get();
14175 if (c == "*") {
14176 return ["\\*", "\\*"];
14177 }
14178 else if (c == "+") {
14179 return ["\\+", "\\+"];
14180 }
14181 else if (c == "=") {
14182 return ["\\=", "\\="];
14183 }
14184 else if (c == "?") {
14185 return ["\\?", "\\?"];
14186 }
14187 else if (c == "{") {
14188 return this.get_token_brace("\\{");
14189 }
14190 else if (c == "@") {
14191 return this.get_token_at("\\@");
14192 }
14193 else if (c == "^") {
14194 return ["\\^", "\\^"];
14195 }
14196 else if (c == "$") {
14197 return ["\\$", "\\$"];
14198 }
14199 else if (c == "<") {
14200 return ["\\<", "\\<"];
14201 }
14202 else if (c == ">") {
14203 return ["\\>", "\\>"];
14204 }
14205 else if (c == "%") {
14206 return this.get_token_percent("\\%");
14207 }
14208 else if (c == "~") {
14209 return ["\\~", "\\~"];
14210 }
14211 else if (c == "[") {
14212 return this.get_token_sq("\\[");
14213 }
14214 else if (c == "|") {
14215 return ["\\|", "\\|"];
14216 }
14217 else if (c == "&") {
14218 return ["\\&", "\\&"];
14219 }
14220 else if (c == "(") {
14221 return ["\\(", "\\("];
14222 }
14223 else if (c == ")") {
14224 return ["\\)", "\\)"];
14225 }
14226 this.reader.seek_set(pos);
14227 return this.get_token_backslash_common();
14228 }
14229 return [c, c];
14230}
14231
14232RegexpParser.prototype.get_token_backslash_common = function() {
14233 var cclass = "iIkKfFpPsSdDxXoOwWhHaAlLuU";
14234 var c = this.reader.get();
14235 if (c == "\\") {
14236 return ["\\\\", "\\\\"];
14237 }
14238 else if (viml_stridx(cclass, c) != -1) {
14239 return ["\\" + c, "\\" + c];
14240 }
14241 else if (c == "_") {
14242 var epos = this.reader.getpos();
14243 var c = this.reader.get();
14244 if (viml_stridx(cclass, c) != -1) {
14245 return ["\\_" + c, "\\_ . c"];
14246 }
14247 else if (c == "^") {
14248 return ["\\_^", "\\_^"];
14249 }
14250 else if (c == "$") {
14251 return ["\\_$", "\\_$"];
14252 }
14253 else if (c == ".") {
14254 return ["\\_.", "\\_."];
14255 }
14256 else if (c == "[") {
14257 return this.get_token_sq("\\_[");
14258 }
14259 throw Err("E63: Invalid use of \\_", epos);
14260 }
14261 else if (viml_stridx("etrb", c) != -1) {
14262 return ["\\" + c, "\\" + c];
14263 }
14264 else if (viml_stridx("123456789", c) != -1) {
14265 return ["\\" + c, "\\" + c];
14266 }
14267 else if (c == "z") {
14268 var epos = this.reader.getpos();
14269 var c = this.reader.get();
14270 if (viml_stridx("123456789", c) != -1) {
14271 return ["\\z" + c, "\\z" + c];
14272 }
14273 else if (c == "s") {
14274 return ["\\zs", "\\zs"];
14275 }
14276 else if (c == "e") {
14277 return ["\\ze", "\\ze"];
14278 }
14279 else if (c == "(") {
14280 return ["\\z(", "\\z("];
14281 }
14282 throw Err("E68: Invalid character after \\z", epos);
14283 }
14284 else if (viml_stridx("cCmMvVZ", c) != -1) {
14285 return ["\\" + c, "\\" + c];
14286 }
14287 else if (c == "%") {
14288 var epos = this.reader.getpos();
14289 var c = this.reader.get();
14290 if (c == "d") {
14291 var r = this.getdecchrs();
14292 if (r != "") {
14293 return ["\\%d" + r, "\\%d" + r];
14294 }
14295 }
14296 else if (c == "o") {
14297 var r = this.getoctchrs();
14298 if (r != "") {
14299 return ["\\%o" + r, "\\%o" + r];
14300 }
14301 }
14302 else if (c == "x") {
14303 var r = this.gethexchrs(2);
14304 if (r != "") {
14305 return ["\\%x" + r, "\\%x" + r];
14306 }
14307 }
14308 else if (c == "u") {
14309 var r = this.gethexchrs(4);
14310 if (r != "") {
14311 return ["\\%u" + r, "\\%u" + r];
14312 }
14313 }
14314 else if (c == "U") {
14315 var r = this.gethexchrs(8);
14316 if (r != "") {
14317 return ["\\%U" + r, "\\%U" + r];
14318 }
14319 }
14320 throw Err("E678: Invalid character after \\%[dxouU]", epos);
14321 }
14322 return ["\\" + c, c];
14323}
14324
14325// \{}
14326RegexpParser.prototype.get_token_brace = function(pre) {
14327 var r = "";
14328 var minus = "";
14329 var comma = "";
14330 var n = "";
14331 var m = "";
14332 if (this.reader.p(0) == "-") {
14333 var minus = this.reader.get();
14334 r += minus;
14335 }
14336 if (isdigit(this.reader.p(0))) {
14337 var n = this.reader.read_digit();
14338 r += n;
14339 }
14340 if (this.reader.p(0) == ",") {
14341 var comma = this.rader.get();
14342 r += comma;
14343 }
14344 if (isdigit(this.reader.p(0))) {
14345 var m = this.reader.read_digit();
14346 r += m;
14347 }
14348 if (this.reader.p(0) == "\\") {
14349 r += this.reader.get();
14350 }
14351 if (this.reader.p(0) != "}") {
14352 throw Err("E554: Syntax error in \\{...}", this.reader.getpos());
14353 }
14354 this.reader.get();
14355 return [pre + r, "\\{" + minus + n + comma + m + "}"];
14356}
14357
14358// \[]
14359RegexpParser.prototype.get_token_sq = function(pre) {
14360 var start = this.reader.tell();
14361 var r = "";
14362 // Complement of range
14363 if (this.reader.p(0) == "^") {
14364 r += this.reader.get();
14365 }
14366 // At the start ']' and '-' mean the literal character.
14367 if (this.reader.p(0) == "]" || this.reader.p(0) == "-") {
14368 r += this.reader.get();
14369 }
14370 while (TRUE) {
14371 var startc = 0;
14372 var c = this.reader.p(0);
14373 if (this.isend(c)) {
14374 // If there is no matching ']', we assume the '[' is a normal character.
14375 this.reader.seek_set(start);
14376 return [pre, "["];
14377 }
14378 else if (c == "]") {
14379 this.reader.seek_cur(1);
14380 return [pre + r + "]", "\\[" + r + "]"];
14381 }
14382 else if (c == "[") {
14383 var e = this.get_token_sq_char_class();
14384 if (e == "") {
14385 var e = this.get_token_sq_equi_class();
14386 if (e == "") {
14387 var e = this.get_token_sq_coll_element();
14388 if (e == "") {
14389 var __tmp = this.get_token_sq_c();
14390 var e = __tmp[0];
14391 var startc = __tmp[1];
14392 }
14393 }
14394 }
14395 r += e;
14396 }
14397 else {
14398 var __tmp = this.get_token_sq_c();
14399 var e = __tmp[0];
14400 var startc = __tmp[1];
14401 r += e;
14402 }
14403 if (startc != 0 && this.reader.p(0) == "-" && !this.isend(this.reader.p(1)) && !(this.reader.p(1) == "\\" && this.reader.p(2) == "n")) {
14404 this.reader.seek_cur(1);
14405 r += "-";
14406 var c = this.reader.p(0);
14407 if (c == "[") {
14408 var e = this.get_token_sq_coll_element();
14409 if (e != "") {
14410 var endc = viml_char2nr(e[2]);
14411 }
14412 else {
14413 var __tmp = this.get_token_sq_c();
14414 var e = __tmp[0];
14415 var endc = __tmp[1];
14416 }
14417 r += e;
14418 }
14419 else {
14420 var __tmp = this.get_token_sq_c();
14421 var e = __tmp[0];
14422 var endc = __tmp[1];
14423 r += e;
14424 }
14425 if (startc > endc || endc > startc + 256) {
14426 throw Err("E16: Invalid range", this.reader.getpos());
14427 }
14428 }
14429 }
14430}
14431
14432// [c]
14433RegexpParser.prototype.get_token_sq_c = function() {
14434 var c = this.reader.p(0);
14435 if (c == "\\") {
14436 this.reader.seek_cur(1);
14437 var c = this.reader.p(0);
14438 if (c == "n") {
14439 this.reader.seek_cur(1);
14440 return ["\\n", 0];
14441 }
14442 else if (c == "r") {
14443 this.reader.seek_cur(1);
14444 return ["\\r", 13];
14445 }
14446 else if (c == "t") {
14447 this.reader.seek_cur(1);
14448 return ["\\t", 9];
14449 }
14450 else if (c == "e") {
14451 this.reader.seek_cur(1);
14452 return ["\\e", 27];
14453 }
14454 else if (c == "b") {
14455 this.reader.seek_cur(1);
14456 return ["\\b", 8];
14457 }
14458 else if (viml_stridx("]^-\\", c) != -1) {
14459 this.reader.seek_cur(1);
14460 return ["\\" + c, viml_char2nr(c)];
14461 }
14462 else if (viml_stridx("doxuU", c) != -1) {
14463 var __tmp = this.get_token_sq_coll_char();
14464 var c = __tmp[0];
14465 var n = __tmp[1];
14466 return [c, n];
14467 }
14468 else {
14469 return ["\\", viml_char2nr("\\")];
14470 }
14471 }
14472 else if (c == "-") {
14473 this.reader.seek_cur(1);
14474 return ["-", viml_char2nr("-")];
14475 }
14476 else {
14477 this.reader.seek_cur(1);
14478 return [c, viml_char2nr(c)];
14479 }
14480}
14481
14482// [\d123]
14483RegexpParser.prototype.get_token_sq_coll_char = function() {
14484 var pos = this.reader.tell();
14485 var c = this.reader.get();
14486 if (c == "d") {
14487 var r = this.getdecchrs();
14488 var n = viml_str2nr(r, 10);
14489 }
14490 else if (c == "o") {
14491 var r = this.getoctchrs();
14492 var n = viml_str2nr(r, 8);
14493 }
14494 else if (c == "x") {
14495 var r = this.gethexchrs(2);
14496 var n = viml_str2nr(r, 16);
14497 }
14498 else if (c == "u") {
14499 var r = this.gethexchrs(4);
14500 var n = viml_str2nr(r, 16);
14501 }
14502 else if (c == "U") {
14503 var r = this.gethexchrs(8);
14504 var n = viml_str2nr(r, 16);
14505 }
14506 else {
14507 var r = "";
14508 }
14509 if (r == "") {
14510 this.reader.seek_set(pos);
14511 return "\\";
14512 }
14513 return ["\\" + c + r, n];
14514}
14515
14516// [[.a.]]
14517RegexpParser.prototype.get_token_sq_coll_element = function() {
14518 if (this.reader.p(0) == "[" && this.reader.p(1) == "." && !this.isend(this.reader.p(2)) && this.reader.p(3) == "." && this.reader.p(4) == "]") {
14519 return this.reader.getn(5);
14520 }
14521 return "";
14522}
14523
14524// [[=a=]]
14525RegexpParser.prototype.get_token_sq_equi_class = function() {
14526 if (this.reader.p(0) == "[" && this.reader.p(1) == "=" && !this.isend(this.reader.p(2)) && this.reader.p(3) == "=" && this.reader.p(4) == "]") {
14527 return this.reader.getn(5);
14528 }
14529 return "";
14530}
14531
14532// [[:alpha:]]
14533RegexpParser.prototype.get_token_sq_char_class = function() {
14534 var class_names = ["alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "xdigit", "tab", "return", "backspace", "escape"];
14535 var pos = this.reader.tell();
14536 if (this.reader.p(0) == "[" && this.reader.p(1) == ":") {
14537 this.reader.seek_cur(2);
14538 var r = this.reader.read_alpha();
14539 if (this.reader.p(0) == ":" && this.reader.p(1) == "]") {
14540 this.reader.seek_cur(2);
14541 var __c15 = class_names;
14542 for (var __i15 = 0; __i15 < __c15.length; ++__i15) {
14543 var name = __c15[__i15];
14544 if (r == name) {
14545 return "[:" + name + ":]";
14546 }
14547 }
14548 }
14549 }
14550 this.reader.seek_set(pos);
14551 return "";
14552}
14553
14554// \@...
14555RegexpParser.prototype.get_token_at = function(pre) {
14556 var epos = this.reader.getpos();
14557 var c = this.reader.get();
14558 if (c == ">") {
14559 return [pre + ">", "\\@>"];
14560 }
14561 else if (c == "=") {
14562 return [pre + "=", "\\@="];
14563 }
14564 else if (c == "!") {
14565 return [pre + "!", "\\@!"];
14566 }
14567 else if (c == "<") {
14568 var c = this.reader.get();
14569 if (c == "=") {
14570 return [pre + "<=", "\\@<="];
14571 }
14572 else if (c == "!") {
14573 return [pre + "<!", "\\@<!"];
14574 }
14575 }
14576 throw Err("E64: @ follows nothing", epos);
14577}
14578
14579// \%...
14580RegexpParser.prototype.get_token_percent = function(pre) {
14581 var c = this.reader.get();
14582 if (c == "^") {
14583 return [pre + "^", "\\%^"];
14584 }
14585 else if (c == "$") {
14586 return [pre + "$", "\\%$"];
14587 }
14588 else if (c == "V") {
14589 return [pre + "V", "\\%V"];
14590 }
14591 else if (c == "#") {
14592 return [pre + "#", "\\%#"];
14593 }
14594 else if (c == "[") {
14595 return this.get_token_percent_sq(pre + "[");
14596 }
14597 else if (c == "(") {
14598 return [pre + "(", "\\%("];
14599 }
14600 else {
14601 return this.get_token_mlcv(pre);
14602 }
14603}
14604
14605// \%[]
14606RegexpParser.prototype.get_token_percent_sq = function(pre) {
14607 var r = "";
14608 while (TRUE) {
14609 var c = this.reader.peek();
14610 if (this.isend(c)) {
14611 throw Err("E69: Missing ] after \\%[", this.reader.getpos());
14612 }
14613 else if (c == "]") {
14614 if (r == "") {
14615 throw Err("E70: Empty \\%[", this.reader.getpos());
14616 }
14617 this.reader.seek_cur(1);
14618 break;
14619 }
14620 this.reader.seek_cur(1);
14621 r += c;
14622 }
14623 return [pre + r + "]", "\\%[" + r + "]"];
14624}
14625
14626// \%'m \%l \%c \%v
14627RegexpParser.prototype.get_token_mlvc = function(pre) {
14628 var r = "";
14629 var cmp = "";
14630 if (this.reader.p(0) == "<" || this.reader.p(0) == ">") {
14631 var cmp = this.reader.get();
14632 r += cmp;
14633 }
14634 if (this.reader.p(0) == "'") {
14635 r += this.reader.get();
14636 var c = this.reader.p(0);
14637 if (this.isend(c)) {
14638 // FIXME: Should be error? Vim allow this.
14639 var c = "";
14640 }
14641 else {
14642 var c = this.reader.get();
14643 }
14644 return [pre + r + c, "\\%" + cmp + "'" + c];
14645 }
14646 else if (isdigit(this.reader.p(0))) {
14647 var d = this.reader.read_digit();
14648 r += d;
14649 var c = this.reader.p(0);
14650 if (c == "l") {
14651 this.reader.get();
14652 return [pre + r + "l", "\\%" + cmp + d + "l"];
14653 }
14654 else if (c == "c") {
14655 this.reader.get();
14656 return [pre + r + "c", "\\%" + cmp + d + "c"];
14657 }
14658 else if (c == "v") {
14659 this.reader.get();
14660 return [pre + r + "v", "\\%" + cmp + d + "v"];
14661 }
14662 }
14663 throw Err("E71: Invalid character after %", this.reader.getpos());
14664}
14665
14666RegexpParser.prototype.getdecchrs = function() {
14667 return this.reader.read_digit();
14668}
14669
14670RegexpParser.prototype.getoctchrs = function() {
14671 return this.reader.read_odigit();
14672}
14673
14674RegexpParser.prototype.gethexchrs = function(n) {
14675 var r = "";
14676 var __c16 = viml_range(n);
14677 for (var __i16 = 0; __i16 < __c16.length; ++__i16) {
14678 var i = __c16[__i16];
14679 var c = this.reader.peek();
14680 if (!isxdigit(c)) {
14681 break;
14682 }
14683 r += this.reader.get();
14684 }
14685 return r;
14686}
14687
14688if (__webpack_require__.c[__webpack_require__.s] === module) {
14689 main();
14690}
14691else {
14692 module.exports = {
14693 VimLParser: VimLParser,
14694 StringReader: StringReader,
14695 Compiler: Compiler
14696 };
14697}
14698
14699
14700/***/ }),
14701
14702/***/ 41:
14703/***/ ((module) => {
14704
14705"use strict";
14706module.exports = require("child_process");;
14707
14708/***/ }),
14709
14710/***/ 15:
14711/***/ ((module) => {
14712
14713"use strict";
14714module.exports = require("crypto");;
14715
14716/***/ }),
14717
14718/***/ 51:
14719/***/ ((module) => {
14720
14721"use strict";
14722module.exports = require("events");;
14723
14724/***/ }),
14725
14726/***/ 40:
14727/***/ ((module) => {
14728
14729"use strict";
14730module.exports = require("fs");;
14731
14732/***/ }),
14733
14734/***/ 16:
14735/***/ ((module) => {
14736
14737"use strict";
14738module.exports = require("net");;
14739
14740/***/ }),
14741
14742/***/ 14:
14743/***/ ((module) => {
14744
14745"use strict";
14746module.exports = require("os");;
14747
14748/***/ }),
14749
14750/***/ 13:
14751/***/ ((module) => {
14752
14753"use strict";
14754module.exports = require("path");;
14755
14756/***/ }),
14757
14758/***/ 39:
14759/***/ ((module) => {
14760
14761"use strict";
14762module.exports = require("url");;
14763
14764/***/ }),
14765
14766/***/ 48:
14767/***/ ((module) => {
14768
14769"use strict";
14770module.exports = require("util");;
14771
14772/***/ })
14773
14774/******/ });
14775/************************************************************************/
14776/******/ // The module cache
14777/******/ var __webpack_module_cache__ = {};
14778/******/
14779/******/ // The require function
14780/******/ function __webpack_require__(moduleId) {
14781/******/ // Check if module is in cache
14782/******/ if(__webpack_module_cache__[moduleId]) {
14783/******/ return __webpack_module_cache__[moduleId].exports;
14784/******/ }
14785/******/ // Create a new module (and put it into the cache)
14786/******/ var module = __webpack_module_cache__[moduleId] = {
14787/******/ id: moduleId,
14788/******/ loaded: false,
14789/******/ exports: {}
14790/******/ };
14791/******/
14792/******/ // Execute the module function
14793/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
14794/******/
14795/******/ // Flag the module as loaded
14796/******/ module.loaded = true;
14797/******/
14798/******/ // Return the exports of the module
14799/******/ return module.exports;
14800/******/ }
14801/******/
14802/******/ // expose the module cache
14803/******/ __webpack_require__.c = __webpack_module_cache__;
14804/******/
14805/************************************************************************/
14806/******/ /* webpack/runtime/define property getters */
14807/******/ (() => {
14808/******/ // define getter functions for harmony exports
14809/******/ __webpack_require__.d = (exports, definition) => {
14810/******/ for(var key in definition) {
14811/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
14812/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14813/******/ }
14814/******/ }
14815/******/ };
14816/******/ })();
14817/******/
14818/******/ /* webpack/runtime/hasOwnProperty shorthand */
14819/******/ (() => {
14820/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
14821/******/ })();
14822/******/
14823/******/ /* webpack/runtime/make namespace object */
14824/******/ (() => {
14825/******/ // define __esModule on exports
14826/******/ __webpack_require__.r = (exports) => {
14827/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
14828/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
14829/******/ }
14830/******/ Object.defineProperty(exports, '__esModule', { value: true });
14831/******/ };
14832/******/ })();
14833/******/
14834/******/ /* webpack/runtime/node module decorator */
14835/******/ (() => {
14836/******/ __webpack_require__.nmd = (module) => {
14837/******/ module.paths = [];
14838/******/ if (!module.children) module.children = [];
14839/******/ return module;
14840/******/ };
14841/******/ })();
14842/******/
14843/************************************************************************/
14844/******/ // module cache are used so entry inlining is disabled
14845/******/ // startup
14846/******/ // Load entry module and return exports
14847/******/ return __webpack_require__(__webpack_require__.s = 370);
14848/******/ })()
14849
14850));
\No newline at end of file