UNPKG

619 kBJavaScriptView Raw
1(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
2/******/ // The module cache
3/******/ var installedModules = {};
4/******/
5/******/ // The require function
6/******/ function __webpack_require__(moduleId) {
7/******/
8/******/ // Check if module is in cache
9/******/ if(installedModules[moduleId]) {
10/******/ return installedModules[moduleId].exports;
11/******/ }
12/******/ // Create a new module (and put it into the cache)
13/******/ var module = installedModules[moduleId] = {
14/******/ i: moduleId,
15/******/ l: false,
16/******/ exports: {}
17/******/ };
18/******/
19/******/ // Execute the module function
20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ // Flag the module as loaded
23/******/ module.l = true;
24/******/
25/******/ // Return the exports of the module
26/******/ return module.exports;
27/******/ }
28/******/
29/******/
30/******/ // expose the modules object (__webpack_modules__)
31/******/ __webpack_require__.m = modules;
32/******/
33/******/ // expose the module cache
34/******/ __webpack_require__.c = installedModules;
35/******/
36/******/ // define getter function for harmony exports
37/******/ __webpack_require__.d = function(exports, name, getter) {
38/******/ if(!__webpack_require__.o(exports, name)) {
39/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40/******/ }
41/******/ };
42/******/
43/******/ // define __esModule on exports
44/******/ __webpack_require__.r = function(exports) {
45/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47/******/ }
48/******/ Object.defineProperty(exports, '__esModule', { value: true });
49/******/ };
50/******/
51/******/ // create a fake namespace object
52/******/ // mode & 1: value is a module id, require it
53/******/ // mode & 2: merge all properties of value into the ns
54/******/ // mode & 4: return value when already ns object
55/******/ // mode & 8|1: behave like require
56/******/ __webpack_require__.t = function(value, mode) {
57/******/ if(mode & 1) value = __webpack_require__(value);
58/******/ if(mode & 8) return value;
59/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60/******/ var ns = Object.create(null);
61/******/ __webpack_require__.r(ns);
62/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64/******/ return ns;
65/******/ };
66/******/
67/******/ // getDefaultExport function for compatibility with non-harmony modules
68/******/ __webpack_require__.n = function(module) {
69/******/ var getter = module && module.__esModule ?
70/******/ function getDefault() { return module['default']; } :
71/******/ function getModuleExports() { return module; };
72/******/ __webpack_require__.d(getter, 'a', getter);
73/******/ return getter;
74/******/ };
75/******/
76/******/ // Object.prototype.hasOwnProperty.call
77/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78/******/
79/******/ // __webpack_public_path__
80/******/ __webpack_require__.p = "";
81/******/
82/******/
83/******/ // Load entry module and return exports
84/******/ return __webpack_require__(__webpack_require__.s = 370);
85/******/ })
86/************************************************************************/
87/******/ ({
88
89/***/ 10:
90/***/ (function(module, exports, __webpack_require__) {
91
92"use strict";
93/*---------------------------------------------------------------------------------------------
94 * Copyright (c) Microsoft Corporation. All rights reserved.
95 * Licensed under the MIT License. See License.txt in the project root for license information.
96 *--------------------------------------------------------------------------------------------*/
97
98Object.defineProperty(exports, "__esModule", { value: true });
99const events_1 = __webpack_require__(8);
100const Is = __webpack_require__(5);
101var CancellationToken;
102(function (CancellationToken) {
103 CancellationToken.None = Object.freeze({
104 isCancellationRequested: false,
105 onCancellationRequested: events_1.Event.None
106 });
107 CancellationToken.Cancelled = Object.freeze({
108 isCancellationRequested: true,
109 onCancellationRequested: events_1.Event.None
110 });
111 function is(value) {
112 let candidate = value;
113 return candidate && (candidate === CancellationToken.None
114 || candidate === CancellationToken.Cancelled
115 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
116 }
117 CancellationToken.is = is;
118})(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
119const shortcutEvent = Object.freeze(function (callback, context) {
120 let handle = setTimeout(callback.bind(context), 0);
121 return { dispose() { clearTimeout(handle); } };
122});
123class MutableToken {
124 constructor() {
125 this._isCancelled = false;
126 }
127 cancel() {
128 if (!this._isCancelled) {
129 this._isCancelled = true;
130 if (this._emitter) {
131 this._emitter.fire(undefined);
132 this.dispose();
133 }
134 }
135 }
136 get isCancellationRequested() {
137 return this._isCancelled;
138 }
139 get onCancellationRequested() {
140 if (this._isCancelled) {
141 return shortcutEvent;
142 }
143 if (!this._emitter) {
144 this._emitter = new events_1.Emitter();
145 }
146 return this._emitter.event;
147 }
148 dispose() {
149 if (this._emitter) {
150 this._emitter.dispose();
151 this._emitter = undefined;
152 }
153 }
154}
155class CancellationTokenSource {
156 get token() {
157 if (!this._token) {
158 // be lazy and create the token only when
159 // actually needed
160 this._token = new MutableToken();
161 }
162 return this._token;
163 }
164 cancel() {
165 if (!this._token) {
166 // save an object by returning the default
167 // cancelled token when cancellation happens
168 // before someone asks for the token
169 this._token = CancellationToken.Cancelled;
170 }
171 else {
172 this._token.cancel();
173 }
174 }
175 dispose() {
176 if (!this._token) {
177 // ensure to initialize with an empty token if we had none
178 this._token = CancellationToken.None;
179 }
180 else if (this._token instanceof MutableToken) {
181 // actually dispose
182 this._token.dispose();
183 }
184 }
185}
186exports.CancellationTokenSource = CancellationTokenSource;
187
188
189/***/ }),
190
191/***/ 11:
192/***/ (function(module, exports, __webpack_require__) {
193
194"use strict";
195
196/*---------------------------------------------------------------------------------------------
197 * Copyright (c) Microsoft Corporation. All rights reserved.
198 * Licensed under the MIT License. See License.txt in the project root for license information.
199 *--------------------------------------------------------------------------------------------*/
200Object.defineProperty(exports, "__esModule", { value: true });
201var Touch;
202(function (Touch) {
203 Touch.None = 0;
204 Touch.First = 1;
205 Touch.Last = 2;
206})(Touch = exports.Touch || (exports.Touch = {}));
207class LinkedMap {
208 constructor() {
209 this._map = new Map();
210 this._head = undefined;
211 this._tail = undefined;
212 this._size = 0;
213 }
214 clear() {
215 this._map.clear();
216 this._head = undefined;
217 this._tail = undefined;
218 this._size = 0;
219 }
220 isEmpty() {
221 return !this._head && !this._tail;
222 }
223 get size() {
224 return this._size;
225 }
226 has(key) {
227 return this._map.has(key);
228 }
229 get(key) {
230 const item = this._map.get(key);
231 if (!item) {
232 return undefined;
233 }
234 return item.value;
235 }
236 set(key, value, touch = Touch.None) {
237 let item = this._map.get(key);
238 if (item) {
239 item.value = value;
240 if (touch !== Touch.None) {
241 this.touch(item, touch);
242 }
243 }
244 else {
245 item = { key, value, next: undefined, previous: undefined };
246 switch (touch) {
247 case Touch.None:
248 this.addItemLast(item);
249 break;
250 case Touch.First:
251 this.addItemFirst(item);
252 break;
253 case Touch.Last:
254 this.addItemLast(item);
255 break;
256 default:
257 this.addItemLast(item);
258 break;
259 }
260 this._map.set(key, item);
261 this._size++;
262 }
263 }
264 delete(key) {
265 const item = this._map.get(key);
266 if (!item) {
267 return false;
268 }
269 this._map.delete(key);
270 this.removeItem(item);
271 this._size--;
272 return true;
273 }
274 shift() {
275 if (!this._head && !this._tail) {
276 return undefined;
277 }
278 if (!this._head || !this._tail) {
279 throw new Error('Invalid list');
280 }
281 const item = this._head;
282 this._map.delete(item.key);
283 this.removeItem(item);
284 this._size--;
285 return item.value;
286 }
287 forEach(callbackfn, thisArg) {
288 let current = this._head;
289 while (current) {
290 if (thisArg) {
291 callbackfn.bind(thisArg)(current.value, current.key, this);
292 }
293 else {
294 callbackfn(current.value, current.key, this);
295 }
296 current = current.next;
297 }
298 }
299 forEachReverse(callbackfn, thisArg) {
300 let current = this._tail;
301 while (current) {
302 if (thisArg) {
303 callbackfn.bind(thisArg)(current.value, current.key, this);
304 }
305 else {
306 callbackfn(current.value, current.key, this);
307 }
308 current = current.previous;
309 }
310 }
311 values() {
312 let result = [];
313 let current = this._head;
314 while (current) {
315 result.push(current.value);
316 current = current.next;
317 }
318 return result;
319 }
320 keys() {
321 let result = [];
322 let current = this._head;
323 while (current) {
324 result.push(current.key);
325 current = current.next;
326 }
327 return result;
328 }
329 /* JSON RPC run on es5 which has no Symbol.iterator
330 public keys(): IterableIterator<K> {
331 let current = this._head;
332 let iterator: IterableIterator<K> = {
333 [Symbol.iterator]() {
334 return iterator;
335 },
336 next():IteratorResult<K> {
337 if (current) {
338 let result = { value: current.key, done: false };
339 current = current.next;
340 return result;
341 } else {
342 return { value: undefined, done: true };
343 }
344 }
345 };
346 return iterator;
347 }
348
349 public values(): IterableIterator<V> {
350 let current = this._head;
351 let iterator: IterableIterator<V> = {
352 [Symbol.iterator]() {
353 return iterator;
354 },
355 next():IteratorResult<V> {
356 if (current) {
357 let result = { value: current.value, done: false };
358 current = current.next;
359 return result;
360 } else {
361 return { value: undefined, done: true };
362 }
363 }
364 };
365 return iterator;
366 }
367 */
368 addItemFirst(item) {
369 // First time Insert
370 if (!this._head && !this._tail) {
371 this._tail = item;
372 }
373 else if (!this._head) {
374 throw new Error('Invalid list');
375 }
376 else {
377 item.next = this._head;
378 this._head.previous = item;
379 }
380 this._head = item;
381 }
382 addItemLast(item) {
383 // First time Insert
384 if (!this._head && !this._tail) {
385 this._head = item;
386 }
387 else if (!this._tail) {
388 throw new Error('Invalid list');
389 }
390 else {
391 item.previous = this._tail;
392 this._tail.next = item;
393 }
394 this._tail = item;
395 }
396 removeItem(item) {
397 if (item === this._head && item === this._tail) {
398 this._head = undefined;
399 this._tail = undefined;
400 }
401 else if (item === this._head) {
402 this._head = item.next;
403 }
404 else if (item === this._tail) {
405 this._tail = item.previous;
406 }
407 else {
408 const next = item.next;
409 const previous = item.previous;
410 if (!next || !previous) {
411 throw new Error('Invalid list');
412 }
413 next.previous = previous;
414 previous.next = next;
415 }
416 }
417 touch(item, touch) {
418 if (!this._head || !this._tail) {
419 throw new Error('Invalid list');
420 }
421 if ((touch !== Touch.First && touch !== Touch.Last)) {
422 return;
423 }
424 if (touch === Touch.First) {
425 if (item === this._head) {
426 return;
427 }
428 const next = item.next;
429 const previous = item.previous;
430 // Unlink the item
431 if (item === this._tail) {
432 // previous must be defined since item was not head but is tail
433 // So there are more than on item in the map
434 previous.next = undefined;
435 this._tail = previous;
436 }
437 else {
438 // Both next and previous are not undefined since item was neither head nor tail.
439 next.previous = previous;
440 previous.next = next;
441 }
442 // Insert the node at head
443 item.previous = undefined;
444 item.next = this._head;
445 this._head.previous = item;
446 this._head = item;
447 }
448 else if (touch === Touch.Last) {
449 if (item === this._tail) {
450 return;
451 }
452 const next = item.next;
453 const previous = item.previous;
454 // Unlink the item.
455 if (item === this._head) {
456 // next must be defined since item was not tail but is head
457 // So there are more than on item in the map
458 next.previous = undefined;
459 this._head = next;
460 }
461 else {
462 // Both next and previous are not undefined since item was neither head nor tail.
463 next.previous = previous;
464 previous.next = next;
465 }
466 item.next = undefined;
467 item.previous = this._tail;
468 this._tail.next = item;
469 this._tail = item;
470 }
471 }
472}
473exports.LinkedMap = LinkedMap;
474
475
476/***/ }),
477
478/***/ 12:
479/***/ (function(module, exports, __webpack_require__) {
480
481"use strict";
482/* --------------------------------------------------------------------------------------------
483 * Copyright (c) Microsoft Corporation. All rights reserved.
484 * Licensed under the MIT License. See License.txt in the project root for license information.
485 * ------------------------------------------------------------------------------------------ */
486
487Object.defineProperty(exports, "__esModule", { value: true });
488const path_1 = __webpack_require__(13);
489const os_1 = __webpack_require__(14);
490const crypto_1 = __webpack_require__(15);
491const net_1 = __webpack_require__(16);
492const messageReader_1 = __webpack_require__(7);
493const messageWriter_1 = __webpack_require__(9);
494function generateRandomPipeName() {
495 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
496 if (process.platform === 'win32') {
497 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
498 }
499 else {
500 // Mac/Unix: use socket file
501 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
502 }
503}
504exports.generateRandomPipeName = generateRandomPipeName;
505function createClientPipeTransport(pipeName, encoding = 'utf-8') {
506 let connectResolve;
507 let connected = new Promise((resolve, _reject) => {
508 connectResolve = resolve;
509 });
510 return new Promise((resolve, reject) => {
511 let server = net_1.createServer((socket) => {
512 server.close();
513 connectResolve([
514 new messageReader_1.SocketMessageReader(socket, encoding),
515 new messageWriter_1.SocketMessageWriter(socket, encoding)
516 ]);
517 });
518 server.on('error', reject);
519 server.listen(pipeName, () => {
520 server.removeListener('error', reject);
521 resolve({
522 onConnected: () => { return connected; }
523 });
524 });
525 });
526}
527exports.createClientPipeTransport = createClientPipeTransport;
528function createServerPipeTransport(pipeName, encoding = 'utf-8') {
529 const socket = net_1.createConnection(pipeName);
530 return [
531 new messageReader_1.SocketMessageReader(socket, encoding),
532 new messageWriter_1.SocketMessageWriter(socket, encoding)
533 ];
534}
535exports.createServerPipeTransport = createServerPipeTransport;
536
537
538/***/ }),
539
540/***/ 13:
541/***/ (function(module, exports) {
542
543module.exports = require("path");
544
545/***/ }),
546
547/***/ 14:
548/***/ (function(module, exports) {
549
550module.exports = require("os");
551
552/***/ }),
553
554/***/ 15:
555/***/ (function(module, exports) {
556
557module.exports = require("crypto");
558
559/***/ }),
560
561/***/ 16:
562/***/ (function(module, exports) {
563
564module.exports = require("net");
565
566/***/ }),
567
568/***/ 17:
569/***/ (function(module, exports, __webpack_require__) {
570
571"use strict";
572/* --------------------------------------------------------------------------------------------
573 * Copyright (c) Microsoft Corporation. All rights reserved.
574 * Licensed under the MIT License. See License.txt in the project root for license information.
575 * ------------------------------------------------------------------------------------------ */
576
577Object.defineProperty(exports, "__esModule", { value: true });
578const net_1 = __webpack_require__(16);
579const messageReader_1 = __webpack_require__(7);
580const messageWriter_1 = __webpack_require__(9);
581function createClientSocketTransport(port, encoding = 'utf-8') {
582 let connectResolve;
583 let connected = new Promise((resolve, _reject) => {
584 connectResolve = resolve;
585 });
586 return new Promise((resolve, reject) => {
587 let server = net_1.createServer((socket) => {
588 server.close();
589 connectResolve([
590 new messageReader_1.SocketMessageReader(socket, encoding),
591 new messageWriter_1.SocketMessageWriter(socket, encoding)
592 ]);
593 });
594 server.on('error', reject);
595 server.listen(port, '127.0.0.1', () => {
596 server.removeListener('error', reject);
597 resolve({
598 onConnected: () => { return connected; }
599 });
600 });
601 });
602}
603exports.createClientSocketTransport = createClientSocketTransport;
604function createServerSocketTransport(port, encoding = 'utf-8') {
605 const socket = net_1.createConnection(port, '127.0.0.1');
606 return [
607 new messageReader_1.SocketMessageReader(socket, encoding),
608 new messageWriter_1.SocketMessageWriter(socket, encoding)
609 ];
610}
611exports.createServerSocketTransport = createServerSocketTransport;
612
613
614/***/ }),
615
616/***/ 18:
617/***/ (function(module, __webpack_exports__, __webpack_require__) {
618
619"use strict";
620__webpack_require__.r(__webpack_exports__);
621/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
622/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
623/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
624/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
625/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
626/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
627/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
628/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
629/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
630/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
631/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
632/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
633/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
634/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
635/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
636/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
637/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
638/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
639/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
640/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
641/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
642/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
643/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
644/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
645/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
646/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
647/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
648/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
649/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemTag", function() { return CompletionItemTag; });
650/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
651/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
652/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
653/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
654/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
655/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
656/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
657/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
658/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
659/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolTag", function() { return SymbolTag; });
660/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
661/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
662/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
663/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
664/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
665/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
666/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
667/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
668/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
669/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
670/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
671/* --------------------------------------------------------------------------------------------
672 * Copyright (c) Microsoft Corporation. All rights reserved.
673 * Licensed under the MIT License. See License.txt in the project root for license information.
674 * ------------------------------------------------------------------------------------------ */
675
676/**
677 * The Position namespace provides helper functions to work with
678 * [Position](#Position) literals.
679 */
680var Position;
681(function (Position) {
682 /**
683 * Creates a new Position literal from the given line and character.
684 * @param line The position's line.
685 * @param character The position's character.
686 */
687 function create(line, character) {
688 return { line: line, character: character };
689 }
690 Position.create = create;
691 /**
692 * Checks whether the given liternal conforms to the [Position](#Position) interface.
693 */
694 function is(value) {
695 var candidate = value;
696 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
697 }
698 Position.is = is;
699})(Position || (Position = {}));
700/**
701 * The Range namespace provides helper functions to work with
702 * [Range](#Range) literals.
703 */
704var Range;
705(function (Range) {
706 function create(one, two, three, four) {
707 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
708 return { start: Position.create(one, two), end: Position.create(three, four) };
709 }
710 else if (Position.is(one) && Position.is(two)) {
711 return { start: one, end: two };
712 }
713 else {
714 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
715 }
716 }
717 Range.create = create;
718 /**
719 * Checks whether the given literal conforms to the [Range](#Range) interface.
720 */
721 function is(value) {
722 var candidate = value;
723 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
724 }
725 Range.is = is;
726})(Range || (Range = {}));
727/**
728 * The Location namespace provides helper functions to work with
729 * [Location](#Location) literals.
730 */
731var Location;
732(function (Location) {
733 /**
734 * Creates a Location literal.
735 * @param uri The location's uri.
736 * @param range The location's range.
737 */
738 function create(uri, range) {
739 return { uri: uri, range: range };
740 }
741 Location.create = create;
742 /**
743 * Checks whether the given literal conforms to the [Location](#Location) interface.
744 */
745 function is(value) {
746 var candidate = value;
747 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
748 }
749 Location.is = is;
750})(Location || (Location = {}));
751/**
752 * The LocationLink namespace provides helper functions to work with
753 * [LocationLink](#LocationLink) literals.
754 */
755var LocationLink;
756(function (LocationLink) {
757 /**
758 * Creates a LocationLink literal.
759 * @param targetUri The definition's uri.
760 * @param targetRange The full range of the definition.
761 * @param targetSelectionRange The span of the symbol definition at the target.
762 * @param originSelectionRange The span of the symbol being defined in the originating source file.
763 */
764 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
765 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
766 }
767 LocationLink.create = create;
768 /**
769 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
770 */
771 function is(value) {
772 var candidate = value;
773 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
774 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
775 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
776 }
777 LocationLink.is = is;
778})(LocationLink || (LocationLink = {}));
779/**
780 * The Color namespace provides helper functions to work with
781 * [Color](#Color) literals.
782 */
783var Color;
784(function (Color) {
785 /**
786 * Creates a new Color literal.
787 */
788 function create(red, green, blue, alpha) {
789 return {
790 red: red,
791 green: green,
792 blue: blue,
793 alpha: alpha,
794 };
795 }
796 Color.create = create;
797 /**
798 * Checks whether the given literal conforms to the [Color](#Color) interface.
799 */
800 function is(value) {
801 var candidate = value;
802 return Is.number(candidate.red)
803 && Is.number(candidate.green)
804 && Is.number(candidate.blue)
805 && Is.number(candidate.alpha);
806 }
807 Color.is = is;
808})(Color || (Color = {}));
809/**
810 * The ColorInformation namespace provides helper functions to work with
811 * [ColorInformation](#ColorInformation) literals.
812 */
813var ColorInformation;
814(function (ColorInformation) {
815 /**
816 * Creates a new ColorInformation literal.
817 */
818 function create(range, color) {
819 return {
820 range: range,
821 color: color,
822 };
823 }
824 ColorInformation.create = create;
825 /**
826 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
827 */
828 function is(value) {
829 var candidate = value;
830 return Range.is(candidate.range) && Color.is(candidate.color);
831 }
832 ColorInformation.is = is;
833})(ColorInformation || (ColorInformation = {}));
834/**
835 * The Color namespace provides helper functions to work with
836 * [ColorPresentation](#ColorPresentation) literals.
837 */
838var ColorPresentation;
839(function (ColorPresentation) {
840 /**
841 * Creates a new ColorInformation literal.
842 */
843 function create(label, textEdit, additionalTextEdits) {
844 return {
845 label: label,
846 textEdit: textEdit,
847 additionalTextEdits: additionalTextEdits,
848 };
849 }
850 ColorPresentation.create = create;
851 /**
852 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
853 */
854 function is(value) {
855 var candidate = value;
856 return Is.string(candidate.label)
857 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
858 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
859 }
860 ColorPresentation.is = is;
861})(ColorPresentation || (ColorPresentation = {}));
862/**
863 * Enum of known range kinds
864 */
865var FoldingRangeKind;
866(function (FoldingRangeKind) {
867 /**
868 * Folding range for a comment
869 */
870 FoldingRangeKind["Comment"] = "comment";
871 /**
872 * Folding range for a imports or includes
873 */
874 FoldingRangeKind["Imports"] = "imports";
875 /**
876 * Folding range for a region (e.g. `#region`)
877 */
878 FoldingRangeKind["Region"] = "region";
879})(FoldingRangeKind || (FoldingRangeKind = {}));
880/**
881 * The folding range namespace provides helper functions to work with
882 * [FoldingRange](#FoldingRange) literals.
883 */
884var FoldingRange;
885(function (FoldingRange) {
886 /**
887 * Creates a new FoldingRange literal.
888 */
889 function create(startLine, endLine, startCharacter, endCharacter, kind) {
890 var result = {
891 startLine: startLine,
892 endLine: endLine
893 };
894 if (Is.defined(startCharacter)) {
895 result.startCharacter = startCharacter;
896 }
897 if (Is.defined(endCharacter)) {
898 result.endCharacter = endCharacter;
899 }
900 if (Is.defined(kind)) {
901 result.kind = kind;
902 }
903 return result;
904 }
905 FoldingRange.create = create;
906 /**
907 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
908 */
909 function is(value) {
910 var candidate = value;
911 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
912 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
913 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
914 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
915 }
916 FoldingRange.is = is;
917})(FoldingRange || (FoldingRange = {}));
918/**
919 * The DiagnosticRelatedInformation namespace provides helper functions to work with
920 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
921 */
922var DiagnosticRelatedInformation;
923(function (DiagnosticRelatedInformation) {
924 /**
925 * Creates a new DiagnosticRelatedInformation literal.
926 */
927 function create(location, message) {
928 return {
929 location: location,
930 message: message
931 };
932 }
933 DiagnosticRelatedInformation.create = create;
934 /**
935 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
936 */
937 function is(value) {
938 var candidate = value;
939 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
940 }
941 DiagnosticRelatedInformation.is = is;
942})(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
943/**
944 * The diagnostic's severity.
945 */
946var DiagnosticSeverity;
947(function (DiagnosticSeverity) {
948 /**
949 * Reports an error.
950 */
951 DiagnosticSeverity.Error = 1;
952 /**
953 * Reports a warning.
954 */
955 DiagnosticSeverity.Warning = 2;
956 /**
957 * Reports an information.
958 */
959 DiagnosticSeverity.Information = 3;
960 /**
961 * Reports a hint.
962 */
963 DiagnosticSeverity.Hint = 4;
964})(DiagnosticSeverity || (DiagnosticSeverity = {}));
965/**
966 * The diagnostic tags.
967 *
968 * @since 3.15.0
969 */
970var DiagnosticTag;
971(function (DiagnosticTag) {
972 /**
973 * Unused or unnecessary code.
974 *
975 * Clients are allowed to render diagnostics with this tag faded out instead of having
976 * an error squiggle.
977 */
978 DiagnosticTag.Unnecessary = 1;
979 /**
980 * Deprecated or obsolete code.
981 *
982 * Clients are allowed to rendered diagnostics with this tag strike through.
983 */
984 DiagnosticTag.Deprecated = 2;
985})(DiagnosticTag || (DiagnosticTag = {}));
986/**
987 * The Diagnostic namespace provides helper functions to work with
988 * [Diagnostic](#Diagnostic) literals.
989 */
990var Diagnostic;
991(function (Diagnostic) {
992 /**
993 * Creates a new Diagnostic literal.
994 */
995 function create(range, message, severity, code, source, relatedInformation) {
996 var result = { range: range, message: message };
997 if (Is.defined(severity)) {
998 result.severity = severity;
999 }
1000 if (Is.defined(code)) {
1001 result.code = code;
1002 }
1003 if (Is.defined(source)) {
1004 result.source = source;
1005 }
1006 if (Is.defined(relatedInformation)) {
1007 result.relatedInformation = relatedInformation;
1008 }
1009 return result;
1010 }
1011 Diagnostic.create = create;
1012 /**
1013 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
1014 */
1015 function is(value) {
1016 var candidate = value;
1017 return Is.defined(candidate)
1018 && Range.is(candidate.range)
1019 && Is.string(candidate.message)
1020 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
1021 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
1022 && (Is.string(candidate.source) || Is.undefined(candidate.source))
1023 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
1024 }
1025 Diagnostic.is = is;
1026})(Diagnostic || (Diagnostic = {}));
1027/**
1028 * The Command namespace provides helper functions to work with
1029 * [Command](#Command) literals.
1030 */
1031var Command;
1032(function (Command) {
1033 /**
1034 * Creates a new Command literal.
1035 */
1036 function create(title, command) {
1037 var args = [];
1038 for (var _i = 2; _i < arguments.length; _i++) {
1039 args[_i - 2] = arguments[_i];
1040 }
1041 var result = { title: title, command: command };
1042 if (Is.defined(args) && args.length > 0) {
1043 result.arguments = args;
1044 }
1045 return result;
1046 }
1047 Command.create = create;
1048 /**
1049 * Checks whether the given literal conforms to the [Command](#Command) interface.
1050 */
1051 function is(value) {
1052 var candidate = value;
1053 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
1054 }
1055 Command.is = is;
1056})(Command || (Command = {}));
1057/**
1058 * The TextEdit namespace provides helper function to create replace,
1059 * insert and delete edits more easily.
1060 */
1061var TextEdit;
1062(function (TextEdit) {
1063 /**
1064 * Creates a replace text edit.
1065 * @param range The range of text to be replaced.
1066 * @param newText The new text.
1067 */
1068 function replace(range, newText) {
1069 return { range: range, newText: newText };
1070 }
1071 TextEdit.replace = replace;
1072 /**
1073 * Creates a insert text edit.
1074 * @param position The position to insert the text at.
1075 * @param newText The text to be inserted.
1076 */
1077 function insert(position, newText) {
1078 return { range: { start: position, end: position }, newText: newText };
1079 }
1080 TextEdit.insert = insert;
1081 /**
1082 * Creates a delete text edit.
1083 * @param range The range of text to be deleted.
1084 */
1085 function del(range) {
1086 return { range: range, newText: '' };
1087 }
1088 TextEdit.del = del;
1089 function is(value) {
1090 var candidate = value;
1091 return Is.objectLiteral(candidate)
1092 && Is.string(candidate.newText)
1093 && Range.is(candidate.range);
1094 }
1095 TextEdit.is = is;
1096})(TextEdit || (TextEdit = {}));
1097/**
1098 * The TextDocumentEdit namespace provides helper function to create
1099 * an edit that manipulates a text document.
1100 */
1101var TextDocumentEdit;
1102(function (TextDocumentEdit) {
1103 /**
1104 * Creates a new `TextDocumentEdit`
1105 */
1106 function create(textDocument, edits) {
1107 return { textDocument: textDocument, edits: edits };
1108 }
1109 TextDocumentEdit.create = create;
1110 function is(value) {
1111 var candidate = value;
1112 return Is.defined(candidate)
1113 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
1114 && Array.isArray(candidate.edits);
1115 }
1116 TextDocumentEdit.is = is;
1117})(TextDocumentEdit || (TextDocumentEdit = {}));
1118var CreateFile;
1119(function (CreateFile) {
1120 function create(uri, options) {
1121 var result = {
1122 kind: 'create',
1123 uri: uri
1124 };
1125 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
1126 result.options = options;
1127 }
1128 return result;
1129 }
1130 CreateFile.create = create;
1131 function is(value) {
1132 var candidate = value;
1133 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
1134 (candidate.options === void 0 ||
1135 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
1136 }
1137 CreateFile.is = is;
1138})(CreateFile || (CreateFile = {}));
1139var RenameFile;
1140(function (RenameFile) {
1141 function create(oldUri, newUri, options) {
1142 var result = {
1143 kind: 'rename',
1144 oldUri: oldUri,
1145 newUri: newUri
1146 };
1147 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
1148 result.options = options;
1149 }
1150 return result;
1151 }
1152 RenameFile.create = create;
1153 function is(value) {
1154 var candidate = value;
1155 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
1156 (candidate.options === void 0 ||
1157 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
1158 }
1159 RenameFile.is = is;
1160})(RenameFile || (RenameFile = {}));
1161var DeleteFile;
1162(function (DeleteFile) {
1163 function create(uri, options) {
1164 var result = {
1165 kind: 'delete',
1166 uri: uri
1167 };
1168 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
1169 result.options = options;
1170 }
1171 return result;
1172 }
1173 DeleteFile.create = create;
1174 function is(value) {
1175 var candidate = value;
1176 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
1177 (candidate.options === void 0 ||
1178 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
1179 }
1180 DeleteFile.is = is;
1181})(DeleteFile || (DeleteFile = {}));
1182var WorkspaceEdit;
1183(function (WorkspaceEdit) {
1184 function is(value) {
1185 var candidate = value;
1186 return candidate &&
1187 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
1188 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
1189 if (Is.string(change.kind)) {
1190 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
1191 }
1192 else {
1193 return TextDocumentEdit.is(change);
1194 }
1195 }));
1196 }
1197 WorkspaceEdit.is = is;
1198})(WorkspaceEdit || (WorkspaceEdit = {}));
1199var TextEditChangeImpl = /** @class */ (function () {
1200 function TextEditChangeImpl(edits) {
1201 this.edits = edits;
1202 }
1203 TextEditChangeImpl.prototype.insert = function (position, newText) {
1204 this.edits.push(TextEdit.insert(position, newText));
1205 };
1206 TextEditChangeImpl.prototype.replace = function (range, newText) {
1207 this.edits.push(TextEdit.replace(range, newText));
1208 };
1209 TextEditChangeImpl.prototype.delete = function (range) {
1210 this.edits.push(TextEdit.del(range));
1211 };
1212 TextEditChangeImpl.prototype.add = function (edit) {
1213 this.edits.push(edit);
1214 };
1215 TextEditChangeImpl.prototype.all = function () {
1216 return this.edits;
1217 };
1218 TextEditChangeImpl.prototype.clear = function () {
1219 this.edits.splice(0, this.edits.length);
1220 };
1221 return TextEditChangeImpl;
1222}());
1223/**
1224 * A workspace change helps constructing changes to a workspace.
1225 */
1226var WorkspaceChange = /** @class */ (function () {
1227 function WorkspaceChange(workspaceEdit) {
1228 var _this = this;
1229 this._textEditChanges = Object.create(null);
1230 if (workspaceEdit) {
1231 this._workspaceEdit = workspaceEdit;
1232 if (workspaceEdit.documentChanges) {
1233 workspaceEdit.documentChanges.forEach(function (change) {
1234 if (TextDocumentEdit.is(change)) {
1235 var textEditChange = new TextEditChangeImpl(change.edits);
1236 _this._textEditChanges[change.textDocument.uri] = textEditChange;
1237 }
1238 });
1239 }
1240 else if (workspaceEdit.changes) {
1241 Object.keys(workspaceEdit.changes).forEach(function (key) {
1242 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
1243 _this._textEditChanges[key] = textEditChange;
1244 });
1245 }
1246 }
1247 }
1248 Object.defineProperty(WorkspaceChange.prototype, "edit", {
1249 /**
1250 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
1251 * use to be returned from a workspace edit operation like rename.
1252 */
1253 get: function () {
1254 return this._workspaceEdit;
1255 },
1256 enumerable: true,
1257 configurable: true
1258 });
1259 WorkspaceChange.prototype.getTextEditChange = function (key) {
1260 if (VersionedTextDocumentIdentifier.is(key)) {
1261 if (!this._workspaceEdit) {
1262 this._workspaceEdit = {
1263 documentChanges: []
1264 };
1265 }
1266 if (!this._workspaceEdit.documentChanges) {
1267 throw new Error('Workspace edit is not configured for document changes.');
1268 }
1269 var textDocument = key;
1270 var result = this._textEditChanges[textDocument.uri];
1271 if (!result) {
1272 var edits = [];
1273 var textDocumentEdit = {
1274 textDocument: textDocument,
1275 edits: edits
1276 };
1277 this._workspaceEdit.documentChanges.push(textDocumentEdit);
1278 result = new TextEditChangeImpl(edits);
1279 this._textEditChanges[textDocument.uri] = result;
1280 }
1281 return result;
1282 }
1283 else {
1284 if (!this._workspaceEdit) {
1285 this._workspaceEdit = {
1286 changes: Object.create(null)
1287 };
1288 }
1289 if (!this._workspaceEdit.changes) {
1290 throw new Error('Workspace edit is not configured for normal text edit changes.');
1291 }
1292 var result = this._textEditChanges[key];
1293 if (!result) {
1294 var edits = [];
1295 this._workspaceEdit.changes[key] = edits;
1296 result = new TextEditChangeImpl(edits);
1297 this._textEditChanges[key] = result;
1298 }
1299 return result;
1300 }
1301 };
1302 WorkspaceChange.prototype.createFile = function (uri, options) {
1303 this.checkDocumentChanges();
1304 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
1305 };
1306 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
1307 this.checkDocumentChanges();
1308 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
1309 };
1310 WorkspaceChange.prototype.deleteFile = function (uri, options) {
1311 this.checkDocumentChanges();
1312 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
1313 };
1314 WorkspaceChange.prototype.checkDocumentChanges = function () {
1315 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
1316 throw new Error('Workspace edit is not configured for document changes.');
1317 }
1318 };
1319 return WorkspaceChange;
1320}());
1321
1322/**
1323 * The TextDocumentIdentifier namespace provides helper functions to work with
1324 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
1325 */
1326var TextDocumentIdentifier;
1327(function (TextDocumentIdentifier) {
1328 /**
1329 * Creates a new TextDocumentIdentifier literal.
1330 * @param uri The document's uri.
1331 */
1332 function create(uri) {
1333 return { uri: uri };
1334 }
1335 TextDocumentIdentifier.create = create;
1336 /**
1337 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
1338 */
1339 function is(value) {
1340 var candidate = value;
1341 return Is.defined(candidate) && Is.string(candidate.uri);
1342 }
1343 TextDocumentIdentifier.is = is;
1344})(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
1345/**
1346 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
1347 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
1348 */
1349var VersionedTextDocumentIdentifier;
1350(function (VersionedTextDocumentIdentifier) {
1351 /**
1352 * Creates a new VersionedTextDocumentIdentifier literal.
1353 * @param uri The document's uri.
1354 * @param uri The document's text.
1355 */
1356 function create(uri, version) {
1357 return { uri: uri, version: version };
1358 }
1359 VersionedTextDocumentIdentifier.create = create;
1360 /**
1361 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
1362 */
1363 function is(value) {
1364 var candidate = value;
1365 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
1366 }
1367 VersionedTextDocumentIdentifier.is = is;
1368})(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
1369/**
1370 * The TextDocumentItem namespace provides helper functions to work with
1371 * [TextDocumentItem](#TextDocumentItem) literals.
1372 */
1373var TextDocumentItem;
1374(function (TextDocumentItem) {
1375 /**
1376 * Creates a new TextDocumentItem literal.
1377 * @param uri The document's uri.
1378 * @param languageId The document's language identifier.
1379 * @param version The document's version number.
1380 * @param text The document's text.
1381 */
1382 function create(uri, languageId, version, text) {
1383 return { uri: uri, languageId: languageId, version: version, text: text };
1384 }
1385 TextDocumentItem.create = create;
1386 /**
1387 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
1388 */
1389 function is(value) {
1390 var candidate = value;
1391 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
1392 }
1393 TextDocumentItem.is = is;
1394})(TextDocumentItem || (TextDocumentItem = {}));
1395/**
1396 * Describes the content type that a client supports in various
1397 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
1398 *
1399 * Please note that `MarkupKinds` must not start with a `$`. This kinds
1400 * are reserved for internal usage.
1401 */
1402var MarkupKind;
1403(function (MarkupKind) {
1404 /**
1405 * Plain text is supported as a content format
1406 */
1407 MarkupKind.PlainText = 'plaintext';
1408 /**
1409 * Markdown is supported as a content format
1410 */
1411 MarkupKind.Markdown = 'markdown';
1412})(MarkupKind || (MarkupKind = {}));
1413(function (MarkupKind) {
1414 /**
1415 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
1416 */
1417 function is(value) {
1418 var candidate = value;
1419 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
1420 }
1421 MarkupKind.is = is;
1422})(MarkupKind || (MarkupKind = {}));
1423var MarkupContent;
1424(function (MarkupContent) {
1425 /**
1426 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
1427 */
1428 function is(value) {
1429 var candidate = value;
1430 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
1431 }
1432 MarkupContent.is = is;
1433})(MarkupContent || (MarkupContent = {}));
1434/**
1435 * The kind of a completion entry.
1436 */
1437var CompletionItemKind;
1438(function (CompletionItemKind) {
1439 CompletionItemKind.Text = 1;
1440 CompletionItemKind.Method = 2;
1441 CompletionItemKind.Function = 3;
1442 CompletionItemKind.Constructor = 4;
1443 CompletionItemKind.Field = 5;
1444 CompletionItemKind.Variable = 6;
1445 CompletionItemKind.Class = 7;
1446 CompletionItemKind.Interface = 8;
1447 CompletionItemKind.Module = 9;
1448 CompletionItemKind.Property = 10;
1449 CompletionItemKind.Unit = 11;
1450 CompletionItemKind.Value = 12;
1451 CompletionItemKind.Enum = 13;
1452 CompletionItemKind.Keyword = 14;
1453 CompletionItemKind.Snippet = 15;
1454 CompletionItemKind.Color = 16;
1455 CompletionItemKind.File = 17;
1456 CompletionItemKind.Reference = 18;
1457 CompletionItemKind.Folder = 19;
1458 CompletionItemKind.EnumMember = 20;
1459 CompletionItemKind.Constant = 21;
1460 CompletionItemKind.Struct = 22;
1461 CompletionItemKind.Event = 23;
1462 CompletionItemKind.Operator = 24;
1463 CompletionItemKind.TypeParameter = 25;
1464})(CompletionItemKind || (CompletionItemKind = {}));
1465/**
1466 * Defines whether the insert text in a completion item should be interpreted as
1467 * plain text or a snippet.
1468 */
1469var InsertTextFormat;
1470(function (InsertTextFormat) {
1471 /**
1472 * The primary text to be inserted is treated as a plain string.
1473 */
1474 InsertTextFormat.PlainText = 1;
1475 /**
1476 * The primary text to be inserted is treated as a snippet.
1477 *
1478 * A snippet can define tab stops and placeholders with `$1`, `$2`
1479 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
1480 * the end of the snippet. Placeholders with equal identifiers are linked,
1481 * that is typing in one will update others too.
1482 *
1483 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
1484 */
1485 InsertTextFormat.Snippet = 2;
1486})(InsertTextFormat || (InsertTextFormat = {}));
1487/**
1488 * Completion item tags are extra annotations that tweak the rendering of a completion
1489 * item.
1490 *
1491 * @since 3.15.0
1492 */
1493var CompletionItemTag;
1494(function (CompletionItemTag) {
1495 /**
1496 * Render a completion as obsolete, usually using a strike-out.
1497 */
1498 CompletionItemTag.Deprecated = 1;
1499})(CompletionItemTag || (CompletionItemTag = {}));
1500/**
1501 * The CompletionItem namespace provides functions to deal with
1502 * completion items.
1503 */
1504var CompletionItem;
1505(function (CompletionItem) {
1506 /**
1507 * Create a completion item and seed it with a label.
1508 * @param label The completion item's label
1509 */
1510 function create(label) {
1511 return { label: label };
1512 }
1513 CompletionItem.create = create;
1514})(CompletionItem || (CompletionItem = {}));
1515/**
1516 * The CompletionList namespace provides functions to deal with
1517 * completion lists.
1518 */
1519var CompletionList;
1520(function (CompletionList) {
1521 /**
1522 * Creates a new completion list.
1523 *
1524 * @param items The completion items.
1525 * @param isIncomplete The list is not complete.
1526 */
1527 function create(items, isIncomplete) {
1528 return { items: items ? items : [], isIncomplete: !!isIncomplete };
1529 }
1530 CompletionList.create = create;
1531})(CompletionList || (CompletionList = {}));
1532var MarkedString;
1533(function (MarkedString) {
1534 /**
1535 * Creates a marked string from plain text.
1536 *
1537 * @param plainText The plain text.
1538 */
1539 function fromPlainText(plainText) {
1540 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
1541 }
1542 MarkedString.fromPlainText = fromPlainText;
1543 /**
1544 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
1545 */
1546 function is(value) {
1547 var candidate = value;
1548 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
1549 }
1550 MarkedString.is = is;
1551})(MarkedString || (MarkedString = {}));
1552var Hover;
1553(function (Hover) {
1554 /**
1555 * Checks whether the given value conforms to the [Hover](#Hover) interface.
1556 */
1557 function is(value) {
1558 var candidate = value;
1559 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
1560 MarkedString.is(candidate.contents) ||
1561 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
1562 }
1563 Hover.is = is;
1564})(Hover || (Hover = {}));
1565/**
1566 * The ParameterInformation namespace provides helper functions to work with
1567 * [ParameterInformation](#ParameterInformation) literals.
1568 */
1569var ParameterInformation;
1570(function (ParameterInformation) {
1571 /**
1572 * Creates a new parameter information literal.
1573 *
1574 * @param label A label string.
1575 * @param documentation A doc string.
1576 */
1577 function create(label, documentation) {
1578 return documentation ? { label: label, documentation: documentation } : { label: label };
1579 }
1580 ParameterInformation.create = create;
1581})(ParameterInformation || (ParameterInformation = {}));
1582/**
1583 * The SignatureInformation namespace provides helper functions to work with
1584 * [SignatureInformation](#SignatureInformation) literals.
1585 */
1586var SignatureInformation;
1587(function (SignatureInformation) {
1588 function create(label, documentation) {
1589 var parameters = [];
1590 for (var _i = 2; _i < arguments.length; _i++) {
1591 parameters[_i - 2] = arguments[_i];
1592 }
1593 var result = { label: label };
1594 if (Is.defined(documentation)) {
1595 result.documentation = documentation;
1596 }
1597 if (Is.defined(parameters)) {
1598 result.parameters = parameters;
1599 }
1600 else {
1601 result.parameters = [];
1602 }
1603 return result;
1604 }
1605 SignatureInformation.create = create;
1606})(SignatureInformation || (SignatureInformation = {}));
1607/**
1608 * A document highlight kind.
1609 */
1610var DocumentHighlightKind;
1611(function (DocumentHighlightKind) {
1612 /**
1613 * A textual occurrence.
1614 */
1615 DocumentHighlightKind.Text = 1;
1616 /**
1617 * Read-access of a symbol, like reading a variable.
1618 */
1619 DocumentHighlightKind.Read = 2;
1620 /**
1621 * Write-access of a symbol, like writing to a variable.
1622 */
1623 DocumentHighlightKind.Write = 3;
1624})(DocumentHighlightKind || (DocumentHighlightKind = {}));
1625/**
1626 * DocumentHighlight namespace to provide helper functions to work with
1627 * [DocumentHighlight](#DocumentHighlight) literals.
1628 */
1629var DocumentHighlight;
1630(function (DocumentHighlight) {
1631 /**
1632 * Create a DocumentHighlight object.
1633 * @param range The range the highlight applies to.
1634 */
1635 function create(range, kind) {
1636 var result = { range: range };
1637 if (Is.number(kind)) {
1638 result.kind = kind;
1639 }
1640 return result;
1641 }
1642 DocumentHighlight.create = create;
1643})(DocumentHighlight || (DocumentHighlight = {}));
1644/**
1645 * A symbol kind.
1646 */
1647var SymbolKind;
1648(function (SymbolKind) {
1649 SymbolKind.File = 1;
1650 SymbolKind.Module = 2;
1651 SymbolKind.Namespace = 3;
1652 SymbolKind.Package = 4;
1653 SymbolKind.Class = 5;
1654 SymbolKind.Method = 6;
1655 SymbolKind.Property = 7;
1656 SymbolKind.Field = 8;
1657 SymbolKind.Constructor = 9;
1658 SymbolKind.Enum = 10;
1659 SymbolKind.Interface = 11;
1660 SymbolKind.Function = 12;
1661 SymbolKind.Variable = 13;
1662 SymbolKind.Constant = 14;
1663 SymbolKind.String = 15;
1664 SymbolKind.Number = 16;
1665 SymbolKind.Boolean = 17;
1666 SymbolKind.Array = 18;
1667 SymbolKind.Object = 19;
1668 SymbolKind.Key = 20;
1669 SymbolKind.Null = 21;
1670 SymbolKind.EnumMember = 22;
1671 SymbolKind.Struct = 23;
1672 SymbolKind.Event = 24;
1673 SymbolKind.Operator = 25;
1674 SymbolKind.TypeParameter = 26;
1675})(SymbolKind || (SymbolKind = {}));
1676/**
1677 * Symbol tags are extra annotations that tweak the rendering of a symbol.
1678 * @since 3.15
1679 */
1680var SymbolTag;
1681(function (SymbolTag) {
1682 /**
1683 * Render a symbol as obsolete, usually using a strike-out.
1684 */
1685 SymbolTag.Deprecated = 1;
1686})(SymbolTag || (SymbolTag = {}));
1687var SymbolInformation;
1688(function (SymbolInformation) {
1689 /**
1690 * Creates a new symbol information literal.
1691 *
1692 * @param name The name of the symbol.
1693 * @param kind The kind of the symbol.
1694 * @param range The range of the location of the symbol.
1695 * @param uri The resource of the location of symbol, defaults to the current document.
1696 * @param containerName The name of the symbol containing the symbol.
1697 */
1698 function create(name, kind, range, uri, containerName) {
1699 var result = {
1700 name: name,
1701 kind: kind,
1702 location: { uri: uri, range: range }
1703 };
1704 if (containerName) {
1705 result.containerName = containerName;
1706 }
1707 return result;
1708 }
1709 SymbolInformation.create = create;
1710})(SymbolInformation || (SymbolInformation = {}));
1711var DocumentSymbol;
1712(function (DocumentSymbol) {
1713 /**
1714 * Creates a new symbol information literal.
1715 *
1716 * @param name The name of the symbol.
1717 * @param detail The detail of the symbol.
1718 * @param kind The kind of the symbol.
1719 * @param range The range of the symbol.
1720 * @param selectionRange The selectionRange of the symbol.
1721 * @param children Children of the symbol.
1722 */
1723 function create(name, detail, kind, range, selectionRange, children) {
1724 var result = {
1725 name: name,
1726 detail: detail,
1727 kind: kind,
1728 range: range,
1729 selectionRange: selectionRange
1730 };
1731 if (children !== void 0) {
1732 result.children = children;
1733 }
1734 return result;
1735 }
1736 DocumentSymbol.create = create;
1737 /**
1738 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
1739 */
1740 function is(value) {
1741 var candidate = value;
1742 return candidate &&
1743 Is.string(candidate.name) && Is.number(candidate.kind) &&
1744 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
1745 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
1746 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
1747 (candidate.children === void 0 || Array.isArray(candidate.children));
1748 }
1749 DocumentSymbol.is = is;
1750})(DocumentSymbol || (DocumentSymbol = {}));
1751/**
1752 * A set of predefined code action kinds
1753 */
1754var CodeActionKind;
1755(function (CodeActionKind) {
1756 /**
1757 * Empty kind.
1758 */
1759 CodeActionKind.Empty = '';
1760 /**
1761 * Base kind for quickfix actions: 'quickfix'
1762 */
1763 CodeActionKind.QuickFix = 'quickfix';
1764 /**
1765 * Base kind for refactoring actions: 'refactor'
1766 */
1767 CodeActionKind.Refactor = 'refactor';
1768 /**
1769 * Base kind for refactoring extraction actions: 'refactor.extract'
1770 *
1771 * Example extract actions:
1772 *
1773 * - Extract method
1774 * - Extract function
1775 * - Extract variable
1776 * - Extract interface from class
1777 * - ...
1778 */
1779 CodeActionKind.RefactorExtract = 'refactor.extract';
1780 /**
1781 * Base kind for refactoring inline actions: 'refactor.inline'
1782 *
1783 * Example inline actions:
1784 *
1785 * - Inline function
1786 * - Inline variable
1787 * - Inline constant
1788 * - ...
1789 */
1790 CodeActionKind.RefactorInline = 'refactor.inline';
1791 /**
1792 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
1793 *
1794 * Example rewrite actions:
1795 *
1796 * - Convert JavaScript function to class
1797 * - Add or remove parameter
1798 * - Encapsulate field
1799 * - Make method static
1800 * - Move method to base class
1801 * - ...
1802 */
1803 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
1804 /**
1805 * Base kind for source actions: `source`
1806 *
1807 * Source code actions apply to the entire file.
1808 */
1809 CodeActionKind.Source = 'source';
1810 /**
1811 * Base kind for an organize imports source action: `source.organizeImports`
1812 */
1813 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
1814 /**
1815 * Base kind for auto-fix source actions: `source.fixAll`.
1816 *
1817 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
1818 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
1819 *
1820 * @since 3.15.0
1821 */
1822 CodeActionKind.SourceFixAll = 'source.fixAll';
1823})(CodeActionKind || (CodeActionKind = {}));
1824/**
1825 * The CodeActionContext namespace provides helper functions to work with
1826 * [CodeActionContext](#CodeActionContext) literals.
1827 */
1828var CodeActionContext;
1829(function (CodeActionContext) {
1830 /**
1831 * Creates a new CodeActionContext literal.
1832 */
1833 function create(diagnostics, only) {
1834 var result = { diagnostics: diagnostics };
1835 if (only !== void 0 && only !== null) {
1836 result.only = only;
1837 }
1838 return result;
1839 }
1840 CodeActionContext.create = create;
1841 /**
1842 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
1843 */
1844 function is(value) {
1845 var candidate = value;
1846 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
1847 }
1848 CodeActionContext.is = is;
1849})(CodeActionContext || (CodeActionContext = {}));
1850var CodeAction;
1851(function (CodeAction) {
1852 function create(title, commandOrEdit, kind) {
1853 var result = { title: title };
1854 if (Command.is(commandOrEdit)) {
1855 result.command = commandOrEdit;
1856 }
1857 else {
1858 result.edit = commandOrEdit;
1859 }
1860 if (kind !== void 0) {
1861 result.kind = kind;
1862 }
1863 return result;
1864 }
1865 CodeAction.create = create;
1866 function is(value) {
1867 var candidate = value;
1868 return candidate && Is.string(candidate.title) &&
1869 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
1870 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
1871 (candidate.edit !== void 0 || candidate.command !== void 0) &&
1872 (candidate.command === void 0 || Command.is(candidate.command)) &&
1873 (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) &&
1874 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
1875 }
1876 CodeAction.is = is;
1877})(CodeAction || (CodeAction = {}));
1878/**
1879 * The CodeLens namespace provides helper functions to work with
1880 * [CodeLens](#CodeLens) literals.
1881 */
1882var CodeLens;
1883(function (CodeLens) {
1884 /**
1885 * Creates a new CodeLens literal.
1886 */
1887 function create(range, data) {
1888 var result = { range: range };
1889 if (Is.defined(data)) {
1890 result.data = data;
1891 }
1892 return result;
1893 }
1894 CodeLens.create = create;
1895 /**
1896 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
1897 */
1898 function is(value) {
1899 var candidate = value;
1900 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
1901 }
1902 CodeLens.is = is;
1903})(CodeLens || (CodeLens = {}));
1904/**
1905 * The FormattingOptions namespace provides helper functions to work with
1906 * [FormattingOptions](#FormattingOptions) literals.
1907 */
1908var FormattingOptions;
1909(function (FormattingOptions) {
1910 /**
1911 * Creates a new FormattingOptions literal.
1912 */
1913 function create(tabSize, insertSpaces) {
1914 return { tabSize: tabSize, insertSpaces: insertSpaces };
1915 }
1916 FormattingOptions.create = create;
1917 /**
1918 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
1919 */
1920 function is(value) {
1921 var candidate = value;
1922 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
1923 }
1924 FormattingOptions.is = is;
1925})(FormattingOptions || (FormattingOptions = {}));
1926/**
1927 * The DocumentLink namespace provides helper functions to work with
1928 * [DocumentLink](#DocumentLink) literals.
1929 */
1930var DocumentLink;
1931(function (DocumentLink) {
1932 /**
1933 * Creates a new DocumentLink literal.
1934 */
1935 function create(range, target, data) {
1936 return { range: range, target: target, data: data };
1937 }
1938 DocumentLink.create = create;
1939 /**
1940 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
1941 */
1942 function is(value) {
1943 var candidate = value;
1944 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
1945 }
1946 DocumentLink.is = is;
1947})(DocumentLink || (DocumentLink = {}));
1948/**
1949 * The SelectionRange namespace provides helper function to work with
1950 * SelectionRange literals.
1951 */
1952var SelectionRange;
1953(function (SelectionRange) {
1954 /**
1955 * Creates a new SelectionRange
1956 * @param range the range.
1957 * @param parent an optional parent.
1958 */
1959 function create(range, parent) {
1960 return { range: range, parent: parent };
1961 }
1962 SelectionRange.create = create;
1963 function is(value) {
1964 var candidate = value;
1965 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
1966 }
1967 SelectionRange.is = is;
1968})(SelectionRange || (SelectionRange = {}));
1969var EOL = ['\n', '\r\n', '\r'];
1970/**
1971 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
1972 */
1973var TextDocument;
1974(function (TextDocument) {
1975 /**
1976 * Creates a new ITextDocument literal from the given uri and content.
1977 * @param uri The document's uri.
1978 * @param languageId The document's language Id.
1979 * @param content The document's content.
1980 */
1981 function create(uri, languageId, version, content) {
1982 return new FullTextDocument(uri, languageId, version, content);
1983 }
1984 TextDocument.create = create;
1985 /**
1986 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
1987 */
1988 function is(value) {
1989 var candidate = value;
1990 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
1991 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
1992 }
1993 TextDocument.is = is;
1994 function applyEdits(document, edits) {
1995 var text = document.getText();
1996 var sortedEdits = mergeSort(edits, function (a, b) {
1997 var diff = a.range.start.line - b.range.start.line;
1998 if (diff === 0) {
1999 return a.range.start.character - b.range.start.character;
2000 }
2001 return diff;
2002 });
2003 var lastModifiedOffset = text.length;
2004 for (var i = sortedEdits.length - 1; i >= 0; i--) {
2005 var e = sortedEdits[i];
2006 var startOffset = document.offsetAt(e.range.start);
2007 var endOffset = document.offsetAt(e.range.end);
2008 if (endOffset <= lastModifiedOffset) {
2009 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
2010 }
2011 else {
2012 throw new Error('Overlapping edit');
2013 }
2014 lastModifiedOffset = startOffset;
2015 }
2016 return text;
2017 }
2018 TextDocument.applyEdits = applyEdits;
2019 function mergeSort(data, compare) {
2020 if (data.length <= 1) {
2021 // sorted
2022 return data;
2023 }
2024 var p = (data.length / 2) | 0;
2025 var left = data.slice(0, p);
2026 var right = data.slice(p);
2027 mergeSort(left, compare);
2028 mergeSort(right, compare);
2029 var leftIdx = 0;
2030 var rightIdx = 0;
2031 var i = 0;
2032 while (leftIdx < left.length && rightIdx < right.length) {
2033 var ret = compare(left[leftIdx], right[rightIdx]);
2034 if (ret <= 0) {
2035 // smaller_equal -> take left to preserve order
2036 data[i++] = left[leftIdx++];
2037 }
2038 else {
2039 // greater -> take right
2040 data[i++] = right[rightIdx++];
2041 }
2042 }
2043 while (leftIdx < left.length) {
2044 data[i++] = left[leftIdx++];
2045 }
2046 while (rightIdx < right.length) {
2047 data[i++] = right[rightIdx++];
2048 }
2049 return data;
2050 }
2051})(TextDocument || (TextDocument = {}));
2052var FullTextDocument = /** @class */ (function () {
2053 function FullTextDocument(uri, languageId, version, content) {
2054 this._uri = uri;
2055 this._languageId = languageId;
2056 this._version = version;
2057 this._content = content;
2058 this._lineOffsets = undefined;
2059 }
2060 Object.defineProperty(FullTextDocument.prototype, "uri", {
2061 get: function () {
2062 return this._uri;
2063 },
2064 enumerable: true,
2065 configurable: true
2066 });
2067 Object.defineProperty(FullTextDocument.prototype, "languageId", {
2068 get: function () {
2069 return this._languageId;
2070 },
2071 enumerable: true,
2072 configurable: true
2073 });
2074 Object.defineProperty(FullTextDocument.prototype, "version", {
2075 get: function () {
2076 return this._version;
2077 },
2078 enumerable: true,
2079 configurable: true
2080 });
2081 FullTextDocument.prototype.getText = function (range) {
2082 if (range) {
2083 var start = this.offsetAt(range.start);
2084 var end = this.offsetAt(range.end);
2085 return this._content.substring(start, end);
2086 }
2087 return this._content;
2088 };
2089 FullTextDocument.prototype.update = function (event, version) {
2090 this._content = event.text;
2091 this._version = version;
2092 this._lineOffsets = undefined;
2093 };
2094 FullTextDocument.prototype.getLineOffsets = function () {
2095 if (this._lineOffsets === undefined) {
2096 var lineOffsets = [];
2097 var text = this._content;
2098 var isLineStart = true;
2099 for (var i = 0; i < text.length; i++) {
2100 if (isLineStart) {
2101 lineOffsets.push(i);
2102 isLineStart = false;
2103 }
2104 var ch = text.charAt(i);
2105 isLineStart = (ch === '\r' || ch === '\n');
2106 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
2107 i++;
2108 }
2109 }
2110 if (isLineStart && text.length > 0) {
2111 lineOffsets.push(text.length);
2112 }
2113 this._lineOffsets = lineOffsets;
2114 }
2115 return this._lineOffsets;
2116 };
2117 FullTextDocument.prototype.positionAt = function (offset) {
2118 offset = Math.max(Math.min(offset, this._content.length), 0);
2119 var lineOffsets = this.getLineOffsets();
2120 var low = 0, high = lineOffsets.length;
2121 if (high === 0) {
2122 return Position.create(0, offset);
2123 }
2124 while (low < high) {
2125 var mid = Math.floor((low + high) / 2);
2126 if (lineOffsets[mid] > offset) {
2127 high = mid;
2128 }
2129 else {
2130 low = mid + 1;
2131 }
2132 }
2133 // low is the least x for which the line offset is larger than the current offset
2134 // or array.length if no line offset is larger than the current offset
2135 var line = low - 1;
2136 return Position.create(line, offset - lineOffsets[line]);
2137 };
2138 FullTextDocument.prototype.offsetAt = function (position) {
2139 var lineOffsets = this.getLineOffsets();
2140 if (position.line >= lineOffsets.length) {
2141 return this._content.length;
2142 }
2143 else if (position.line < 0) {
2144 return 0;
2145 }
2146 var lineOffset = lineOffsets[position.line];
2147 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
2148 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
2149 };
2150 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
2151 get: function () {
2152 return this.getLineOffsets().length;
2153 },
2154 enumerable: true,
2155 configurable: true
2156 });
2157 return FullTextDocument;
2158}());
2159var Is;
2160(function (Is) {
2161 var toString = Object.prototype.toString;
2162 function defined(value) {
2163 return typeof value !== 'undefined';
2164 }
2165 Is.defined = defined;
2166 function undefined(value) {
2167 return typeof value === 'undefined';
2168 }
2169 Is.undefined = undefined;
2170 function boolean(value) {
2171 return value === true || value === false;
2172 }
2173 Is.boolean = boolean;
2174 function string(value) {
2175 return toString.call(value) === '[object String]';
2176 }
2177 Is.string = string;
2178 function number(value) {
2179 return toString.call(value) === '[object Number]';
2180 }
2181 Is.number = number;
2182 function func(value) {
2183 return toString.call(value) === '[object Function]';
2184 }
2185 Is.func = func;
2186 function objectLiteral(value) {
2187 // Strictly speaking class instances pass this check as well. Since the LSP
2188 // doesn't use classes we ignore this for now. If we do we need to add something
2189 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
2190 return value !== null && typeof value === 'object';
2191 }
2192 Is.objectLiteral = objectLiteral;
2193 function typedArray(value, check) {
2194 return Array.isArray(value) && value.every(check);
2195 }
2196 Is.typedArray = typedArray;
2197})(Is || (Is = {}));
2198
2199
2200/***/ }),
2201
2202/***/ 19:
2203/***/ (function(module, exports, __webpack_require__) {
2204
2205"use strict";
2206/* --------------------------------------------------------------------------------------------
2207 * Copyright (c) Microsoft Corporation. All rights reserved.
2208 * Licensed under the MIT License. See License.txt in the project root for license information.
2209 * ------------------------------------------------------------------------------------------ */
2210
2211Object.defineProperty(exports, "__esModule", { value: true });
2212const Is = __webpack_require__(20);
2213const vscode_jsonrpc_1 = __webpack_require__(4);
2214const messages_1 = __webpack_require__(21);
2215const protocol_implementation_1 = __webpack_require__(22);
2216exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
2217const protocol_typeDefinition_1 = __webpack_require__(23);
2218exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
2219const protocol_workspaceFolders_1 = __webpack_require__(24);
2220exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
2221exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
2222const protocol_configuration_1 = __webpack_require__(25);
2223exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
2224const protocol_colorProvider_1 = __webpack_require__(26);
2225exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
2226exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
2227const protocol_foldingRange_1 = __webpack_require__(27);
2228exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
2229const protocol_declaration_1 = __webpack_require__(28);
2230exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
2231const protocol_selectionRange_1 = __webpack_require__(29);
2232exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
2233const protocol_progress_1 = __webpack_require__(30);
2234exports.WorkDoneProgress = protocol_progress_1.WorkDoneProgress;
2235exports.WorkDoneProgressCreateRequest = protocol_progress_1.WorkDoneProgressCreateRequest;
2236exports.WorkDoneProgressCancelNotification = protocol_progress_1.WorkDoneProgressCancelNotification;
2237// @ts-ignore: to avoid inlining LocatioLink as dynamic import
2238let __noDynamicImport;
2239/**
2240 * The DocumentFilter namespace provides helper functions to work with
2241 * [DocumentFilter](#DocumentFilter) literals.
2242 */
2243var DocumentFilter;
2244(function (DocumentFilter) {
2245 function is(value) {
2246 const candidate = value;
2247 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
2248 }
2249 DocumentFilter.is = is;
2250})(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
2251/**
2252 * The DocumentSelector namespace provides helper functions to work with
2253 * [DocumentSelector](#DocumentSelector)s.
2254 */
2255var DocumentSelector;
2256(function (DocumentSelector) {
2257 function is(value) {
2258 if (!Array.isArray(value)) {
2259 return false;
2260 }
2261 for (let elem of value) {
2262 if (!Is.string(elem) && !DocumentFilter.is(elem)) {
2263 return false;
2264 }
2265 }
2266 return true;
2267 }
2268 DocumentSelector.is = is;
2269})(DocumentSelector = exports.DocumentSelector || (exports.DocumentSelector = {}));
2270/**
2271 * The `client/registerCapability` request is sent from the server to the client to register a new capability
2272 * handler on the client side.
2273 */
2274var RegistrationRequest;
2275(function (RegistrationRequest) {
2276 RegistrationRequest.type = new messages_1.ProtocolRequestType('client/registerCapability');
2277})(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
2278/**
2279 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
2280 * handler on the client side.
2281 */
2282var UnregistrationRequest;
2283(function (UnregistrationRequest) {
2284 UnregistrationRequest.type = new messages_1.ProtocolRequestType('client/unregisterCapability');
2285})(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
2286var ResourceOperationKind;
2287(function (ResourceOperationKind) {
2288 /**
2289 * Supports creating new files and folders.
2290 */
2291 ResourceOperationKind.Create = 'create';
2292 /**
2293 * Supports renaming existing files and folders.
2294 */
2295 ResourceOperationKind.Rename = 'rename';
2296 /**
2297 * Supports deleting existing files and folders.
2298 */
2299 ResourceOperationKind.Delete = 'delete';
2300})(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
2301var FailureHandlingKind;
2302(function (FailureHandlingKind) {
2303 /**
2304 * Applying the workspace change is simply aborted if one of the changes provided
2305 * fails. All operations executed before the failing operation stay executed.
2306 */
2307 FailureHandlingKind.Abort = 'abort';
2308 /**
2309 * All operations are executed transactional. That means they either all
2310 * succeed or no changes at all are applied to the workspace.
2311 */
2312 FailureHandlingKind.Transactional = 'transactional';
2313 /**
2314 * If the workspace edit contains only textual file changes they are executed transactional.
2315 * If resource changes (create, rename or delete file) are part of the change the failure
2316 * handling startegy is abort.
2317 */
2318 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
2319 /**
2320 * The client tries to undo the operations already executed. But there is no
2321 * guarantee that this is succeeding.
2322 */
2323 FailureHandlingKind.Undo = 'undo';
2324})(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
2325/**
2326 * The StaticRegistrationOptions namespace provides helper functions to work with
2327 * [StaticRegistrationOptions](#StaticRegistrationOptions) literals.
2328 */
2329var StaticRegistrationOptions;
2330(function (StaticRegistrationOptions) {
2331 function hasId(value) {
2332 const candidate = value;
2333 return candidate && Is.string(candidate.id) && candidate.id.length > 0;
2334 }
2335 StaticRegistrationOptions.hasId = hasId;
2336})(StaticRegistrationOptions = exports.StaticRegistrationOptions || (exports.StaticRegistrationOptions = {}));
2337/**
2338 * The TextDocumentRegistrationOptions namespace provides helper functions to work with
2339 * [TextDocumentRegistrationOptions](#TextDocumentRegistrationOptions) literals.
2340 */
2341var TextDocumentRegistrationOptions;
2342(function (TextDocumentRegistrationOptions) {
2343 function is(value) {
2344 const candidate = value;
2345 return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
2346 }
2347 TextDocumentRegistrationOptions.is = is;
2348})(TextDocumentRegistrationOptions = exports.TextDocumentRegistrationOptions || (exports.TextDocumentRegistrationOptions = {}));
2349/**
2350 * The WorkDoneProgressOptions namespace provides helper functions to work with
2351 * [WorkDoneProgressOptions](#WorkDoneProgressOptions) literals.
2352 */
2353var WorkDoneProgressOptions;
2354(function (WorkDoneProgressOptions) {
2355 function is(value) {
2356 const candidate = value;
2357 return Is.objectLiteral(candidate) && (candidate.workDoneProgress === undefined || Is.boolean(candidate.workDoneProgress));
2358 }
2359 WorkDoneProgressOptions.is = is;
2360 function hasWorkDoneProgress(value) {
2361 const candidate = value;
2362 return candidate && Is.boolean(candidate.workDoneProgress);
2363 }
2364 WorkDoneProgressOptions.hasWorkDoneProgress = hasWorkDoneProgress;
2365})(WorkDoneProgressOptions = exports.WorkDoneProgressOptions || (exports.WorkDoneProgressOptions = {}));
2366/**
2367 * The initialize request is sent from the client to the server.
2368 * It is sent once as the request after starting up the server.
2369 * The requests parameter is of type [InitializeParams](#InitializeParams)
2370 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
2371 * resolves to such.
2372 */
2373var InitializeRequest;
2374(function (InitializeRequest) {
2375 InitializeRequest.type = new messages_1.ProtocolRequestType('initialize');
2376})(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
2377/**
2378 * Known error codes for an `InitializeError`;
2379 */
2380var InitializeError;
2381(function (InitializeError) {
2382 /**
2383 * If the protocol version provided by the client can't be handled by the server.
2384 * @deprecated This initialize error got replaced by client capabilities. There is
2385 * no version handshake in version 3.0x
2386 */
2387 InitializeError.unknownProtocolVersion = 1;
2388})(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
2389/**
2390 * The intialized notification is sent from the client to the
2391 * server after the client is fully initialized and the server
2392 * is allowed to send requests from the server to the client.
2393 */
2394var InitializedNotification;
2395(function (InitializedNotification) {
2396 InitializedNotification.type = new messages_1.ProtocolNotificationType('initialized');
2397})(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
2398//---- Shutdown Method ----
2399/**
2400 * A shutdown request is sent from the client to the server.
2401 * It is sent once when the client decides to shutdown the
2402 * server. The only notification that is sent after a shutdown request
2403 * is the exit event.
2404 */
2405var ShutdownRequest;
2406(function (ShutdownRequest) {
2407 ShutdownRequest.type = new messages_1.ProtocolRequestType0('shutdown');
2408})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
2409//---- Exit Notification ----
2410/**
2411 * The exit event is sent from the client to the server to
2412 * ask the server to exit its process.
2413 */
2414var ExitNotification;
2415(function (ExitNotification) {
2416 ExitNotification.type = new messages_1.ProtocolNotificationType0('exit');
2417})(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
2418/**
2419 * The configuration change notification is sent from the client to the server
2420 * when the client's configuration has changed. The notification contains
2421 * the changed configuration as defined by the language client.
2422 */
2423var DidChangeConfigurationNotification;
2424(function (DidChangeConfigurationNotification) {
2425 DidChangeConfigurationNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeConfiguration');
2426})(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
2427//---- Message show and log notifications ----
2428/**
2429 * The message type
2430 */
2431var MessageType;
2432(function (MessageType) {
2433 /**
2434 * An error message.
2435 */
2436 MessageType.Error = 1;
2437 /**
2438 * A warning message.
2439 */
2440 MessageType.Warning = 2;
2441 /**
2442 * An information message.
2443 */
2444 MessageType.Info = 3;
2445 /**
2446 * A log message.
2447 */
2448 MessageType.Log = 4;
2449})(MessageType = exports.MessageType || (exports.MessageType = {}));
2450/**
2451 * The show message notification is sent from a server to a client to ask
2452 * the client to display a particular message in the user interface.
2453 */
2454var ShowMessageNotification;
2455(function (ShowMessageNotification) {
2456 ShowMessageNotification.type = new messages_1.ProtocolNotificationType('window/showMessage');
2457})(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
2458/**
2459 * The show message request is sent from the server to the client to show a message
2460 * and a set of options actions to the user.
2461 */
2462var ShowMessageRequest;
2463(function (ShowMessageRequest) {
2464 ShowMessageRequest.type = new messages_1.ProtocolRequestType('window/showMessageRequest');
2465})(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
2466/**
2467 * The log message notification is sent from the server to the client to ask
2468 * the client to log a particular message.
2469 */
2470var LogMessageNotification;
2471(function (LogMessageNotification) {
2472 LogMessageNotification.type = new messages_1.ProtocolNotificationType('window/logMessage');
2473})(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
2474//---- Telemetry notification
2475/**
2476 * The telemetry event notification is sent from the server to the client to ask
2477 * the client to log telemetry data.
2478 */
2479var TelemetryEventNotification;
2480(function (TelemetryEventNotification) {
2481 TelemetryEventNotification.type = new messages_1.ProtocolNotificationType('telemetry/event');
2482})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
2483/**
2484 * Defines how the host (editor) should sync
2485 * document changes to the language server.
2486 */
2487var TextDocumentSyncKind;
2488(function (TextDocumentSyncKind) {
2489 /**
2490 * Documents should not be synced at all.
2491 */
2492 TextDocumentSyncKind.None = 0;
2493 /**
2494 * Documents are synced by always sending the full content
2495 * of the document.
2496 */
2497 TextDocumentSyncKind.Full = 1;
2498 /**
2499 * Documents are synced by sending the full content on open.
2500 * After that only incremental updates to the document are
2501 * send.
2502 */
2503 TextDocumentSyncKind.Incremental = 2;
2504})(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
2505/**
2506 * The document open notification is sent from the client to the server to signal
2507 * newly opened text documents. The document's truth is now managed by the client
2508 * and the server must not try to read the document's truth using the document's
2509 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
2510 * mean that its content is presented in an editor. An open notification must not
2511 * be sent more than once without a corresponding close notification send before.
2512 * This means open and close notification must be balanced and the max open count
2513 * is one.
2514 */
2515var DidOpenTextDocumentNotification;
2516(function (DidOpenTextDocumentNotification) {
2517 DidOpenTextDocumentNotification.method = 'textDocument/didOpen';
2518 DidOpenTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidOpenTextDocumentNotification.method);
2519})(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
2520/**
2521 * The document change notification is sent from the client to the server to signal
2522 * changes to a text document.
2523 */
2524var DidChangeTextDocumentNotification;
2525(function (DidChangeTextDocumentNotification) {
2526 DidChangeTextDocumentNotification.method = 'textDocument/didChange';
2527 DidChangeTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidChangeTextDocumentNotification.method);
2528})(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
2529/**
2530 * The document close notification is sent from the client to the server when
2531 * the document got closed in the client. The document's truth now exists where
2532 * the document's uri points to (e.g. if the document's uri is a file uri the
2533 * truth now exists on disk). As with the open notification the close notification
2534 * is about managing the document's content. Receiving a close notification
2535 * doesn't mean that the document was open in an editor before. A close
2536 * notification requires a previous open notification to be sent.
2537 */
2538var DidCloseTextDocumentNotification;
2539(function (DidCloseTextDocumentNotification) {
2540 DidCloseTextDocumentNotification.method = 'textDocument/didClose';
2541 DidCloseTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidCloseTextDocumentNotification.method);
2542})(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
2543/**
2544 * The document save notification is sent from the client to the server when
2545 * the document got saved in the client.
2546 */
2547var DidSaveTextDocumentNotification;
2548(function (DidSaveTextDocumentNotification) {
2549 DidSaveTextDocumentNotification.method = 'textDocument/didSave';
2550 DidSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidSaveTextDocumentNotification.method);
2551})(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
2552/**
2553 * Represents reasons why a text document is saved.
2554 */
2555var TextDocumentSaveReason;
2556(function (TextDocumentSaveReason) {
2557 /**
2558 * Manually triggered, e.g. by the user pressing save, by starting debugging,
2559 * or by an API call.
2560 */
2561 TextDocumentSaveReason.Manual = 1;
2562 /**
2563 * Automatic after a delay.
2564 */
2565 TextDocumentSaveReason.AfterDelay = 2;
2566 /**
2567 * When the editor lost focus.
2568 */
2569 TextDocumentSaveReason.FocusOut = 3;
2570})(TextDocumentSaveReason = exports.TextDocumentSaveReason || (exports.TextDocumentSaveReason = {}));
2571/**
2572 * A document will save notification is sent from the client to the server before
2573 * the document is actually saved.
2574 */
2575var WillSaveTextDocumentNotification;
2576(function (WillSaveTextDocumentNotification) {
2577 WillSaveTextDocumentNotification.method = 'textDocument/willSave';
2578 WillSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(WillSaveTextDocumentNotification.method);
2579})(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
2580/**
2581 * A document will save request is sent from the client to the server before
2582 * the document is actually saved. The request can return an array of TextEdits
2583 * which will be applied to the text document before it is saved. Please note that
2584 * clients might drop results if computing the text edits took too long or if a
2585 * server constantly fails on this request. This is done to keep the save fast and
2586 * reliable.
2587 */
2588var WillSaveTextDocumentWaitUntilRequest;
2589(function (WillSaveTextDocumentWaitUntilRequest) {
2590 WillSaveTextDocumentWaitUntilRequest.method = 'textDocument/willSaveWaitUntil';
2591 WillSaveTextDocumentWaitUntilRequest.type = new messages_1.ProtocolRequestType(WillSaveTextDocumentWaitUntilRequest.method);
2592})(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
2593/**
2594 * The watched files notification is sent from the client to the server when
2595 * the client detects changes to file watched by the language client.
2596 */
2597var DidChangeWatchedFilesNotification;
2598(function (DidChangeWatchedFilesNotification) {
2599 DidChangeWatchedFilesNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWatchedFiles');
2600})(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
2601/**
2602 * The file event type
2603 */
2604var FileChangeType;
2605(function (FileChangeType) {
2606 /**
2607 * The file got created.
2608 */
2609 FileChangeType.Created = 1;
2610 /**
2611 * The file got changed.
2612 */
2613 FileChangeType.Changed = 2;
2614 /**
2615 * The file got deleted.
2616 */
2617 FileChangeType.Deleted = 3;
2618})(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
2619var WatchKind;
2620(function (WatchKind) {
2621 /**
2622 * Interested in create events.
2623 */
2624 WatchKind.Create = 1;
2625 /**
2626 * Interested in change events
2627 */
2628 WatchKind.Change = 2;
2629 /**
2630 * Interested in delete events
2631 */
2632 WatchKind.Delete = 4;
2633})(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
2634/**
2635 * Diagnostics notification are sent from the server to the client to signal
2636 * results of validation runs.
2637 */
2638var PublishDiagnosticsNotification;
2639(function (PublishDiagnosticsNotification) {
2640 PublishDiagnosticsNotification.type = new messages_1.ProtocolNotificationType('textDocument/publishDiagnostics');
2641})(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
2642/**
2643 * How a completion was triggered
2644 */
2645var CompletionTriggerKind;
2646(function (CompletionTriggerKind) {
2647 /**
2648 * Completion was triggered by typing an identifier (24x7 code
2649 * complete), manual invocation (e.g Ctrl+Space) or via API.
2650 */
2651 CompletionTriggerKind.Invoked = 1;
2652 /**
2653 * Completion was triggered by a trigger character specified by
2654 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
2655 */
2656 CompletionTriggerKind.TriggerCharacter = 2;
2657 /**
2658 * Completion was re-triggered as current completion list is incomplete
2659 */
2660 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
2661})(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
2662/**
2663 * Request to request completion at a given text document position. The request's
2664 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
2665 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
2666 * or a Thenable that resolves to such.
2667 *
2668 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
2669 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
2670 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
2671 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
2672 */
2673var CompletionRequest;
2674(function (CompletionRequest) {
2675 CompletionRequest.method = 'textDocument/completion';
2676 CompletionRequest.type = new messages_1.ProtocolRequestType(CompletionRequest.method);
2677 /** @deprecated Use CompletionRequest.type */
2678 CompletionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2679})(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
2680/**
2681 * Request to resolve additional information for a given completion item.The request's
2682 * parameter is of type [CompletionItem](#CompletionItem) the response
2683 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
2684 */
2685var CompletionResolveRequest;
2686(function (CompletionResolveRequest) {
2687 CompletionResolveRequest.method = 'completionItem/resolve';
2688 CompletionResolveRequest.type = new messages_1.ProtocolRequestType(CompletionResolveRequest.method);
2689})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
2690/**
2691 * Request to request hover information at a given text document position. The request's
2692 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
2693 * type [Hover](#Hover) or a Thenable that resolves to such.
2694 */
2695var HoverRequest;
2696(function (HoverRequest) {
2697 HoverRequest.method = 'textDocument/hover';
2698 HoverRequest.type = new messages_1.ProtocolRequestType(HoverRequest.method);
2699})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
2700/**
2701 * How a signature help was triggered.
2702 *
2703 * @since 3.15.0
2704 */
2705var SignatureHelpTriggerKind;
2706(function (SignatureHelpTriggerKind) {
2707 /**
2708 * Signature help was invoked manually by the user or by a command.
2709 */
2710 SignatureHelpTriggerKind.Invoked = 1;
2711 /**
2712 * Signature help was triggered by a trigger character.
2713 */
2714 SignatureHelpTriggerKind.TriggerCharacter = 2;
2715 /**
2716 * Signature help was triggered by the cursor moving or by the document content changing.
2717 */
2718 SignatureHelpTriggerKind.ContentChange = 3;
2719})(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
2720var SignatureHelpRequest;
2721(function (SignatureHelpRequest) {
2722 SignatureHelpRequest.method = 'textDocument/signatureHelp';
2723 SignatureHelpRequest.type = new messages_1.ProtocolRequestType(SignatureHelpRequest.method);
2724})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
2725/**
2726 * A request to resolve the definition location of a symbol at a given text
2727 * document position. The request's parameter is of type [TextDocumentPosition]
2728 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
2729 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
2730 * to such.
2731 */
2732var DefinitionRequest;
2733(function (DefinitionRequest) {
2734 DefinitionRequest.method = 'textDocument/definition';
2735 DefinitionRequest.type = new messages_1.ProtocolRequestType(DefinitionRequest.method);
2736 /** @deprecated Use DefinitionRequest.type */
2737 DefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2738})(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
2739/**
2740 * A request to resolve project-wide references for the symbol denoted
2741 * by the given text document position. The request's parameter is of
2742 * type [ReferenceParams](#ReferenceParams) the response is of type
2743 * [Location[]](#Location) or a Thenable that resolves to such.
2744 */
2745var ReferencesRequest;
2746(function (ReferencesRequest) {
2747 ReferencesRequest.method = 'textDocument/references';
2748 ReferencesRequest.type = new messages_1.ProtocolRequestType(ReferencesRequest.method);
2749 /** @deprecated Use ReferencesRequest.type */
2750 ReferencesRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2751})(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
2752/**
2753 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
2754 * text document position. The request's parameter is of type [TextDocumentPosition]
2755 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
2756 * (#DocumentHighlight) or a Thenable that resolves to such.
2757 */
2758var DocumentHighlightRequest;
2759(function (DocumentHighlightRequest) {
2760 DocumentHighlightRequest.method = 'textDocument/documentHighlight';
2761 DocumentHighlightRequest.type = new messages_1.ProtocolRequestType(DocumentHighlightRequest.method);
2762 /** @deprecated Use DocumentHighlightRequest.type */
2763 DocumentHighlightRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2764})(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
2765/**
2766 * A request to list all symbols found in a given text document. The request's
2767 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
2768 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
2769 * that resolves to such.
2770 */
2771var DocumentSymbolRequest;
2772(function (DocumentSymbolRequest) {
2773 DocumentSymbolRequest.method = 'textDocument/documentSymbol';
2774 DocumentSymbolRequest.type = new messages_1.ProtocolRequestType(DocumentSymbolRequest.method);
2775 /** @deprecated Use DocumentSymbolRequest.type */
2776 DocumentSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2777})(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
2778/**
2779 * A request to provide commands for the given text document and range.
2780 */
2781var CodeActionRequest;
2782(function (CodeActionRequest) {
2783 CodeActionRequest.method = 'textDocument/codeAction';
2784 CodeActionRequest.type = new messages_1.ProtocolRequestType(CodeActionRequest.method);
2785 /** @deprecated Use CodeActionRequest.type */
2786 CodeActionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2787})(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
2788/**
2789 * A request to list project-wide symbols matching the query string given
2790 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
2791 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
2792 * resolves to such.
2793 */
2794var WorkspaceSymbolRequest;
2795(function (WorkspaceSymbolRequest) {
2796 WorkspaceSymbolRequest.method = 'workspace/symbol';
2797 WorkspaceSymbolRequest.type = new messages_1.ProtocolRequestType(WorkspaceSymbolRequest.method);
2798 /** @deprecated Use WorkspaceSymbolRequest.type */
2799 WorkspaceSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2800})(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
2801/**
2802 * A request to provide code lens for the given text document.
2803 */
2804var CodeLensRequest;
2805(function (CodeLensRequest) {
2806 CodeLensRequest.type = new messages_1.ProtocolRequestType('textDocument/codeLens');
2807 /** @deprecated Use CodeLensRequest.type */
2808 CodeLensRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2809})(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
2810/**
2811 * A request to resolve a command for a given code lens.
2812 */
2813var CodeLensResolveRequest;
2814(function (CodeLensResolveRequest) {
2815 CodeLensResolveRequest.type = new messages_1.ProtocolRequestType('codeLens/resolve');
2816})(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
2817/**
2818 * A request to provide document links
2819 */
2820var DocumentLinkRequest;
2821(function (DocumentLinkRequest) {
2822 DocumentLinkRequest.method = 'textDocument/documentLink';
2823 DocumentLinkRequest.type = new messages_1.ProtocolRequestType(DocumentLinkRequest.method);
2824 /** @deprecated Use DocumentLinkRequest.type */
2825 DocumentLinkRequest.resultType = new vscode_jsonrpc_1.ProgressType();
2826})(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
2827/**
2828 * Request to resolve additional information for a given document link. The request's
2829 * parameter is of type [DocumentLink](#DocumentLink) the response
2830 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
2831 */
2832var DocumentLinkResolveRequest;
2833(function (DocumentLinkResolveRequest) {
2834 DocumentLinkResolveRequest.type = new messages_1.ProtocolRequestType('documentLink/resolve');
2835})(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
2836/**
2837 * A request to to format a whole document.
2838 */
2839var DocumentFormattingRequest;
2840(function (DocumentFormattingRequest) {
2841 DocumentFormattingRequest.method = 'textDocument/formatting';
2842 DocumentFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentFormattingRequest.method);
2843})(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
2844/**
2845 * A request to to format a range in a document.
2846 */
2847var DocumentRangeFormattingRequest;
2848(function (DocumentRangeFormattingRequest) {
2849 DocumentRangeFormattingRequest.method = 'textDocument/rangeFormatting';
2850 DocumentRangeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentRangeFormattingRequest.method);
2851})(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
2852/**
2853 * A request to format a document on type.
2854 */
2855var DocumentOnTypeFormattingRequest;
2856(function (DocumentOnTypeFormattingRequest) {
2857 DocumentOnTypeFormattingRequest.method = 'textDocument/onTypeFormatting';
2858 DocumentOnTypeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentOnTypeFormattingRequest.method);
2859})(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
2860/**
2861 * A request to rename a symbol.
2862 */
2863var RenameRequest;
2864(function (RenameRequest) {
2865 RenameRequest.method = 'textDocument/rename';
2866 RenameRequest.type = new messages_1.ProtocolRequestType(RenameRequest.method);
2867})(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
2868/**
2869 * A request to test and perform the setup necessary for a rename.
2870 */
2871var PrepareRenameRequest;
2872(function (PrepareRenameRequest) {
2873 PrepareRenameRequest.method = 'textDocument/prepareRename';
2874 PrepareRenameRequest.type = new messages_1.ProtocolRequestType(PrepareRenameRequest.method);
2875})(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
2876/**
2877 * A request send from the client to the server to execute a command. The request might return
2878 * a workspace edit which the client will apply to the workspace.
2879 */
2880var ExecuteCommandRequest;
2881(function (ExecuteCommandRequest) {
2882 ExecuteCommandRequest.type = new messages_1.ProtocolRequestType('workspace/executeCommand');
2883})(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
2884/**
2885 * A request sent from the server to the client to modified certain resources.
2886 */
2887var ApplyWorkspaceEditRequest;
2888(function (ApplyWorkspaceEditRequest) {
2889 ApplyWorkspaceEditRequest.type = new messages_1.ProtocolRequestType('workspace/applyEdit');
2890})(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
2891
2892
2893/***/ }),
2894
2895/***/ 2:
2896/***/ (function(module, exports, __webpack_require__) {
2897
2898"use strict";
2899/* --------------------------------------------------------------------------------------------
2900 * Copyright (c) Microsoft Corporation. All rights reserved.
2901 * Licensed under the MIT License. See License.txt in the project root for license information.
2902 * ------------------------------------------------------------------------------------------ */
2903/// <reference path="../typings/thenable.d.ts" />
2904
2905function __export(m) {
2906 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
2907}
2908Object.defineProperty(exports, "__esModule", { value: true });
2909const vscode_languageserver_protocol_1 = __webpack_require__(3);
2910exports.Event = vscode_languageserver_protocol_1.Event;
2911const configuration_1 = __webpack_require__(33);
2912const workspaceFolders_1 = __webpack_require__(35);
2913const progress_1 = __webpack_require__(36);
2914const Is = __webpack_require__(34);
2915const UUID = __webpack_require__(37);
2916// ------------- Reexport the API surface of the language worker API ----------------------
2917__export(__webpack_require__(3));
2918const fm = __webpack_require__(38);
2919var Files;
2920(function (Files) {
2921 Files.uriToFilePath = fm.uriToFilePath;
2922 Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
2923 Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
2924 Files.resolve = fm.resolve;
2925 Files.resolveModulePath = fm.resolveModulePath;
2926})(Files = exports.Files || (exports.Files = {}));
2927let shutdownReceived = false;
2928let exitTimer = undefined;
2929function setupExitTimer() {
2930 const argName = '--clientProcessId';
2931 function runTimer(value) {
2932 try {
2933 let processId = parseInt(value);
2934 if (!isNaN(processId)) {
2935 exitTimer = setInterval(() => {
2936 try {
2937 process.kill(processId, 0);
2938 }
2939 catch (ex) {
2940 // Parent process doesn't exist anymore. Exit the server.
2941 process.exit(shutdownReceived ? 0 : 1);
2942 }
2943 }, 3000);
2944 }
2945 }
2946 catch (e) {
2947 // Ignore errors;
2948 }
2949 }
2950 for (let i = 2; i < process.argv.length; i++) {
2951 let arg = process.argv[i];
2952 if (arg === argName && i + 1 < process.argv.length) {
2953 runTimer(process.argv[i + 1]);
2954 return;
2955 }
2956 else {
2957 let args = arg.split('=');
2958 if (args[0] === argName) {
2959 runTimer(args[1]);
2960 }
2961 }
2962 }
2963}
2964setupExitTimer();
2965function null2Undefined(value) {
2966 if (value === null) {
2967 return void 0;
2968 }
2969 return value;
2970}
2971/**
2972 * A manager for simple text documents
2973 */
2974class TextDocuments {
2975 /**
2976 * Create a new text document manager.
2977 */
2978 constructor(configuration) {
2979 this._documents = Object.create(null);
2980 this._configuration = configuration;
2981 this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
2982 this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
2983 this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
2984 this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
2985 this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
2986 }
2987 /**
2988 * An event that fires when a text document managed by this manager
2989 * has been opened or the content changes.
2990 */
2991 get onDidChangeContent() {
2992 return this._onDidChangeContent.event;
2993 }
2994 /**
2995 * An event that fires when a text document managed by this manager
2996 * has been opened.
2997 */
2998 get onDidOpen() {
2999 return this._onDidOpen.event;
3000 }
3001 /**
3002 * An event that fires when a text document managed by this manager
3003 * will be saved.
3004 */
3005 get onWillSave() {
3006 return this._onWillSave.event;
3007 }
3008 /**
3009 * Sets a handler that will be called if a participant wants to provide
3010 * edits during a text document save.
3011 */
3012 onWillSaveWaitUntil(handler) {
3013 this._willSaveWaitUntil = handler;
3014 }
3015 /**
3016 * An event that fires when a text document managed by this manager
3017 * has been saved.
3018 */
3019 get onDidSave() {
3020 return this._onDidSave.event;
3021 }
3022 /**
3023 * An event that fires when a text document managed by this manager
3024 * has been closed.
3025 */
3026 get onDidClose() {
3027 return this._onDidClose.event;
3028 }
3029 /**
3030 * Returns the document for the given URI. Returns undefined if
3031 * the document is not mananged by this instance.
3032 *
3033 * @param uri The text document's URI to retrieve.
3034 * @return the text document or `undefined`.
3035 */
3036 get(uri) {
3037 return this._documents[uri];
3038 }
3039 /**
3040 * Returns all text documents managed by this instance.
3041 *
3042 * @return all text documents.
3043 */
3044 all() {
3045 return Object.keys(this._documents).map(key => this._documents[key]);
3046 }
3047 /**
3048 * Returns the URIs of all text documents managed by this instance.
3049 *
3050 * @return the URI's of all text documents.
3051 */
3052 keys() {
3053 return Object.keys(this._documents);
3054 }
3055 /**
3056 * Listens for `low level` notification on the given connection to
3057 * update the text documents managed by this instance.
3058 *
3059 * @param connection The connection to listen on.
3060 */
3061 listen(connection) {
3062 connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
3063 connection.onDidOpenTextDocument((event) => {
3064 let td = event.textDocument;
3065 let document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
3066 this._documents[td.uri] = document;
3067 let toFire = Object.freeze({ document });
3068 this._onDidOpen.fire(toFire);
3069 this._onDidChangeContent.fire(toFire);
3070 });
3071 connection.onDidChangeTextDocument((event) => {
3072 let td = event.textDocument;
3073 let changes = event.contentChanges;
3074 if (changes.length === 0) {
3075 return;
3076 }
3077 let document = this._documents[td.uri];
3078 const { version } = td;
3079 if (version === null || version === void 0) {
3080 throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
3081 }
3082 document = this._configuration.update(document, changes, version);
3083 this._documents[td.uri] = document;
3084 this._onDidChangeContent.fire(Object.freeze({ document }));
3085 });
3086 connection.onDidCloseTextDocument((event) => {
3087 let document = this._documents[event.textDocument.uri];
3088 if (document) {
3089 delete this._documents[event.textDocument.uri];
3090 this._onDidClose.fire(Object.freeze({ document }));
3091 }
3092 });
3093 connection.onWillSaveTextDocument((event) => {
3094 let document = this._documents[event.textDocument.uri];
3095 if (document) {
3096 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
3097 }
3098 });
3099 connection.onWillSaveTextDocumentWaitUntil((event, token) => {
3100 let document = this._documents[event.textDocument.uri];
3101 if (document && this._willSaveWaitUntil) {
3102 return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);
3103 }
3104 else {
3105 return [];
3106 }
3107 });
3108 connection.onDidSaveTextDocument((event) => {
3109 let document = this._documents[event.textDocument.uri];
3110 if (document) {
3111 this._onDidSave.fire(Object.freeze({ document }));
3112 }
3113 });
3114 }
3115}
3116exports.TextDocuments = TextDocuments;
3117/**
3118 * Helps tracking error message. Equal occurences of the same
3119 * message are only stored once. This class is for example
3120 * useful if text documents are validated in a loop and equal
3121 * error message should be folded into one.
3122 */
3123class ErrorMessageTracker {
3124 constructor() {
3125 this._messages = Object.create(null);
3126 }
3127 /**
3128 * Add a message to the tracker.
3129 *
3130 * @param message The message to add.
3131 */
3132 add(message) {
3133 let count = this._messages[message];
3134 if (!count) {
3135 count = 0;
3136 }
3137 count++;
3138 this._messages[message] = count;
3139 }
3140 /**
3141 * Send all tracked messages to the connection's window.
3142 *
3143 * @param connection The connection established between client and server.
3144 */
3145 sendErrors(connection) {
3146 Object.keys(this._messages).forEach(message => {
3147 connection.window.showErrorMessage(message);
3148 });
3149 }
3150}
3151exports.ErrorMessageTracker = ErrorMessageTracker;
3152class RemoteConsoleImpl {
3153 constructor() {
3154 }
3155 rawAttach(connection) {
3156 this._rawConnection = connection;
3157 }
3158 attach(connection) {
3159 this._connection = connection;
3160 }
3161 get connection() {
3162 if (!this._connection) {
3163 throw new Error('Remote is not attached to a connection yet.');
3164 }
3165 return this._connection;
3166 }
3167 fillServerCapabilities(_capabilities) {
3168 }
3169 initialize(_capabilities) {
3170 }
3171 error(message) {
3172 this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
3173 }
3174 warn(message) {
3175 this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
3176 }
3177 info(message) {
3178 this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
3179 }
3180 log(message) {
3181 this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
3182 }
3183 send(type, message) {
3184 if (this._rawConnection) {
3185 this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });
3186 }
3187 }
3188}
3189class _RemoteWindowImpl {
3190 constructor() {
3191 }
3192 attach(connection) {
3193 this._connection = connection;
3194 }
3195 get connection() {
3196 if (!this._connection) {
3197 throw new Error('Remote is not attached to a connection yet.');
3198 }
3199 return this._connection;
3200 }
3201 initialize(_capabilities) {
3202 }
3203 fillServerCapabilities(_capabilities) {
3204 }
3205 showErrorMessage(message, ...actions) {
3206 let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };
3207 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
3208 }
3209 showWarningMessage(message, ...actions) {
3210 let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };
3211 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
3212 }
3213 showInformationMessage(message, ...actions) {
3214 let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };
3215 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
3216 }
3217}
3218const RemoteWindowImpl = progress_1.ProgressFeature(_RemoteWindowImpl);
3219var BulkRegistration;
3220(function (BulkRegistration) {
3221 /**
3222 * Creates a new bulk registration.
3223 * @return an empty bulk registration.
3224 */
3225 function create() {
3226 return new BulkRegistrationImpl();
3227 }
3228 BulkRegistration.create = create;
3229})(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));
3230class BulkRegistrationImpl {
3231 constructor() {
3232 this._registrations = [];
3233 this._registered = new Set();
3234 }
3235 add(type, registerOptions) {
3236 const method = Is.string(type) ? type : type.method;
3237 if (this._registered.has(method)) {
3238 throw new Error(`${method} is already added to this registration`);
3239 }
3240 const id = UUID.generateUuid();
3241 this._registrations.push({
3242 id: id,
3243 method: method,
3244 registerOptions: registerOptions || {}
3245 });
3246 this._registered.add(method);
3247 }
3248 asRegistrationParams() {
3249 return {
3250 registrations: this._registrations
3251 };
3252 }
3253}
3254var BulkUnregistration;
3255(function (BulkUnregistration) {
3256 function create() {
3257 return new BulkUnregistrationImpl(undefined, []);
3258 }
3259 BulkUnregistration.create = create;
3260})(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));
3261class BulkUnregistrationImpl {
3262 constructor(_connection, unregistrations) {
3263 this._connection = _connection;
3264 this._unregistrations = new Map();
3265 unregistrations.forEach(unregistration => {
3266 this._unregistrations.set(unregistration.method, unregistration);
3267 });
3268 }
3269 get isAttached() {
3270 return !!this._connection;
3271 }
3272 attach(connection) {
3273 this._connection = connection;
3274 }
3275 add(unregistration) {
3276 this._unregistrations.set(unregistration.method, unregistration);
3277 }
3278 dispose() {
3279 let unregistrations = [];
3280 for (let unregistration of this._unregistrations.values()) {
3281 unregistrations.push(unregistration);
3282 }
3283 let params = {
3284 unregisterations: unregistrations
3285 };
3286 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
3287 this._connection.console.info(`Bulk unregistration failed.`);
3288 });
3289 }
3290 disposeSingle(arg) {
3291 const method = Is.string(arg) ? arg : arg.method;
3292 const unregistration = this._unregistrations.get(method);
3293 if (!unregistration) {
3294 return false;
3295 }
3296 let params = {
3297 unregisterations: [unregistration]
3298 };
3299 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
3300 this._unregistrations.delete(method);
3301 }, (_error) => {
3302 this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);
3303 });
3304 return true;
3305 }
3306}
3307class RemoteClientImpl {
3308 attach(connection) {
3309 this._connection = connection;
3310 }
3311 get connection() {
3312 if (!this._connection) {
3313 throw new Error('Remote is not attached to a connection yet.');
3314 }
3315 return this._connection;
3316 }
3317 initialize(_capabilities) {
3318 }
3319 fillServerCapabilities(_capabilities) {
3320 }
3321 register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
3322 if (typeOrRegistrations instanceof BulkRegistrationImpl) {
3323 return this.registerMany(typeOrRegistrations);
3324 }
3325 else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
3326 return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
3327 }
3328 else {
3329 return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
3330 }
3331 }
3332 registerSingle1(unregistration, type, registerOptions) {
3333 const method = Is.string(type) ? type : type.method;
3334 const id = UUID.generateUuid();
3335 let params = {
3336 registrations: [{ id, method, registerOptions: registerOptions || {} }]
3337 };
3338 if (!unregistration.isAttached) {
3339 unregistration.attach(this._connection);
3340 }
3341 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
3342 unregistration.add({ id: id, method: method });
3343 return unregistration;
3344 }, (_error) => {
3345 this.connection.console.info(`Registering request handler for ${method} failed.`);
3346 return Promise.reject(_error);
3347 });
3348 }
3349 registerSingle2(type, registerOptions) {
3350 const method = Is.string(type) ? type : type.method;
3351 const id = UUID.generateUuid();
3352 let params = {
3353 registrations: [{ id, method, registerOptions: registerOptions || {} }]
3354 };
3355 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
3356 return vscode_languageserver_protocol_1.Disposable.create(() => {
3357 this.unregisterSingle(id, method);
3358 });
3359 }, (_error) => {
3360 this.connection.console.info(`Registering request handler for ${method} failed.`);
3361 return Promise.reject(_error);
3362 });
3363 }
3364 unregisterSingle(id, method) {
3365 let params = {
3366 unregisterations: [{ id, method }]
3367 };
3368 return this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
3369 this.connection.console.info(`Unregistering request handler for ${id} failed.`);
3370 });
3371 }
3372 registerMany(registrations) {
3373 let params = registrations.asRegistrationParams();
3374 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
3375 return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
3376 }, (_error) => {
3377 this.connection.console.info(`Bulk registration failed.`);
3378 return Promise.reject(_error);
3379 });
3380 }
3381}
3382class _RemoteWorkspaceImpl {
3383 constructor() {
3384 }
3385 attach(connection) {
3386 this._connection = connection;
3387 }
3388 get connection() {
3389 if (!this._connection) {
3390 throw new Error('Remote is not attached to a connection yet.');
3391 }
3392 return this._connection;
3393 }
3394 initialize(_capabilities) {
3395 }
3396 fillServerCapabilities(_capabilities) {
3397 }
3398 applyEdit(paramOrEdit) {
3399 function isApplyWorkspaceEditParams(value) {
3400 return value && !!value.edit;
3401 }
3402 let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
3403 return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
3404 }
3405}
3406const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));
3407class TelemetryImpl {
3408 constructor() {
3409 }
3410 attach(connection) {
3411 this._connection = connection;
3412 }
3413 get connection() {
3414 if (!this._connection) {
3415 throw new Error('Remote is not attached to a connection yet.');
3416 }
3417 return this._connection;
3418 }
3419 initialize(_capabilities) {
3420 }
3421 fillServerCapabilities(_capabilities) {
3422 }
3423 logEvent(data) {
3424 this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
3425 }
3426}
3427class TracerImpl {
3428 constructor() {
3429 this._trace = vscode_languageserver_protocol_1.Trace.Off;
3430 }
3431 attach(connection) {
3432 this._connection = connection;
3433 }
3434 get connection() {
3435 if (!this._connection) {
3436 throw new Error('Remote is not attached to a connection yet.');
3437 }
3438 return this._connection;
3439 }
3440 initialize(_capabilities) {
3441 }
3442 fillServerCapabilities(_capabilities) {
3443 }
3444 set trace(value) {
3445 this._trace = value;
3446 }
3447 log(message, verbose) {
3448 if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
3449 return;
3450 }
3451 this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
3452 message: message,
3453 verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
3454 });
3455 }
3456}
3457class LanguagesImpl {
3458 constructor() {
3459 }
3460 attach(connection) {
3461 this._connection = connection;
3462 }
3463 get connection() {
3464 if (!this._connection) {
3465 throw new Error('Remote is not attached to a connection yet.');
3466 }
3467 return this._connection;
3468 }
3469 initialize(_capabilities) {
3470 }
3471 fillServerCapabilities(_capabilities) {
3472 }
3473 attachWorkDoneProgress(params) {
3474 return progress_1.attachWorkDone(this.connection, params);
3475 }
3476 attachPartialResultProgress(_type, params) {
3477 return progress_1.attachPartialResult(this.connection, params);
3478 }
3479}
3480exports.LanguagesImpl = LanguagesImpl;
3481function combineConsoleFeatures(one, two) {
3482 return function (Base) {
3483 return two(one(Base));
3484 };
3485}
3486exports.combineConsoleFeatures = combineConsoleFeatures;
3487function combineTelemetryFeatures(one, two) {
3488 return function (Base) {
3489 return two(one(Base));
3490 };
3491}
3492exports.combineTelemetryFeatures = combineTelemetryFeatures;
3493function combineTracerFeatures(one, two) {
3494 return function (Base) {
3495 return two(one(Base));
3496 };
3497}
3498exports.combineTracerFeatures = combineTracerFeatures;
3499function combineClientFeatures(one, two) {
3500 return function (Base) {
3501 return two(one(Base));
3502 };
3503}
3504exports.combineClientFeatures = combineClientFeatures;
3505function combineWindowFeatures(one, two) {
3506 return function (Base) {
3507 return two(one(Base));
3508 };
3509}
3510exports.combineWindowFeatures = combineWindowFeatures;
3511function combineWorkspaceFeatures(one, two) {
3512 return function (Base) {
3513 return two(one(Base));
3514 };
3515}
3516exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
3517function combineLanguagesFeatures(one, two) {
3518 return function (Base) {
3519 return two(one(Base));
3520 };
3521}
3522exports.combineLanguagesFeatures = combineLanguagesFeatures;
3523function combineFeatures(one, two) {
3524 function combine(one, two, func) {
3525 if (one && two) {
3526 return func(one, two);
3527 }
3528 else if (one) {
3529 return one;
3530 }
3531 else {
3532 return two;
3533 }
3534 }
3535 let result = {
3536 __brand: 'features',
3537 console: combine(one.console, two.console, combineConsoleFeatures),
3538 tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
3539 telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
3540 client: combine(one.client, two.client, combineClientFeatures),
3541 window: combine(one.window, two.window, combineWindowFeatures),
3542 workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)
3543 };
3544 return result;
3545}
3546exports.combineFeatures = combineFeatures;
3547function createConnection(arg1, arg2, arg3, arg4) {
3548 let factories;
3549 let input;
3550 let output;
3551 let strategy;
3552 if (arg1 !== void 0 && arg1.__brand === 'features') {
3553 factories = arg1;
3554 arg1 = arg2;
3555 arg2 = arg3;
3556 arg3 = arg4;
3557 }
3558 if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {
3559 strategy = arg1;
3560 }
3561 else {
3562 input = arg1;
3563 output = arg2;
3564 strategy = arg3;
3565 }
3566 return _createConnection(input, output, strategy, factories);
3567}
3568exports.createConnection = createConnection;
3569function _createConnection(input, output, strategy, factories) {
3570 if (!input && !output && process.argv.length > 2) {
3571 let port = void 0;
3572 let pipeName = void 0;
3573 let argv = process.argv.slice(2);
3574 for (let i = 0; i < argv.length; i++) {
3575 let arg = argv[i];
3576 if (arg === '--node-ipc') {
3577 input = new vscode_languageserver_protocol_1.IPCMessageReader(process);
3578 output = new vscode_languageserver_protocol_1.IPCMessageWriter(process);
3579 break;
3580 }
3581 else if (arg === '--stdio') {
3582 input = process.stdin;
3583 output = process.stdout;
3584 break;
3585 }
3586 else if (arg === '--socket') {
3587 port = parseInt(argv[i + 1]);
3588 break;
3589 }
3590 else if (arg === '--pipe') {
3591 pipeName = argv[i + 1];
3592 break;
3593 }
3594 else {
3595 var args = arg.split('=');
3596 if (args[0] === '--socket') {
3597 port = parseInt(args[1]);
3598 break;
3599 }
3600 else if (args[0] === '--pipe') {
3601 pipeName = args[1];
3602 break;
3603 }
3604 }
3605 }
3606 if (port) {
3607 let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);
3608 input = transport[0];
3609 output = transport[1];
3610 }
3611 else if (pipeName) {
3612 let transport = vscode_languageserver_protocol_1.createServerPipeTransport(pipeName);
3613 input = transport[0];
3614 output = transport[1];
3615 }
3616 }
3617 var commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
3618 if (!input) {
3619 throw new Error('Connection input stream is not set. ' + commandLineMessage);
3620 }
3621 if (!output) {
3622 throw new Error('Connection output stream is not set. ' + commandLineMessage);
3623 }
3624 // Backwards compatibility
3625 if (Is.func(input.read) && Is.func(input.on)) {
3626 let inputStream = input;
3627 inputStream.on('end', () => {
3628 process.exit(shutdownReceived ? 0 : 1);
3629 });
3630 inputStream.on('close', () => {
3631 process.exit(shutdownReceived ? 0 : 1);
3632 });
3633 }
3634 const logger = (factories && factories.console ? new (factories.console(RemoteConsoleImpl))() : new RemoteConsoleImpl());
3635 const connection = vscode_languageserver_protocol_1.createProtocolConnection(input, output, logger, strategy);
3636 logger.rawAttach(connection);
3637 const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());
3638 const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());
3639 const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());
3640 const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());
3641 const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());
3642 const languages = (factories && factories.languages ? new (factories.languages(LanguagesImpl))() : new LanguagesImpl());
3643 const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages];
3644 function asPromise(value) {
3645 if (value instanceof Promise) {
3646 return value;
3647 }
3648 else if (Is.thenable(value)) {
3649 return new Promise((resolve, reject) => {
3650 value.then((resolved) => resolve(resolved), (error) => reject(error));
3651 });
3652 }
3653 else {
3654 return Promise.resolve(value);
3655 }
3656 }
3657 let shutdownHandler = undefined;
3658 let initializeHandler = undefined;
3659 let exitHandler = undefined;
3660 let protocolConnection = {
3661 listen: () => connection.listen(),
3662 sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
3663 onRequest: (type, handler) => connection.onRequest(type, handler),
3664 sendNotification: (type, param) => {
3665 const method = Is.string(type) ? type : type.method;
3666 if (arguments.length === 1) {
3667 connection.sendNotification(method);
3668 }
3669 else {
3670 connection.sendNotification(method, param);
3671 }
3672 },
3673 onNotification: (type, handler) => connection.onNotification(type, handler),
3674 onProgress: connection.onProgress,
3675 sendProgress: connection.sendProgress,
3676 onInitialize: (handler) => initializeHandler = handler,
3677 onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
3678 onShutdown: (handler) => shutdownHandler = handler,
3679 onExit: (handler) => exitHandler = handler,
3680 get console() { return logger; },
3681 get telemetry() { return telemetry; },
3682 get tracer() { return tracer; },
3683 get client() { return client; },
3684 get window() { return remoteWindow; },
3685 get workspace() { return workspace; },
3686 get languages() { return languages; },
3687 onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
3688 onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
3689 __textDocumentSync: undefined,
3690 onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
3691 onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
3692 onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
3693 onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
3694 onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
3695 onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
3696 sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
3697 onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, (params, cancel) => {
3698 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
3699 }),
3700 onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
3701 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3702 }),
3703 onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
3704 onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
3705 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
3706 }),
3707 onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
3708 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3709 }),
3710 onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
3711 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3712 }),
3713 onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
3714 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3715 }),
3716 onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
3717 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3718 }),
3719 onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
3720 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3721 }),
3722 onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
3723 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3724 }),
3725 onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
3726 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3727 }),
3728 onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
3729 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3730 }),
3731 onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
3732 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3733 }),
3734 onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
3735 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3736 }),
3737 onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, (params, cancel) => {
3738 return handler(params, cancel);
3739 }),
3740 onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
3741 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
3742 }),
3743 onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
3744 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
3745 }),
3746 onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, (params, cancel) => {
3747 return handler(params, cancel);
3748 }),
3749 onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, (params, cancel) => {
3750 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
3751 }),
3752 onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, (params, cancel) => {
3753 return handler(params, cancel);
3754 }),
3755 onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, (params, cancel) => {
3756 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3757 }),
3758 onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, (params, cancel) => {
3759 return handler(params, cancel);
3760 }),
3761 onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
3762 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3763 }),
3764 onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
3765 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3766 }),
3767 onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
3768 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3769 }),
3770 onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
3771 return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
3772 }),
3773 onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
3774 return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
3775 }),
3776 dispose: () => connection.dispose()
3777 };
3778 for (let remote of allRemotes) {
3779 remote.attach(protocolConnection);
3780 }
3781 connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
3782 const processId = params.processId;
3783 if (Is.number(processId) && exitTimer === void 0) {
3784 // We received a parent process id. Set up a timer to periodically check
3785 // if the parent is still alive.
3786 setInterval(() => {
3787 try {
3788 process.kill(processId, 0);
3789 }
3790 catch (ex) {
3791 // Parent process doesn't exist anymore. Exit the server.
3792 process.exit(shutdownReceived ? 0 : 1);
3793 }
3794 }, 3000);
3795 }
3796 if (Is.string(params.trace)) {
3797 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
3798 }
3799 for (let remote of allRemotes) {
3800 remote.initialize(params.capabilities);
3801 }
3802 if (initializeHandler) {
3803 let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token, progress_1.attachWorkDone(connection, params), undefined);
3804 return asPromise(result).then((value) => {
3805 if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
3806 return value;
3807 }
3808 let result = value;
3809 if (!result) {
3810 result = { capabilities: {} };
3811 }
3812 let capabilities = result.capabilities;
3813 if (!capabilities) {
3814 capabilities = {};
3815 result.capabilities = capabilities;
3816 }
3817 if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {
3818 capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
3819 }
3820 else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
3821 capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
3822 }
3823 for (let remote of allRemotes) {
3824 remote.fillServerCapabilities(capabilities);
3825 }
3826 return result;
3827 });
3828 }
3829 else {
3830 let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };
3831 for (let remote of allRemotes) {
3832 remote.fillServerCapabilities(result.capabilities);
3833 }
3834 return result;
3835 }
3836 });
3837 connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
3838 shutdownReceived = true;
3839 if (shutdownHandler) {
3840 return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
3841 }
3842 else {
3843 return undefined;
3844 }
3845 });
3846 connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
3847 try {
3848 if (exitHandler) {
3849 exitHandler();
3850 }
3851 }
3852 finally {
3853 if (shutdownReceived) {
3854 process.exit(0);
3855 }
3856 else {
3857 process.exit(1);
3858 }
3859 }
3860 });
3861 connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
3862 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
3863 });
3864 return protocolConnection;
3865}
3866// Export the protocol currently in proposed state.
3867const callHierarchy_proposed_1 = __webpack_require__(42);
3868const st = __webpack_require__(43);
3869var ProposedFeatures;
3870(function (ProposedFeatures) {
3871 ProposedFeatures.all = {
3872 __brand: 'features',
3873 languages: combineLanguagesFeatures(callHierarchy_proposed_1.CallHierarchyFeature, st.SemanticTokensFeature)
3874 };
3875 ProposedFeatures.SemanticTokensBuilder = st.SemanticTokensBuilder;
3876})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
3877//# sourceMappingURL=main.js.map
3878
3879/***/ }),
3880
3881/***/ 20:
3882/***/ (function(module, exports, __webpack_require__) {
3883
3884"use strict";
3885/* --------------------------------------------------------------------------------------------
3886 * Copyright (c) Microsoft Corporation. All rights reserved.
3887 * Licensed under the MIT License. See License.txt in the project root for license information.
3888 * ------------------------------------------------------------------------------------------ */
3889
3890Object.defineProperty(exports, "__esModule", { value: true });
3891function boolean(value) {
3892 return value === true || value === false;
3893}
3894exports.boolean = boolean;
3895function string(value) {
3896 return typeof value === 'string' || value instanceof String;
3897}
3898exports.string = string;
3899function number(value) {
3900 return typeof value === 'number' || value instanceof Number;
3901}
3902exports.number = number;
3903function error(value) {
3904 return value instanceof Error;
3905}
3906exports.error = error;
3907function func(value) {
3908 return typeof value === 'function';
3909}
3910exports.func = func;
3911function array(value) {
3912 return Array.isArray(value);
3913}
3914exports.array = array;
3915function stringArray(value) {
3916 return array(value) && value.every(elem => string(elem));
3917}
3918exports.stringArray = stringArray;
3919function typedArray(value, check) {
3920 return Array.isArray(value) && value.every(check);
3921}
3922exports.typedArray = typedArray;
3923function objectLiteral(value) {
3924 // Strictly speaking class instances pass this check as well. Since the LSP
3925 // doesn't use classes we ignore this for now. If we do we need to add something
3926 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
3927 return value !== null && typeof value === 'object';
3928}
3929exports.objectLiteral = objectLiteral;
3930
3931
3932/***/ }),
3933
3934/***/ 21:
3935/***/ (function(module, exports, __webpack_require__) {
3936
3937"use strict";
3938/* --------------------------------------------------------------------------------------------
3939 * Copyright (c) Microsoft Corporation. All rights reserved.
3940 * Licensed under the MIT License. See License.txt in the project root for license information.
3941 * ------------------------------------------------------------------------------------------ */
3942
3943Object.defineProperty(exports, "__esModule", { value: true });
3944const vscode_jsonrpc_1 = __webpack_require__(4);
3945class ProtocolRequestType0 extends vscode_jsonrpc_1.RequestType0 {
3946 constructor(method) {
3947 super(method);
3948 }
3949}
3950exports.ProtocolRequestType0 = ProtocolRequestType0;
3951class ProtocolRequestType extends vscode_jsonrpc_1.RequestType {
3952 constructor(method) {
3953 super(method);
3954 }
3955}
3956exports.ProtocolRequestType = ProtocolRequestType;
3957class ProtocolNotificationType extends vscode_jsonrpc_1.NotificationType {
3958 constructor(method) {
3959 super(method);
3960 }
3961}
3962exports.ProtocolNotificationType = ProtocolNotificationType;
3963class ProtocolNotificationType0 extends vscode_jsonrpc_1.NotificationType0 {
3964 constructor(method) {
3965 super(method);
3966 }
3967}
3968exports.ProtocolNotificationType0 = ProtocolNotificationType0;
3969
3970
3971/***/ }),
3972
3973/***/ 22:
3974/***/ (function(module, exports, __webpack_require__) {
3975
3976"use strict";
3977/* --------------------------------------------------------------------------------------------
3978 * Copyright (c) Microsoft Corporation. All rights reserved.
3979 * Licensed under the MIT License. See License.txt in the project root for license information.
3980 * ------------------------------------------------------------------------------------------ */
3981
3982Object.defineProperty(exports, "__esModule", { value: true });
3983const vscode_jsonrpc_1 = __webpack_require__(4);
3984const messages_1 = __webpack_require__(21);
3985// @ts-ignore: to avoid inlining LocatioLink as dynamic import
3986let __noDynamicImport;
3987/**
3988 * A request to resolve the implementation locations of a symbol at a given text
3989 * document position. The request's parameter is of type [TextDocumentPositioParams]
3990 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
3991 * Thenable that resolves to such.
3992 */
3993var ImplementationRequest;
3994(function (ImplementationRequest) {
3995 ImplementationRequest.method = 'textDocument/implementation';
3996 ImplementationRequest.type = new messages_1.ProtocolRequestType(ImplementationRequest.method);
3997 /** @deprecated Use ImplementationRequest.type */
3998 ImplementationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
3999})(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
4000
4001
4002/***/ }),
4003
4004/***/ 23:
4005/***/ (function(module, exports, __webpack_require__) {
4006
4007"use strict";
4008/* --------------------------------------------------------------------------------------------
4009 * Copyright (c) Microsoft Corporation. All rights reserved.
4010 * Licensed under the MIT License. See License.txt in the project root for license information.
4011 * ------------------------------------------------------------------------------------------ */
4012
4013Object.defineProperty(exports, "__esModule", { value: true });
4014const vscode_jsonrpc_1 = __webpack_require__(4);
4015const messages_1 = __webpack_require__(21);
4016// @ts-ignore: to avoid inlining LocatioLink as dynamic import
4017let __noDynamicImport;
4018/**
4019 * A request to resolve the type definition locations of a symbol at a given text
4020 * document position. The request's parameter is of type [TextDocumentPositioParams]
4021 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
4022 * Thenable that resolves to such.
4023 */
4024var TypeDefinitionRequest;
4025(function (TypeDefinitionRequest) {
4026 TypeDefinitionRequest.method = 'textDocument/typeDefinition';
4027 TypeDefinitionRequest.type = new messages_1.ProtocolRequestType(TypeDefinitionRequest.method);
4028 /** @deprecated Use TypeDefinitionRequest.type */
4029 TypeDefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4030})(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
4031
4032
4033/***/ }),
4034
4035/***/ 24:
4036/***/ (function(module, exports, __webpack_require__) {
4037
4038"use strict";
4039/* --------------------------------------------------------------------------------------------
4040 * Copyright (c) Microsoft Corporation. All rights reserved.
4041 * Licensed under the MIT License. See License.txt in the project root for license information.
4042 * ------------------------------------------------------------------------------------------ */
4043
4044Object.defineProperty(exports, "__esModule", { value: true });
4045const messages_1 = __webpack_require__(21);
4046/**
4047 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
4048 */
4049var WorkspaceFoldersRequest;
4050(function (WorkspaceFoldersRequest) {
4051 WorkspaceFoldersRequest.type = new messages_1.ProtocolRequestType0('workspace/workspaceFolders');
4052})(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
4053/**
4054 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
4055 * folder configuration changes.
4056 */
4057var DidChangeWorkspaceFoldersNotification;
4058(function (DidChangeWorkspaceFoldersNotification) {
4059 DidChangeWorkspaceFoldersNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWorkspaceFolders');
4060})(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
4061
4062
4063/***/ }),
4064
4065/***/ 25:
4066/***/ (function(module, exports, __webpack_require__) {
4067
4068"use strict";
4069/* --------------------------------------------------------------------------------------------
4070 * Copyright (c) Microsoft Corporation. All rights reserved.
4071 * Licensed under the MIT License. See License.txt in the project root for license information.
4072 * ------------------------------------------------------------------------------------------ */
4073
4074Object.defineProperty(exports, "__esModule", { value: true });
4075const messages_1 = __webpack_require__(21);
4076/**
4077 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
4078 * configuration setting.
4079 *
4080 * This pull model replaces the old push model were the client signaled configuration change via an
4081 * event. If the server still needs to react to configuration changes (since the server caches the
4082 * result of `workspace/configuration` requests) the server should register for an empty configuration
4083 * change event and empty the cache if such an event is received.
4084 */
4085var ConfigurationRequest;
4086(function (ConfigurationRequest) {
4087 ConfigurationRequest.type = new messages_1.ProtocolRequestType('workspace/configuration');
4088})(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
4089
4090
4091/***/ }),
4092
4093/***/ 26:
4094/***/ (function(module, exports, __webpack_require__) {
4095
4096"use strict";
4097/* --------------------------------------------------------------------------------------------
4098 * Copyright (c) Microsoft Corporation. All rights reserved.
4099 * Licensed under the MIT License. See License.txt in the project root for license information.
4100 * ------------------------------------------------------------------------------------------ */
4101
4102Object.defineProperty(exports, "__esModule", { value: true });
4103const vscode_jsonrpc_1 = __webpack_require__(4);
4104const messages_1 = __webpack_require__(21);
4105/**
4106 * A request to list all color symbols found in a given text document. The request's
4107 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
4108 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4109 * that resolves to such.
4110 */
4111var DocumentColorRequest;
4112(function (DocumentColorRequest) {
4113 DocumentColorRequest.method = 'textDocument/documentColor';
4114 DocumentColorRequest.type = new messages_1.ProtocolRequestType(DocumentColorRequest.method);
4115 /** @deprecated Use DocumentColorRequest.type */
4116 DocumentColorRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4117})(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
4118/**
4119 * A request to list all presentation for a color. The request's
4120 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
4121 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
4122 * that resolves to such.
4123 */
4124var ColorPresentationRequest;
4125(function (ColorPresentationRequest) {
4126 ColorPresentationRequest.type = new messages_1.ProtocolRequestType('textDocument/colorPresentation');
4127})(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
4128
4129
4130/***/ }),
4131
4132/***/ 27:
4133/***/ (function(module, exports, __webpack_require__) {
4134
4135"use strict";
4136
4137/*---------------------------------------------------------------------------------------------
4138 * Copyright (c) Microsoft Corporation. All rights reserved.
4139 * Licensed under the MIT License. See License.txt in the project root for license information.
4140 *--------------------------------------------------------------------------------------------*/
4141Object.defineProperty(exports, "__esModule", { value: true });
4142const vscode_jsonrpc_1 = __webpack_require__(4);
4143const messages_1 = __webpack_require__(21);
4144/**
4145 * Enum of known range kinds
4146 */
4147var FoldingRangeKind;
4148(function (FoldingRangeKind) {
4149 /**
4150 * Folding range for a comment
4151 */
4152 FoldingRangeKind["Comment"] = "comment";
4153 /**
4154 * Folding range for a imports or includes
4155 */
4156 FoldingRangeKind["Imports"] = "imports";
4157 /**
4158 * Folding range for a region (e.g. `#region`)
4159 */
4160 FoldingRangeKind["Region"] = "region";
4161})(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
4162/**
4163 * A request to provide folding ranges in a document. The request's
4164 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
4165 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
4166 * that resolves to such.
4167 */
4168var FoldingRangeRequest;
4169(function (FoldingRangeRequest) {
4170 FoldingRangeRequest.method = 'textDocument/foldingRange';
4171 FoldingRangeRequest.type = new messages_1.ProtocolRequestType(FoldingRangeRequest.method);
4172 /** @deprecated Use FoldingRangeRequest.type */
4173 FoldingRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4174})(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
4175
4176
4177/***/ }),
4178
4179/***/ 28:
4180/***/ (function(module, exports, __webpack_require__) {
4181
4182"use strict";
4183/* --------------------------------------------------------------------------------------------
4184 * Copyright (c) Microsoft Corporation. All rights reserved.
4185 * Licensed under the MIT License. See License.txt in the project root for license information.
4186 * ------------------------------------------------------------------------------------------ */
4187
4188Object.defineProperty(exports, "__esModule", { value: true });
4189const vscode_jsonrpc_1 = __webpack_require__(4);
4190const messages_1 = __webpack_require__(21);
4191// @ts-ignore: to avoid inlining LocatioLink as dynamic import
4192let __noDynamicImport;
4193/**
4194 * A request to resolve the type definition locations of a symbol at a given text
4195 * document position. The request's parameter is of type [TextDocumentPositioParams]
4196 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
4197 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
4198 * to such.
4199 */
4200var DeclarationRequest;
4201(function (DeclarationRequest) {
4202 DeclarationRequest.method = 'textDocument/declaration';
4203 DeclarationRequest.type = new messages_1.ProtocolRequestType(DeclarationRequest.method);
4204 /** @deprecated Use DeclarationRequest.type */
4205 DeclarationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4206})(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
4207
4208
4209/***/ }),
4210
4211/***/ 29:
4212/***/ (function(module, exports, __webpack_require__) {
4213
4214"use strict";
4215
4216/*---------------------------------------------------------------------------------------------
4217 * Copyright (c) Microsoft Corporation. All rights reserved.
4218 * Licensed under the MIT License. See License.txt in the project root for license information.
4219 *--------------------------------------------------------------------------------------------*/
4220Object.defineProperty(exports, "__esModule", { value: true });
4221const vscode_jsonrpc_1 = __webpack_require__(4);
4222const messages_1 = __webpack_require__(21);
4223/**
4224 * A request to provide selection ranges in a document. The request's
4225 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
4226 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
4227 * that resolves to such.
4228 */
4229var SelectionRangeRequest;
4230(function (SelectionRangeRequest) {
4231 SelectionRangeRequest.method = 'textDocument/selectionRange';
4232 SelectionRangeRequest.type = new messages_1.ProtocolRequestType(SelectionRangeRequest.method);
4233 /** @deprecated Use SelectionRangeRequest.type */
4234 SelectionRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
4235})(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
4236
4237
4238/***/ }),
4239
4240/***/ 3:
4241/***/ (function(module, exports, __webpack_require__) {
4242
4243"use strict";
4244/* --------------------------------------------------------------------------------------------
4245 * Copyright (c) Microsoft Corporation. All rights reserved.
4246 * Licensed under the MIT License. See License.txt in the project root for license information.
4247 * ------------------------------------------------------------------------------------------ */
4248
4249function __export(m) {
4250 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4251}
4252Object.defineProperty(exports, "__esModule", { value: true });
4253const vscode_jsonrpc_1 = __webpack_require__(4);
4254exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
4255exports.ResponseError = vscode_jsonrpc_1.ResponseError;
4256exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
4257exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
4258exports.Disposable = vscode_jsonrpc_1.Disposable;
4259exports.Event = vscode_jsonrpc_1.Event;
4260exports.Emitter = vscode_jsonrpc_1.Emitter;
4261exports.Trace = vscode_jsonrpc_1.Trace;
4262exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
4263exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
4264exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
4265exports.RequestType = vscode_jsonrpc_1.RequestType;
4266exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
4267exports.NotificationType = vscode_jsonrpc_1.NotificationType;
4268exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
4269exports.MessageReader = vscode_jsonrpc_1.MessageReader;
4270exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
4271exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
4272exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
4273exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
4274exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
4275exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
4276exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
4277exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
4278exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
4279exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
4280exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
4281exports.ProgressType = vscode_jsonrpc_1.ProgressType;
4282__export(__webpack_require__(18));
4283__export(__webpack_require__(19));
4284const callHierarchy = __webpack_require__(31);
4285const st = __webpack_require__(32);
4286var Proposed;
4287(function (Proposed) {
4288 let CallHierarchyPrepareRequest;
4289 (function (CallHierarchyPrepareRequest) {
4290 CallHierarchyPrepareRequest.method = callHierarchy.CallHierarchyPrepareRequest.method;
4291 CallHierarchyPrepareRequest.type = callHierarchy.CallHierarchyPrepareRequest.type;
4292 })(CallHierarchyPrepareRequest = Proposed.CallHierarchyPrepareRequest || (Proposed.CallHierarchyPrepareRequest = {}));
4293 let CallHierarchyIncomingCallsRequest;
4294 (function (CallHierarchyIncomingCallsRequest) {
4295 CallHierarchyIncomingCallsRequest.method = callHierarchy.CallHierarchyIncomingCallsRequest.method;
4296 CallHierarchyIncomingCallsRequest.type = callHierarchy.CallHierarchyIncomingCallsRequest.type;
4297 })(CallHierarchyIncomingCallsRequest = Proposed.CallHierarchyIncomingCallsRequest || (Proposed.CallHierarchyIncomingCallsRequest = {}));
4298 let CallHierarchyOutgoingCallsRequest;
4299 (function (CallHierarchyOutgoingCallsRequest) {
4300 CallHierarchyOutgoingCallsRequest.method = callHierarchy.CallHierarchyOutgoingCallsRequest.method;
4301 CallHierarchyOutgoingCallsRequest.type = callHierarchy.CallHierarchyOutgoingCallsRequest.type;
4302 })(CallHierarchyOutgoingCallsRequest = Proposed.CallHierarchyOutgoingCallsRequest || (Proposed.CallHierarchyOutgoingCallsRequest = {}));
4303 Proposed.SemanticTokenTypes = st.SemanticTokenTypes;
4304 Proposed.SemanticTokenModifiers = st.SemanticTokenModifiers;
4305 Proposed.SemanticTokens = st.SemanticTokens;
4306 let SemanticTokensRequest;
4307 (function (SemanticTokensRequest) {
4308 SemanticTokensRequest.method = st.SemanticTokensRequest.method;
4309 SemanticTokensRequest.type = st.SemanticTokensRequest.type;
4310 })(SemanticTokensRequest = Proposed.SemanticTokensRequest || (Proposed.SemanticTokensRequest = {}));
4311 let SemanticTokensEditsRequest;
4312 (function (SemanticTokensEditsRequest) {
4313 SemanticTokensEditsRequest.method = st.SemanticTokensEditsRequest.method;
4314 SemanticTokensEditsRequest.type = st.SemanticTokensEditsRequest.type;
4315 })(SemanticTokensEditsRequest = Proposed.SemanticTokensEditsRequest || (Proposed.SemanticTokensEditsRequest = {}));
4316 let SemanticTokensRangeRequest;
4317 (function (SemanticTokensRangeRequest) {
4318 SemanticTokensRangeRequest.method = st.SemanticTokensRangeRequest.method;
4319 SemanticTokensRangeRequest.type = st.SemanticTokensRangeRequest.type;
4320 })(SemanticTokensRangeRequest = Proposed.SemanticTokensRangeRequest || (Proposed.SemanticTokensRangeRequest = {}));
4321})(Proposed = exports.Proposed || (exports.Proposed = {}));
4322function createProtocolConnection(reader, writer, logger, strategy) {
4323 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
4324}
4325exports.createProtocolConnection = createProtocolConnection;
4326
4327
4328/***/ }),
4329
4330/***/ 30:
4331/***/ (function(module, exports, __webpack_require__) {
4332
4333"use strict";
4334/* --------------------------------------------------------------------------------------------
4335 * Copyright (c) Microsoft Corporation. All rights reserved.
4336 * Licensed under the MIT License. See License.txt in the project root for license information.
4337 * ------------------------------------------------------------------------------------------ */
4338
4339Object.defineProperty(exports, "__esModule", { value: true });
4340const vscode_jsonrpc_1 = __webpack_require__(4);
4341const messages_1 = __webpack_require__(21);
4342var WorkDoneProgress;
4343(function (WorkDoneProgress) {
4344 WorkDoneProgress.type = new vscode_jsonrpc_1.ProgressType();
4345})(WorkDoneProgress = exports.WorkDoneProgress || (exports.WorkDoneProgress = {}));
4346/**
4347 * The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
4348 * reporting from the server.
4349 */
4350var WorkDoneProgressCreateRequest;
4351(function (WorkDoneProgressCreateRequest) {
4352 WorkDoneProgressCreateRequest.type = new messages_1.ProtocolRequestType('window/workDoneProgress/create');
4353})(WorkDoneProgressCreateRequest = exports.WorkDoneProgressCreateRequest || (exports.WorkDoneProgressCreateRequest = {}));
4354/**
4355 * The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
4356 * initiated on the server side.
4357 */
4358var WorkDoneProgressCancelNotification;
4359(function (WorkDoneProgressCancelNotification) {
4360 WorkDoneProgressCancelNotification.type = new messages_1.ProtocolNotificationType('window/workDoneProgress/cancel');
4361})(WorkDoneProgressCancelNotification = exports.WorkDoneProgressCancelNotification || (exports.WorkDoneProgressCancelNotification = {}));
4362
4363
4364/***/ }),
4365
4366/***/ 31:
4367/***/ (function(module, exports, __webpack_require__) {
4368
4369"use strict";
4370/* --------------------------------------------------------------------------------------------
4371 * Copyright (c) TypeFox and others. All rights reserved.
4372 * Licensed under the MIT License. See License.txt in the project root for license information.
4373 * ------------------------------------------------------------------------------------------ */
4374
4375Object.defineProperty(exports, "__esModule", { value: true });
4376const messages_1 = __webpack_require__(21);
4377/**
4378 * A request to result a `CallHierarchyItem` in a document at a given position.
4379 * Can be used as an input to a incoming or outgoing call hierarchy.
4380 *
4381 * @since 3.16.0 - Proposed state
4382 */
4383var CallHierarchyPrepareRequest;
4384(function (CallHierarchyPrepareRequest) {
4385 CallHierarchyPrepareRequest.method = 'textDocument/prepareCallHierarchy';
4386 CallHierarchyPrepareRequest.type = new messages_1.ProtocolRequestType(CallHierarchyPrepareRequest.method);
4387})(CallHierarchyPrepareRequest = exports.CallHierarchyPrepareRequest || (exports.CallHierarchyPrepareRequest = {}));
4388/**
4389 * A request to resolve the incoming calls for a given `CallHierarchyItem`.
4390 *
4391 * @since 3.16.0 - Proposed state
4392 */
4393var CallHierarchyIncomingCallsRequest;
4394(function (CallHierarchyIncomingCallsRequest) {
4395 CallHierarchyIncomingCallsRequest.method = 'callHierarchy/incomingCalls';
4396 CallHierarchyIncomingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyIncomingCallsRequest.method);
4397})(CallHierarchyIncomingCallsRequest = exports.CallHierarchyIncomingCallsRequest || (exports.CallHierarchyIncomingCallsRequest = {}));
4398/**
4399 * A request to resolve the outgoing calls for a given `CallHierarchyItem`.
4400 *
4401 * @since 3.16.0 - Proposed state
4402 */
4403var CallHierarchyOutgoingCallsRequest;
4404(function (CallHierarchyOutgoingCallsRequest) {
4405 CallHierarchyOutgoingCallsRequest.method = 'callHierarchy/outgoingCalls';
4406 CallHierarchyOutgoingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyOutgoingCallsRequest.method);
4407})(CallHierarchyOutgoingCallsRequest = exports.CallHierarchyOutgoingCallsRequest || (exports.CallHierarchyOutgoingCallsRequest = {}));
4408
4409
4410/***/ }),
4411
4412/***/ 32:
4413/***/ (function(module, exports, __webpack_require__) {
4414
4415"use strict";
4416/* --------------------------------------------------------------------------------------------
4417 * Copyright (c) Microsoft Corporation. All rights reserved.
4418 * Licensed under the MIT License. See License.txt in the project root for license information.
4419 * ------------------------------------------------------------------------------------------ */
4420
4421Object.defineProperty(exports, "__esModule", { value: true });
4422const messages_1 = __webpack_require__(21);
4423/**
4424 * A set of predefined token types. This set is not fixed
4425 * an clients can specify additional token types via the
4426 * corresponding client capabilities.
4427 *
4428 * @since 3.16.0 - Proposed state
4429 */
4430var SemanticTokenTypes;
4431(function (SemanticTokenTypes) {
4432 SemanticTokenTypes["comment"] = "comment";
4433 SemanticTokenTypes["keyword"] = "keyword";
4434 SemanticTokenTypes["string"] = "string";
4435 SemanticTokenTypes["number"] = "number";
4436 SemanticTokenTypes["regexp"] = "regexp";
4437 SemanticTokenTypes["operator"] = "operator";
4438 SemanticTokenTypes["namespace"] = "namespace";
4439 SemanticTokenTypes["type"] = "type";
4440 SemanticTokenTypes["struct"] = "struct";
4441 SemanticTokenTypes["class"] = "class";
4442 SemanticTokenTypes["interface"] = "interface";
4443 SemanticTokenTypes["enum"] = "enum";
4444 SemanticTokenTypes["typeParameter"] = "typeParameter";
4445 SemanticTokenTypes["function"] = "function";
4446 SemanticTokenTypes["member"] = "member";
4447 SemanticTokenTypes["property"] = "property";
4448 SemanticTokenTypes["macro"] = "macro";
4449 SemanticTokenTypes["variable"] = "variable";
4450 SemanticTokenTypes["parameter"] = "parameter";
4451 SemanticTokenTypes["label"] = "label";
4452})(SemanticTokenTypes = exports.SemanticTokenTypes || (exports.SemanticTokenTypes = {}));
4453/**
4454 * A set of predefined token modifiers. This set is not fixed
4455 * an clients can specify additional token types via the
4456 * corresponding client capabilities.
4457 *
4458 * @since 3.16.0 - Proposed state
4459 */
4460var SemanticTokenModifiers;
4461(function (SemanticTokenModifiers) {
4462 SemanticTokenModifiers["documentation"] = "documentation";
4463 SemanticTokenModifiers["declaration"] = "declaration";
4464 SemanticTokenModifiers["definition"] = "definition";
4465 SemanticTokenModifiers["reference"] = "reference";
4466 SemanticTokenModifiers["static"] = "static";
4467 SemanticTokenModifiers["abstract"] = "abstract";
4468 SemanticTokenModifiers["deprecated"] = "deprecated";
4469 SemanticTokenModifiers["async"] = "async";
4470 SemanticTokenModifiers["volatile"] = "volatile";
4471 SemanticTokenModifiers["readonly"] = "readonly";
4472})(SemanticTokenModifiers = exports.SemanticTokenModifiers || (exports.SemanticTokenModifiers = {}));
4473/**
4474 * @since 3.16.0 - Proposed state
4475 */
4476var SemanticTokens;
4477(function (SemanticTokens) {
4478 function is(value) {
4479 const candidate = value;
4480 return candidate !== undefined && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
4481 Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
4482 }
4483 SemanticTokens.is = is;
4484})(SemanticTokens = exports.SemanticTokens || (exports.SemanticTokens = {}));
4485/**
4486 * @since 3.16.0 - Proposed state
4487 */
4488var SemanticTokensRequest;
4489(function (SemanticTokensRequest) {
4490 SemanticTokensRequest.method = 'textDocument/semanticTokens';
4491 SemanticTokensRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRequest.method);
4492})(SemanticTokensRequest = exports.SemanticTokensRequest || (exports.SemanticTokensRequest = {}));
4493/**
4494 * @since 3.16.0 - Proposed state
4495 */
4496var SemanticTokensEditsRequest;
4497(function (SemanticTokensEditsRequest) {
4498 SemanticTokensEditsRequest.method = 'textDocument/semanticTokens/edits';
4499 SemanticTokensEditsRequest.type = new messages_1.ProtocolRequestType(SemanticTokensEditsRequest.method);
4500})(SemanticTokensEditsRequest = exports.SemanticTokensEditsRequest || (exports.SemanticTokensEditsRequest = {}));
4501/**
4502 * @since 3.16.0 - Proposed state
4503 */
4504var SemanticTokensRangeRequest;
4505(function (SemanticTokensRangeRequest) {
4506 SemanticTokensRangeRequest.method = 'textDocument/semanticTokens/range';
4507 SemanticTokensRangeRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRangeRequest.method);
4508})(SemanticTokensRangeRequest = exports.SemanticTokensRangeRequest || (exports.SemanticTokensRangeRequest = {}));
4509
4510
4511/***/ }),
4512
4513/***/ 33:
4514/***/ (function(module, exports, __webpack_require__) {
4515
4516"use strict";
4517/* --------------------------------------------------------------------------------------------
4518 * Copyright (c) Microsoft Corporation. All rights reserved.
4519 * Licensed under the MIT License. See License.txt in the project root for license information.
4520 * ------------------------------------------------------------------------------------------ */
4521
4522Object.defineProperty(exports, "__esModule", { value: true });
4523const vscode_languageserver_protocol_1 = __webpack_require__(3);
4524const Is = __webpack_require__(34);
4525exports.ConfigurationFeature = (Base) => {
4526 return class extends Base {
4527 getConfiguration(arg) {
4528 if (!arg) {
4529 return this._getConfiguration({});
4530 }
4531 else if (Is.string(arg)) {
4532 return this._getConfiguration({ section: arg });
4533 }
4534 else {
4535 return this._getConfiguration(arg);
4536 }
4537 }
4538 _getConfiguration(arg) {
4539 let params = {
4540 items: Array.isArray(arg) ? arg : [arg]
4541 };
4542 return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {
4543 return Array.isArray(arg) ? result : result[0];
4544 });
4545 }
4546 };
4547};
4548//# sourceMappingURL=configuration.js.map
4549
4550/***/ }),
4551
4552/***/ 34:
4553/***/ (function(module, exports, __webpack_require__) {
4554
4555"use strict";
4556/* --------------------------------------------------------------------------------------------
4557 * Copyright (c) Microsoft Corporation. All rights reserved.
4558 * Licensed under the MIT License. See License.txt in the project root for license information.
4559 * ------------------------------------------------------------------------------------------ */
4560
4561Object.defineProperty(exports, "__esModule", { value: true });
4562function boolean(value) {
4563 return value === true || value === false;
4564}
4565exports.boolean = boolean;
4566function string(value) {
4567 return typeof value === 'string' || value instanceof String;
4568}
4569exports.string = string;
4570function number(value) {
4571 return typeof value === 'number' || value instanceof Number;
4572}
4573exports.number = number;
4574function error(value) {
4575 return value instanceof Error;
4576}
4577exports.error = error;
4578function func(value) {
4579 return typeof value === 'function';
4580}
4581exports.func = func;
4582function array(value) {
4583 return Array.isArray(value);
4584}
4585exports.array = array;
4586function stringArray(value) {
4587 return array(value) && value.every(elem => string(elem));
4588}
4589exports.stringArray = stringArray;
4590function typedArray(value, check) {
4591 return Array.isArray(value) && value.every(check);
4592}
4593exports.typedArray = typedArray;
4594function thenable(value) {
4595 return value && func(value.then);
4596}
4597exports.thenable = thenable;
4598//# sourceMappingURL=is.js.map
4599
4600/***/ }),
4601
4602/***/ 35:
4603/***/ (function(module, exports, __webpack_require__) {
4604
4605"use strict";
4606/* --------------------------------------------------------------------------------------------
4607 * Copyright (c) Microsoft Corporation. All rights reserved.
4608 * Licensed under the MIT License. See License.txt in the project root for license information.
4609 * ------------------------------------------------------------------------------------------ */
4610
4611Object.defineProperty(exports, "__esModule", { value: true });
4612const vscode_languageserver_protocol_1 = __webpack_require__(3);
4613exports.WorkspaceFoldersFeature = (Base) => {
4614 return class extends Base {
4615 initialize(capabilities) {
4616 let workspaceCapabilities = capabilities.workspace;
4617 if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {
4618 this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();
4619 this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {
4620 this._onDidChangeWorkspaceFolders.fire(params.event);
4621 });
4622 }
4623 }
4624 getWorkspaceFolders() {
4625 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
4626 }
4627 get onDidChangeWorkspaceFolders() {
4628 if (!this._onDidChangeWorkspaceFolders) {
4629 throw new Error('Client doesn\'t support sending workspace folder change events.');
4630 }
4631 if (!this._unregistration) {
4632 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
4633 }
4634 return this._onDidChangeWorkspaceFolders.event;
4635 }
4636 };
4637};
4638//# sourceMappingURL=workspaceFolders.js.map
4639
4640/***/ }),
4641
4642/***/ 36:
4643/***/ (function(module, exports, __webpack_require__) {
4644
4645"use strict";
4646/* --------------------------------------------------------------------------------------------
4647 * Copyright (c) Microsoft Corporation. All rights reserved.
4648 * Licensed under the MIT License. See License.txt in the project root for license information.
4649 * ------------------------------------------------------------------------------------------ */
4650
4651Object.defineProperty(exports, "__esModule", { value: true });
4652const vscode_languageserver_protocol_1 = __webpack_require__(3);
4653const uuid_1 = __webpack_require__(37);
4654class WorkDoneProgressImpl {
4655 constructor(_connection, _token) {
4656 this._connection = _connection;
4657 this._token = _token;
4658 WorkDoneProgressImpl.Instances.set(this._token, this);
4659 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
4660 }
4661 get token() {
4662 return this._source.token;
4663 }
4664 begin(title, percentage, message, cancellable) {
4665 let param = {
4666 kind: 'begin',
4667 title,
4668 percentage,
4669 message,
4670 cancellable
4671 };
4672 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
4673 }
4674 report(arg0, arg1) {
4675 let param = {
4676 kind: 'report'
4677 };
4678 if (typeof arg0 === 'number') {
4679 param.percentage = arg0;
4680 if (arg1 !== undefined) {
4681 param.message = arg1;
4682 }
4683 }
4684 else {
4685 param.message = arg0;
4686 }
4687 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
4688 }
4689 done() {
4690 WorkDoneProgressImpl.Instances.delete(this._token);
4691 this._source.dispose();
4692 this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, { kind: 'end' });
4693 }
4694 cancel() {
4695 this._source.cancel();
4696 }
4697}
4698WorkDoneProgressImpl.Instances = new Map();
4699class NullProgress {
4700 constructor() {
4701 this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
4702 }
4703 get token() {
4704 return this._source.token;
4705 }
4706 begin() {
4707 }
4708 report() {
4709 }
4710 done() {
4711 }
4712}
4713function attachWorkDone(connection, params) {
4714 if (params === undefined || params.workDoneToken === undefined) {
4715 return new NullProgress();
4716 }
4717 const token = params.workDoneToken;
4718 delete params.workDoneToken;
4719 return new WorkDoneProgressImpl(connection, token);
4720}
4721exports.attachWorkDone = attachWorkDone;
4722exports.ProgressFeature = (Base) => {
4723 return class extends Base {
4724 initialize(capabilities) {
4725 var _a;
4726 if (((_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.window) === null || _a === void 0 ? void 0 : _a.workDoneProgress) === true) {
4727 this._progressSupported = true;
4728 this.connection.onNotification(vscode_languageserver_protocol_1.WorkDoneProgressCancelNotification.type, (params) => {
4729 let progress = WorkDoneProgressImpl.Instances.get(params.token);
4730 if (progress !== undefined) {
4731 progress.cancel();
4732 }
4733 });
4734 }
4735 }
4736 attachWorkDoneProgress(token) {
4737 if (token === undefined) {
4738 return new NullProgress();
4739 }
4740 else {
4741 return new WorkDoneProgressImpl(this.connection, token);
4742 }
4743 }
4744 createWorkDoneProgress() {
4745 if (this._progressSupported) {
4746 const token = uuid_1.generateUuid();
4747 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkDoneProgressCreateRequest.type, { token }).then(() => {
4748 const result = new WorkDoneProgressImpl(this.connection, token);
4749 return result;
4750 });
4751 }
4752 else {
4753 return Promise.resolve(new NullProgress());
4754 }
4755 }
4756 };
4757};
4758var ResultProgress;
4759(function (ResultProgress) {
4760 ResultProgress.type = new vscode_languageserver_protocol_1.ProgressType();
4761})(ResultProgress || (ResultProgress = {}));
4762class ResultProgressImpl {
4763 constructor(_connection, _token) {
4764 this._connection = _connection;
4765 this._token = _token;
4766 }
4767 report(data) {
4768 this._connection.sendProgress(ResultProgress.type, this._token, data);
4769 }
4770}
4771function attachPartialResult(connection, params) {
4772 if (params === undefined || params.partialResultToken === undefined) {
4773 return undefined;
4774 }
4775 const token = params.partialResultToken;
4776 delete params.partialResultToken;
4777 return new ResultProgressImpl(connection, token);
4778}
4779exports.attachPartialResult = attachPartialResult;
4780//# sourceMappingURL=progress.js.map
4781
4782/***/ }),
4783
4784/***/ 37:
4785/***/ (function(module, exports, __webpack_require__) {
4786
4787"use strict";
4788/*---------------------------------------------------------------------------------------------
4789 * Copyright (c) Microsoft Corporation. All rights reserved.
4790 * Licensed under the MIT License. See License.txt in the project root for license information.
4791 *--------------------------------------------------------------------------------------------*/
4792
4793Object.defineProperty(exports, "__esModule", { value: true });
4794class ValueUUID {
4795 constructor(_value) {
4796 this._value = _value;
4797 // empty
4798 }
4799 asHex() {
4800 return this._value;
4801 }
4802 equals(other) {
4803 return this.asHex() === other.asHex();
4804 }
4805}
4806class V4UUID extends ValueUUID {
4807 constructor() {
4808 super([
4809 V4UUID._randomHex(),
4810 V4UUID._randomHex(),
4811 V4UUID._randomHex(),
4812 V4UUID._randomHex(),
4813 V4UUID._randomHex(),
4814 V4UUID._randomHex(),
4815 V4UUID._randomHex(),
4816 V4UUID._randomHex(),
4817 '-',
4818 V4UUID._randomHex(),
4819 V4UUID._randomHex(),
4820 V4UUID._randomHex(),
4821 V4UUID._randomHex(),
4822 '-',
4823 '4',
4824 V4UUID._randomHex(),
4825 V4UUID._randomHex(),
4826 V4UUID._randomHex(),
4827 '-',
4828 V4UUID._oneOf(V4UUID._timeHighBits),
4829 V4UUID._randomHex(),
4830 V4UUID._randomHex(),
4831 V4UUID._randomHex(),
4832 '-',
4833 V4UUID._randomHex(),
4834 V4UUID._randomHex(),
4835 V4UUID._randomHex(),
4836 V4UUID._randomHex(),
4837 V4UUID._randomHex(),
4838 V4UUID._randomHex(),
4839 V4UUID._randomHex(),
4840 V4UUID._randomHex(),
4841 V4UUID._randomHex(),
4842 V4UUID._randomHex(),
4843 V4UUID._randomHex(),
4844 V4UUID._randomHex(),
4845 ].join(''));
4846 }
4847 static _oneOf(array) {
4848 return array[Math.floor(array.length * Math.random())];
4849 }
4850 static _randomHex() {
4851 return V4UUID._oneOf(V4UUID._chars);
4852 }
4853}
4854V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
4855V4UUID._timeHighBits = ['8', '9', 'a', 'b'];
4856/**
4857 * An empty UUID that contains only zeros.
4858 */
4859exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');
4860function v4() {
4861 return new V4UUID();
4862}
4863exports.v4 = v4;
4864const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4865function isUUID(value) {
4866 return _UUIDPattern.test(value);
4867}
4868exports.isUUID = isUUID;
4869/**
4870 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
4871 * @param value A uuid string.
4872 */
4873function parse(value) {
4874 if (!isUUID(value)) {
4875 throw new Error('invalid uuid');
4876 }
4877 return new ValueUUID(value);
4878}
4879exports.parse = parse;
4880function generateUuid() {
4881 return v4().asHex();
4882}
4883exports.generateUuid = generateUuid;
4884//# sourceMappingURL=uuid.js.map
4885
4886/***/ }),
4887
4888/***/ 370:
4889/***/ (function(module, exports, __webpack_require__) {
4890
4891"use strict";
4892
4893var __assign = (this && this.__assign) || function () {
4894 __assign = Object.assign || function(t) {
4895 for (var s, i = 1, n = arguments.length; i < n; i++) {
4896 s = arguments[i];
4897 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4898 t[p] = s[p];
4899 }
4900 return t;
4901 };
4902 return __assign.apply(this, arguments);
4903};
4904var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4905 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4906 return new (P || (P = Promise))(function (resolve, reject) {
4907 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4908 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4909 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4910 step((generator = generator.apply(thisArg, _arguments || [])).next());
4911 });
4912};
4913var __generator = (this && this.__generator) || function (thisArg, body) {
4914 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4915 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4916 function verb(n) { return function (v) { return step([n, v]); }; }
4917 function step(op) {
4918 if (f) throw new TypeError("Generator is already executing.");
4919 while (_) try {
4920 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;
4921 if (y = 0, t) op = [op[0] & 2, t.value];
4922 switch (op[0]) {
4923 case 0: case 1: t = op; break;
4924 case 4: _.label++; return { value: op[1], done: false };
4925 case 5: _.label++; y = op[1]; op = [0]; continue;
4926 case 7: op = _.ops.pop(); _.trys.pop(); continue;
4927 default:
4928 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4929 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4930 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4931 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4932 if (t[2]) _.ops.pop();
4933 _.trys.pop(); continue;
4934 }
4935 op = body.call(thisArg, _);
4936 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4937 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4938 }
4939};
4940Object.defineProperty(exports, "__esModule", { value: true });
4941/*
4942 * vim builtin completion items
4943 *
4944 * 1. functions
4945 * 2. options
4946 * 3. variables
4947 * 4. commands
4948 * 5. has features
4949 * 6. expand Keyword
4950 */
4951var fs_1 = __webpack_require__(40);
4952var path_1 = __webpack_require__(13);
4953var vscode_languageserver_1 = __webpack_require__(2);
4954var constant_1 = __webpack_require__(44);
4955var util_1 = __webpack_require__(47);
4956var EVAL_PATH = "/doc/eval.txt";
4957var OPTIONS_PATH = "/doc/options.txt";
4958var INDEX_PATH = "/doc/index.txt";
4959var API_PATH = "/doc/api.txt";
4960var AUTOCMD_PATH = "/doc/autocmd.txt";
4961var POPUP_PATH = "/doc/popup.txt";
4962var CHANNEL_PATH = "/doc/channel.txt";
4963var TEXTPROP_PATH = "/doc/textprop.txt";
4964var TERMINAL_PATH = "/doc/terminal.txt";
4965var TESTING_PATH = "/doc/testing.txt";
4966var Server = /** @class */ (function () {
4967 function Server(config) {
4968 this.config = config;
4969 // completion items
4970 this.vimPredefinedVariablesItems = [];
4971 this.vimOptionItems = [];
4972 this.vimBuiltinFunctionItems = [];
4973 this.vimCommandItems = [];
4974 this.vimFeatureItems = [];
4975 this.vimExpandKeywordItems = [];
4976 this.vimAutocmdItems = [];
4977 // documents
4978 this.vimBuiltFunctionDocuments = {};
4979 this.vimOptionDocuments = {};
4980 this.vimPredefinedVariableDocuments = {};
4981 this.vimCommandDocuments = {};
4982 this.vimFeatureDocuments = {};
4983 this.expandKeywordDocuments = {};
4984 // signature help
4985 this.vimBuiltFunctionSignatureHelp = {};
4986 // raw docs
4987 this.text = {};
4988 }
4989 Server.prototype.build = function () {
4990 return __awaiter(this, void 0, void 0, function () {
4991 var vimruntime, paths, index, p, _a, err, data;
4992 return __generator(this, function (_b) {
4993 switch (_b.label) {
4994 case 0:
4995 vimruntime = this.config.vimruntime;
4996 if (!vimruntime) return [3 /*break*/, 5];
4997 paths = [
4998 EVAL_PATH,
4999 OPTIONS_PATH,
5000 INDEX_PATH,
5001 API_PATH,
5002 AUTOCMD_PATH,
5003 POPUP_PATH,
5004 CHANNEL_PATH,
5005 TEXTPROP_PATH,
5006 TERMINAL_PATH,
5007 TESTING_PATH,
5008 ];
5009 index = 0;
5010 _b.label = 1;
5011 case 1:
5012 if (!(index < paths.length)) return [3 /*break*/, 4];
5013 p = path_1.join(vimruntime, paths[index]);
5014 return [4 /*yield*/, util_1.pcb(fs_1.readFile)(p, "utf-8")];
5015 case 2:
5016 _a = _b.sent(), err = _a[0], data = _a[1];
5017 if (err) {
5018 // tslint:disable-next-line: no-console
5019 console.error("[vimls]: read " + p + " error: " + err.message);
5020 }
5021 this.text[paths[index]] = (data && data.toString().split("\n")) || [];
5022 _b.label = 3;
5023 case 3:
5024 index++;
5025 return [3 /*break*/, 1];
5026 case 4:
5027 this.resolveVimPredefinedVariables();
5028 this.resolveVimOptions();
5029 this.resolveBuiltinFunctions();
5030 this.resolveBuiltinFunctionsDocument();
5031 this.resolveBuiltinVimPopupFunctionsDocument();
5032 this.resolveBuiltinVimChannelFunctionsDocument();
5033 this.resolveBuiltinVimJobFunctionsDocument();
5034 this.resolveBuiltinVimTextpropFunctionsDocument();
5035 this.resolveBuiltinVimTerminalFunctionsDocument();
5036 this.resolveBuiltinVimTestingFunctionsDocument();
5037 this.resolveBuiltinNvimFunctions();
5038 this.resolveExpandKeywords();
5039 this.resolveVimCommands();
5040 this.resolveVimFeatures();
5041 this.resolveVimAutocmds();
5042 _b.label = 5;
5043 case 5: return [2 /*return*/];
5044 }
5045 });
5046 });
5047 };
5048 Server.prototype.serialize = function () {
5049 var str = JSON.stringify({
5050 completionItems: {
5051 commands: this.vimCommandItems,
5052 functions: this.vimBuiltinFunctionItems,
5053 variables: this.vimPredefinedVariablesItems,
5054 options: this.vimOptionItems,
5055 features: this.vimFeatureItems,
5056 expandKeywords: this.vimExpandKeywordItems,
5057 autocmds: this.vimAutocmdItems,
5058 },
5059 signatureHelp: this.vimBuiltFunctionSignatureHelp,
5060 documents: {
5061 commands: this.vimCommandDocuments,
5062 functions: this.vimBuiltFunctionDocuments,
5063 variables: this.vimPredefinedVariableDocuments,
5064 options: this.vimOptionDocuments,
5065 features: this.vimFeatureDocuments,
5066 expandKeywords: this.expandKeywordDocuments,
5067 },
5068 }, null, 2);
5069 fs_1.writeFileSync("./src/docs/builtin-docs.json", str, "utf-8");
5070 };
5071 Server.prototype.formatFunctionSnippets = function (fname, snippets) {
5072 if (snippets === "") {
5073 return fname + "(${0})";
5074 }
5075 var idx = 0;
5076 if (/^\[.+\]/.test(snippets)) {
5077 return fname + "(${1})${0}";
5078 }
5079 var str = snippets.split("[")[0].trim().replace(/\{?(\w+)\}?/g, function (m, g1) {
5080 return "${" + (idx += 1) + ":" + g1 + "}";
5081 });
5082 return fname + "(" + str + ")${0}";
5083 };
5084 // get vim predefined variables from vim document eval.txt
5085 Server.prototype.resolveVimPredefinedVariables = function () {
5086 var evalText = this.text[EVAL_PATH] || [];
5087 var isMatchLine = false;
5088 var completionItem;
5089 for (var _i = 0, evalText_1 = evalText; _i < evalText_1.length; _i++) {
5090 var line = evalText_1[_i];
5091 if (!isMatchLine) {
5092 if (/\*vim-variable\*/.test(line)) {
5093 isMatchLine = true;
5094 }
5095 continue;
5096 }
5097 else {
5098 var m = line.match(/^(v:[^ \t]+)[ \t]+([^ ].*)$/);
5099 if (m) {
5100 if (completionItem) {
5101 this.vimPredefinedVariablesItems.push(completionItem);
5102 this.vimPredefinedVariableDocuments[completionItem.label].pop();
5103 completionItem = undefined;
5104 }
5105 var label = m[1];
5106 completionItem = {
5107 label: label,
5108 kind: vscode_languageserver_1.CompletionItemKind.Variable,
5109 sortText: constant_1.sortTexts.four,
5110 insertText: label.slice(2),
5111 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
5112 };
5113 if (!this.vimPredefinedVariableDocuments[label]) {
5114 this.vimPredefinedVariableDocuments[label] = [];
5115 }
5116 this.vimPredefinedVariableDocuments[label].push(m[2]);
5117 }
5118 else if (/^\s*$/.test(line) && completionItem) {
5119 this.vimPredefinedVariablesItems.push(completionItem);
5120 completionItem = undefined;
5121 }
5122 else if (completionItem) {
5123 this.vimPredefinedVariableDocuments[completionItem.label].push(line);
5124 }
5125 else if (/===============/.test(line)) {
5126 break;
5127 }
5128 }
5129 }
5130 };
5131 // get vim options from vim document options.txt
5132 Server.prototype.resolveVimOptions = function () {
5133 var optionsText = this.text[OPTIONS_PATH] || [];
5134 var isMatchLine = false;
5135 var completionItem;
5136 for (var _i = 0, optionsText_1 = optionsText; _i < optionsText_1.length; _i++) {
5137 var line = optionsText_1[_i];
5138 if (!isMatchLine) {
5139 if (/\*'aleph'\*/.test(line)) {
5140 isMatchLine = true;
5141 }
5142 continue;
5143 }
5144 else {
5145 var m = line.match(/^'([^']+)'[ \t]+('[^']+')?[ \t]+([^ \t].*)$/);
5146 if (m) {
5147 var label = m[1];
5148 completionItem = {
5149 label: label,
5150 kind: vscode_languageserver_1.CompletionItemKind.Property,
5151 detail: m[3].trim().split(/[ \t]/)[0],
5152 documentation: "",
5153 sortText: "00004",
5154 insertText: m[1],
5155 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
5156 };
5157 if (!this.vimOptionDocuments[label]) {
5158 this.vimOptionDocuments[label] = [];
5159 }
5160 this.vimOptionDocuments[label].push(m[3]);
5161 }
5162 else if (/^\s*$/.test(line) && completionItem) {
5163 this.vimOptionItems.push(completionItem);
5164 completionItem = undefined;
5165 }
5166 else if (completionItem) {
5167 this.vimOptionDocuments[completionItem.label].push(line);
5168 }
5169 }
5170 }
5171 };
5172 // get vim builtin function from document eval.txt
5173 Server.prototype.resolveBuiltinFunctions = function () {
5174 var evalText = this.text[EVAL_PATH] || [];
5175 var isMatchLine = false;
5176 var completionItem;
5177 for (var _i = 0, evalText_2 = evalText; _i < evalText_2.length; _i++) {
5178 var line = evalText_2[_i];
5179 if (!isMatchLine) {
5180 if (/\*functions\*/.test(line)) {
5181 isMatchLine = true;
5182 }
5183 continue;
5184 }
5185 else {
5186 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5187 if (m) {
5188 if (completionItem) {
5189 this.vimBuiltinFunctionItems.push(completionItem);
5190 }
5191 var label = m[2];
5192 completionItem = {
5193 label: label,
5194 kind: vscode_languageserver_1.CompletionItemKind.Function,
5195 detail: (m[4] || "").split(/[ \t]/)[0],
5196 sortText: "00004",
5197 insertText: this.formatFunctionSnippets(m[2], m[3]),
5198 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
5199 };
5200 this.vimBuiltFunctionSignatureHelp[label] = [
5201 m[3],
5202 (m[4] || "").split(/[ \t]/)[0],
5203 ];
5204 }
5205 else if (/^[ \t]*$/.test(line)) {
5206 if (completionItem) {
5207 this.vimBuiltinFunctionItems.push(completionItem);
5208 completionItem = undefined;
5209 break;
5210 }
5211 }
5212 else if (completionItem) {
5213 if (completionItem.detail === "") {
5214 completionItem.detail = line.trim().split(/[ \t]/)[0];
5215 if (this.vimBuiltFunctionSignatureHelp[completionItem.label]) {
5216 this.vimBuiltFunctionSignatureHelp[completionItem.label][1] = line.trim().split(/[ \t]/)[0];
5217 }
5218 }
5219 }
5220 }
5221 }
5222 };
5223 Server.prototype.resolveBuiltinFunctionsDocument = function () {
5224 var evalText = this.text[EVAL_PATH] || [];
5225 var isMatchLine = false;
5226 var label = "";
5227 for (var idx = 0; idx < evalText.length; idx++) {
5228 var line = evalText[idx];
5229 if (!isMatchLine) {
5230 if (/\*abs\(\)\*/.test(line)) {
5231 isMatchLine = true;
5232 idx -= 1;
5233 }
5234 continue;
5235 }
5236 else {
5237 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5238 if (m) {
5239 if (label) {
5240 this.vimBuiltFunctionDocuments[label].pop();
5241 }
5242 label = m[2];
5243 if (!this.vimBuiltFunctionDocuments[label]) {
5244 this.vimBuiltFunctionDocuments[label] = [];
5245 }
5246 }
5247 else if (/^[ \t]*\*string-match\*[ \t]*$/.test(line)) {
5248 if (label) {
5249 this.vimBuiltFunctionDocuments[label].pop();
5250 }
5251 break;
5252 }
5253 else if (label) {
5254 this.vimBuiltFunctionDocuments[label].push(line);
5255 }
5256 }
5257 }
5258 };
5259 Server.prototype.resolveBuiltinVimPopupFunctionsDocument = function () {
5260 var popupText = this.text[POPUP_PATH] || [];
5261 var isMatchLine = false;
5262 var label = "";
5263 for (var idx = 0; idx < popupText.length; idx++) {
5264 var line = popupText[idx];
5265 if (!isMatchLine) {
5266 if (/^DETAILS\s+\*popup-function-details\*/.test(line)) {
5267 isMatchLine = true;
5268 idx += 1;
5269 }
5270 continue;
5271 }
5272 else {
5273 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5274 if (m) {
5275 if (label) {
5276 this.vimBuiltFunctionDocuments[label].pop();
5277 }
5278 label = m[2];
5279 if (!this.vimBuiltFunctionDocuments[label]) {
5280 this.vimBuiltFunctionDocuments[label] = [];
5281 }
5282 }
5283 else if (/^=+$/.test(line)) {
5284 if (label) {
5285 this.vimBuiltFunctionDocuments[label].pop();
5286 }
5287 break;
5288 }
5289 else if (label) {
5290 this.vimBuiltFunctionDocuments[label].push(line);
5291 }
5292 }
5293 }
5294 };
5295 Server.prototype.resolveBuiltinVimChannelFunctionsDocument = function () {
5296 var channelText = this.text[CHANNEL_PATH] || [];
5297 var isMatchLine = false;
5298 var label = "";
5299 for (var idx = 0; idx < channelText.length; idx++) {
5300 var line = channelText[idx];
5301 if (!isMatchLine) {
5302 if (/^8\.\sChannel\sfunctions\sdetails\s+\*channel-functions-details\*/.test(line)) {
5303 isMatchLine = true;
5304 idx += 1;
5305 }
5306 continue;
5307 }
5308 else {
5309 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5310 if (m) {
5311 if (label) {
5312 this.vimBuiltFunctionDocuments[label].pop();
5313 }
5314 label = m[2];
5315 if (!this.vimBuiltFunctionDocuments[label]) {
5316 this.vimBuiltFunctionDocuments[label] = [];
5317 }
5318 }
5319 else if (/^=+$/.test(line)) {
5320 if (label) {
5321 this.vimBuiltFunctionDocuments[label].pop();
5322 }
5323 break;
5324 }
5325 else if (label) {
5326 this.vimBuiltFunctionDocuments[label].push(line);
5327 }
5328 }
5329 }
5330 };
5331 Server.prototype.resolveBuiltinVimJobFunctionsDocument = function () {
5332 var channelText = this.text[CHANNEL_PATH] || [];
5333 var isMatchLine = false;
5334 var label = "";
5335 for (var idx = 0; idx < channelText.length; idx++) {
5336 var line = channelText[idx];
5337 if (!isMatchLine) {
5338 if (/^11\.\sJob\sfunctions\s+\*job-functions-details\*/.test(line)) {
5339 isMatchLine = true;
5340 idx += 1;
5341 }
5342 continue;
5343 }
5344 else {
5345 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5346 if (m) {
5347 if (label) {
5348 this.vimBuiltFunctionDocuments[label].pop();
5349 }
5350 label = m[2];
5351 if (!this.vimBuiltFunctionDocuments[label]) {
5352 this.vimBuiltFunctionDocuments[label] = [];
5353 }
5354 }
5355 else if (/^=+$/.test(line)) {
5356 if (label) {
5357 this.vimBuiltFunctionDocuments[label].pop();
5358 }
5359 break;
5360 }
5361 else if (label) {
5362 this.vimBuiltFunctionDocuments[label].push(line);
5363 }
5364 }
5365 }
5366 };
5367 Server.prototype.resolveBuiltinVimTextpropFunctionsDocument = function () {
5368 var textpropText = this.text[TEXTPROP_PATH] || [];
5369 var isMatchLine = false;
5370 var label = "";
5371 // tslint:disable-next-line: prefer-for-of
5372 for (var idx = 0; idx < textpropText.length; idx++) {
5373 var line = textpropText[idx];
5374 if (!isMatchLine) {
5375 if (/^\s+\*prop_add\(\)\*\s\*E965/.test(line)) {
5376 isMatchLine = true;
5377 }
5378 continue;
5379 }
5380 else {
5381 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5382 if (m) {
5383 if (label) {
5384 this.vimBuiltFunctionDocuments[label].pop();
5385 }
5386 label = m[2];
5387 if (!this.vimBuiltFunctionDocuments[label]) {
5388 this.vimBuiltFunctionDocuments[label] = [];
5389 }
5390 }
5391 else if (/^=+$/.test(line)) {
5392 if (label) {
5393 this.vimBuiltFunctionDocuments[label].pop();
5394 }
5395 break;
5396 }
5397 else if (label) {
5398 this.vimBuiltFunctionDocuments[label].push(line);
5399 }
5400 }
5401 }
5402 };
5403 Server.prototype.resolveBuiltinVimTerminalFunctionsDocument = function () {
5404 var terminalText = this.text[TERMINAL_PATH] || [];
5405 var isMatchLine = false;
5406 var label = "";
5407 // tslint:disable-next-line: prefer-for-of
5408 for (var idx = 0; idx < terminalText.length; idx++) {
5409 var line = terminalText[idx];
5410 if (!isMatchLine) {
5411 if (/^\s+\*term_dumpdiff\(\)/.test(line)) {
5412 isMatchLine = true;
5413 }
5414 continue;
5415 }
5416 else {
5417 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5418 if (m) {
5419 if (label) {
5420 this.vimBuiltFunctionDocuments[label].pop();
5421 }
5422 label = m[2];
5423 if (!this.vimBuiltFunctionDocuments[label]) {
5424 this.vimBuiltFunctionDocuments[label] = [];
5425 }
5426 }
5427 else if (/^=+$/.test(line)) {
5428 if (label) {
5429 this.vimBuiltFunctionDocuments[label].pop();
5430 }
5431 break;
5432 }
5433 else if (label) {
5434 this.vimBuiltFunctionDocuments[label].push(line);
5435 }
5436 }
5437 }
5438 };
5439 Server.prototype.resolveBuiltinVimTestingFunctionsDocument = function () {
5440 var testingText = this.text[TESTING_PATH] || [];
5441 var isMatchLine = false;
5442 var label = "";
5443 // tslint:disable-next-line: prefer-for-of
5444 for (var idx = 0; idx < testingText.length; idx++) {
5445 var line = testingText[idx];
5446 if (!isMatchLine) {
5447 if (/^2\.\sTest\sfunctions\s+\*test-functions-details\*/.test(line)) {
5448 isMatchLine = true;
5449 idx += 1;
5450 }
5451 continue;
5452 }
5453 else {
5454 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
5455 if (m) {
5456 if (label) {
5457 this.vimBuiltFunctionDocuments[label].pop();
5458 }
5459 label = m[2];
5460 if (!this.vimBuiltFunctionDocuments[label]) {
5461 this.vimBuiltFunctionDocuments[label] = [];
5462 }
5463 }
5464 else if (/^=+$/.test(line)) {
5465 if (label) {
5466 this.vimBuiltFunctionDocuments[label].pop();
5467 }
5468 break;
5469 }
5470 else if (label) {
5471 this.vimBuiltFunctionDocuments[label].push(line);
5472 }
5473 }
5474 }
5475 };
5476 Server.prototype.resolveBuiltinNvimFunctions = function () {
5477 var evalText = this.text[API_PATH] || [];
5478 var completionItem;
5479 var pattern = /^((nvim_\w+)\(([^)]*)\))[ \t]*/m;
5480 for (var idx = 0; idx < evalText.length; idx++) {
5481 var line = evalText[idx];
5482 var m = line.match(pattern);
5483 if (!m && evalText[idx + 1]) {
5484 m = [line, evalText[idx + 1].trim()].join(" ").match(pattern);
5485 if (m) {
5486 idx++;
5487 }
5488 }
5489 if (m) {
5490 if (completionItem) {
5491 this.vimBuiltinFunctionItems.push(completionItem);
5492 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
5493 this.vimBuiltFunctionDocuments[completionItem.label].pop();
5494 }
5495 }
5496 var label = m[2];
5497 completionItem = {
5498 label: label,
5499 kind: vscode_languageserver_1.CompletionItemKind.Function,
5500 detail: "",
5501 documentation: "",
5502 sortText: "00004",
5503 insertText: this.formatFunctionSnippets(m[2], m[3]),
5504 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
5505 };
5506 if (!this.vimBuiltFunctionDocuments[label]) {
5507 this.vimBuiltFunctionDocuments[label] = [];
5508 }
5509 this.vimBuiltFunctionSignatureHelp[label] = [
5510 m[3],
5511 "",
5512 ];
5513 }
5514 else if (/^(================|[ \t]*vim:tw=78:ts=8:ft=help:norl:)/.test(line)) {
5515 if (completionItem) {
5516 this.vimBuiltinFunctionItems.push(completionItem);
5517 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
5518 this.vimBuiltFunctionDocuments[completionItem.label].pop();
5519 }
5520 completionItem = undefined;
5521 }
5522 }
5523 else if (completionItem && !/^[ \t]\*nvim(_\w+)+\(\)\*\s*$/.test(line)) {
5524 this.vimBuiltFunctionDocuments[completionItem.label].push(line);
5525 }
5526 }
5527 };
5528 Server.prototype.resolveVimCommands = function () {
5529 var indexText = this.text[INDEX_PATH] || [];
5530 var isMatchLine = false;
5531 var completionItem;
5532 for (var _i = 0, indexText_1 = indexText; _i < indexText_1.length; _i++) {
5533 var line = indexText_1[_i];
5534 if (!isMatchLine) {
5535 if (/\*ex-cmd-index\*/.test(line)) {
5536 isMatchLine = true;
5537 }
5538 continue;
5539 }
5540 else {
5541 var m = line.match(/^\|?:([^ \t]+?)\|?[ \t]+:([^ \t]+)[ \t]+([^ \t].*)$/);
5542 if (m) {
5543 if (completionItem) {
5544 this.vimCommandItems.push(completionItem);
5545 }
5546 var label = m[1];
5547 completionItem = {
5548 label: m[1],
5549 kind: vscode_languageserver_1.CompletionItemKind.Operator,
5550 detail: m[2],
5551 documentation: m[3],
5552 sortText: "00004",
5553 insertText: m[1],
5554 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
5555 };
5556 if (!this.vimCommandDocuments[label]) {
5557 this.vimCommandDocuments[label] = [];
5558 }
5559 this.vimCommandDocuments[label].push(m[3]);
5560 }
5561 else if (/^[ \t]*$/.test(line)) {
5562 if (completionItem) {
5563 this.vimCommandItems.push(completionItem);
5564 completionItem = undefined;
5565 break;
5566 }
5567 }
5568 else if (completionItem) {
5569 completionItem.documentation += " " + line.trim();
5570 this.vimCommandDocuments[completionItem.label].push(line);
5571 }
5572 }
5573 }
5574 };
5575 Server.prototype.resolveVimFeatures = function () {
5576 var text = this.text[EVAL_PATH] || [];
5577 var isMatchLine = false;
5578 var completionItem;
5579 var features = [];
5580 for (var idx = 0; idx < text.length; idx++) {
5581 var line = text[idx];
5582 if (!isMatchLine) {
5583 if (/^[ \t]*acl[ \t]/.test(line)) {
5584 isMatchLine = true;
5585 idx -= 1;
5586 }
5587 continue;
5588 }
5589 else {
5590 var m = line.match(/^[ \t]*\*?([^ \t]+?)\*?[ \t]+([^ \t].*)$/);
5591 if (m) {
5592 if (completionItem) {
5593 features.push(completionItem);
5594 }
5595 var label = m[1];
5596 completionItem = {
5597 label: m[1],
5598 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
5599 documentation: "",
5600 sortText: "00004",
5601 insertText: m[1],
5602 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
5603 };
5604 if (!this.vimFeatureDocuments[label]) {
5605 this.vimFeatureDocuments[label] = [];
5606 }
5607 this.vimFeatureDocuments[label].push(m[2]);
5608 }
5609 else if (/^[ \t]*$/.test(line)) {
5610 if (completionItem) {
5611 features.push(completionItem);
5612 break;
5613 }
5614 }
5615 else if (completionItem) {
5616 this.vimFeatureDocuments[completionItem.label].push(line);
5617 }
5618 }
5619 }
5620 this.vimFeatureItems = features;
5621 };
5622 Server.prototype.resolveVimAutocmds = function () {
5623 var text = this.text[AUTOCMD_PATH] || [];
5624 var isMatchLine = false;
5625 for (var idx = 0; idx < text.length; idx++) {
5626 var line = text[idx];
5627 if (!isMatchLine) {
5628 if (/^\|BufNewFile\|/.test(line)) {
5629 isMatchLine = true;
5630 idx -= 1;
5631 }
5632 continue;
5633 }
5634 else {
5635 var m = line.match(/^\|([^ \t]+)\|[ \t]+([^ \t].*)$/);
5636 if (m) {
5637 this.vimAutocmdItems.push({
5638 label: m[1],
5639 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
5640 documentation: m[2],
5641 sortText: "00004",
5642 insertText: m[1],
5643 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
5644 });
5645 if (m[1] === "Signal") {
5646 break;
5647 }
5648 }
5649 }
5650 }
5651 };
5652 Server.prototype.resolveExpandKeywords = function () {
5653 var _this = this;
5654 this.vimExpandKeywordItems = [
5655 "<cfile>,file name under the cursor",
5656 "<afile>,autocmd file name",
5657 "<abuf>,autocmd buffer number (as a String!)",
5658 "<amatch>,autocmd matched name",
5659 "<sfile>,sourced script file or function name",
5660 "<slnum>,sourced script file line number",
5661 "<cword>,word under the cursor",
5662 "<cWORD>,WORD under the cursor",
5663 "<client>,the {clientid} of the last received message `server2client()`",
5664 ].map(function (line) {
5665 var item = line.split(",");
5666 _this.expandKeywordDocuments[item[0]] = [
5667 item[1],
5668 ];
5669 return {
5670 label: item[0],
5671 kind: vscode_languageserver_1.CompletionItemKind.Keyword,
5672 documentation: item[1],
5673 sortText: "00004",
5674 insertText: item[0],
5675 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
5676 };
5677 });
5678 };
5679 return Server;
5680}());
5681function main() {
5682 return __awaiter(this, void 0, void 0, function () {
5683 var servers, idx, server;
5684 return __generator(this, function (_a) {
5685 switch (_a.label) {
5686 case 0:
5687 servers = [];
5688 idx = 2;
5689 _a.label = 1;
5690 case 1:
5691 if (!(idx < process.argv.length)) return [3 /*break*/, 4];
5692 servers.push(new Server({
5693 vimruntime: process.argv[idx],
5694 }));
5695 return [4 /*yield*/, servers[servers.length - 1].build()];
5696 case 2:
5697 _a.sent();
5698 _a.label = 3;
5699 case 3:
5700 idx++;
5701 return [3 /*break*/, 1];
5702 case 4:
5703 server = servers.reduce(function (pre, next) {
5704 // merge functions
5705 next.vimBuiltinFunctionItems.forEach(function (item) {
5706 var label = item.label;
5707 if (!pre.vimBuiltFunctionDocuments[label]) {
5708 pre.vimBuiltinFunctionItems.push(item);
5709 pre.vimBuiltFunctionDocuments[label] = next.vimBuiltFunctionDocuments[label];
5710 }
5711 });
5712 // merge commands
5713 next.vimCommandItems.forEach(function (item) {
5714 var label = item.label;
5715 if (!pre.vimCommandDocuments[label]) {
5716 pre.vimCommandItems.push(item);
5717 pre.vimCommandDocuments[label] = next.vimCommandDocuments[label];
5718 }
5719 });
5720 // merge options
5721 next.vimOptionItems.forEach(function (item) {
5722 var label = item.label;
5723 if (!pre.vimOptionDocuments[label]) {
5724 pre.vimOptionItems.push(item);
5725 pre.vimOptionDocuments[label] = next.vimOptionDocuments[label];
5726 }
5727 });
5728 // merge variables
5729 next.vimPredefinedVariablesItems.forEach(function (item) {
5730 var label = item.label;
5731 if (!pre.vimPredefinedVariableDocuments[label]) {
5732 pre.vimPredefinedVariablesItems.push(item);
5733 pre.vimPredefinedVariableDocuments[label] = next.vimPredefinedVariableDocuments[label];
5734 }
5735 });
5736 // merge features
5737 next.vimFeatureItems.forEach(function (item) {
5738 var label = item.label;
5739 if (!pre.vimFeatureDocuments[label]) {
5740 pre.vimFeatureItems.push(item);
5741 pre.vimFeatureDocuments[label] = next.vimFeatureDocuments[label];
5742 }
5743 });
5744 // merge expand key words
5745 next.vimExpandKeywordItems.forEach(function (item) {
5746 var label = item.label;
5747 if (!pre.expandKeywordDocuments[label]) {
5748 pre.vimExpandKeywordItems.push(item);
5749 pre.expandKeywordDocuments[label] = next.expandKeywordDocuments[label];
5750 }
5751 });
5752 // merge autocmd
5753 next.vimAutocmdItems.forEach(function (item) {
5754 var label = item.label;
5755 if (!pre.vimAutocmdItems.some(function (n) { return n.label === label; })) {
5756 pre.vimAutocmdItems.push(item);
5757 }
5758 });
5759 // merge signature help
5760 pre.vimBuiltFunctionSignatureHelp = __assign(__assign({}, next.vimBuiltFunctionSignatureHelp), pre.vimBuiltFunctionSignatureHelp);
5761 return pre;
5762 });
5763 server.serialize();
5764 return [2 /*return*/];
5765 }
5766 });
5767 });
5768}
5769main();
5770
5771
5772/***/ }),
5773
5774/***/ 38:
5775/***/ (function(module, exports, __webpack_require__) {
5776
5777"use strict";
5778/* --------------------------------------------------------------------------------------------
5779 * Copyright (c) Microsoft Corporation. All rights reserved.
5780 * Licensed under the MIT License. See License.txt in the project root for license information.
5781 * ------------------------------------------------------------------------------------------ */
5782
5783Object.defineProperty(exports, "__esModule", { value: true });
5784const url = __webpack_require__(39);
5785const path = __webpack_require__(13);
5786const fs = __webpack_require__(40);
5787const child_process_1 = __webpack_require__(41);
5788/**
5789 * @deprecated Use the `vscode-uri` npm module which provides a more
5790 * complete implementation of handling VS Code URIs.
5791 */
5792function uriToFilePath(uri) {
5793 let parsed = url.parse(uri);
5794 if (parsed.protocol !== 'file:' || !parsed.path) {
5795 return undefined;
5796 }
5797 let segments = parsed.path.split('/');
5798 for (var i = 0, len = segments.length; i < len; i++) {
5799 segments[i] = decodeURIComponent(segments[i]);
5800 }
5801 if (process.platform === 'win32' && segments.length > 1) {
5802 let first = segments[0];
5803 let second = segments[1];
5804 // Do we have a drive letter and we started with a / which is the
5805 // case if the first segement is empty (see split above)
5806 if (first.length === 0 && second.length > 1 && second[1] === ':') {
5807 // Remove first slash
5808 segments.shift();
5809 }
5810 }
5811 return path.normalize(segments.join('/'));
5812}
5813exports.uriToFilePath = uriToFilePath;
5814function isWindows() {
5815 return process.platform === 'win32';
5816}
5817function resolve(moduleName, nodePath, cwd, tracer) {
5818 const nodePathKey = 'NODE_PATH';
5819 const app = [
5820 'var p = process;',
5821 'p.on(\'message\',function(m){',
5822 'if(m.c===\'e\'){',
5823 'p.exit(0);',
5824 '}',
5825 'else if(m.c===\'rs\'){',
5826 'try{',
5827 'var r=require.resolve(m.a);',
5828 'p.send({c:\'r\',s:true,r:r});',
5829 '}',
5830 'catch(err){',
5831 'p.send({c:\'r\',s:false});',
5832 '}',
5833 '}',
5834 '});'
5835 ].join('');
5836 return new Promise((resolve, reject) => {
5837 let env = process.env;
5838 let newEnv = Object.create(null);
5839 Object.keys(env).forEach(key => newEnv[key] = env[key]);
5840 if (nodePath && fs.existsSync(nodePath) /* see issue 545 */) {
5841 if (newEnv[nodePathKey]) {
5842 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
5843 }
5844 else {
5845 newEnv[nodePathKey] = nodePath;
5846 }
5847 if (tracer) {
5848 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
5849 }
5850 }
5851 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
5852 try {
5853 let cp = child_process_1.fork('', [], {
5854 cwd: cwd,
5855 env: newEnv,
5856 execArgv: ['-e', app]
5857 });
5858 if (cp.pid === void 0) {
5859 reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
5860 return;
5861 }
5862 cp.on('error', (error) => {
5863 reject(error);
5864 });
5865 cp.on('message', (message) => {
5866 if (message.c === 'r') {
5867 cp.send({ c: 'e' });
5868 if (message.s) {
5869 resolve(message.r);
5870 }
5871 else {
5872 reject(new Error(`Failed to resolve module: ${moduleName}`));
5873 }
5874 }
5875 });
5876 let message = {
5877 c: 'rs',
5878 a: moduleName
5879 };
5880 cp.send(message);
5881 }
5882 catch (error) {
5883 reject(error);
5884 }
5885 });
5886}
5887exports.resolve = resolve;
5888/**
5889 * Resolve the global npm package path.
5890 * @deprecated Since this depends on the used package manager and their version the best is that servers
5891 * implement this themselves since they know best what kind of package managers to support.
5892 * @param tracer the tracer to use
5893 */
5894function resolveGlobalNodePath(tracer) {
5895 let npmCommand = 'npm';
5896 const env = Object.create(null);
5897 Object.keys(process.env).forEach(key => env[key] = process.env[key]);
5898 env['NO_UPDATE_NOTIFIER'] = 'true';
5899 const options = {
5900 encoding: 'utf8',
5901 env
5902 };
5903 if (isWindows()) {
5904 npmCommand = 'npm.cmd';
5905 options.shell = true;
5906 }
5907 let handler = () => { };
5908 try {
5909 process.on('SIGPIPE', handler);
5910 let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;
5911 if (!stdout) {
5912 if (tracer) {
5913 tracer(`'npm config get prefix' didn't return a value.`);
5914 }
5915 return undefined;
5916 }
5917 let prefix = stdout.trim();
5918 if (tracer) {
5919 tracer(`'npm config get prefix' value is: ${prefix}`);
5920 }
5921 if (prefix.length > 0) {
5922 if (isWindows()) {
5923 return path.join(prefix, 'node_modules');
5924 }
5925 else {
5926 return path.join(prefix, 'lib', 'node_modules');
5927 }
5928 }
5929 return undefined;
5930 }
5931 catch (err) {
5932 return undefined;
5933 }
5934 finally {
5935 process.removeListener('SIGPIPE', handler);
5936 }
5937}
5938exports.resolveGlobalNodePath = resolveGlobalNodePath;
5939/*
5940 * Resolve the global yarn pakage path.
5941 * @deprecated Since this depends on the used package manager and their version the best is that servers
5942 * implement this themselves since they know best what kind of package managers to support.
5943 * @param tracer the tracer to use
5944 */
5945function resolveGlobalYarnPath(tracer) {
5946 let yarnCommand = 'yarn';
5947 let options = {
5948 encoding: 'utf8'
5949 };
5950 if (isWindows()) {
5951 yarnCommand = 'yarn.cmd';
5952 options.shell = true;
5953 }
5954 let handler = () => { };
5955 try {
5956 process.on('SIGPIPE', handler);
5957 let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);
5958 let stdout = results.stdout;
5959 if (!stdout) {
5960 if (tracer) {
5961 tracer(`'yarn global dir' didn't return a value.`);
5962 if (results.stderr) {
5963 tracer(results.stderr);
5964 }
5965 }
5966 return undefined;
5967 }
5968 let lines = stdout.trim().split(/\r?\n/);
5969 for (let line of lines) {
5970 try {
5971 let yarn = JSON.parse(line);
5972 if (yarn.type === 'log') {
5973 return path.join(yarn.data, 'node_modules');
5974 }
5975 }
5976 catch (e) {
5977 // Do nothing. Ignore the line
5978 }
5979 }
5980 return undefined;
5981 }
5982 catch (err) {
5983 return undefined;
5984 }
5985 finally {
5986 process.removeListener('SIGPIPE', handler);
5987 }
5988}
5989exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
5990var FileSystem;
5991(function (FileSystem) {
5992 let _isCaseSensitive = undefined;
5993 function isCaseSensitive() {
5994 if (_isCaseSensitive !== void 0) {
5995 return _isCaseSensitive;
5996 }
5997 if (process.platform === 'win32') {
5998 _isCaseSensitive = false;
5999 }
6000 else {
6001 // convert current file name to upper case / lower case and check if file exists
6002 // (guards against cases when name is already all uppercase or lowercase)
6003 _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
6004 }
6005 return _isCaseSensitive;
6006 }
6007 FileSystem.isCaseSensitive = isCaseSensitive;
6008 function isParent(parent, child) {
6009 if (isCaseSensitive()) {
6010 return path.normalize(child).indexOf(path.normalize(parent)) === 0;
6011 }
6012 else {
6013 return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) === 0;
6014 }
6015 }
6016 FileSystem.isParent = isParent;
6017})(FileSystem = exports.FileSystem || (exports.FileSystem = {}));
6018function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
6019 if (nodePath) {
6020 if (!path.isAbsolute(nodePath)) {
6021 nodePath = path.join(workspaceRoot, nodePath);
6022 }
6023 return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
6024 if (FileSystem.isParent(nodePath, value)) {
6025 return value;
6026 }
6027 else {
6028 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
6029 }
6030 }).then(undefined, (_error) => {
6031 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
6032 });
6033 }
6034 else {
6035 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
6036 }
6037}
6038exports.resolveModulePath = resolveModulePath;
6039//# sourceMappingURL=files.js.map
6040
6041/***/ }),
6042
6043/***/ 39:
6044/***/ (function(module, exports) {
6045
6046module.exports = require("url");
6047
6048/***/ }),
6049
6050/***/ 4:
6051/***/ (function(module, exports, __webpack_require__) {
6052
6053"use strict";
6054/* --------------------------------------------------------------------------------------------
6055 * Copyright (c) Microsoft Corporation. All rights reserved.
6056 * Licensed under the MIT License. See License.txt in the project root for license information.
6057 * ------------------------------------------------------------------------------------------ */
6058/// <reference path="../typings/thenable.d.ts" />
6059
6060function __export(m) {
6061 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
6062}
6063Object.defineProperty(exports, "__esModule", { value: true });
6064const Is = __webpack_require__(5);
6065const messages_1 = __webpack_require__(6);
6066exports.RequestType = messages_1.RequestType;
6067exports.RequestType0 = messages_1.RequestType0;
6068exports.RequestType1 = messages_1.RequestType1;
6069exports.RequestType2 = messages_1.RequestType2;
6070exports.RequestType3 = messages_1.RequestType3;
6071exports.RequestType4 = messages_1.RequestType4;
6072exports.RequestType5 = messages_1.RequestType5;
6073exports.RequestType6 = messages_1.RequestType6;
6074exports.RequestType7 = messages_1.RequestType7;
6075exports.RequestType8 = messages_1.RequestType8;
6076exports.RequestType9 = messages_1.RequestType9;
6077exports.ResponseError = messages_1.ResponseError;
6078exports.ErrorCodes = messages_1.ErrorCodes;
6079exports.NotificationType = messages_1.NotificationType;
6080exports.NotificationType0 = messages_1.NotificationType0;
6081exports.NotificationType1 = messages_1.NotificationType1;
6082exports.NotificationType2 = messages_1.NotificationType2;
6083exports.NotificationType3 = messages_1.NotificationType3;
6084exports.NotificationType4 = messages_1.NotificationType4;
6085exports.NotificationType5 = messages_1.NotificationType5;
6086exports.NotificationType6 = messages_1.NotificationType6;
6087exports.NotificationType7 = messages_1.NotificationType7;
6088exports.NotificationType8 = messages_1.NotificationType8;
6089exports.NotificationType9 = messages_1.NotificationType9;
6090const messageReader_1 = __webpack_require__(7);
6091exports.MessageReader = messageReader_1.MessageReader;
6092exports.StreamMessageReader = messageReader_1.StreamMessageReader;
6093exports.IPCMessageReader = messageReader_1.IPCMessageReader;
6094exports.SocketMessageReader = messageReader_1.SocketMessageReader;
6095const messageWriter_1 = __webpack_require__(9);
6096exports.MessageWriter = messageWriter_1.MessageWriter;
6097exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
6098exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
6099exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
6100const events_1 = __webpack_require__(8);
6101exports.Disposable = events_1.Disposable;
6102exports.Event = events_1.Event;
6103exports.Emitter = events_1.Emitter;
6104const cancellation_1 = __webpack_require__(10);
6105exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
6106exports.CancellationToken = cancellation_1.CancellationToken;
6107const linkedMap_1 = __webpack_require__(11);
6108__export(__webpack_require__(12));
6109__export(__webpack_require__(17));
6110var CancelNotification;
6111(function (CancelNotification) {
6112 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
6113})(CancelNotification || (CancelNotification = {}));
6114var ProgressNotification;
6115(function (ProgressNotification) {
6116 ProgressNotification.type = new messages_1.NotificationType('$/progress');
6117})(ProgressNotification || (ProgressNotification = {}));
6118class ProgressType {
6119 constructor() {
6120 }
6121}
6122exports.ProgressType = ProgressType;
6123exports.NullLogger = Object.freeze({
6124 error: () => { },
6125 warn: () => { },
6126 info: () => { },
6127 log: () => { }
6128});
6129var Trace;
6130(function (Trace) {
6131 Trace[Trace["Off"] = 0] = "Off";
6132 Trace[Trace["Messages"] = 1] = "Messages";
6133 Trace[Trace["Verbose"] = 2] = "Verbose";
6134})(Trace = exports.Trace || (exports.Trace = {}));
6135(function (Trace) {
6136 function fromString(value) {
6137 if (!Is.string(value)) {
6138 return Trace.Off;
6139 }
6140 value = value.toLowerCase();
6141 switch (value) {
6142 case 'off':
6143 return Trace.Off;
6144 case 'messages':
6145 return Trace.Messages;
6146 case 'verbose':
6147 return Trace.Verbose;
6148 default:
6149 return Trace.Off;
6150 }
6151 }
6152 Trace.fromString = fromString;
6153 function toString(value) {
6154 switch (value) {
6155 case Trace.Off:
6156 return 'off';
6157 case Trace.Messages:
6158 return 'messages';
6159 case Trace.Verbose:
6160 return 'verbose';
6161 default:
6162 return 'off';
6163 }
6164 }
6165 Trace.toString = toString;
6166})(Trace = exports.Trace || (exports.Trace = {}));
6167var TraceFormat;
6168(function (TraceFormat) {
6169 TraceFormat["Text"] = "text";
6170 TraceFormat["JSON"] = "json";
6171})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
6172(function (TraceFormat) {
6173 function fromString(value) {
6174 value = value.toLowerCase();
6175 if (value === 'json') {
6176 return TraceFormat.JSON;
6177 }
6178 else {
6179 return TraceFormat.Text;
6180 }
6181 }
6182 TraceFormat.fromString = fromString;
6183})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
6184var SetTraceNotification;
6185(function (SetTraceNotification) {
6186 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
6187})(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
6188var LogTraceNotification;
6189(function (LogTraceNotification) {
6190 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
6191})(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
6192var ConnectionErrors;
6193(function (ConnectionErrors) {
6194 /**
6195 * The connection is closed.
6196 */
6197 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
6198 /**
6199 * The connection got disposed.
6200 */
6201 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
6202 /**
6203 * The connection is already in listening mode.
6204 */
6205 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
6206})(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
6207class ConnectionError extends Error {
6208 constructor(code, message) {
6209 super(message);
6210 this.code = code;
6211 Object.setPrototypeOf(this, ConnectionError.prototype);
6212 }
6213}
6214exports.ConnectionError = ConnectionError;
6215var ConnectionStrategy;
6216(function (ConnectionStrategy) {
6217 function is(value) {
6218 let candidate = value;
6219 return candidate && Is.func(candidate.cancelUndispatched);
6220 }
6221 ConnectionStrategy.is = is;
6222})(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
6223var ConnectionState;
6224(function (ConnectionState) {
6225 ConnectionState[ConnectionState["New"] = 1] = "New";
6226 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
6227 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
6228 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
6229})(ConnectionState || (ConnectionState = {}));
6230function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
6231 let sequenceNumber = 0;
6232 let notificationSquenceNumber = 0;
6233 let unknownResponseSquenceNumber = 0;
6234 const version = '2.0';
6235 let starRequestHandler = undefined;
6236 let requestHandlers = Object.create(null);
6237 let starNotificationHandler = undefined;
6238 let notificationHandlers = Object.create(null);
6239 let progressHandlers = new Map();
6240 let timer;
6241 let messageQueue = new linkedMap_1.LinkedMap();
6242 let responsePromises = Object.create(null);
6243 let requestTokens = Object.create(null);
6244 let trace = Trace.Off;
6245 let traceFormat = TraceFormat.Text;
6246 let tracer;
6247 let state = ConnectionState.New;
6248 let errorEmitter = new events_1.Emitter();
6249 let closeEmitter = new events_1.Emitter();
6250 let unhandledNotificationEmitter = new events_1.Emitter();
6251 let unhandledProgressEmitter = new events_1.Emitter();
6252 let disposeEmitter = new events_1.Emitter();
6253 function createRequestQueueKey(id) {
6254 return 'req-' + id.toString();
6255 }
6256 function createResponseQueueKey(id) {
6257 if (id === null) {
6258 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
6259 }
6260 else {
6261 return 'res-' + id.toString();
6262 }
6263 }
6264 function createNotificationQueueKey() {
6265 return 'not-' + (++notificationSquenceNumber).toString();
6266 }
6267 function addMessageToQueue(queue, message) {
6268 if (messages_1.isRequestMessage(message)) {
6269 queue.set(createRequestQueueKey(message.id), message);
6270 }
6271 else if (messages_1.isResponseMessage(message)) {
6272 queue.set(createResponseQueueKey(message.id), message);
6273 }
6274 else {
6275 queue.set(createNotificationQueueKey(), message);
6276 }
6277 }
6278 function cancelUndispatched(_message) {
6279 return undefined;
6280 }
6281 function isListening() {
6282 return state === ConnectionState.Listening;
6283 }
6284 function isClosed() {
6285 return state === ConnectionState.Closed;
6286 }
6287 function isDisposed() {
6288 return state === ConnectionState.Disposed;
6289 }
6290 function closeHandler() {
6291 if (state === ConnectionState.New || state === ConnectionState.Listening) {
6292 state = ConnectionState.Closed;
6293 closeEmitter.fire(undefined);
6294 }
6295 // If the connection is disposed don't sent close events.
6296 }
6297 function readErrorHandler(error) {
6298 errorEmitter.fire([error, undefined, undefined]);
6299 }
6300 function writeErrorHandler(data) {
6301 errorEmitter.fire(data);
6302 }
6303 messageReader.onClose(closeHandler);
6304 messageReader.onError(readErrorHandler);
6305 messageWriter.onClose(closeHandler);
6306 messageWriter.onError(writeErrorHandler);
6307 function triggerMessageQueue() {
6308 if (timer || messageQueue.size === 0) {
6309 return;
6310 }
6311 timer = setImmediate(() => {
6312 timer = undefined;
6313 processMessageQueue();
6314 });
6315 }
6316 function processMessageQueue() {
6317 if (messageQueue.size === 0) {
6318 return;
6319 }
6320 let message = messageQueue.shift();
6321 try {
6322 if (messages_1.isRequestMessage(message)) {
6323 handleRequest(message);
6324 }
6325 else if (messages_1.isNotificationMessage(message)) {
6326 handleNotification(message);
6327 }
6328 else if (messages_1.isResponseMessage(message)) {
6329 handleResponse(message);
6330 }
6331 else {
6332 handleInvalidMessage(message);
6333 }
6334 }
6335 finally {
6336 triggerMessageQueue();
6337 }
6338 }
6339 let callback = (message) => {
6340 try {
6341 // We have received a cancellation message. Check if the message is still in the queue
6342 // and cancel it if allowed to do so.
6343 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
6344 let key = createRequestQueueKey(message.params.id);
6345 let toCancel = messageQueue.get(key);
6346 if (messages_1.isRequestMessage(toCancel)) {
6347 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
6348 if (response && (response.error !== void 0 || response.result !== void 0)) {
6349 messageQueue.delete(key);
6350 response.id = toCancel.id;
6351 traceSendingResponse(response, message.method, Date.now());
6352 messageWriter.write(response);
6353 return;
6354 }
6355 }
6356 }
6357 addMessageToQueue(messageQueue, message);
6358 }
6359 finally {
6360 triggerMessageQueue();
6361 }
6362 };
6363 function handleRequest(requestMessage) {
6364 if (isDisposed()) {
6365 // we return here silently since we fired an event when the
6366 // connection got disposed.
6367 return;
6368 }
6369 function reply(resultOrError, method, startTime) {
6370 let message = {
6371 jsonrpc: version,
6372 id: requestMessage.id
6373 };
6374 if (resultOrError instanceof messages_1.ResponseError) {
6375 message.error = resultOrError.toJson();
6376 }
6377 else {
6378 message.result = resultOrError === void 0 ? null : resultOrError;
6379 }
6380 traceSendingResponse(message, method, startTime);
6381 messageWriter.write(message);
6382 }
6383 function replyError(error, method, startTime) {
6384 let message = {
6385 jsonrpc: version,
6386 id: requestMessage.id,
6387 error: error.toJson()
6388 };
6389 traceSendingResponse(message, method, startTime);
6390 messageWriter.write(message);
6391 }
6392 function replySuccess(result, method, startTime) {
6393 // The JSON RPC defines that a response must either have a result or an error
6394 // So we can't treat undefined as a valid response result.
6395 if (result === void 0) {
6396 result = null;
6397 }
6398 let message = {
6399 jsonrpc: version,
6400 id: requestMessage.id,
6401 result: result
6402 };
6403 traceSendingResponse(message, method, startTime);
6404 messageWriter.write(message);
6405 }
6406 traceReceivedRequest(requestMessage);
6407 let element = requestHandlers[requestMessage.method];
6408 let type;
6409 let requestHandler;
6410 if (element) {
6411 type = element.type;
6412 requestHandler = element.handler;
6413 }
6414 let startTime = Date.now();
6415 if (requestHandler || starRequestHandler) {
6416 let cancellationSource = new cancellation_1.CancellationTokenSource();
6417 let tokenKey = String(requestMessage.id);
6418 requestTokens[tokenKey] = cancellationSource;
6419 try {
6420 let handlerResult;
6421 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
6422 handlerResult = requestHandler
6423 ? requestHandler(cancellationSource.token)
6424 : starRequestHandler(requestMessage.method, cancellationSource.token);
6425 }
6426 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
6427 handlerResult = requestHandler
6428 ? requestHandler(...requestMessage.params, cancellationSource.token)
6429 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
6430 }
6431 else {
6432 handlerResult = requestHandler
6433 ? requestHandler(requestMessage.params, cancellationSource.token)
6434 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
6435 }
6436 let promise = handlerResult;
6437 if (!handlerResult) {
6438 delete requestTokens[tokenKey];
6439 replySuccess(handlerResult, requestMessage.method, startTime);
6440 }
6441 else if (promise.then) {
6442 promise.then((resultOrError) => {
6443 delete requestTokens[tokenKey];
6444 reply(resultOrError, requestMessage.method, startTime);
6445 }, error => {
6446 delete requestTokens[tokenKey];
6447 if (error instanceof messages_1.ResponseError) {
6448 replyError(error, requestMessage.method, startTime);
6449 }
6450 else if (error && Is.string(error.message)) {
6451 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
6452 }
6453 else {
6454 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
6455 }
6456 });
6457 }
6458 else {
6459 delete requestTokens[tokenKey];
6460 reply(handlerResult, requestMessage.method, startTime);
6461 }
6462 }
6463 catch (error) {
6464 delete requestTokens[tokenKey];
6465 if (error instanceof messages_1.ResponseError) {
6466 reply(error, requestMessage.method, startTime);
6467 }
6468 else if (error && Is.string(error.message)) {
6469 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
6470 }
6471 else {
6472 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
6473 }
6474 }
6475 }
6476 else {
6477 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
6478 }
6479 }
6480 function handleResponse(responseMessage) {
6481 if (isDisposed()) {
6482 // See handle request.
6483 return;
6484 }
6485 if (responseMessage.id === null) {
6486 if (responseMessage.error) {
6487 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
6488 }
6489 else {
6490 logger.error(`Received response message without id. No further error information provided.`);
6491 }
6492 }
6493 else {
6494 let key = String(responseMessage.id);
6495 let responsePromise = responsePromises[key];
6496 traceReceivedResponse(responseMessage, responsePromise);
6497 if (responsePromise) {
6498 delete responsePromises[key];
6499 try {
6500 if (responseMessage.error) {
6501 let error = responseMessage.error;
6502 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
6503 }
6504 else if (responseMessage.result !== void 0) {
6505 responsePromise.resolve(responseMessage.result);
6506 }
6507 else {
6508 throw new Error('Should never happen.');
6509 }
6510 }
6511 catch (error) {
6512 if (error.message) {
6513 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
6514 }
6515 else {
6516 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
6517 }
6518 }
6519 }
6520 }
6521 }
6522 function handleNotification(message) {
6523 if (isDisposed()) {
6524 // See handle request.
6525 return;
6526 }
6527 let type = undefined;
6528 let notificationHandler;
6529 if (message.method === CancelNotification.type.method) {
6530 notificationHandler = (params) => {
6531 let id = params.id;
6532 let source = requestTokens[String(id)];
6533 if (source) {
6534 source.cancel();
6535 }
6536 };
6537 }
6538 else {
6539 let element = notificationHandlers[message.method];
6540 if (element) {
6541 notificationHandler = element.handler;
6542 type = element.type;
6543 }
6544 }
6545 if (notificationHandler || starNotificationHandler) {
6546 try {
6547 traceReceivedNotification(message);
6548 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
6549 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
6550 }
6551 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
6552 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
6553 }
6554 else {
6555 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
6556 }
6557 }
6558 catch (error) {
6559 if (error.message) {
6560 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
6561 }
6562 else {
6563 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
6564 }
6565 }
6566 }
6567 else {
6568 unhandledNotificationEmitter.fire(message);
6569 }
6570 }
6571 function handleInvalidMessage(message) {
6572 if (!message) {
6573 logger.error('Received empty message.');
6574 return;
6575 }
6576 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
6577 // Test whether we find an id to reject the promise
6578 let responseMessage = message;
6579 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
6580 let key = String(responseMessage.id);
6581 let responseHandler = responsePromises[key];
6582 if (responseHandler) {
6583 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
6584 }
6585 }
6586 }
6587 function traceSendingRequest(message) {
6588 if (trace === Trace.Off || !tracer) {
6589 return;
6590 }
6591 if (traceFormat === TraceFormat.Text) {
6592 let data = undefined;
6593 if (trace === Trace.Verbose && message.params) {
6594 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
6595 }
6596 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
6597 }
6598 else {
6599 logLSPMessage('send-request', message);
6600 }
6601 }
6602 function traceSendingNotification(message) {
6603 if (trace === Trace.Off || !tracer) {
6604 return;
6605 }
6606 if (traceFormat === TraceFormat.Text) {
6607 let data = undefined;
6608 if (trace === Trace.Verbose) {
6609 if (message.params) {
6610 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
6611 }
6612 else {
6613 data = 'No parameters provided.\n\n';
6614 }
6615 }
6616 tracer.log(`Sending notification '${message.method}'.`, data);
6617 }
6618 else {
6619 logLSPMessage('send-notification', message);
6620 }
6621 }
6622 function traceSendingResponse(message, method, startTime) {
6623 if (trace === Trace.Off || !tracer) {
6624 return;
6625 }
6626 if (traceFormat === TraceFormat.Text) {
6627 let data = undefined;
6628 if (trace === Trace.Verbose) {
6629 if (message.error && message.error.data) {
6630 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
6631 }
6632 else {
6633 if (message.result) {
6634 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
6635 }
6636 else if (message.error === void 0) {
6637 data = 'No result returned.\n\n';
6638 }
6639 }
6640 }
6641 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
6642 }
6643 else {
6644 logLSPMessage('send-response', message);
6645 }
6646 }
6647 function traceReceivedRequest(message) {
6648 if (trace === Trace.Off || !tracer) {
6649 return;
6650 }
6651 if (traceFormat === TraceFormat.Text) {
6652 let data = undefined;
6653 if (trace === Trace.Verbose && message.params) {
6654 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
6655 }
6656 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
6657 }
6658 else {
6659 logLSPMessage('receive-request', message);
6660 }
6661 }
6662 function traceReceivedNotification(message) {
6663 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
6664 return;
6665 }
6666 if (traceFormat === TraceFormat.Text) {
6667 let data = undefined;
6668 if (trace === Trace.Verbose) {
6669 if (message.params) {
6670 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
6671 }
6672 else {
6673 data = 'No parameters provided.\n\n';
6674 }
6675 }
6676 tracer.log(`Received notification '${message.method}'.`, data);
6677 }
6678 else {
6679 logLSPMessage('receive-notification', message);
6680 }
6681 }
6682 function traceReceivedResponse(message, responsePromise) {
6683 if (trace === Trace.Off || !tracer) {
6684 return;
6685 }
6686 if (traceFormat === TraceFormat.Text) {
6687 let data = undefined;
6688 if (trace === Trace.Verbose) {
6689 if (message.error && message.error.data) {
6690 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
6691 }
6692 else {
6693 if (message.result) {
6694 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
6695 }
6696 else if (message.error === void 0) {
6697 data = 'No result returned.\n\n';
6698 }
6699 }
6700 }
6701 if (responsePromise) {
6702 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
6703 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
6704 }
6705 else {
6706 tracer.log(`Received response ${message.id} without active response promise.`, data);
6707 }
6708 }
6709 else {
6710 logLSPMessage('receive-response', message);
6711 }
6712 }
6713 function logLSPMessage(type, message) {
6714 if (!tracer || trace === Trace.Off) {
6715 return;
6716 }
6717 const lspMessage = {
6718 isLSPMessage: true,
6719 type,
6720 message,
6721 timestamp: Date.now()
6722 };
6723 tracer.log(lspMessage);
6724 }
6725 function throwIfClosedOrDisposed() {
6726 if (isClosed()) {
6727 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
6728 }
6729 if (isDisposed()) {
6730 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
6731 }
6732 }
6733 function throwIfListening() {
6734 if (isListening()) {
6735 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
6736 }
6737 }
6738 function throwIfNotListening() {
6739 if (!isListening()) {
6740 throw new Error('Call listen() first.');
6741 }
6742 }
6743 function undefinedToNull(param) {
6744 if (param === void 0) {
6745 return null;
6746 }
6747 else {
6748 return param;
6749 }
6750 }
6751 function computeMessageParams(type, params) {
6752 let result;
6753 let numberOfParams = type.numberOfParams;
6754 switch (numberOfParams) {
6755 case 0:
6756 result = null;
6757 break;
6758 case 1:
6759 result = undefinedToNull(params[0]);
6760 break;
6761 default:
6762 result = [];
6763 for (let i = 0; i < params.length && i < numberOfParams; i++) {
6764 result.push(undefinedToNull(params[i]));
6765 }
6766 if (params.length < numberOfParams) {
6767 for (let i = params.length; i < numberOfParams; i++) {
6768 result.push(null);
6769 }
6770 }
6771 break;
6772 }
6773 return result;
6774 }
6775 let connection = {
6776 sendNotification: (type, ...params) => {
6777 throwIfClosedOrDisposed();
6778 let method;
6779 let messageParams;
6780 if (Is.string(type)) {
6781 method = type;
6782 switch (params.length) {
6783 case 0:
6784 messageParams = null;
6785 break;
6786 case 1:
6787 messageParams = params[0];
6788 break;
6789 default:
6790 messageParams = params;
6791 break;
6792 }
6793 }
6794 else {
6795 method = type.method;
6796 messageParams = computeMessageParams(type, params);
6797 }
6798 let notificationMessage = {
6799 jsonrpc: version,
6800 method: method,
6801 params: messageParams
6802 };
6803 traceSendingNotification(notificationMessage);
6804 messageWriter.write(notificationMessage);
6805 },
6806 onNotification: (type, handler) => {
6807 throwIfClosedOrDisposed();
6808 if (Is.func(type)) {
6809 starNotificationHandler = type;
6810 }
6811 else if (handler) {
6812 if (Is.string(type)) {
6813 notificationHandlers[type] = { type: undefined, handler };
6814 }
6815 else {
6816 notificationHandlers[type.method] = { type, handler };
6817 }
6818 }
6819 },
6820 onProgress: (_type, token, handler) => {
6821 if (progressHandlers.has(token)) {
6822 throw new Error(`Progress handler for token ${token} already registered`);
6823 }
6824 progressHandlers.set(token, handler);
6825 return {
6826 dispose: () => {
6827 progressHandlers.delete(token);
6828 }
6829 };
6830 },
6831 sendProgress: (_type, token, value) => {
6832 connection.sendNotification(ProgressNotification.type, { token, value });
6833 },
6834 onUnhandledProgress: unhandledProgressEmitter.event,
6835 sendRequest: (type, ...params) => {
6836 throwIfClosedOrDisposed();
6837 throwIfNotListening();
6838 let method;
6839 let messageParams;
6840 let token = undefined;
6841 if (Is.string(type)) {
6842 method = type;
6843 switch (params.length) {
6844 case 0:
6845 messageParams = null;
6846 break;
6847 case 1:
6848 // The cancellation token is optional so it can also be undefined.
6849 if (cancellation_1.CancellationToken.is(params[0])) {
6850 messageParams = null;
6851 token = params[0];
6852 }
6853 else {
6854 messageParams = undefinedToNull(params[0]);
6855 }
6856 break;
6857 default:
6858 const last = params.length - 1;
6859 if (cancellation_1.CancellationToken.is(params[last])) {
6860 token = params[last];
6861 if (params.length === 2) {
6862 messageParams = undefinedToNull(params[0]);
6863 }
6864 else {
6865 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
6866 }
6867 }
6868 else {
6869 messageParams = params.map(value => undefinedToNull(value));
6870 }
6871 break;
6872 }
6873 }
6874 else {
6875 method = type.method;
6876 messageParams = computeMessageParams(type, params);
6877 let numberOfParams = type.numberOfParams;
6878 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
6879 }
6880 let id = sequenceNumber++;
6881 let result = new Promise((resolve, reject) => {
6882 let requestMessage = {
6883 jsonrpc: version,
6884 id: id,
6885 method: method,
6886 params: messageParams
6887 };
6888 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
6889 traceSendingRequest(requestMessage);
6890 try {
6891 messageWriter.write(requestMessage);
6892 }
6893 catch (e) {
6894 // Writing the message failed. So we need to reject the promise.
6895 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
6896 responsePromise = null;
6897 }
6898 if (responsePromise) {
6899 responsePromises[String(id)] = responsePromise;
6900 }
6901 });
6902 if (token) {
6903 token.onCancellationRequested(() => {
6904 connection.sendNotification(CancelNotification.type, { id });
6905 });
6906 }
6907 return result;
6908 },
6909 onRequest: (type, handler) => {
6910 throwIfClosedOrDisposed();
6911 if (Is.func(type)) {
6912 starRequestHandler = type;
6913 }
6914 else if (handler) {
6915 if (Is.string(type)) {
6916 requestHandlers[type] = { type: undefined, handler };
6917 }
6918 else {
6919 requestHandlers[type.method] = { type, handler };
6920 }
6921 }
6922 },
6923 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
6924 let _sendNotification = false;
6925 let _traceFormat = TraceFormat.Text;
6926 if (sendNotificationOrTraceOptions !== void 0) {
6927 if (Is.boolean(sendNotificationOrTraceOptions)) {
6928 _sendNotification = sendNotificationOrTraceOptions;
6929 }
6930 else {
6931 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
6932 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
6933 }
6934 }
6935 trace = _value;
6936 traceFormat = _traceFormat;
6937 if (trace === Trace.Off) {
6938 tracer = undefined;
6939 }
6940 else {
6941 tracer = _tracer;
6942 }
6943 if (_sendNotification && !isClosed() && !isDisposed()) {
6944 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
6945 }
6946 },
6947 onError: errorEmitter.event,
6948 onClose: closeEmitter.event,
6949 onUnhandledNotification: unhandledNotificationEmitter.event,
6950 onDispose: disposeEmitter.event,
6951 dispose: () => {
6952 if (isDisposed()) {
6953 return;
6954 }
6955 state = ConnectionState.Disposed;
6956 disposeEmitter.fire(undefined);
6957 let error = new Error('Connection got disposed.');
6958 Object.keys(responsePromises).forEach((key) => {
6959 responsePromises[key].reject(error);
6960 });
6961 responsePromises = Object.create(null);
6962 requestTokens = Object.create(null);
6963 messageQueue = new linkedMap_1.LinkedMap();
6964 // Test for backwards compatibility
6965 if (Is.func(messageWriter.dispose)) {
6966 messageWriter.dispose();
6967 }
6968 if (Is.func(messageReader.dispose)) {
6969 messageReader.dispose();
6970 }
6971 },
6972 listen: () => {
6973 throwIfClosedOrDisposed();
6974 throwIfListening();
6975 state = ConnectionState.Listening;
6976 messageReader.listen(callback);
6977 },
6978 inspect: () => {
6979 // eslint-disable-next-line no-console
6980 console.log('inspect');
6981 }
6982 };
6983 connection.onNotification(LogTraceNotification.type, (params) => {
6984 if (trace === Trace.Off || !tracer) {
6985 return;
6986 }
6987 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
6988 });
6989 connection.onNotification(ProgressNotification.type, (params) => {
6990 const handler = progressHandlers.get(params.token);
6991 if (handler) {
6992 handler(params.value);
6993 }
6994 else {
6995 unhandledProgressEmitter.fire(params);
6996 }
6997 });
6998 return connection;
6999}
7000function isMessageReader(value) {
7001 return value.listen !== void 0 && value.read === void 0;
7002}
7003function isMessageWriter(value) {
7004 return value.write !== void 0 && value.end === void 0;
7005}
7006function createMessageConnection(input, output, logger, strategy) {
7007 if (!logger) {
7008 logger = exports.NullLogger;
7009 }
7010 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
7011 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
7012 return _createMessageConnection(reader, writer, logger, strategy);
7013}
7014exports.createMessageConnection = createMessageConnection;
7015
7016
7017/***/ }),
7018
7019/***/ 40:
7020/***/ (function(module, exports) {
7021
7022module.exports = require("fs");
7023
7024/***/ }),
7025
7026/***/ 41:
7027/***/ (function(module, exports) {
7028
7029module.exports = require("child_process");
7030
7031/***/ }),
7032
7033/***/ 42:
7034/***/ (function(module, exports, __webpack_require__) {
7035
7036"use strict";
7037/* --------------------------------------------------------------------------------------------
7038 * Copyright (c) Microsoft Corporation. All rights reserved.
7039 * Licensed under the MIT License. See License.txt in the project root for license information.
7040 * ------------------------------------------------------------------------------------------ */
7041
7042Object.defineProperty(exports, "__esModule", { value: true });
7043const vscode_languageserver_protocol_1 = __webpack_require__(3);
7044exports.CallHierarchyFeature = (Base) => {
7045 return class extends Base {
7046 get callHierarchy() {
7047 return {
7048 onPrepare: (handler) => {
7049 this.connection.onRequest(vscode_languageserver_protocol_1.Proposed.CallHierarchyPrepareRequest.type, (params, cancel) => {
7050 return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
7051 });
7052 },
7053 onIncomingCalls: (handler) => {
7054 const type = vscode_languageserver_protocol_1.Proposed.CallHierarchyIncomingCallsRequest.type;
7055 this.connection.onRequest(type, (params, cancel) => {
7056 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
7057 });
7058 },
7059 onOutgoingCalls: (handler) => {
7060 const type = vscode_languageserver_protocol_1.Proposed.CallHierarchyOutgoingCallsRequest.type;
7061 this.connection.onRequest(type, (params, cancel) => {
7062 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
7063 });
7064 }
7065 };
7066 }
7067 };
7068};
7069//# sourceMappingURL=callHierarchy.proposed.js.map
7070
7071/***/ }),
7072
7073/***/ 43:
7074/***/ (function(module, exports, __webpack_require__) {
7075
7076"use strict";
7077/* --------------------------------------------------------------------------------------------
7078 * Copyright (c) Microsoft Corporation. All rights reserved.
7079 * Licensed under the MIT License. See License.txt in the project root for license information.
7080 * ------------------------------------------------------------------------------------------ */
7081
7082Object.defineProperty(exports, "__esModule", { value: true });
7083const vscode_languageserver_protocol_1 = __webpack_require__(3);
7084exports.SemanticTokensFeature = (Base) => {
7085 return class extends Base {
7086 get semanticTokens() {
7087 return {
7088 on: (handler) => {
7089 const type = vscode_languageserver_protocol_1.Proposed.SemanticTokensRequest.type;
7090 this.connection.onRequest(type, (params, cancel) => {
7091 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
7092 });
7093 },
7094 onEdits: (handler) => {
7095 const type = vscode_languageserver_protocol_1.Proposed.SemanticTokensEditsRequest.type;
7096 this.connection.onRequest(type, (params, cancel) => {
7097 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
7098 });
7099 },
7100 onRange: (handler) => {
7101 const type = vscode_languageserver_protocol_1.Proposed.SemanticTokensRangeRequest.type;
7102 this.connection.onRequest(type, (params, cancel) => {
7103 return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
7104 });
7105 }
7106 };
7107 }
7108 };
7109};
7110class SemanticTokensBuilder {
7111 constructor() {
7112 this._prevData = undefined;
7113 this.initialize();
7114 }
7115 initialize() {
7116 this._id = Date.now();
7117 this._prevLine = 0;
7118 this._prevChar = 0;
7119 this._data = [];
7120 this._dataLen = 0;
7121 }
7122 push(line, char, length, tokenType, tokenModifiers) {
7123 let pushLine = line;
7124 let pushChar = char;
7125 if (this._dataLen > 0) {
7126 pushLine -= this._prevLine;
7127 if (pushLine === 0) {
7128 pushChar -= this._prevChar;
7129 }
7130 }
7131 this._data[this._dataLen++] = pushLine;
7132 this._data[this._dataLen++] = pushChar;
7133 this._data[this._dataLen++] = length;
7134 this._data[this._dataLen++] = tokenType;
7135 this._data[this._dataLen++] = tokenModifiers;
7136 this._prevLine = line;
7137 this._prevChar = char;
7138 }
7139 get id() {
7140 return this._id.toString();
7141 }
7142 previousResult(id) {
7143 if (this.id === id) {
7144 this._prevData = this._data;
7145 }
7146 this.initialize();
7147 }
7148 build() {
7149 this._prevData = undefined;
7150 return {
7151 resultId: this.id,
7152 data: this._data
7153 };
7154 }
7155 canBuildEdits() {
7156 return this._prevData !== undefined;
7157 }
7158 buildEdits() {
7159 if (this._prevData !== undefined) {
7160 const prevDataLength = this._prevData.length;
7161 const dataLength = this._data.length;
7162 let startIndex = 0;
7163 while (startIndex < dataLength && startIndex < prevDataLength && this._prevData[startIndex] === this._data[startIndex]) {
7164 startIndex++;
7165 }
7166 if (startIndex < dataLength && startIndex < prevDataLength) {
7167 // Find end index
7168 let endIndex = 0;
7169 while (endIndex < dataLength && endIndex < prevDataLength && this._prevData[prevDataLength - 1 - endIndex] === this._data[dataLength - 1 - endIndex]) {
7170 endIndex++;
7171 }
7172 const newData = this._data.slice(startIndex, dataLength - endIndex);
7173 const result = {
7174 resultId: this.id,
7175 edits: [
7176 { start: startIndex, deleteCount: prevDataLength - endIndex - startIndex, data: newData }
7177 ]
7178 };
7179 return result;
7180 }
7181 else if (startIndex < dataLength) {
7182 return { resultId: this.id, edits: [
7183 { start: startIndex, deleteCount: 0, data: this._data.slice(startIndex) }
7184 ] };
7185 }
7186 else if (startIndex < prevDataLength) {
7187 return { resultId: this.id, edits: [
7188 { start: startIndex, deleteCount: prevDataLength - startIndex }
7189 ] };
7190 }
7191 else {
7192 return { resultId: this.id, edits: [] };
7193 }
7194 }
7195 else {
7196 return this.build();
7197 }
7198 }
7199}
7200exports.SemanticTokensBuilder = SemanticTokensBuilder;
7201//# sourceMappingURL=sematicTokens.proposed.js.map
7202
7203/***/ }),
7204
7205/***/ 44:
7206/***/ (function(module, exports, __webpack_require__) {
7207
7208"use strict";
7209
7210Object.defineProperty(exports, "__esModule", { value: true });
7211exports.sortTexts = {
7212 one: "00001",
7213 two: "00002",
7214 three: "00003",
7215 four: "00004",
7216};
7217exports.projectRootPatterns = [".git", "autoload", "plugin"];
7218
7219
7220/***/ }),
7221
7222/***/ 47:
7223/***/ (function(module, exports, __webpack_require__) {
7224
7225"use strict";
7226
7227var __assign = (this && this.__assign) || function () {
7228 __assign = Object.assign || function(t) {
7229 for (var s, i = 1, n = arguments.length; i < n; i++) {
7230 s = arguments[i];
7231 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7232 t[p] = s[p];
7233 }
7234 return t;
7235 };
7236 return __assign.apply(this, arguments);
7237};
7238var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7239 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7240 return new (P || (P = Promise))(function (resolve, reject) {
7241 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7242 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7243 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7244 step((generator = generator.apply(thisArg, _arguments || [])).next());
7245 });
7246};
7247var __generator = (this && this.__generator) || function (thisArg, body) {
7248 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
7249 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
7250 function verb(n) { return function (v) { return step([n, v]); }; }
7251 function step(op) {
7252 if (f) throw new TypeError("Generator is already executing.");
7253 while (_) try {
7254 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;
7255 if (y = 0, t) op = [op[0] & 2, t.value];
7256 switch (op[0]) {
7257 case 0: case 1: t = op; break;
7258 case 4: _.label++; return { value: op[1], done: false };
7259 case 5: _.label++; y = op[1]; op = [0]; continue;
7260 case 7: op = _.ops.pop(); _.trys.pop(); continue;
7261 default:
7262 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
7263 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
7264 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
7265 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
7266 if (t[2]) _.ops.pop();
7267 _.trys.pop(); continue;
7268 }
7269 op = body.call(thisArg, _);
7270 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
7271 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
7272 }
7273};
7274var __spreadArrays = (this && this.__spreadArrays) || function () {
7275 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
7276 for (var r = Array(s), k = 0, i = 0; i < il; i++)
7277 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
7278 r[k] = a[j];
7279 return r;
7280};
7281var __importDefault = (this && this.__importDefault) || function (mod) {
7282 return (mod && mod.__esModule) ? mod : { "default": mod };
7283};
7284Object.defineProperty(exports, "__esModule", { value: true });
7285var child_process_1 = __webpack_require__(41);
7286var findup_1 = __importDefault(__webpack_require__(48));
7287var fs_1 = __importDefault(__webpack_require__(40));
7288var path_1 = __importDefault(__webpack_require__(13));
7289var vscode_languageserver_1 = __webpack_require__(2);
7290var vimparser_1 = __webpack_require__(53);
7291var patterns_1 = __webpack_require__(55);
7292function isSomeMatchPattern(patterns, line) {
7293 return patterns.some(function (p) { return p.test(line); });
7294}
7295exports.isSomeMatchPattern = isSomeMatchPattern;
7296function executeFile(input, command, args, option) {
7297 return new Promise(function (resolve, reject) {
7298 var stdout = "";
7299 var stderr = "";
7300 var error;
7301 var isPassAsText = false;
7302 args = (args || []).map(function (arg) {
7303 if (/%text/.test(arg)) {
7304 isPassAsText = true;
7305 return arg.replace(/%text/g, input.toString());
7306 }
7307 return arg;
7308 });
7309 var cp = child_process_1.spawn(command, args, option);
7310 cp.stdout.on("data", function (data) {
7311 stdout += data;
7312 });
7313 cp.stderr.on("data", function (data) {
7314 stderr += data;
7315 });
7316 cp.on("error", function (err) {
7317 error = err;
7318 reject(error);
7319 });
7320 cp.on("close", function (code) {
7321 if (!error) {
7322 resolve({ code: code, stdout: stdout, stderr: stderr });
7323 }
7324 });
7325 // error will occur when cp get error
7326 if (!isPassAsText) {
7327 input.pipe(cp.stdin).on("error", function () { return; });
7328 }
7329 });
7330}
7331exports.executeFile = executeFile;
7332// cover cb type async function to promise
7333function pcb(cb) {
7334 return function () {
7335 var args = [];
7336 for (var _i = 0; _i < arguments.length; _i++) {
7337 args[_i] = arguments[_i];
7338 }
7339 return new Promise(function (resolve) {
7340 cb.apply(void 0, __spreadArrays(args, [function () {
7341 var params = [];
7342 for (var _i = 0; _i < arguments.length; _i++) {
7343 params[_i] = arguments[_i];
7344 }
7345 resolve(params);
7346 }]));
7347 });
7348 };
7349}
7350exports.pcb = pcb;
7351// find work dirname by root patterns
7352function findProjectRoot(filePath, rootPatterns) {
7353 return __awaiter(this, void 0, void 0, function () {
7354 var dirname, patterns, dirCandidate, _i, patterns_2, pattern, _a, err, dir;
7355 return __generator(this, function (_b) {
7356 switch (_b.label) {
7357 case 0:
7358 dirname = path_1.default.dirname(filePath);
7359 patterns = [].concat(rootPatterns);
7360 dirCandidate = "";
7361 _i = 0, patterns_2 = patterns;
7362 _b.label = 1;
7363 case 1:
7364 if (!(_i < patterns_2.length)) return [3 /*break*/, 4];
7365 pattern = patterns_2[_i];
7366 return [4 /*yield*/, pcb(findup_1.default)(dirname, pattern)];
7367 case 2:
7368 _a = _b.sent(), err = _a[0], dir = _a[1];
7369 if (!err && dir && dir !== "/" && dir.length > dirCandidate.length) {
7370 dirCandidate = dir;
7371 }
7372 _b.label = 3;
7373 case 3:
7374 _i++;
7375 return [3 /*break*/, 1];
7376 case 4:
7377 if (dirCandidate.length) {
7378 return [2 /*return*/, dirCandidate];
7379 }
7380 return [2 /*return*/, dirname];
7381 }
7382 });
7383 });
7384}
7385exports.findProjectRoot = findProjectRoot;
7386function markupSnippets(snippets) {
7387 return [
7388 "```vim",
7389 snippets.replace(/\$\{[0-9]+(:([^}]+))?\}/g, "$2"),
7390 "```",
7391 ].join("\n");
7392}
7393exports.markupSnippets = markupSnippets;
7394function getWordFromPosition(doc, position) {
7395 if (!doc) {
7396 return;
7397 }
7398 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)));
7399 // not keyword position
7400 if (!character || !patterns_1.keywordPattern.test(character)) {
7401 return;
7402 }
7403 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)));
7404 // comment line
7405 if (patterns_1.commentPattern.test(currentLine)) {
7406 return;
7407 }
7408 var preSegment = currentLine.slice(0, position.character);
7409 var nextSegment = currentLine.slice(position.character);
7410 var wordLeft = preSegment.match(patterns_1.wordPrePattern);
7411 var wordRight = nextSegment.match(patterns_1.wordNextPattern);
7412 var word = "" + (wordLeft && wordLeft[1] || "") + (wordRight && wordRight[1] || "");
7413 return {
7414 word: word,
7415 left: wordLeft && wordLeft[1] || "",
7416 right: wordRight && wordRight[1] || "",
7417 wordLeft: wordLeft && wordLeft[1]
7418 ? preSegment.replace(new RegExp(wordLeft[1] + "$"), word)
7419 : "" + preSegment + word,
7420 wordRight: wordRight && wordRight[1]
7421 ? nextSegment.replace(new RegExp("^" + wordRight[1]), word)
7422 : "" + word + nextSegment,
7423 };
7424}
7425exports.getWordFromPosition = getWordFromPosition;
7426// parse vim buffer
7427function handleParse(textDoc) {
7428 return __awaiter(this, void 0, void 0, function () {
7429 var text, tokens, node;
7430 return __generator(this, function (_a) {
7431 text = textDoc instanceof Object ? textDoc.getText() : textDoc;
7432 tokens = new vimparser_1.StringReader(text.split(/\r\n|\r|\n/));
7433 try {
7434 node = new vimparser_1.VimLParser(true).parse(tokens);
7435 return [2 /*return*/, [node, ""]];
7436 }
7437 catch (error) {
7438 return [2 /*return*/, [null, error]];
7439 }
7440 return [2 /*return*/];
7441 });
7442 });
7443}
7444exports.handleParse = handleParse;
7445// remove snippets of completionItem
7446function removeSnippets(completionItems) {
7447 if (completionItems === void 0) { completionItems = []; }
7448 return completionItems.map(function (item) {
7449 if (item.insertTextFormat === vscode_languageserver_1.InsertTextFormat.Snippet) {
7450 return __assign(__assign({}, item), { insertText: item.label, insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText });
7451 }
7452 return item;
7453 });
7454}
7455exports.removeSnippets = removeSnippets;
7456exports.isSymbolLink = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
7457 return __generator(this, function (_a) {
7458 return [2 /*return*/, new Promise(function (resolve) {
7459 fs_1.default.lstat(filePath, function (err, stats) {
7460 resolve({
7461 err: err,
7462 stats: stats && stats.isSymbolicLink(),
7463 });
7464 });
7465 })];
7466 });
7467}); };
7468exports.getRealPath = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
7469 var _a, err, stats;
7470 return __generator(this, function (_b) {
7471 switch (_b.label) {
7472 case 0: return [4 /*yield*/, exports.isSymbolLink(filePath)];
7473 case 1:
7474 _a = _b.sent(), err = _a.err, stats = _a.stats;
7475 if (!err && stats) {
7476 return [2 /*return*/, new Promise(function (resolve) {
7477 fs_1.default.realpath(filePath, function (error, realPath) {
7478 if (error) {
7479 return resolve(filePath);
7480 }
7481 resolve(realPath);
7482 });
7483 })];
7484 }
7485 return [2 /*return*/, filePath];
7486 }
7487 });
7488}); };
7489
7490
7491/***/ }),
7492
7493/***/ 48:
7494/***/ (function(module, exports, __webpack_require__) {
7495
7496var fs = __webpack_require__(40),
7497 Path = __webpack_require__(13),
7498 util = __webpack_require__(49),
7499 colors = __webpack_require__(50),
7500 EE = __webpack_require__(52).EventEmitter,
7501 fsExists = fs.exists ? fs.exists : Path.exists,
7502 fsExistsSync = fs.existsSync ? fs.existsSync : Path.existsSync;
7503
7504module.exports = function(dir, iterator, options, callback){
7505 return FindUp(dir, iterator, options, callback);
7506};
7507
7508function FindUp(dir, iterator, options, callback){
7509 if (!(this instanceof FindUp)) {
7510 return new FindUp(dir, iterator, options, callback);
7511 }
7512 if(typeof options === 'function'){
7513 callback = options;
7514 options = {};
7515 }
7516 options = options || {};
7517
7518 EE.call(this);
7519 this.found = false;
7520 this.stopPlease = false;
7521 var self = this;
7522
7523 if(typeof iterator === 'string'){
7524 var file = iterator;
7525 iterator = function(dir, cb){
7526 return fsExists(Path.join(dir, file), cb);
7527 };
7528 }
7529
7530 if(callback) {
7531 this.on('found', function(dir){
7532 if(options.verbose) console.log(('found '+ dir ).green);
7533 callback(null, dir);
7534 self.stop();
7535 });
7536
7537 this.on('end', function(){
7538 if(options.verbose) console.log('end'.grey);
7539 if(!self.found) callback(new Error('not found'));
7540 });
7541
7542 this.on('error', function(err){
7543 if(options.verbose) console.log('error'.red, err);
7544 callback(err);
7545 });
7546 }
7547
7548 this._find(dir, iterator, options, callback);
7549}
7550util.inherits(FindUp, EE);
7551
7552FindUp.prototype._find = function(dir, iterator, options, callback){
7553 var self = this;
7554
7555 iterator(dir, function(exists){
7556 if(options.verbose) console.log(('traverse '+ dir).grey);
7557 if(exists) {
7558 self.found = true;
7559 self.emit('found', dir);
7560 }
7561
7562 var parentDir = Path.join(dir, '..');
7563 if (self.stopPlease) return self.emit('end');
7564 if (dir === parentDir) return self.emit('end');
7565 if(dir.indexOf('../../') !== -1 ) return self.emit('error', new Error(dir + ' is not correct.'));
7566 self._find(parentDir, iterator, options, callback);
7567 });
7568};
7569
7570FindUp.prototype.stop = function(){
7571 this.stopPlease = true;
7572};
7573
7574module.exports.FindUp = FindUp;
7575
7576module.exports.sync = function(dir, iteratorSync){
7577 if(typeof iteratorSync === 'string'){
7578 var file = iteratorSync;
7579 iteratorSync = function(dir){
7580 return fsExistsSync(Path.join(dir, file));
7581 };
7582 }
7583 var initialDir = dir;
7584 while(dir !== Path.join(dir, '..')){
7585 if(dir.indexOf('../../') !== -1 ) throw new Error(initialDir + ' is not correct.');
7586 if(iteratorSync(dir)) return dir;
7587 dir = Path.join(dir, '..');
7588 }
7589 throw new Error('not found');
7590};
7591
7592
7593/***/ }),
7594
7595/***/ 49:
7596/***/ (function(module, exports) {
7597
7598module.exports = require("util");
7599
7600/***/ }),
7601
7602/***/ 5:
7603/***/ (function(module, exports, __webpack_require__) {
7604
7605"use strict";
7606/* --------------------------------------------------------------------------------------------
7607 * Copyright (c) Microsoft Corporation. All rights reserved.
7608 * Licensed under the MIT License. See License.txt in the project root for license information.
7609 * ------------------------------------------------------------------------------------------ */
7610
7611Object.defineProperty(exports, "__esModule", { value: true });
7612function boolean(value) {
7613 return value === true || value === false;
7614}
7615exports.boolean = boolean;
7616function string(value) {
7617 return typeof value === 'string' || value instanceof String;
7618}
7619exports.string = string;
7620function number(value) {
7621 return typeof value === 'number' || value instanceof Number;
7622}
7623exports.number = number;
7624function error(value) {
7625 return value instanceof Error;
7626}
7627exports.error = error;
7628function func(value) {
7629 return typeof value === 'function';
7630}
7631exports.func = func;
7632function array(value) {
7633 return Array.isArray(value);
7634}
7635exports.array = array;
7636function stringArray(value) {
7637 return array(value) && value.every(elem => string(elem));
7638}
7639exports.stringArray = stringArray;
7640
7641
7642/***/ }),
7643
7644/***/ 50:
7645/***/ (function(module, exports, __webpack_require__) {
7646
7647/*
7648colors.js
7649
7650Copyright (c) 2010
7651
7652Marak Squires
7653Alexis Sellier (cloudhead)
7654
7655Permission is hereby granted, free of charge, to any person obtaining a copy
7656of this software and associated documentation files (the "Software"), to deal
7657in the Software without restriction, including without limitation the rights
7658to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7659copies of the Software, and to permit persons to whom the Software is
7660furnished to do so, subject to the following conditions:
7661
7662The above copyright notice and this permission notice shall be included in
7663all copies or substantial portions of the Software.
7664
7665THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7666IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7667FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7668AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7669LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7670OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
7671THE SOFTWARE.
7672
7673*/
7674
7675var isHeadless = false;
7676
7677if (typeof module !== 'undefined') {
7678 isHeadless = true;
7679}
7680
7681if (!isHeadless) {
7682 var exports = {};
7683 var module = {};
7684 var colors = exports;
7685 exports.mode = "browser";
7686} else {
7687 exports.mode = "console";
7688}
7689
7690//
7691// Prototypes the string object to have additional method calls that add terminal colors
7692//
7693var addProperty = function (color, func) {
7694 exports[color] = function (str) {
7695 return func.apply(str);
7696 };
7697 String.prototype.__defineGetter__(color, func);
7698};
7699
7700function stylize(str, style) {
7701
7702 var styles;
7703
7704 if (exports.mode === 'console') {
7705 styles = {
7706 //styles
7707 'bold' : ['\x1B[1m', '\x1B[22m'],
7708 'italic' : ['\x1B[3m', '\x1B[23m'],
7709 'underline' : ['\x1B[4m', '\x1B[24m'],
7710 'inverse' : ['\x1B[7m', '\x1B[27m'],
7711 'strikethrough' : ['\x1B[9m', '\x1B[29m'],
7712 //text colors
7713 //grayscale
7714 'white' : ['\x1B[37m', '\x1B[39m'],
7715 'grey' : ['\x1B[90m', '\x1B[39m'],
7716 'black' : ['\x1B[30m', '\x1B[39m'],
7717 //colors
7718 'blue' : ['\x1B[34m', '\x1B[39m'],
7719 'cyan' : ['\x1B[36m', '\x1B[39m'],
7720 'green' : ['\x1B[32m', '\x1B[39m'],
7721 'magenta' : ['\x1B[35m', '\x1B[39m'],
7722 'red' : ['\x1B[31m', '\x1B[39m'],
7723 'yellow' : ['\x1B[33m', '\x1B[39m'],
7724 //background colors
7725 //grayscale
7726 'whiteBG' : ['\x1B[47m', '\x1B[49m'],
7727 'greyBG' : ['\x1B[49;5;8m', '\x1B[49m'],
7728 'blackBG' : ['\x1B[40m', '\x1B[49m'],
7729 //colors
7730 'blueBG' : ['\x1B[44m', '\x1B[49m'],
7731 'cyanBG' : ['\x1B[46m', '\x1B[49m'],
7732 'greenBG' : ['\x1B[42m', '\x1B[49m'],
7733 'magentaBG' : ['\x1B[45m', '\x1B[49m'],
7734 'redBG' : ['\x1B[41m', '\x1B[49m'],
7735 'yellowBG' : ['\x1B[43m', '\x1B[49m']
7736 };
7737 } else if (exports.mode === 'browser') {
7738 styles = {
7739 //styles
7740 'bold' : ['<b>', '</b>'],
7741 'italic' : ['<i>', '</i>'],
7742 'underline' : ['<u>', '</u>'],
7743 'inverse' : ['<span style="background-color:black;color:white;">', '</span>'],
7744 'strikethrough' : ['<del>', '</del>'],
7745 //text colors
7746 //grayscale
7747 'white' : ['<span style="color:white;">', '</span>'],
7748 'grey' : ['<span style="color:gray;">', '</span>'],
7749 'black' : ['<span style="color:black;">', '</span>'],
7750 //colors
7751 'blue' : ['<span style="color:blue;">', '</span>'],
7752 'cyan' : ['<span style="color:cyan;">', '</span>'],
7753 'green' : ['<span style="color:green;">', '</span>'],
7754 'magenta' : ['<span style="color:magenta;">', '</span>'],
7755 'red' : ['<span style="color:red;">', '</span>'],
7756 'yellow' : ['<span style="color:yellow;">', '</span>'],
7757 //background colors
7758 //grayscale
7759 'whiteBG' : ['<span style="background-color:white;">', '</span>'],
7760 'greyBG' : ['<span style="background-color:gray;">', '</span>'],
7761 'blackBG' : ['<span style="background-color:black;">', '</span>'],
7762 //colors
7763 'blueBG' : ['<span style="background-color:blue;">', '</span>'],
7764 'cyanBG' : ['<span style="background-color:cyan;">', '</span>'],
7765 'greenBG' : ['<span style="background-color:green;">', '</span>'],
7766 'magentaBG' : ['<span style="background-color:magenta;">', '</span>'],
7767 'redBG' : ['<span style="background-color:red;">', '</span>'],
7768 'yellowBG' : ['<span style="background-color:yellow;">', '</span>']
7769 };
7770 } else if (exports.mode === 'none') {
7771 return str + '';
7772 } else {
7773 console.log('unsupported mode, try "browser", "console" or "none"');
7774 }
7775 return styles[style][0] + str + styles[style][1];
7776}
7777
7778function applyTheme(theme) {
7779
7780 //
7781 // Remark: This is a list of methods that exist
7782 // on String that you should not overwrite.
7783 //
7784 var stringPrototypeBlacklist = [
7785 '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
7786 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
7787 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
7788 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
7789 ];
7790
7791 Object.keys(theme).forEach(function (prop) {
7792 if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
7793 console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
7794 }
7795 else {
7796 if (typeof(theme[prop]) === 'string') {
7797 addProperty(prop, function () {
7798 return exports[theme[prop]](this);
7799 });
7800 }
7801 else {
7802 addProperty(prop, function () {
7803 var ret = this;
7804 for (var t = 0; t < theme[prop].length; t++) {
7805 ret = exports[theme[prop][t]](ret);
7806 }
7807 return ret;
7808 });
7809 }
7810 }
7811 });
7812}
7813
7814
7815//
7816// Iterate through all default styles and colors
7817//
7818var x = ['bold', 'underline', 'strikethrough', 'italic', 'inverse', 'grey', 'black', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta', 'greyBG', 'blackBG', 'yellowBG', 'redBG', 'greenBG', 'blueBG', 'whiteBG', 'cyanBG', 'magentaBG'];
7819x.forEach(function (style) {
7820
7821 // __defineGetter__ at the least works in more browsers
7822 // http://robertnyman.com/javascript/javascript-getters-setters.html
7823 // Object.defineProperty only works in Chrome
7824 addProperty(style, function () {
7825 return stylize(this, style);
7826 });
7827});
7828
7829function sequencer(map) {
7830 return function () {
7831 if (!isHeadless) {
7832 return this.replace(/( )/, '$1');
7833 }
7834 var exploded = this.split(""), i = 0;
7835 exploded = exploded.map(map);
7836 return exploded.join("");
7837 };
7838}
7839
7840var rainbowMap = (function () {
7841 var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
7842 return function (letter, i, exploded) {
7843 if (letter === " ") {
7844 return letter;
7845 } else {
7846 return stylize(letter, rainbowColors[i++ % rainbowColors.length]);
7847 }
7848 };
7849})();
7850
7851exports.themes = {};
7852
7853exports.addSequencer = function (name, map) {
7854 addProperty(name, sequencer(map));
7855};
7856
7857exports.addSequencer('rainbow', rainbowMap);
7858exports.addSequencer('zebra', function (letter, i, exploded) {
7859 return i % 2 === 0 ? letter : letter.inverse;
7860});
7861
7862exports.setTheme = function (theme) {
7863 if (typeof theme === 'string') {
7864 try {
7865 exports.themes[theme] = __webpack_require__(51)(theme);
7866 applyTheme(exports.themes[theme]);
7867 return exports.themes[theme];
7868 } catch (err) {
7869 console.log(err);
7870 return err;
7871 }
7872 } else {
7873 applyTheme(theme);
7874 }
7875};
7876
7877
7878addProperty('stripColors', function () {
7879 return ("" + this).replace(/\x1B\[\d+m/g, '');
7880});
7881
7882// please no
7883function zalgo(text, options) {
7884 var soul = {
7885 "up" : [
7886 '̍', '̎', '̄', '̅',
7887 '̿', '̑', '̆', '̐',
7888 '͒', '͗', '͑', '̇',
7889 '̈', '̊', '͂', '̓',
7890 '̈', '͊', '͋', '͌',
7891 '̃', '̂', '̌', '͐',
7892 '̀', '́', '̋', '̏',
7893 '̒', '̓', '̔', '̽',
7894 '̉', 'ͣ', 'ͤ', 'ͥ',
7895 'ͦ', 'ͧ', 'ͨ', 'ͩ',
7896 'ͪ', 'ͫ', 'ͬ', 'ͭ',
7897 'ͮ', 'ͯ', '̾', '͛',
7898 '͆', '̚'
7899 ],
7900 "down" : [
7901 '̖', '̗', '̘', '̙',
7902 '̜', '̝', '̞', '̟',
7903 '̠', '̤', '̥', '̦',
7904 '̩', '̪', '̫', '̬',
7905 '̭', '̮', '̯', '̰',
7906 '̱', '̲', '̳', '̹',
7907 '̺', '̻', '̼', 'ͅ',
7908 '͇', '͈', '͉', '͍',
7909 '͎', '͓', '͔', '͕',
7910 '͖', '͙', '͚', '̣'
7911 ],
7912 "mid" : [
7913 '̕', '̛', '̀', '́',
7914 '͘', '̡', '̢', '̧',
7915 '̨', '̴', '̵', '̶',
7916 '͜', '͝', '͞',
7917 '͟', '͠', '͢', '̸',
7918 '̷', '͡', ' ҉'
7919 ]
7920 },
7921 all = [].concat(soul.up, soul.down, soul.mid),
7922 zalgo = {};
7923
7924 function randomNumber(range) {
7925 var r = Math.floor(Math.random() * range);
7926 return r;
7927 }
7928
7929 function is_char(character) {
7930 var bool = false;
7931 all.filter(function (i) {
7932 bool = (i === character);
7933 });
7934 return bool;
7935 }
7936
7937 function heComes(text, options) {
7938 var result = '', counts, l;
7939 options = options || {};
7940 options["up"] = options["up"] || true;
7941 options["mid"] = options["mid"] || true;
7942 options["down"] = options["down"] || true;
7943 options["size"] = options["size"] || "maxi";
7944 text = text.split('');
7945 for (l in text) {
7946 if (is_char(l)) {
7947 continue;
7948 }
7949 result = result + text[l];
7950 counts = {"up" : 0, "down" : 0, "mid" : 0};
7951 switch (options.size) {
7952 case 'mini':
7953 counts.up = randomNumber(8);
7954 counts.min = randomNumber(2);
7955 counts.down = randomNumber(8);
7956 break;
7957 case 'maxi':
7958 counts.up = randomNumber(16) + 3;
7959 counts.min = randomNumber(4) + 1;
7960 counts.down = randomNumber(64) + 3;
7961 break;
7962 default:
7963 counts.up = randomNumber(8) + 1;
7964 counts.mid = randomNumber(6) / 2;
7965 counts.down = randomNumber(8) + 1;
7966 break;
7967 }
7968
7969 var arr = ["up", "mid", "down"];
7970 for (var d in arr) {
7971 var index = arr[d];
7972 for (var i = 0 ; i <= counts[index]; i++) {
7973 if (options[index]) {
7974 result = result + soul[index][randomNumber(soul[index].length)];
7975 }
7976 }
7977 }
7978 }
7979 return result;
7980 }
7981 return heComes(text);
7982}
7983
7984
7985// don't summon zalgo
7986addProperty('zalgo', function () {
7987 return zalgo(this);
7988});
7989
7990
7991/***/ }),
7992
7993/***/ 51:
7994/***/ (function(module, exports) {
7995
7996function webpackEmptyContext(req) {
7997 var e = new Error("Cannot find module '" + req + "'");
7998 e.code = 'MODULE_NOT_FOUND';
7999 throw e;
8000}
8001webpackEmptyContext.keys = function() { return []; };
8002webpackEmptyContext.resolve = webpackEmptyContext;
8003module.exports = webpackEmptyContext;
8004webpackEmptyContext.id = 51;
8005
8006/***/ }),
8007
8008/***/ 52:
8009/***/ (function(module, exports) {
8010
8011module.exports = require("events");
8012
8013/***/ }),
8014
8015/***/ 53:
8016/***/ (function(module, exports, __webpack_require__) {
8017
8018/* WEBPACK VAR INJECTION */(function(module) {//!/usr/bin/env nodejs
8019// usage: nodejs vimlparser.js [--neovim] foo.vim
8020
8021var fs = __webpack_require__(40);
8022var util = __webpack_require__(49);
8023
8024function main() {
8025 var neovim = false;
8026 var fpath = ''
8027 var args = process.argv;
8028 if (args.length == 4) {
8029 if (args[2] == '--neovim') {
8030 neovim = true;
8031 }
8032 fpath = args[3];
8033 } else if (args.length == 3) {
8034 neovim = false;
8035 fpath = args[2]
8036 }
8037 var r = new StringReader(viml_readfile(fpath));
8038 var p = new VimLParser(neovim);
8039 var c = new Compiler();
8040 try {
8041 var lines = c.compile(p.parse(r));
8042 for (var i in lines) {
8043 process.stdout.write(lines[i] + "\n");
8044 }
8045 } catch (e) {
8046 process.stdout.write(e + '\n');
8047 }
8048}
8049
8050var pat_vim2js = {
8051 "[0-9a-zA-Z]" : "[0-9a-zA-Z]",
8052 "[@*!=><&~#]" : "[@*!=><&~#]",
8053 "\\<ARGOPT\\>" : "\\bARGOPT\\b",
8054 "\\<BANG\\>" : "\\bBANG\\b",
8055 "\\<EDITCMD\\>" : "\\bEDITCMD\\b",
8056 "\\<NOTRLCOM\\>" : "\\bNOTRLCOM\\b",
8057 "\\<TRLBAR\\>" : "\\bTRLBAR\\b",
8058 "\\<USECTRLV\\>" : "\\bUSECTRLV\\b",
8059 "\\<USERCMD\\>" : "\\bUSERCMD\\b",
8060 "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>" : "\\b(XFILE|FILES|FILE1)\\b",
8061 "\\S" : "\\S",
8062 "\\a" : "[A-Za-z]",
8063 "\\d" : "\\d",
8064 "\\h" : "[A-Za-z_]",
8065 "\\s" : "\\s",
8066 "\\v^d%[elete][lp]$" : "^d(elete|elet|ele|el|e)[lp]$",
8067 "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])" : "^s(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])",
8068 "\\w" : "[0-9A-Za-z_]",
8069 "\\w\\|[:#]" : "[0-9A-Za-z_]|[:#]",
8070 "\\x" : "[0-9A-Fa-f]",
8071 "^++" : "^\+\+",
8072 "^++bad=\\(keep\\|drop\\|.\\)\\>" : "^\\+\\+bad=(keep|drop|.)\\b",
8073 "^++bad=drop" : "^\\+\\+bad=drop",
8074 "^++bad=keep" : "^\\+\\+bad=keep",
8075 "^++bin\\>" : "^\\+\\+bin\\b",
8076 "^++edit\\>" : "^\\+\\+edit\\b",
8077 "^++enc=\\S" : "^\\+\\+enc=\\S",
8078 "^++encoding=\\S" : "^\\+\\+encoding=\\S",
8079 "^++ff=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+ff=(dos|unix|mac)\\b",
8080 "^++fileformat=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+fileformat=(dos|unix|mac)\\b",
8081 "^++nobin\\>" : "^\\+\\+nobin\\b",
8082 "^[A-Z]" : "^[A-Z]",
8083 "^\\$\\w\\+" : "^\\$[0-9A-Za-z_]+",
8084 "^\\(!\\|global\\|vglobal\\)$" : "^(!|global|vglobal)$",
8085 "^\\(WHILE\\|FOR\\)$" : "^(WHILE|FOR)$",
8086 "^\\(vimgrep\\|vimgrepadd\\|lvimgrep\\|lvimgrepadd\\)$" : "^(vimgrep|vimgrepadd|lvimgrep|lvimgrepadd)$",
8087 "^\\d" : "^\\d",
8088 "^\\h" : "^[A-Za-z_]",
8089 "^\\s" : "^\\s",
8090 "^\\s*\\\\" : "^\\s*\\\\",
8091 "^[ \\t]$" : "^[ \\t]$",
8092 "^[A-Za-z]$" : "^[A-Za-z]$",
8093 "^[0-9A-Za-z]$" : "^[0-9A-Za-z]$",
8094 "^[0-9]$" : "^[0-9]$",
8095 "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$",
8096 "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$",
8097 "^[A-Za-z_]$" : "^[A-Za-z_]$",
8098 "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$",
8099 "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$",
8100 "^[A-Z]$" : "^[A-Z]$",
8101 "^[a-z]$" : "^[a-z]$",
8102 "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$",
8103 "^[0-7]$" : "^[0-7]$",
8104 "^[0-9A-Fa-f][0-9A-Fa-f]$" : "^[0-9A-Fa-f][0-9A-Fa-f]$",
8105 "^\\.[0-9A-Fa-f]$" : "^\\.[0-9A-Fa-f]$",
8106 "^[0-9A-Fa-f][^0-9A-Fa-f]$" : "^[0-9A-Fa-f][^0-9A-Fa-f]$",
8107}
8108
8109function viml_add(lst, item) {
8110 lst.push(item);
8111}
8112
8113function viml_call(func, args) {
8114 return func.apply(null, args);
8115}
8116
8117function viml_char2nr(c) {
8118 return c.charCodeAt(0);
8119}
8120
8121function viml_empty(obj) {
8122 return obj.length == 0;
8123}
8124
8125function viml_equalci(a, b) {
8126 return a.toLowerCase() == b.toLowerCase();
8127}
8128
8129function viml_eqreg(s, reg) {
8130 var mx = new RegExp(pat_vim2js[reg]);
8131 return mx.exec(s) != null;
8132}
8133
8134function viml_eqregh(s, reg) {
8135 var mx = new RegExp(pat_vim2js[reg]);
8136 return mx.exec(s) != null;
8137}
8138
8139function viml_eqregq(s, reg) {
8140 var mx = new RegExp(pat_vim2js[reg], "i");
8141 return mx.exec(s) != null;
8142}
8143
8144function viml_escape(s, chars) {
8145 var r = '';
8146 for (var i = 0; i < s.length; ++i) {
8147 if (chars.indexOf(s.charAt(i)) != -1) {
8148 r = r + "\\" + s.charAt(i);
8149 } else {
8150 r = r + s.charAt(i);
8151 }
8152 }
8153 return r;
8154}
8155
8156function viml_extend(obj, item) {
8157 obj.push.apply(obj, item);
8158}
8159
8160function viml_insert(lst, item) {
8161 var idx = arguments.length >= 3 ? arguments[2] : 0;
8162 lst.splice(0, 0, item);
8163}
8164
8165function viml_join(lst, sep) {
8166 return lst.join(sep);
8167}
8168
8169function viml_keys(obj) {
8170 return Object.keys(obj);
8171}
8172
8173function viml_len(obj) {
8174 if (typeof obj === 'string') {
8175 var len = 0;
8176 for (var i = 0; i < obj.length; i++) {
8177 var c = obj.charCodeAt(i);
8178 len += c < 128 ? 1 : ((c > 127) && (c < 2048)) ? 2 : 3;
8179 }
8180 return len;
8181 }
8182 return obj.length;
8183}
8184
8185function viml_printf() {
8186 var a000 = Array.prototype.slice.call(arguments, 0);
8187 if (a000.length == 1) {
8188 return a000[0];
8189 } else {
8190 return util.format.apply(null, a000);
8191 }
8192}
8193
8194function viml_range(start) {
8195 var end = arguments.length >= 2 ? arguments[1] : null;
8196 if (end == null) {
8197 var x = [];
8198 for (var i = 0; i < start; ++i) {
8199 x.push(i);
8200 }
8201 return x;
8202 } else {
8203 var x = []
8204 for (var i = start; i <= end; ++i) {
8205 x.push(i);
8206 }
8207 return x;
8208 }
8209}
8210
8211function viml_readfile(path) {
8212 // FIXME: newline?
8213 return fs.readFileSync(path, 'utf-8').split(/\r\n|\r|\n/);
8214}
8215
8216function viml_remove(lst, idx) {
8217 lst.splice(idx, 1);
8218}
8219
8220function viml_split(s, sep) {
8221 if (sep == "\\zs") {
8222 return s.split("");
8223 }
8224 throw "NotImplemented";
8225}
8226
8227function viml_str2nr(s) {
8228 var base = arguments.length >= 2 ? arguments[1] : 10;
8229 return parseInt(s, base);
8230}
8231
8232function viml_string(obj) {
8233 return obj.toString();
8234}
8235
8236function viml_has_key(obj, key) {
8237 return obj[key] !== undefined;
8238}
8239
8240function viml_stridx(a, b) {
8241 return a.indexOf(b);
8242}
8243
8244var NIL = [];
8245var TRUE = 1;
8246var FALSE = 0;
8247var NODE_TOPLEVEL = 1;
8248var NODE_COMMENT = 2;
8249var NODE_EXCMD = 3;
8250var NODE_FUNCTION = 4;
8251var NODE_ENDFUNCTION = 5;
8252var NODE_DELFUNCTION = 6;
8253var NODE_RETURN = 7;
8254var NODE_EXCALL = 8;
8255var NODE_LET = 9;
8256var NODE_UNLET = 10;
8257var NODE_LOCKVAR = 11;
8258var NODE_UNLOCKVAR = 12;
8259var NODE_IF = 13;
8260var NODE_ELSEIF = 14;
8261var NODE_ELSE = 15;
8262var NODE_ENDIF = 16;
8263var NODE_WHILE = 17;
8264var NODE_ENDWHILE = 18;
8265var NODE_FOR = 19;
8266var NODE_ENDFOR = 20;
8267var NODE_CONTINUE = 21;
8268var NODE_BREAK = 22;
8269var NODE_TRY = 23;
8270var NODE_CATCH = 24;
8271var NODE_FINALLY = 25;
8272var NODE_ENDTRY = 26;
8273var NODE_THROW = 27;
8274var NODE_ECHO = 28;
8275var NODE_ECHON = 29;
8276var NODE_ECHOHL = 30;
8277var NODE_ECHOMSG = 31;
8278var NODE_ECHOERR = 32;
8279var NODE_EXECUTE = 33;
8280var NODE_TERNARY = 34;
8281var NODE_OR = 35;
8282var NODE_AND = 36;
8283var NODE_EQUAL = 37;
8284var NODE_EQUALCI = 38;
8285var NODE_EQUALCS = 39;
8286var NODE_NEQUAL = 40;
8287var NODE_NEQUALCI = 41;
8288var NODE_NEQUALCS = 42;
8289var NODE_GREATER = 43;
8290var NODE_GREATERCI = 44;
8291var NODE_GREATERCS = 45;
8292var NODE_GEQUAL = 46;
8293var NODE_GEQUALCI = 47;
8294var NODE_GEQUALCS = 48;
8295var NODE_SMALLER = 49;
8296var NODE_SMALLERCI = 50;
8297var NODE_SMALLERCS = 51;
8298var NODE_SEQUAL = 52;
8299var NODE_SEQUALCI = 53;
8300var NODE_SEQUALCS = 54;
8301var NODE_MATCH = 55;
8302var NODE_MATCHCI = 56;
8303var NODE_MATCHCS = 57;
8304var NODE_NOMATCH = 58;
8305var NODE_NOMATCHCI = 59;
8306var NODE_NOMATCHCS = 60;
8307var NODE_IS = 61;
8308var NODE_ISCI = 62;
8309var NODE_ISCS = 63;
8310var NODE_ISNOT = 64;
8311var NODE_ISNOTCI = 65;
8312var NODE_ISNOTCS = 66;
8313var NODE_ADD = 67;
8314var NODE_SUBTRACT = 68;
8315var NODE_CONCAT = 69;
8316var NODE_MULTIPLY = 70;
8317var NODE_DIVIDE = 71;
8318var NODE_REMAINDER = 72;
8319var NODE_NOT = 73;
8320var NODE_MINUS = 74;
8321var NODE_PLUS = 75;
8322var NODE_SUBSCRIPT = 76;
8323var NODE_SLICE = 77;
8324var NODE_CALL = 78;
8325var NODE_DOT = 79;
8326var NODE_NUMBER = 80;
8327var NODE_STRING = 81;
8328var NODE_LIST = 82;
8329var NODE_DICT = 83;
8330var NODE_OPTION = 85;
8331var NODE_IDENTIFIER = 86;
8332var NODE_CURLYNAME = 87;
8333var NODE_ENV = 88;
8334var NODE_REG = 89;
8335var NODE_CURLYNAMEPART = 90;
8336var NODE_CURLYNAMEEXPR = 91;
8337var NODE_LAMBDA = 92;
8338var NODE_BLOB = 93;
8339var NODE_CONST = 94;
8340var NODE_EVAL = 95;
8341var NODE_HEREDOC = 96;
8342var NODE_METHOD = 97;
8343var TOKEN_EOF = 1;
8344var TOKEN_EOL = 2;
8345var TOKEN_SPACE = 3;
8346var TOKEN_OROR = 4;
8347var TOKEN_ANDAND = 5;
8348var TOKEN_EQEQ = 6;
8349var TOKEN_EQEQCI = 7;
8350var TOKEN_EQEQCS = 8;
8351var TOKEN_NEQ = 9;
8352var TOKEN_NEQCI = 10;
8353var TOKEN_NEQCS = 11;
8354var TOKEN_GT = 12;
8355var TOKEN_GTCI = 13;
8356var TOKEN_GTCS = 14;
8357var TOKEN_GTEQ = 15;
8358var TOKEN_GTEQCI = 16;
8359var TOKEN_GTEQCS = 17;
8360var TOKEN_LT = 18;
8361var TOKEN_LTCI = 19;
8362var TOKEN_LTCS = 20;
8363var TOKEN_LTEQ = 21;
8364var TOKEN_LTEQCI = 22;
8365var TOKEN_LTEQCS = 23;
8366var TOKEN_MATCH = 24;
8367var TOKEN_MATCHCI = 25;
8368var TOKEN_MATCHCS = 26;
8369var TOKEN_NOMATCH = 27;
8370var TOKEN_NOMATCHCI = 28;
8371var TOKEN_NOMATCHCS = 29;
8372var TOKEN_IS = 30;
8373var TOKEN_ISCI = 31;
8374var TOKEN_ISCS = 32;
8375var TOKEN_ISNOT = 33;
8376var TOKEN_ISNOTCI = 34;
8377var TOKEN_ISNOTCS = 35;
8378var TOKEN_PLUS = 36;
8379var TOKEN_MINUS = 37;
8380var TOKEN_DOT = 38;
8381var TOKEN_STAR = 39;
8382var TOKEN_SLASH = 40;
8383var TOKEN_PERCENT = 41;
8384var TOKEN_NOT = 42;
8385var TOKEN_QUESTION = 43;
8386var TOKEN_COLON = 44;
8387var TOKEN_POPEN = 45;
8388var TOKEN_PCLOSE = 46;
8389var TOKEN_SQOPEN = 47;
8390var TOKEN_SQCLOSE = 48;
8391var TOKEN_COPEN = 49;
8392var TOKEN_CCLOSE = 50;
8393var TOKEN_COMMA = 51;
8394var TOKEN_NUMBER = 52;
8395var TOKEN_SQUOTE = 53;
8396var TOKEN_DQUOTE = 54;
8397var TOKEN_OPTION = 55;
8398var TOKEN_IDENTIFIER = 56;
8399var TOKEN_ENV = 57;
8400var TOKEN_REG = 58;
8401var TOKEN_EQ = 59;
8402var TOKEN_OR = 60;
8403var TOKEN_SEMICOLON = 61;
8404var TOKEN_BACKTICK = 62;
8405var TOKEN_DOTDOTDOT = 63;
8406var TOKEN_SHARP = 64;
8407var TOKEN_ARROW = 65;
8408var TOKEN_BLOB = 66;
8409var TOKEN_LITCOPEN = 67;
8410var TOKEN_DOTDOT = 68;
8411var TOKEN_HEREDOC = 69;
8412var MAX_FUNC_ARGS = 20;
8413function isalpha(c) {
8414 return viml_eqregh(c, "^[A-Za-z]$");
8415}
8416
8417function isalnum(c) {
8418 return viml_eqregh(c, "^[0-9A-Za-z]$");
8419}
8420
8421function isdigit(c) {
8422 return viml_eqregh(c, "^[0-9]$");
8423}
8424
8425function isodigit(c) {
8426 return viml_eqregh(c, "^[0-7]$");
8427}
8428
8429function isxdigit(c) {
8430 return viml_eqregh(c, "^[0-9A-Fa-f]$");
8431}
8432
8433function iswordc(c) {
8434 return viml_eqregh(c, "^[0-9A-Za-z_]$");
8435}
8436
8437function iswordc1(c) {
8438 return viml_eqregh(c, "^[A-Za-z_]$");
8439}
8440
8441function iswhite(c) {
8442 return viml_eqregh(c, "^[ \\t]$");
8443}
8444
8445function isnamec(c) {
8446 return viml_eqregh(c, "^[0-9A-Za-z_:#]$");
8447}
8448
8449function isnamec1(c) {
8450 return viml_eqregh(c, "^[A-Za-z_]$");
8451}
8452
8453function isargname(s) {
8454 return viml_eqregh(s, "^[A-Za-z_][0-9A-Za-z_]*$");
8455}
8456
8457function isvarname(s) {
8458 return viml_eqregh(s, "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$");
8459}
8460
8461// FIXME:
8462function isidc(c) {
8463 return viml_eqregh(c, "^[0-9A-Za-z_]$");
8464}
8465
8466function isupper(c) {
8467 return viml_eqregh(c, "^[A-Z]$");
8468}
8469
8470function islower(c) {
8471 return viml_eqregh(c, "^[a-z]$");
8472}
8473
8474function ExArg() {
8475 var ea = {};
8476 ea.forceit = FALSE;
8477 ea.addr_count = 0;
8478 ea.line1 = 0;
8479 ea.line2 = 0;
8480 ea.flags = 0;
8481 ea.do_ecmd_cmd = "";
8482 ea.do_ecmd_lnum = 0;
8483 ea.append = 0;
8484 ea.usefilter = FALSE;
8485 ea.amount = 0;
8486 ea.regname = 0;
8487 ea.force_bin = 0;
8488 ea.read_edit = 0;
8489 ea.force_ff = 0;
8490 ea.force_enc = 0;
8491 ea.bad_char = 0;
8492 ea.linepos = {};
8493 ea.cmdpos = [];
8494 ea.argpos = [];
8495 ea.cmd = {};
8496 ea.modifiers = [];
8497 ea.range = [];
8498 ea.argopt = {};
8499 ea.argcmd = {};
8500 return ea;
8501}
8502
8503// struct node {
8504// int type
8505// pos pos
8506// node left
8507// node right
8508// node cond
8509// node rest
8510// node[] list
8511// node[] rlist
8512// node[] default_args
8513// node[] body
8514// string op
8515// string str
8516// int depth
8517// variant value
8518// }
8519// TOPLEVEL .body
8520// COMMENT .str
8521// EXCMD .ea .str
8522// FUNCTION .ea .body .left .rlist .default_args .attr .endfunction
8523// ENDFUNCTION .ea
8524// DELFUNCTION .ea .left
8525// RETURN .ea .left
8526// EXCALL .ea .left
8527// LET .ea .op .left .list .rest .right
8528// CONST .ea .op .left .list .rest .right
8529// UNLET .ea .list
8530// LOCKVAR .ea .depth .list
8531// UNLOCKVAR .ea .depth .list
8532// IF .ea .body .cond .elseif .else .endif
8533// ELSEIF .ea .body .cond
8534// ELSE .ea .body
8535// ENDIF .ea
8536// WHILE .ea .body .cond .endwhile
8537// ENDWHILE .ea
8538// FOR .ea .body .left .list .rest .right .endfor
8539// ENDFOR .ea
8540// CONTINUE .ea
8541// BREAK .ea
8542// TRY .ea .body .catch .finally .endtry
8543// CATCH .ea .body .pattern
8544// FINALLY .ea .body
8545// ENDTRY .ea
8546// THROW .ea .left
8547// EVAL .ea .left
8548// ECHO .ea .list
8549// ECHON .ea .list
8550// ECHOHL .ea .str
8551// ECHOMSG .ea .list
8552// ECHOERR .ea .list
8553// EXECUTE .ea .list
8554// TERNARY .cond .left .right
8555// OR .left .right
8556// AND .left .right
8557// EQUAL .left .right
8558// EQUALCI .left .right
8559// EQUALCS .left .right
8560// NEQUAL .left .right
8561// NEQUALCI .left .right
8562// NEQUALCS .left .right
8563// GREATER .left .right
8564// GREATERCI .left .right
8565// GREATERCS .left .right
8566// GEQUAL .left .right
8567// GEQUALCI .left .right
8568// GEQUALCS .left .right
8569// SMALLER .left .right
8570// SMALLERCI .left .right
8571// SMALLERCS .left .right
8572// SEQUAL .left .right
8573// SEQUALCI .left .right
8574// SEQUALCS .left .right
8575// MATCH .left .right
8576// MATCHCI .left .right
8577// MATCHCS .left .right
8578// NOMATCH .left .right
8579// NOMATCHCI .left .right
8580// NOMATCHCS .left .right
8581// IS .left .right
8582// ISCI .left .right
8583// ISCS .left .right
8584// ISNOT .left .right
8585// ISNOTCI .left .right
8586// ISNOTCS .left .right
8587// ADD .left .right
8588// SUBTRACT .left .right
8589// CONCAT .left .right
8590// MULTIPLY .left .right
8591// DIVIDE .left .right
8592// REMAINDER .left .right
8593// NOT .left
8594// MINUS .left
8595// PLUS .left
8596// SUBSCRIPT .left .right
8597// SLICE .left .rlist
8598// METHOD .left .right
8599// CALL .left .rlist
8600// DOT .left .right
8601// NUMBER .value
8602// STRING .value
8603// LIST .value
8604// DICT .value
8605// BLOB .value
8606// NESTING .left
8607// OPTION .value
8608// IDENTIFIER .value
8609// CURLYNAME .value
8610// ENV .value
8611// REG .value
8612// CURLYNAMEPART .value
8613// CURLYNAMEEXPR .value
8614// LAMBDA .rlist .left
8615// HEREDOC .rlist .op .body
8616function Node(type) {
8617 return {"type":type};
8618}
8619
8620function Err(msg, pos) {
8621 return viml_printf("vimlparser: %s: line %d col %d", msg, pos.lnum, pos.col);
8622}
8623
8624function VimLParser() { this.__init__.apply(this, arguments); }
8625VimLParser.prototype.__init__ = function() {
8626 var a000 = Array.prototype.slice.call(arguments, 0);
8627 if (viml_len(a000) > 0) {
8628 this.neovim = a000[0];
8629 }
8630 else {
8631 this.neovim = 0;
8632 }
8633 this.find_command_cache = {};
8634}
8635
8636VimLParser.prototype.push_context = function(node) {
8637 viml_insert(this.context, node);
8638}
8639
8640VimLParser.prototype.pop_context = function() {
8641 viml_remove(this.context, 0);
8642}
8643
8644VimLParser.prototype.find_context = function(type) {
8645 var i = 0;
8646 var __c3 = this.context;
8647 for (var __i3 = 0; __i3 < __c3.length; ++__i3) {
8648 var node = __c3[__i3];
8649 if (node.type == type) {
8650 return i;
8651 }
8652 i += 1;
8653 }
8654 return -1;
8655}
8656
8657VimLParser.prototype.add_node = function(node) {
8658 viml_add(this.context[0].body, node);
8659}
8660
8661VimLParser.prototype.check_missing_endfunction = function(ends, pos) {
8662 if (this.context[0].type == NODE_FUNCTION) {
8663 throw Err(viml_printf("E126: Missing :endfunction: %s", ends), pos);
8664 }
8665}
8666
8667VimLParser.prototype.check_missing_endif = function(ends, pos) {
8668 if (this.context[0].type == NODE_IF || this.context[0].type == NODE_ELSEIF || this.context[0].type == NODE_ELSE) {
8669 throw Err(viml_printf("E171: Missing :endif: %s", ends), pos);
8670 }
8671}
8672
8673VimLParser.prototype.check_missing_endtry = function(ends, pos) {
8674 if (this.context[0].type == NODE_TRY || this.context[0].type == NODE_CATCH || this.context[0].type == NODE_FINALLY) {
8675 throw Err(viml_printf("E600: Missing :endtry: %s", ends), pos);
8676 }
8677}
8678
8679VimLParser.prototype.check_missing_endwhile = function(ends, pos) {
8680 if (this.context[0].type == NODE_WHILE) {
8681 throw Err(viml_printf("E170: Missing :endwhile: %s", ends), pos);
8682 }
8683}
8684
8685VimLParser.prototype.check_missing_endfor = function(ends, pos) {
8686 if (this.context[0].type == NODE_FOR) {
8687 throw Err(viml_printf("E170: Missing :endfor: %s", ends), pos);
8688 }
8689}
8690
8691VimLParser.prototype.parse = function(reader) {
8692 this.reader = reader;
8693 this.context = [];
8694 var toplevel = Node(NODE_TOPLEVEL);
8695 toplevel.pos = this.reader.getpos();
8696 toplevel.body = [];
8697 this.push_context(toplevel);
8698 while (this.reader.peek() != "<EOF>") {
8699 this.parse_one_cmd();
8700 }
8701 this.check_missing_endfunction("TOPLEVEL", this.reader.getpos());
8702 this.check_missing_endif("TOPLEVEL", this.reader.getpos());
8703 this.check_missing_endtry("TOPLEVEL", this.reader.getpos());
8704 this.check_missing_endwhile("TOPLEVEL", this.reader.getpos());
8705 this.check_missing_endfor("TOPLEVEL", this.reader.getpos());
8706 this.pop_context();
8707 return toplevel;
8708}
8709
8710VimLParser.prototype.parse_one_cmd = function() {
8711 this.ea = ExArg();
8712 if (this.reader.peekn(2) == "#!") {
8713 this.parse_hashbang();
8714 this.reader.get();
8715 return;
8716 }
8717 this.reader.skip_white_and_colon();
8718 if (this.reader.peekn(1) == "") {
8719 this.reader.get();
8720 return;
8721 }
8722 if (this.reader.peekn(1) == "\"") {
8723 this.parse_comment();
8724 this.reader.get();
8725 return;
8726 }
8727 this.ea.linepos = this.reader.getpos();
8728 this.parse_command_modifiers();
8729 this.parse_range();
8730 this.parse_command();
8731 this.parse_trail();
8732}
8733
8734// FIXME:
8735VimLParser.prototype.parse_command_modifiers = function() {
8736 var modifiers = [];
8737 while (TRUE) {
8738 var pos = this.reader.tell();
8739 var d = "";
8740 if (isdigit(this.reader.peekn(1))) {
8741 var d = this.reader.read_digit();
8742 this.reader.skip_white();
8743 }
8744 var k = this.reader.read_alpha();
8745 var c = this.reader.peekn(1);
8746 this.reader.skip_white();
8747 if (viml_stridx("aboveleft", k) == 0 && viml_len(k) >= 3) {
8748 // abo\%[veleft]
8749 viml_add(modifiers, {"name":"aboveleft"});
8750 }
8751 else if (viml_stridx("belowright", k) == 0 && viml_len(k) >= 3) {
8752 // bel\%[owright]
8753 viml_add(modifiers, {"name":"belowright"});
8754 }
8755 else if (viml_stridx("browse", k) == 0 && viml_len(k) >= 3) {
8756 // bro\%[wse]
8757 viml_add(modifiers, {"name":"browse"});
8758 }
8759 else if (viml_stridx("botright", k) == 0 && viml_len(k) >= 2) {
8760 // bo\%[tright]
8761 viml_add(modifiers, {"name":"botright"});
8762 }
8763 else if (viml_stridx("confirm", k) == 0 && viml_len(k) >= 4) {
8764 // conf\%[irm]
8765 viml_add(modifiers, {"name":"confirm"});
8766 }
8767 else if (viml_stridx("keepmarks", k) == 0 && viml_len(k) >= 3) {
8768 // kee\%[pmarks]
8769 viml_add(modifiers, {"name":"keepmarks"});
8770 }
8771 else if (viml_stridx("keepalt", k) == 0 && viml_len(k) >= 5) {
8772 // keepa\%[lt]
8773 viml_add(modifiers, {"name":"keepalt"});
8774 }
8775 else if (viml_stridx("keepjumps", k) == 0 && viml_len(k) >= 5) {
8776 // keepj\%[umps]
8777 viml_add(modifiers, {"name":"keepjumps"});
8778 }
8779 else if (viml_stridx("keeppatterns", k) == 0 && viml_len(k) >= 5) {
8780 // keepp\%[atterns]
8781 viml_add(modifiers, {"name":"keeppatterns"});
8782 }
8783 else if (viml_stridx("hide", k) == 0 && viml_len(k) >= 3) {
8784 // hid\%[e]
8785 if (this.ends_excmds(c)) {
8786 break;
8787 }
8788 viml_add(modifiers, {"name":"hide"});
8789 }
8790 else if (viml_stridx("lockmarks", k) == 0 && viml_len(k) >= 3) {
8791 // loc\%[kmarks]
8792 viml_add(modifiers, {"name":"lockmarks"});
8793 }
8794 else if (viml_stridx("leftabove", k) == 0 && viml_len(k) >= 5) {
8795 // lefta\%[bove]
8796 viml_add(modifiers, {"name":"leftabove"});
8797 }
8798 else if (viml_stridx("noautocmd", k) == 0 && viml_len(k) >= 3) {
8799 // noa\%[utocmd]
8800 viml_add(modifiers, {"name":"noautocmd"});
8801 }
8802 else if (viml_stridx("noswapfile", k) == 0 && viml_len(k) >= 3) {
8803 // :nos\%[wapfile]
8804 viml_add(modifiers, {"name":"noswapfile"});
8805 }
8806 else if (viml_stridx("rightbelow", k) == 0 && viml_len(k) >= 6) {
8807 // rightb\%[elow]
8808 viml_add(modifiers, {"name":"rightbelow"});
8809 }
8810 else if (viml_stridx("sandbox", k) == 0 && viml_len(k) >= 3) {
8811 // san\%[dbox]
8812 viml_add(modifiers, {"name":"sandbox"});
8813 }
8814 else if (viml_stridx("silent", k) == 0 && viml_len(k) >= 3) {
8815 // sil\%[ent]
8816 if (c == "!") {
8817 this.reader.get();
8818 viml_add(modifiers, {"name":"silent", "bang":1});
8819 }
8820 else {
8821 viml_add(modifiers, {"name":"silent", "bang":0});
8822 }
8823 }
8824 else if (k == "tab") {
8825 // tab
8826 if (d != "") {
8827 viml_add(modifiers, {"name":"tab", "count":viml_str2nr(d, 10)});
8828 }
8829 else {
8830 viml_add(modifiers, {"name":"tab"});
8831 }
8832 }
8833 else if (viml_stridx("topleft", k) == 0 && viml_len(k) >= 2) {
8834 // to\%[pleft]
8835 viml_add(modifiers, {"name":"topleft"});
8836 }
8837 else if (viml_stridx("unsilent", k) == 0 && viml_len(k) >= 3) {
8838 // uns\%[ilent]
8839 viml_add(modifiers, {"name":"unsilent"});
8840 }
8841 else if (viml_stridx("vertical", k) == 0 && viml_len(k) >= 4) {
8842 // vert\%[ical]
8843 viml_add(modifiers, {"name":"vertical"});
8844 }
8845 else if (viml_stridx("verbose", k) == 0 && viml_len(k) >= 4) {
8846 // verb\%[ose]
8847 if (d != "") {
8848 viml_add(modifiers, {"name":"verbose", "count":viml_str2nr(d, 10)});
8849 }
8850 else {
8851 viml_add(modifiers, {"name":"verbose", "count":1});
8852 }
8853 }
8854 else {
8855 this.reader.seek_set(pos);
8856 break;
8857 }
8858 }
8859 this.ea.modifiers = modifiers;
8860}
8861
8862// FIXME:
8863VimLParser.prototype.parse_range = function() {
8864 var tokens = [];
8865 while (TRUE) {
8866 while (TRUE) {
8867 this.reader.skip_white();
8868 var c = this.reader.peekn(1);
8869 if (c == "") {
8870 break;
8871 }
8872 if (c == ".") {
8873 viml_add(tokens, this.reader.getn(1));
8874 }
8875 else if (c == "$") {
8876 viml_add(tokens, this.reader.getn(1));
8877 }
8878 else if (c == "'") {
8879 this.reader.getn(1);
8880 var m = this.reader.getn(1);
8881 if (m == "") {
8882 break;
8883 }
8884 viml_add(tokens, "'" + m);
8885 }
8886 else if (c == "/") {
8887 this.reader.getn(1);
8888 var __tmp = this.parse_pattern(c);
8889 var pattern = __tmp[0];
8890 var _ = __tmp[1];
8891 viml_add(tokens, pattern);
8892 }
8893 else if (c == "?") {
8894 this.reader.getn(1);
8895 var __tmp = this.parse_pattern(c);
8896 var pattern = __tmp[0];
8897 var _ = __tmp[1];
8898 viml_add(tokens, pattern);
8899 }
8900 else if (c == "\\") {
8901 var m = this.reader.p(1);
8902 if (m == "&" || m == "?" || m == "/") {
8903 this.reader.seek_cur(2);
8904 viml_add(tokens, "\\" + m);
8905 }
8906 else {
8907 throw Err("E10: \\\\ should be followed by /, ? or &", this.reader.getpos());
8908 }
8909 }
8910 else if (isdigit(c)) {
8911 viml_add(tokens, this.reader.read_digit());
8912 }
8913 while (TRUE) {
8914 this.reader.skip_white();
8915 if (this.reader.peekn(1) == "") {
8916 break;
8917 }
8918 var n = this.reader.read_integer();
8919 if (n == "") {
8920 break;
8921 }
8922 viml_add(tokens, n);
8923 }
8924 if (this.reader.p(0) != "/" && this.reader.p(0) != "?") {
8925 break;
8926 }
8927 }
8928 if (this.reader.peekn(1) == "%") {
8929 viml_add(tokens, this.reader.getn(1));
8930 }
8931 else if (this.reader.peekn(1) == "*") {
8932 // && &cpoptions !~ '\*'
8933 viml_add(tokens, this.reader.getn(1));
8934 }
8935 if (this.reader.peekn(1) == ";") {
8936 viml_add(tokens, this.reader.getn(1));
8937 continue;
8938 }
8939 else if (this.reader.peekn(1) == ",") {
8940 viml_add(tokens, this.reader.getn(1));
8941 continue;
8942 }
8943 break;
8944 }
8945 this.ea.range = tokens;
8946}
8947
8948// FIXME:
8949VimLParser.prototype.parse_pattern = function(delimiter) {
8950 var pattern = "";
8951 var endc = "";
8952 var inbracket = 0;
8953 while (TRUE) {
8954 var c = this.reader.getn(1);
8955 if (c == "") {
8956 break;
8957 }
8958 if (c == delimiter && inbracket == 0) {
8959 var endc = c;
8960 break;
8961 }
8962 pattern += c;
8963 if (c == "\\") {
8964 var c = this.reader.peekn(1);
8965 if (c == "") {
8966 throw Err("E682: Invalid search pattern or delimiter", this.reader.getpos());
8967 }
8968 this.reader.getn(1);
8969 pattern += c;
8970 }
8971 else if (c == "[") {
8972 inbracket += 1;
8973 }
8974 else if (c == "]") {
8975 inbracket -= 1;
8976 }
8977 }
8978 return [pattern, endc];
8979}
8980
8981VimLParser.prototype.parse_command = function() {
8982 this.reader.skip_white_and_colon();
8983 this.ea.cmdpos = this.reader.getpos();
8984 if (this.reader.peekn(1) == "" || this.reader.peekn(1) == "\"") {
8985 if (!viml_empty(this.ea.modifiers) || !viml_empty(this.ea.range)) {
8986 this.parse_cmd_modifier_range();
8987 }
8988 return;
8989 }
8990 this.ea.cmd = this.find_command();
8991 if (this.ea.cmd === NIL) {
8992 this.reader.setpos(this.ea.cmdpos);
8993 throw Err(viml_printf("E492: Not an editor command: %s", this.reader.peekline()), this.ea.cmdpos);
8994 }
8995 if (this.reader.peekn(1) == "!" && this.ea.cmd.name != "substitute" && this.ea.cmd.name != "smagic" && this.ea.cmd.name != "snomagic") {
8996 this.reader.getn(1);
8997 this.ea.forceit = TRUE;
8998 }
8999 else {
9000 this.ea.forceit = FALSE;
9001 }
9002 if (!viml_eqregh(this.ea.cmd.flags, "\\<BANG\\>") && this.ea.forceit && !viml_eqregh(this.ea.cmd.flags, "\\<USERCMD\\>")) {
9003 throw Err("E477: No ! allowed", this.ea.cmdpos);
9004 }
9005 if (this.ea.cmd.name != "!") {
9006 this.reader.skip_white();
9007 }
9008 this.ea.argpos = this.reader.getpos();
9009 if (viml_eqregh(this.ea.cmd.flags, "\\<ARGOPT\\>")) {
9010 this.parse_argopt();
9011 }
9012 if (this.ea.cmd.name == "write" || this.ea.cmd.name == "update") {
9013 if (this.reader.p(0) == ">") {
9014 if (this.reader.p(1) != ">") {
9015 throw Err("E494: Use w or w>>", this.ea.cmdpos);
9016 }
9017 this.reader.seek_cur(2);
9018 this.reader.skip_white();
9019 this.ea.append = 1;
9020 }
9021 else if (this.reader.peekn(1) == "!" && this.ea.cmd.name == "write") {
9022 this.reader.getn(1);
9023 this.ea.usefilter = TRUE;
9024 }
9025 }
9026 if (this.ea.cmd.name == "read") {
9027 if (this.ea.forceit) {
9028 this.ea.usefilter = TRUE;
9029 this.ea.forceit = FALSE;
9030 }
9031 else if (this.reader.peekn(1) == "!") {
9032 this.reader.getn(1);
9033 this.ea.usefilter = TRUE;
9034 }
9035 }
9036 if (this.ea.cmd.name == "<" || this.ea.cmd.name == ">") {
9037 this.ea.amount = 1;
9038 while (this.reader.peekn(1) == this.ea.cmd.name) {
9039 this.reader.getn(1);
9040 this.ea.amount += 1;
9041 }
9042 this.reader.skip_white();
9043 }
9044 if (viml_eqregh(this.ea.cmd.flags, "\\<EDITCMD\\>") && !this.ea.usefilter) {
9045 this.parse_argcmd();
9046 }
9047 this._parse_command(this.ea.cmd.parser);
9048}
9049
9050// TODO: self[a:parser]
9051VimLParser.prototype._parse_command = function(parser) {
9052 if (parser == "parse_cmd_append") {
9053 this.parse_cmd_append();
9054 }
9055 else if (parser == "parse_cmd_break") {
9056 this.parse_cmd_break();
9057 }
9058 else if (parser == "parse_cmd_call") {
9059 this.parse_cmd_call();
9060 }
9061 else if (parser == "parse_cmd_catch") {
9062 this.parse_cmd_catch();
9063 }
9064 else if (parser == "parse_cmd_common") {
9065 this.parse_cmd_common();
9066 }
9067 else if (parser == "parse_cmd_continue") {
9068 this.parse_cmd_continue();
9069 }
9070 else if (parser == "parse_cmd_delfunction") {
9071 this.parse_cmd_delfunction();
9072 }
9073 else if (parser == "parse_cmd_echo") {
9074 this.parse_cmd_echo();
9075 }
9076 else if (parser == "parse_cmd_echoerr") {
9077 this.parse_cmd_echoerr();
9078 }
9079 else if (parser == "parse_cmd_echohl") {
9080 this.parse_cmd_echohl();
9081 }
9082 else if (parser == "parse_cmd_echomsg") {
9083 this.parse_cmd_echomsg();
9084 }
9085 else if (parser == "parse_cmd_echon") {
9086 this.parse_cmd_echon();
9087 }
9088 else if (parser == "parse_cmd_else") {
9089 this.parse_cmd_else();
9090 }
9091 else if (parser == "parse_cmd_elseif") {
9092 this.parse_cmd_elseif();
9093 }
9094 else if (parser == "parse_cmd_endfor") {
9095 this.parse_cmd_endfor();
9096 }
9097 else if (parser == "parse_cmd_endfunction") {
9098 this.parse_cmd_endfunction();
9099 }
9100 else if (parser == "parse_cmd_endif") {
9101 this.parse_cmd_endif();
9102 }
9103 else if (parser == "parse_cmd_endtry") {
9104 this.parse_cmd_endtry();
9105 }
9106 else if (parser == "parse_cmd_endwhile") {
9107 this.parse_cmd_endwhile();
9108 }
9109 else if (parser == "parse_cmd_execute") {
9110 this.parse_cmd_execute();
9111 }
9112 else if (parser == "parse_cmd_finally") {
9113 this.parse_cmd_finally();
9114 }
9115 else if (parser == "parse_cmd_finish") {
9116 this.parse_cmd_finish();
9117 }
9118 else if (parser == "parse_cmd_for") {
9119 this.parse_cmd_for();
9120 }
9121 else if (parser == "parse_cmd_function") {
9122 this.parse_cmd_function();
9123 }
9124 else if (parser == "parse_cmd_if") {
9125 this.parse_cmd_if();
9126 }
9127 else if (parser == "parse_cmd_insert") {
9128 this.parse_cmd_insert();
9129 }
9130 else if (parser == "parse_cmd_let") {
9131 this.parse_cmd_let();
9132 }
9133 else if (parser == "parse_cmd_const") {
9134 this.parse_cmd_const();
9135 }
9136 else if (parser == "parse_cmd_loadkeymap") {
9137 this.parse_cmd_loadkeymap();
9138 }
9139 else if (parser == "parse_cmd_lockvar") {
9140 this.parse_cmd_lockvar();
9141 }
9142 else if (parser == "parse_cmd_lua") {
9143 this.parse_cmd_lua();
9144 }
9145 else if (parser == "parse_cmd_modifier_range") {
9146 this.parse_cmd_modifier_range();
9147 }
9148 else if (parser == "parse_cmd_mzscheme") {
9149 this.parse_cmd_mzscheme();
9150 }
9151 else if (parser == "parse_cmd_perl") {
9152 this.parse_cmd_perl();
9153 }
9154 else if (parser == "parse_cmd_python") {
9155 this.parse_cmd_python();
9156 }
9157 else if (parser == "parse_cmd_python3") {
9158 this.parse_cmd_python3();
9159 }
9160 else if (parser == "parse_cmd_return") {
9161 this.parse_cmd_return();
9162 }
9163 else if (parser == "parse_cmd_ruby") {
9164 this.parse_cmd_ruby();
9165 }
9166 else if (parser == "parse_cmd_tcl") {
9167 this.parse_cmd_tcl();
9168 }
9169 else if (parser == "parse_cmd_throw") {
9170 this.parse_cmd_throw();
9171 }
9172 else if (parser == "parse_cmd_eval") {
9173 this.parse_cmd_eval();
9174 }
9175 else if (parser == "parse_cmd_try") {
9176 this.parse_cmd_try();
9177 }
9178 else if (parser == "parse_cmd_unlet") {
9179 this.parse_cmd_unlet();
9180 }
9181 else if (parser == "parse_cmd_unlockvar") {
9182 this.parse_cmd_unlockvar();
9183 }
9184 else if (parser == "parse_cmd_usercmd") {
9185 this.parse_cmd_usercmd();
9186 }
9187 else if (parser == "parse_cmd_while") {
9188 this.parse_cmd_while();
9189 }
9190 else if (parser == "parse_wincmd") {
9191 this.parse_wincmd();
9192 }
9193 else if (parser == "parse_cmd_syntax") {
9194 this.parse_cmd_syntax();
9195 }
9196 else {
9197 throw viml_printf("unknown parser: %s", viml_string(parser));
9198 }
9199}
9200
9201VimLParser.prototype.find_command = function() {
9202 var c = this.reader.peekn(1);
9203 var name = "";
9204 if (c == "k") {
9205 this.reader.getn(1);
9206 var name = "k";
9207 }
9208 else if (c == "s" && viml_eqregh(this.reader.peekn(5), "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])")) {
9209 this.reader.getn(1);
9210 var name = "substitute";
9211 }
9212 else if (viml_eqregh(c, "[@*!=><&~#]")) {
9213 this.reader.getn(1);
9214 var name = c;
9215 }
9216 else if (this.reader.peekn(2) == "py") {
9217 var name = this.reader.read_alnum();
9218 }
9219 else {
9220 var pos = this.reader.tell();
9221 var name = this.reader.read_alpha();
9222 if (name != "del" && viml_eqregh(name, "\\v^d%[elete][lp]$")) {
9223 this.reader.seek_set(pos);
9224 var name = this.reader.getn(viml_len(name) - 1);
9225 }
9226 }
9227 if (name == "") {
9228 return NIL;
9229 }
9230 if (viml_has_key(this.find_command_cache, name)) {
9231 return this.find_command_cache[name];
9232 }
9233 var cmd = NIL;
9234 var __c4 = this.builtin_commands;
9235 for (var __i4 = 0; __i4 < __c4.length; ++__i4) {
9236 var x = __c4[__i4];
9237 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
9238 delete cmd;
9239 var cmd = x;
9240 break;
9241 }
9242 }
9243 if (this.neovim) {
9244 var __c5 = this.neovim_additional_commands;
9245 for (var __i5 = 0; __i5 < __c5.length; ++__i5) {
9246 var x = __c5[__i5];
9247 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
9248 delete cmd;
9249 var cmd = x;
9250 break;
9251 }
9252 }
9253 var __c6 = this.neovim_removed_commands;
9254 for (var __i6 = 0; __i6 < __c6.length; ++__i6) {
9255 var x = __c6[__i6];
9256 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
9257 delete cmd;
9258 var cmd = NIL;
9259 break;
9260 }
9261 }
9262 }
9263 // FIXME: user defined command
9264 if ((cmd === NIL || cmd.name == "Print") && viml_eqregh(name, "^[A-Z]")) {
9265 name += this.reader.read_alnum();
9266 delete cmd;
9267 var cmd = {"name":name, "flags":"USERCMD", "parser":"parse_cmd_usercmd"};
9268 }
9269 this.find_command_cache[name] = cmd;
9270 return cmd;
9271}
9272
9273// TODO:
9274VimLParser.prototype.parse_hashbang = function() {
9275 this.reader.getn(-1);
9276}
9277
9278// TODO:
9279// ++opt=val
9280VimLParser.prototype.parse_argopt = function() {
9281 while (this.reader.p(0) == "+" && this.reader.p(1) == "+") {
9282 var s = this.reader.peekn(20);
9283 if (viml_eqregh(s, "^++bin\\>")) {
9284 this.reader.getn(5);
9285 this.ea.force_bin = 1;
9286 }
9287 else if (viml_eqregh(s, "^++nobin\\>")) {
9288 this.reader.getn(7);
9289 this.ea.force_bin = 2;
9290 }
9291 else if (viml_eqregh(s, "^++edit\\>")) {
9292 this.reader.getn(6);
9293 this.ea.read_edit = 1;
9294 }
9295 else if (viml_eqregh(s, "^++ff=\\(dos\\|unix\\|mac\\)\\>")) {
9296 this.reader.getn(5);
9297 this.ea.force_ff = this.reader.read_alpha();
9298 }
9299 else if (viml_eqregh(s, "^++fileformat=\\(dos\\|unix\\|mac\\)\\>")) {
9300 this.reader.getn(13);
9301 this.ea.force_ff = this.reader.read_alpha();
9302 }
9303 else if (viml_eqregh(s, "^++enc=\\S")) {
9304 this.reader.getn(6);
9305 this.ea.force_enc = this.reader.read_nonwhite();
9306 }
9307 else if (viml_eqregh(s, "^++encoding=\\S")) {
9308 this.reader.getn(11);
9309 this.ea.force_enc = this.reader.read_nonwhite();
9310 }
9311 else if (viml_eqregh(s, "^++bad=\\(keep\\|drop\\|.\\)\\>")) {
9312 this.reader.getn(6);
9313 if (viml_eqregh(s, "^++bad=keep")) {
9314 this.ea.bad_char = this.reader.getn(4);
9315 }
9316 else if (viml_eqregh(s, "^++bad=drop")) {
9317 this.ea.bad_char = this.reader.getn(4);
9318 }
9319 else {
9320 this.ea.bad_char = this.reader.getn(1);
9321 }
9322 }
9323 else if (viml_eqregh(s, "^++")) {
9324 throw Err("E474: Invalid Argument", this.reader.getpos());
9325 }
9326 else {
9327 break;
9328 }
9329 this.reader.skip_white();
9330 }
9331}
9332
9333// TODO:
9334// +command
9335VimLParser.prototype.parse_argcmd = function() {
9336 if (this.reader.peekn(1) == "+") {
9337 this.reader.getn(1);
9338 if (this.reader.peekn(1) == " ") {
9339 this.ea.do_ecmd_cmd = "$";
9340 }
9341 else {
9342 this.ea.do_ecmd_cmd = this.read_cmdarg();
9343 }
9344 }
9345}
9346
9347VimLParser.prototype.read_cmdarg = function() {
9348 var r = "";
9349 while (TRUE) {
9350 var c = this.reader.peekn(1);
9351 if (c == "" || iswhite(c)) {
9352 break;
9353 }
9354 this.reader.getn(1);
9355 if (c == "\\") {
9356 var c = this.reader.getn(1);
9357 }
9358 r += c;
9359 }
9360 return r;
9361}
9362
9363VimLParser.prototype.parse_comment = function() {
9364 var npos = this.reader.getpos();
9365 var c = this.reader.get();
9366 if (c != "\"") {
9367 throw Err(viml_printf("unexpected character: %s", c), npos);
9368 }
9369 var node = Node(NODE_COMMENT);
9370 node.pos = npos;
9371 node.str = this.reader.getn(-1);
9372 this.add_node(node);
9373}
9374
9375VimLParser.prototype.parse_trail = function() {
9376 this.reader.skip_white();
9377 var c = this.reader.peek();
9378 if (c == "<EOF>") {
9379 // pass
9380 }
9381 else if (c == "<EOL>") {
9382 this.reader.get();
9383 }
9384 else if (c == "|") {
9385 this.reader.get();
9386 }
9387 else if (c == "\"") {
9388 this.parse_comment();
9389 this.reader.get();
9390 }
9391 else {
9392 throw Err(viml_printf("E488: Trailing characters: %s", c), this.reader.getpos());
9393 }
9394}
9395
9396// modifier or range only command line
9397VimLParser.prototype.parse_cmd_modifier_range = function() {
9398 var node = Node(NODE_EXCMD);
9399 node.pos = this.ea.cmdpos;
9400 node.ea = this.ea;
9401 node.str = this.reader.getstr(this.ea.linepos, this.reader.getpos());
9402 this.add_node(node);
9403}
9404
9405// TODO:
9406VimLParser.prototype.parse_cmd_common = function() {
9407 var end = this.reader.getpos();
9408 if (viml_eqregh(this.ea.cmd.flags, "\\<TRLBAR\\>") && !this.ea.usefilter) {
9409 var end = this.separate_nextcmd();
9410 }
9411 else if (this.ea.cmd.name == "!" || this.ea.cmd.name == "global" || this.ea.cmd.name == "vglobal" || this.ea.usefilter) {
9412 while (TRUE) {
9413 var end = this.reader.getpos();
9414 if (this.reader.getn(1) == "") {
9415 break;
9416 }
9417 }
9418 }
9419 else {
9420 while (TRUE) {
9421 var end = this.reader.getpos();
9422 if (this.reader.getn(1) == "") {
9423 break;
9424 }
9425 }
9426 }
9427 var node = Node(NODE_EXCMD);
9428 node.pos = this.ea.cmdpos;
9429 node.ea = this.ea;
9430 node.str = this.reader.getstr(this.ea.linepos, end);
9431 this.add_node(node);
9432}
9433
9434VimLParser.prototype.separate_nextcmd = function() {
9435 if (this.ea.cmd.name == "vimgrep" || this.ea.cmd.name == "vimgrepadd" || this.ea.cmd.name == "lvimgrep" || this.ea.cmd.name == "lvimgrepadd") {
9436 this.skip_vimgrep_pat();
9437 }
9438 var pc = "";
9439 var end = this.reader.getpos();
9440 var nospend = end;
9441 while (TRUE) {
9442 var end = this.reader.getpos();
9443 if (!iswhite(pc)) {
9444 var nospend = end;
9445 }
9446 var c = this.reader.peek();
9447 if (c == "<EOF>" || c == "<EOL>") {
9448 break;
9449 }
9450 else if (c == "\x16") {
9451 // <C-V>
9452 this.reader.get();
9453 var end = this.reader.getpos();
9454 var nospend = this.reader.getpos();
9455 var c = this.reader.peek();
9456 if (c == "<EOF>" || c == "<EOL>") {
9457 break;
9458 }
9459 this.reader.get();
9460 }
9461 else if (this.reader.peekn(2) == "`=" && viml_eqregh(this.ea.cmd.flags, "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>")) {
9462 this.reader.getn(2);
9463 this.parse_expr();
9464 var c = this.reader.peekn(1);
9465 if (c != "`") {
9466 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
9467 }
9468 this.reader.getn(1);
9469 }
9470 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 != "@")) {
9471 var has_cpo_bar = FALSE;
9472 // &cpoptions =~ 'b'
9473 if ((!has_cpo_bar || !viml_eqregh(this.ea.cmd.flags, "\\<USECTRLV\\>")) && pc == "\\") {
9474 this.reader.get();
9475 }
9476 else {
9477 break;
9478 }
9479 }
9480 else {
9481 this.reader.get();
9482 }
9483 var pc = c;
9484 }
9485 if (!viml_eqregh(this.ea.cmd.flags, "\\<NOTRLCOM\\>")) {
9486 var end = nospend;
9487 }
9488 return end;
9489}
9490
9491// FIXME
9492VimLParser.prototype.skip_vimgrep_pat = function() {
9493 if (this.reader.peekn(1) == "") {
9494 // pass
9495 }
9496 else if (isidc(this.reader.peekn(1))) {
9497 // :vimgrep pattern fname
9498 this.reader.read_nonwhite();
9499 }
9500 else {
9501 // :vimgrep /pattern/[g][j] fname
9502 var c = this.reader.getn(1);
9503 var __tmp = this.parse_pattern(c);
9504 var _ = __tmp[0];
9505 var endc = __tmp[1];
9506 if (c != endc) {
9507 return;
9508 }
9509 while (this.reader.p(0) == "g" || this.reader.p(0) == "j") {
9510 this.reader.getn(1);
9511 }
9512 }
9513}
9514
9515VimLParser.prototype.parse_cmd_append = function() {
9516 this.reader.setpos(this.ea.linepos);
9517 var cmdline = this.reader.readline();
9518 var lines = [cmdline];
9519 var m = ".";
9520 while (TRUE) {
9521 if (this.reader.peek() == "<EOF>") {
9522 break;
9523 }
9524 var line = this.reader.getn(-1);
9525 viml_add(lines, line);
9526 if (line == m) {
9527 break;
9528 }
9529 this.reader.get();
9530 }
9531 var node = Node(NODE_EXCMD);
9532 node.pos = this.ea.cmdpos;
9533 node.ea = this.ea;
9534 node.str = viml_join(lines, "\n");
9535 this.add_node(node);
9536}
9537
9538VimLParser.prototype.parse_cmd_insert = function() {
9539 this.parse_cmd_append();
9540}
9541
9542VimLParser.prototype.parse_cmd_loadkeymap = function() {
9543 this.reader.setpos(this.ea.linepos);
9544 var cmdline = this.reader.readline();
9545 var lines = [cmdline];
9546 while (TRUE) {
9547 if (this.reader.peek() == "<EOF>") {
9548 break;
9549 }
9550 var line = this.reader.readline();
9551 viml_add(lines, line);
9552 }
9553 var node = Node(NODE_EXCMD);
9554 node.pos = this.ea.cmdpos;
9555 node.ea = this.ea;
9556 node.str = viml_join(lines, "\n");
9557 this.add_node(node);
9558}
9559
9560VimLParser.prototype.parse_cmd_lua = function() {
9561 var lines = [];
9562 this.reader.skip_white();
9563 if (this.reader.peekn(2) == "<<") {
9564 this.reader.getn(2);
9565 this.reader.skip_white();
9566 var m = this.reader.readline();
9567 if (m == "") {
9568 var m = ".";
9569 }
9570 this.reader.setpos(this.ea.linepos);
9571 var cmdline = this.reader.getn(-1);
9572 var lines = [cmdline];
9573 this.reader.get();
9574 while (TRUE) {
9575 if (this.reader.peek() == "<EOF>") {
9576 break;
9577 }
9578 var line = this.reader.getn(-1);
9579 viml_add(lines, line);
9580 if (line == m) {
9581 break;
9582 }
9583 this.reader.get();
9584 }
9585 }
9586 else {
9587 this.reader.setpos(this.ea.linepos);
9588 var cmdline = this.reader.getn(-1);
9589 var lines = [cmdline];
9590 }
9591 var node = Node(NODE_EXCMD);
9592 node.pos = this.ea.cmdpos;
9593 node.ea = this.ea;
9594 node.str = viml_join(lines, "\n");
9595 this.add_node(node);
9596}
9597
9598VimLParser.prototype.parse_cmd_mzscheme = function() {
9599 this.parse_cmd_lua();
9600}
9601
9602VimLParser.prototype.parse_cmd_perl = function() {
9603 this.parse_cmd_lua();
9604}
9605
9606VimLParser.prototype.parse_cmd_python = function() {
9607 this.parse_cmd_lua();
9608}
9609
9610VimLParser.prototype.parse_cmd_python3 = function() {
9611 this.parse_cmd_lua();
9612}
9613
9614VimLParser.prototype.parse_cmd_ruby = function() {
9615 this.parse_cmd_lua();
9616}
9617
9618VimLParser.prototype.parse_cmd_tcl = function() {
9619 this.parse_cmd_lua();
9620}
9621
9622VimLParser.prototype.parse_cmd_finish = function() {
9623 this.parse_cmd_common();
9624 if (this.context[0].type == NODE_TOPLEVEL) {
9625 this.reader.seek_end(0);
9626 }
9627}
9628
9629// FIXME
9630VimLParser.prototype.parse_cmd_usercmd = function() {
9631 this.parse_cmd_common();
9632}
9633
9634VimLParser.prototype.parse_cmd_function = function() {
9635 var pos = this.reader.tell();
9636 this.reader.skip_white();
9637 // :function
9638 if (this.ends_excmds(this.reader.peek())) {
9639 this.reader.seek_set(pos);
9640 this.parse_cmd_common();
9641 return;
9642 }
9643 // :function /pattern
9644 if (this.reader.peekn(1) == "/") {
9645 this.reader.seek_set(pos);
9646 this.parse_cmd_common();
9647 return;
9648 }
9649 var left = this.parse_lvalue_func();
9650 this.reader.skip_white();
9651 if (left.type == NODE_IDENTIFIER) {
9652 var s = left.value;
9653 var ss = viml_split(s, "\\zs");
9654 if (ss[0] != "<" && ss[0] != "_" && !isupper(ss[0]) && viml_stridx(s, ":") == -1 && viml_stridx(s, "#") == -1) {
9655 throw Err(viml_printf("E128: Function name must start with a capital or contain a colon: %s", s), left.pos);
9656 }
9657 }
9658 // :function {name}
9659 if (this.reader.peekn(1) != "(") {
9660 this.reader.seek_set(pos);
9661 this.parse_cmd_common();
9662 return;
9663 }
9664 // :function[!] {name}([arguments]) [range] [abort] [dict] [closure]
9665 var node = Node(NODE_FUNCTION);
9666 node.pos = this.ea.cmdpos;
9667 node.body = [];
9668 node.ea = this.ea;
9669 node.left = left;
9670 node.rlist = [];
9671 node.default_args = [];
9672 node.attr = {"range":0, "abort":0, "dict":0, "closure":0};
9673 node.endfunction = NIL;
9674 this.reader.getn(1);
9675 var tokenizer = new ExprTokenizer(this.reader);
9676 if (tokenizer.peek().type == TOKEN_PCLOSE) {
9677 tokenizer.get();
9678 }
9679 else {
9680 var named = {};
9681 while (TRUE) {
9682 var varnode = Node(NODE_IDENTIFIER);
9683 var token = tokenizer.get();
9684 if (token.type == TOKEN_IDENTIFIER) {
9685 if (!isargname(token.value) || token.value == "firstline" || token.value == "lastline") {
9686 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
9687 }
9688 else if (viml_has_key(named, token.value)) {
9689 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
9690 }
9691 named[token.value] = 1;
9692 varnode.pos = token.pos;
9693 varnode.value = token.value;
9694 viml_add(node.rlist, varnode);
9695 if (tokenizer.peek().type == TOKEN_EQ) {
9696 tokenizer.get();
9697 viml_add(node.default_args, this.parse_expr());
9698 }
9699 else if (viml_len(node.default_args) > 0) {
9700 throw Err("E989: Non-default argument follows default argument", varnode.pos);
9701 }
9702 // XXX: Vim doesn't skip white space before comma. F(a ,b) => E475
9703 if (iswhite(this.reader.p(0)) && tokenizer.peek().type == TOKEN_COMMA) {
9704 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
9705 }
9706 var token = tokenizer.get();
9707 if (token.type == TOKEN_COMMA) {
9708 // XXX: Vim allows last comma. F(a, b, ) => OK
9709 if (tokenizer.peek().type == TOKEN_PCLOSE) {
9710 tokenizer.get();
9711 break;
9712 }
9713 }
9714 else if (token.type == TOKEN_PCLOSE) {
9715 break;
9716 }
9717 else {
9718 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9719 }
9720 }
9721 else if (token.type == TOKEN_DOTDOTDOT) {
9722 varnode.pos = token.pos;
9723 varnode.value = token.value;
9724 viml_add(node.rlist, varnode);
9725 var token = tokenizer.get();
9726 if (token.type == TOKEN_PCLOSE) {
9727 break;
9728 }
9729 else {
9730 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9731 }
9732 }
9733 else {
9734 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9735 }
9736 }
9737 }
9738 while (TRUE) {
9739 this.reader.skip_white();
9740 var epos = this.reader.getpos();
9741 var key = this.reader.read_alpha();
9742 if (key == "") {
9743 break;
9744 }
9745 else if (key == "range") {
9746 node.attr.range = TRUE;
9747 }
9748 else if (key == "abort") {
9749 node.attr.abort = TRUE;
9750 }
9751 else if (key == "dict") {
9752 node.attr.dict = TRUE;
9753 }
9754 else if (key == "closure") {
9755 node.attr.closure = TRUE;
9756 }
9757 else {
9758 throw Err(viml_printf("unexpected token: %s", key), epos);
9759 }
9760 }
9761 this.add_node(node);
9762 this.push_context(node);
9763}
9764
9765VimLParser.prototype.parse_cmd_endfunction = function() {
9766 this.check_missing_endif("ENDFUNCTION", this.ea.cmdpos);
9767 this.check_missing_endtry("ENDFUNCTION", this.ea.cmdpos);
9768 this.check_missing_endwhile("ENDFUNCTION", this.ea.cmdpos);
9769 this.check_missing_endfor("ENDFUNCTION", this.ea.cmdpos);
9770 if (this.context[0].type != NODE_FUNCTION) {
9771 throw Err("E193: :endfunction not inside a function", this.ea.cmdpos);
9772 }
9773 this.reader.getn(-1);
9774 var node = Node(NODE_ENDFUNCTION);
9775 node.pos = this.ea.cmdpos;
9776 node.ea = this.ea;
9777 this.context[0].endfunction = node;
9778 this.pop_context();
9779}
9780
9781VimLParser.prototype.parse_cmd_delfunction = function() {
9782 var node = Node(NODE_DELFUNCTION);
9783 node.pos = this.ea.cmdpos;
9784 node.ea = this.ea;
9785 node.left = this.parse_lvalue_func();
9786 this.add_node(node);
9787}
9788
9789VimLParser.prototype.parse_cmd_return = function() {
9790 if (this.find_context(NODE_FUNCTION) == -1) {
9791 throw Err("E133: :return not inside a function", this.ea.cmdpos);
9792 }
9793 var node = Node(NODE_RETURN);
9794 node.pos = this.ea.cmdpos;
9795 node.ea = this.ea;
9796 node.left = NIL;
9797 this.reader.skip_white();
9798 var c = this.reader.peek();
9799 if (c == "\"" || !this.ends_excmds(c)) {
9800 node.left = this.parse_expr();
9801 }
9802 this.add_node(node);
9803}
9804
9805VimLParser.prototype.parse_cmd_call = function() {
9806 var node = Node(NODE_EXCALL);
9807 node.pos = this.ea.cmdpos;
9808 node.ea = this.ea;
9809 this.reader.skip_white();
9810 var c = this.reader.peek();
9811 if (this.ends_excmds(c)) {
9812 throw Err("E471: Argument required", this.reader.getpos());
9813 }
9814 node.left = this.parse_expr();
9815 if (node.left.type != NODE_CALL) {
9816 throw Err("Not an function call", node.left.pos);
9817 }
9818 this.add_node(node);
9819}
9820
9821VimLParser.prototype.parse_heredoc = function() {
9822 var node = Node(NODE_HEREDOC);
9823 node.pos = this.ea.cmdpos;
9824 node.op = "";
9825 node.rlist = [];
9826 node.body = [];
9827 while (TRUE) {
9828 this.reader.skip_white();
9829 var key = this.reader.read_word();
9830 if (key == "") {
9831 break;
9832 }
9833 if (!islower(key[0])) {
9834 node.op = key;
9835 break;
9836 }
9837 else {
9838 viml_add(node.rlist, key);
9839 }
9840 }
9841 if (node.op == "") {
9842 throw Err("E172: Missing marker", this.reader.getpos());
9843 }
9844 this.parse_trail();
9845 while (TRUE) {
9846 if (this.reader.peek() == "<EOF>") {
9847 break;
9848 }
9849 var line = this.reader.getn(-1);
9850 if (line == node.op) {
9851 return node;
9852 }
9853 viml_add(node.body, line);
9854 this.reader.get();
9855 }
9856 throw Err(viml_printf("E990: Missing end marker '%s'", node.op), this.reader.getpos());
9857}
9858
9859VimLParser.prototype.parse_cmd_let = function() {
9860 var pos = this.reader.tell();
9861 this.reader.skip_white();
9862 // :let
9863 if (this.ends_excmds(this.reader.peek())) {
9864 this.reader.seek_set(pos);
9865 this.parse_cmd_common();
9866 return;
9867 }
9868 var lhs = this.parse_letlhs();
9869 this.reader.skip_white();
9870 var s1 = this.reader.peekn(1);
9871 var s2 = this.reader.peekn(2);
9872 // TODO check scriptversion?
9873 if (s2 == "..") {
9874 var s2 = this.reader.peekn(3);
9875 }
9876 else if (s2 == "=<") {
9877 var s2 = this.reader.peekn(3);
9878 }
9879 // :let {var-name} ..
9880 if (this.ends_excmds(s1) || s2 != "+=" && s2 != "-=" && s2 != ".=" && s2 != "..=" && s2 != "*=" && s2 != "/=" && s2 != "%=" && s2 != "=<<" && s1 != "=") {
9881 this.reader.seek_set(pos);
9882 this.parse_cmd_common();
9883 return;
9884 }
9885 // :let left op right
9886 var node = Node(NODE_LET);
9887 node.pos = this.ea.cmdpos;
9888 node.ea = this.ea;
9889 node.op = "";
9890 node.left = lhs.left;
9891 node.list = lhs.list;
9892 node.rest = lhs.rest;
9893 node.right = NIL;
9894 if (s2 == "+=" || s2 == "-=" || s2 == ".=" || s2 == "..=" || s2 == "*=" || s2 == "/=" || s2 == "%=") {
9895 this.reader.getn(viml_len(s2));
9896 node.op = s2;
9897 }
9898 else if (s2 == "=<<") {
9899 this.reader.getn(viml_len(s2));
9900 this.reader.skip_white();
9901 node.op = s2;
9902 node.right = this.parse_heredoc();
9903 this.add_node(node);
9904 return;
9905 }
9906 else if (s1 == "=") {
9907 this.reader.getn(1);
9908 node.op = s1;
9909 }
9910 else {
9911 throw "NOT REACHED";
9912 }
9913 node.right = this.parse_expr();
9914 this.add_node(node);
9915}
9916
9917VimLParser.prototype.parse_cmd_const = function() {
9918 var pos = this.reader.tell();
9919 this.reader.skip_white();
9920 // :const
9921 if (this.ends_excmds(this.reader.peek())) {
9922 this.reader.seek_set(pos);
9923 this.parse_cmd_common();
9924 return;
9925 }
9926 var lhs = this.parse_constlhs();
9927 this.reader.skip_white();
9928 var s1 = this.reader.peekn(1);
9929 // :const {var-name}
9930 if (this.ends_excmds(s1) || s1 != "=") {
9931 this.reader.seek_set(pos);
9932 this.parse_cmd_common();
9933 return;
9934 }
9935 // :const left op right
9936 var node = Node(NODE_CONST);
9937 node.pos = this.ea.cmdpos;
9938 node.ea = this.ea;
9939 this.reader.getn(1);
9940 node.op = s1;
9941 node.left = lhs.left;
9942 node.list = lhs.list;
9943 node.rest = lhs.rest;
9944 node.right = this.parse_expr();
9945 this.add_node(node);
9946}
9947
9948VimLParser.prototype.parse_cmd_unlet = function() {
9949 var node = Node(NODE_UNLET);
9950 node.pos = this.ea.cmdpos;
9951 node.ea = this.ea;
9952 node.list = this.parse_lvaluelist();
9953 this.add_node(node);
9954}
9955
9956VimLParser.prototype.parse_cmd_lockvar = function() {
9957 var node = Node(NODE_LOCKVAR);
9958 node.pos = this.ea.cmdpos;
9959 node.ea = this.ea;
9960 node.depth = NIL;
9961 node.list = [];
9962 this.reader.skip_white();
9963 if (isdigit(this.reader.peekn(1))) {
9964 node.depth = viml_str2nr(this.reader.read_digit(), 10);
9965 }
9966 node.list = this.parse_lvaluelist();
9967 this.add_node(node);
9968}
9969
9970VimLParser.prototype.parse_cmd_unlockvar = function() {
9971 var node = Node(NODE_UNLOCKVAR);
9972 node.pos = this.ea.cmdpos;
9973 node.ea = this.ea;
9974 node.depth = NIL;
9975 node.list = [];
9976 this.reader.skip_white();
9977 if (isdigit(this.reader.peekn(1))) {
9978 node.depth = viml_str2nr(this.reader.read_digit(), 10);
9979 }
9980 node.list = this.parse_lvaluelist();
9981 this.add_node(node);
9982}
9983
9984VimLParser.prototype.parse_cmd_if = function() {
9985 var node = Node(NODE_IF);
9986 node.pos = this.ea.cmdpos;
9987 node.body = [];
9988 node.ea = this.ea;
9989 node.cond = this.parse_expr();
9990 node.elseif = [];
9991 node._else = NIL;
9992 node.endif = NIL;
9993 this.add_node(node);
9994 this.push_context(node);
9995}
9996
9997VimLParser.prototype.parse_cmd_elseif = function() {
9998 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
9999 throw Err("E582: :elseif without :if", this.ea.cmdpos);
10000 }
10001 if (this.context[0].type != NODE_IF) {
10002 this.pop_context();
10003 }
10004 var node = Node(NODE_ELSEIF);
10005 node.pos = this.ea.cmdpos;
10006 node.body = [];
10007 node.ea = this.ea;
10008 node.cond = this.parse_expr();
10009 viml_add(this.context[0].elseif, node);
10010 this.push_context(node);
10011}
10012
10013VimLParser.prototype.parse_cmd_else = function() {
10014 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
10015 throw Err("E581: :else without :if", this.ea.cmdpos);
10016 }
10017 if (this.context[0].type != NODE_IF) {
10018 this.pop_context();
10019 }
10020 var node = Node(NODE_ELSE);
10021 node.pos = this.ea.cmdpos;
10022 node.body = [];
10023 node.ea = this.ea;
10024 this.context[0]._else = node;
10025 this.push_context(node);
10026}
10027
10028VimLParser.prototype.parse_cmd_endif = function() {
10029 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF && this.context[0].type != NODE_ELSE) {
10030 throw Err("E580: :endif without :if", this.ea.cmdpos);
10031 }
10032 if (this.context[0].type != NODE_IF) {
10033 this.pop_context();
10034 }
10035 var node = Node(NODE_ENDIF);
10036 node.pos = this.ea.cmdpos;
10037 node.ea = this.ea;
10038 this.context[0].endif = node;
10039 this.pop_context();
10040}
10041
10042VimLParser.prototype.parse_cmd_while = function() {
10043 var node = Node(NODE_WHILE);
10044 node.pos = this.ea.cmdpos;
10045 node.body = [];
10046 node.ea = this.ea;
10047 node.cond = this.parse_expr();
10048 node.endwhile = NIL;
10049 this.add_node(node);
10050 this.push_context(node);
10051}
10052
10053VimLParser.prototype.parse_cmd_endwhile = function() {
10054 if (this.context[0].type != NODE_WHILE) {
10055 throw Err("E588: :endwhile without :while", this.ea.cmdpos);
10056 }
10057 var node = Node(NODE_ENDWHILE);
10058 node.pos = this.ea.cmdpos;
10059 node.ea = this.ea;
10060 this.context[0].endwhile = node;
10061 this.pop_context();
10062}
10063
10064VimLParser.prototype.parse_cmd_for = function() {
10065 var node = Node(NODE_FOR);
10066 node.pos = this.ea.cmdpos;
10067 node.body = [];
10068 node.ea = this.ea;
10069 node.left = NIL;
10070 node.right = NIL;
10071 node.endfor = NIL;
10072 var lhs = this.parse_letlhs();
10073 node.left = lhs.left;
10074 node.list = lhs.list;
10075 node.rest = lhs.rest;
10076 this.reader.skip_white();
10077 var epos = this.reader.getpos();
10078 if (this.reader.read_alpha() != "in") {
10079 throw Err("Missing \"in\" after :for", epos);
10080 }
10081 node.right = this.parse_expr();
10082 this.add_node(node);
10083 this.push_context(node);
10084}
10085
10086VimLParser.prototype.parse_cmd_endfor = function() {
10087 if (this.context[0].type != NODE_FOR) {
10088 throw Err("E588: :endfor without :for", this.ea.cmdpos);
10089 }
10090 var node = Node(NODE_ENDFOR);
10091 node.pos = this.ea.cmdpos;
10092 node.ea = this.ea;
10093 this.context[0].endfor = node;
10094 this.pop_context();
10095}
10096
10097VimLParser.prototype.parse_cmd_continue = function() {
10098 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
10099 throw Err("E586: :continue without :while or :for", this.ea.cmdpos);
10100 }
10101 var node = Node(NODE_CONTINUE);
10102 node.pos = this.ea.cmdpos;
10103 node.ea = this.ea;
10104 this.add_node(node);
10105}
10106
10107VimLParser.prototype.parse_cmd_break = function() {
10108 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
10109 throw Err("E587: :break without :while or :for", this.ea.cmdpos);
10110 }
10111 var node = Node(NODE_BREAK);
10112 node.pos = this.ea.cmdpos;
10113 node.ea = this.ea;
10114 this.add_node(node);
10115}
10116
10117VimLParser.prototype.parse_cmd_try = function() {
10118 var node = Node(NODE_TRY);
10119 node.pos = this.ea.cmdpos;
10120 node.body = [];
10121 node.ea = this.ea;
10122 node.catch = [];
10123 node._finally = NIL;
10124 node.endtry = NIL;
10125 this.add_node(node);
10126 this.push_context(node);
10127}
10128
10129VimLParser.prototype.parse_cmd_catch = function() {
10130 if (this.context[0].type == NODE_FINALLY) {
10131 throw Err("E604: :catch after :finally", this.ea.cmdpos);
10132 }
10133 else if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
10134 throw Err("E603: :catch without :try", this.ea.cmdpos);
10135 }
10136 if (this.context[0].type != NODE_TRY) {
10137 this.pop_context();
10138 }
10139 var node = Node(NODE_CATCH);
10140 node.pos = this.ea.cmdpos;
10141 node.body = [];
10142 node.ea = this.ea;
10143 node.pattern = NIL;
10144 this.reader.skip_white();
10145 if (!this.ends_excmds(this.reader.peek())) {
10146 var __tmp = this.parse_pattern(this.reader.get());
10147 node.pattern = __tmp[0];
10148 var _ = __tmp[1];
10149 }
10150 viml_add(this.context[0].catch, node);
10151 this.push_context(node);
10152}
10153
10154VimLParser.prototype.parse_cmd_finally = function() {
10155 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
10156 throw Err("E606: :finally without :try", this.ea.cmdpos);
10157 }
10158 if (this.context[0].type != NODE_TRY) {
10159 this.pop_context();
10160 }
10161 var node = Node(NODE_FINALLY);
10162 node.pos = this.ea.cmdpos;
10163 node.body = [];
10164 node.ea = this.ea;
10165 this.context[0]._finally = node;
10166 this.push_context(node);
10167}
10168
10169VimLParser.prototype.parse_cmd_endtry = function() {
10170 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH && this.context[0].type != NODE_FINALLY) {
10171 throw Err("E602: :endtry without :try", this.ea.cmdpos);
10172 }
10173 if (this.context[0].type != NODE_TRY) {
10174 this.pop_context();
10175 }
10176 var node = Node(NODE_ENDTRY);
10177 node.pos = this.ea.cmdpos;
10178 node.ea = this.ea;
10179 this.context[0].endtry = node;
10180 this.pop_context();
10181}
10182
10183VimLParser.prototype.parse_cmd_throw = function() {
10184 var node = Node(NODE_THROW);
10185 node.pos = this.ea.cmdpos;
10186 node.ea = this.ea;
10187 node.left = this.parse_expr();
10188 this.add_node(node);
10189}
10190
10191VimLParser.prototype.parse_cmd_eval = function() {
10192 var node = Node(NODE_EVAL);
10193 node.pos = this.ea.cmdpos;
10194 node.ea = this.ea;
10195 node.left = this.parse_expr();
10196 this.add_node(node);
10197}
10198
10199VimLParser.prototype.parse_cmd_echo = function() {
10200 var node = Node(NODE_ECHO);
10201 node.pos = this.ea.cmdpos;
10202 node.ea = this.ea;
10203 node.list = this.parse_exprlist();
10204 this.add_node(node);
10205}
10206
10207VimLParser.prototype.parse_cmd_echon = function() {
10208 var node = Node(NODE_ECHON);
10209 node.pos = this.ea.cmdpos;
10210 node.ea = this.ea;
10211 node.list = this.parse_exprlist();
10212 this.add_node(node);
10213}
10214
10215VimLParser.prototype.parse_cmd_echohl = function() {
10216 var node = Node(NODE_ECHOHL);
10217 node.pos = this.ea.cmdpos;
10218 node.ea = this.ea;
10219 node.str = "";
10220 while (!this.ends_excmds(this.reader.peek())) {
10221 node.str += this.reader.get();
10222 }
10223 this.add_node(node);
10224}
10225
10226VimLParser.prototype.parse_cmd_echomsg = function() {
10227 var node = Node(NODE_ECHOMSG);
10228 node.pos = this.ea.cmdpos;
10229 node.ea = this.ea;
10230 node.list = this.parse_exprlist();
10231 this.add_node(node);
10232}
10233
10234VimLParser.prototype.parse_cmd_echoerr = function() {
10235 var node = Node(NODE_ECHOERR);
10236 node.pos = this.ea.cmdpos;
10237 node.ea = this.ea;
10238 node.list = this.parse_exprlist();
10239 this.add_node(node);
10240}
10241
10242VimLParser.prototype.parse_cmd_execute = function() {
10243 var node = Node(NODE_EXECUTE);
10244 node.pos = this.ea.cmdpos;
10245 node.ea = this.ea;
10246 node.list = this.parse_exprlist();
10247 this.add_node(node);
10248}
10249
10250VimLParser.prototype.parse_expr = function() {
10251 return new ExprParser(this.reader).parse();
10252}
10253
10254VimLParser.prototype.parse_exprlist = function() {
10255 var list = [];
10256 while (TRUE) {
10257 this.reader.skip_white();
10258 var c = this.reader.peek();
10259 if (c != "\"" && this.ends_excmds(c)) {
10260 break;
10261 }
10262 var node = this.parse_expr();
10263 viml_add(list, node);
10264 }
10265 return list;
10266}
10267
10268VimLParser.prototype.parse_lvalue_func = function() {
10269 var p = new LvalueParser(this.reader);
10270 var node = p.parse();
10271 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) {
10272 return node;
10273 }
10274 throw Err("Invalid Expression", node.pos);
10275}
10276
10277// FIXME:
10278VimLParser.prototype.parse_lvalue = function() {
10279 var p = new LvalueParser(this.reader);
10280 var node = p.parse();
10281 if (node.type == NODE_IDENTIFIER) {
10282 if (!isvarname(node.value)) {
10283 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
10284 }
10285 }
10286 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) {
10287 return node;
10288 }
10289 throw Err("Invalid Expression", node.pos);
10290}
10291
10292// TODO: merge with s:VimLParser.parse_lvalue()
10293VimLParser.prototype.parse_constlvalue = function() {
10294 var p = new LvalueParser(this.reader);
10295 var node = p.parse();
10296 if (node.type == NODE_IDENTIFIER) {
10297 if (!isvarname(node.value)) {
10298 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
10299 }
10300 }
10301 if (node.type == NODE_IDENTIFIER || node.type == NODE_CURLYNAME) {
10302 return node;
10303 }
10304 else if (node.type == NODE_SUBSCRIPT || node.type == NODE_SLICE || node.type == NODE_DOT) {
10305 throw Err("E996: Cannot lock a list or dict", node.pos);
10306 }
10307 else if (node.type == NODE_OPTION) {
10308 throw Err("E996: Cannot lock an option", node.pos);
10309 }
10310 else if (node.type == NODE_ENV) {
10311 throw Err("E996: Cannot lock an environment variable", node.pos);
10312 }
10313 else if (node.type == NODE_REG) {
10314 throw Err("E996: Cannot lock a register", node.pos);
10315 }
10316 throw Err("Invalid Expression", node.pos);
10317}
10318
10319VimLParser.prototype.parse_lvaluelist = function() {
10320 var list = [];
10321 var node = this.parse_expr();
10322 viml_add(list, node);
10323 while (TRUE) {
10324 this.reader.skip_white();
10325 if (this.ends_excmds(this.reader.peek())) {
10326 break;
10327 }
10328 var node = this.parse_lvalue();
10329 viml_add(list, node);
10330 }
10331 return list;
10332}
10333
10334// FIXME:
10335VimLParser.prototype.parse_letlhs = function() {
10336 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
10337 var tokenizer = new ExprTokenizer(this.reader);
10338 if (tokenizer.peek().type == TOKEN_SQOPEN) {
10339 tokenizer.get();
10340 lhs.list = [];
10341 while (TRUE) {
10342 var node = this.parse_lvalue();
10343 viml_add(lhs.list, node);
10344 var token = tokenizer.get();
10345 if (token.type == TOKEN_SQCLOSE) {
10346 break;
10347 }
10348 else if (token.type == TOKEN_COMMA) {
10349 continue;
10350 }
10351 else if (token.type == TOKEN_SEMICOLON) {
10352 var node = this.parse_lvalue();
10353 lhs.rest = node;
10354 var token = tokenizer.get();
10355 if (token.type == TOKEN_SQCLOSE) {
10356 break;
10357 }
10358 else {
10359 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
10360 }
10361 }
10362 else {
10363 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
10364 }
10365 }
10366 }
10367 else {
10368 lhs.left = this.parse_lvalue();
10369 }
10370 return lhs;
10371}
10372
10373// TODO: merge with s:VimLParser.parse_letlhs() ?
10374VimLParser.prototype.parse_constlhs = function() {
10375 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
10376 var tokenizer = new ExprTokenizer(this.reader);
10377 if (tokenizer.peek().type == TOKEN_SQOPEN) {
10378 tokenizer.get();
10379 lhs.list = [];
10380 while (TRUE) {
10381 var node = this.parse_lvalue();
10382 viml_add(lhs.list, node);
10383 var token = tokenizer.get();
10384 if (token.type == TOKEN_SQCLOSE) {
10385 break;
10386 }
10387 else if (token.type == TOKEN_COMMA) {
10388 continue;
10389 }
10390 else if (token.type == TOKEN_SEMICOLON) {
10391 var node = this.parse_lvalue();
10392 lhs.rest = node;
10393 var token = tokenizer.get();
10394 if (token.type == TOKEN_SQCLOSE) {
10395 break;
10396 }
10397 else {
10398 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
10399 }
10400 }
10401 else {
10402 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
10403 }
10404 }
10405 }
10406 else {
10407 lhs.left = this.parse_constlvalue();
10408 }
10409 return lhs;
10410}
10411
10412VimLParser.prototype.ends_excmds = function(c) {
10413 return c == "" || c == "|" || c == "\"" || c == "<EOF>" || c == "<EOL>";
10414}
10415
10416// FIXME: validate argument
10417VimLParser.prototype.parse_wincmd = function() {
10418 var c = this.reader.getn(1);
10419 if (c == "") {
10420 throw Err("E471: Argument required", this.reader.getpos());
10421 }
10422 else if (c == "g" || c == "\x07") {
10423 // <C-G>
10424 var c2 = this.reader.getn(1);
10425 if (c2 == "" || iswhite(c2)) {
10426 throw Err("E474: Invalid Argument", this.reader.getpos());
10427 }
10428 }
10429 var end = this.reader.getpos();
10430 this.reader.skip_white();
10431 if (!this.ends_excmds(this.reader.peek())) {
10432 throw Err("E474: Invalid Argument", this.reader.getpos());
10433 }
10434 var node = Node(NODE_EXCMD);
10435 node.pos = this.ea.cmdpos;
10436 node.ea = this.ea;
10437 node.str = this.reader.getstr(this.ea.linepos, end);
10438 this.add_node(node);
10439}
10440
10441// FIXME: validate argument
10442VimLParser.prototype.parse_cmd_syntax = function() {
10443 var end = this.reader.getpos();
10444 while (TRUE) {
10445 var end = this.reader.getpos();
10446 var c = this.reader.peek();
10447 if (c == "/" || c == "'" || c == "\"") {
10448 this.reader.getn(1);
10449 this.parse_pattern(c);
10450 }
10451 else if (c == "=") {
10452 this.reader.getn(1);
10453 this.parse_pattern(" ");
10454 }
10455 else if (this.ends_excmds(c)) {
10456 break;
10457 }
10458 this.reader.getn(1);
10459 }
10460 var node = Node(NODE_EXCMD);
10461 node.pos = this.ea.cmdpos;
10462 node.ea = this.ea;
10463 node.str = this.reader.getstr(this.ea.linepos, end);
10464 this.add_node(node);
10465}
10466
10467VimLParser.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"}];
10468VimLParser.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"}];
10469// To find new builtin_commands, run the below script.
10470// $ scripts/update_builtin_commands.sh /path/to/vim/src/ex_cmds.h
10471VimLParser.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"}];
10472// To find new builtin_functions, run the below script.
10473// $ scripts/update_builtin_functions.sh /path/to/vim/src/evalfunc.c
10474VimLParser.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"}];
10475function ExprTokenizer() { this.__init__.apply(this, arguments); }
10476ExprTokenizer.prototype.__init__ = function(reader) {
10477 this.reader = reader;
10478 this.cache = {};
10479}
10480
10481ExprTokenizer.prototype.token = function(type, value, pos) {
10482 return {"type":type, "value":value, "pos":pos};
10483}
10484
10485ExprTokenizer.prototype.peek = function() {
10486 var pos = this.reader.tell();
10487 var r = this.get();
10488 this.reader.seek_set(pos);
10489 return r;
10490}
10491
10492ExprTokenizer.prototype.get = function() {
10493 // FIXME: remove dirty hack
10494 if (viml_has_key(this.cache, this.reader.tell())) {
10495 var x = this.cache[this.reader.tell()];
10496 this.reader.seek_set(x[0]);
10497 return x[1];
10498 }
10499 var pos = this.reader.tell();
10500 this.reader.skip_white();
10501 var r = this.get2();
10502 this.cache[pos] = [this.reader.tell(), r];
10503 return r;
10504}
10505
10506ExprTokenizer.prototype.get2 = function() {
10507 var r = this.reader;
10508 var pos = r.getpos();
10509 var c = r.peek();
10510 if (c == "<EOF>") {
10511 return this.token(TOKEN_EOF, c, pos);
10512 }
10513 else if (c == "<EOL>") {
10514 r.seek_cur(1);
10515 return this.token(TOKEN_EOL, c, pos);
10516 }
10517 else if (iswhite(c)) {
10518 var s = r.read_white();
10519 return this.token(TOKEN_SPACE, s, pos);
10520 }
10521 else if (c == "0" && (r.p(1) == "X" || r.p(1) == "x") && isxdigit(r.p(2))) {
10522 var s = r.getn(3);
10523 s += r.read_xdigit();
10524 return this.token(TOKEN_NUMBER, s, pos);
10525 }
10526 else if (c == "0" && (r.p(1) == "B" || r.p(1) == "b") && (r.p(2) == "0" || r.p(2) == "1")) {
10527 var s = r.getn(3);
10528 s += r.read_bdigit();
10529 return this.token(TOKEN_NUMBER, s, pos);
10530 }
10531 else if (c == "0" && (r.p(1) == "Z" || r.p(1) == "z") && r.p(2) != ".") {
10532 var s = r.getn(2);
10533 s += r.read_blob();
10534 return this.token(TOKEN_BLOB, s, pos);
10535 }
10536 else if (isdigit(c)) {
10537 var s = r.read_digit();
10538 if (r.p(0) == "." && isdigit(r.p(1))) {
10539 s += r.getn(1);
10540 s += r.read_digit();
10541 if ((r.p(0) == "E" || r.p(0) == "e") && (isdigit(r.p(1)) || (r.p(1) == "-" || r.p(1) == "+") && isdigit(r.p(2)))) {
10542 s += r.getn(2);
10543 s += r.read_digit();
10544 }
10545 }
10546 return this.token(TOKEN_NUMBER, s, pos);
10547 }
10548 else if (c == "i" && r.p(1) == "s" && !isidc(r.p(2))) {
10549 if (r.p(2) == "?") {
10550 r.seek_cur(3);
10551 return this.token(TOKEN_ISCI, "is?", pos);
10552 }
10553 else if (r.p(2) == "#") {
10554 r.seek_cur(3);
10555 return this.token(TOKEN_ISCS, "is#", pos);
10556 }
10557 else {
10558 r.seek_cur(2);
10559 return this.token(TOKEN_IS, "is", pos);
10560 }
10561 }
10562 else if (c == "i" && r.p(1) == "s" && r.p(2) == "n" && r.p(3) == "o" && r.p(4) == "t" && !isidc(r.p(5))) {
10563 if (r.p(5) == "?") {
10564 r.seek_cur(6);
10565 return this.token(TOKEN_ISNOTCI, "isnot?", pos);
10566 }
10567 else if (r.p(5) == "#") {
10568 r.seek_cur(6);
10569 return this.token(TOKEN_ISNOTCS, "isnot#", pos);
10570 }
10571 else {
10572 r.seek_cur(5);
10573 return this.token(TOKEN_ISNOT, "isnot", pos);
10574 }
10575 }
10576 else if (isnamec1(c)) {
10577 var s = r.read_name();
10578 return this.token(TOKEN_IDENTIFIER, s, pos);
10579 }
10580 else if (c == "|" && r.p(1) == "|") {
10581 r.seek_cur(2);
10582 return this.token(TOKEN_OROR, "||", pos);
10583 }
10584 else if (c == "&" && r.p(1) == "&") {
10585 r.seek_cur(2);
10586 return this.token(TOKEN_ANDAND, "&&", pos);
10587 }
10588 else if (c == "=" && r.p(1) == "=") {
10589 if (r.p(2) == "?") {
10590 r.seek_cur(3);
10591 return this.token(TOKEN_EQEQCI, "==?", pos);
10592 }
10593 else if (r.p(2) == "#") {
10594 r.seek_cur(3);
10595 return this.token(TOKEN_EQEQCS, "==#", pos);
10596 }
10597 else {
10598 r.seek_cur(2);
10599 return this.token(TOKEN_EQEQ, "==", pos);
10600 }
10601 }
10602 else if (c == "!" && r.p(1) == "=") {
10603 if (r.p(2) == "?") {
10604 r.seek_cur(3);
10605 return this.token(TOKEN_NEQCI, "!=?", pos);
10606 }
10607 else if (r.p(2) == "#") {
10608 r.seek_cur(3);
10609 return this.token(TOKEN_NEQCS, "!=#", pos);
10610 }
10611 else {
10612 r.seek_cur(2);
10613 return this.token(TOKEN_NEQ, "!=", pos);
10614 }
10615 }
10616 else if (c == ">" && r.p(1) == "=") {
10617 if (r.p(2) == "?") {
10618 r.seek_cur(3);
10619 return this.token(TOKEN_GTEQCI, ">=?", pos);
10620 }
10621 else if (r.p(2) == "#") {
10622 r.seek_cur(3);
10623 return this.token(TOKEN_GTEQCS, ">=#", pos);
10624 }
10625 else {
10626 r.seek_cur(2);
10627 return this.token(TOKEN_GTEQ, ">=", pos);
10628 }
10629 }
10630 else if (c == "<" && r.p(1) == "=") {
10631 if (r.p(2) == "?") {
10632 r.seek_cur(3);
10633 return this.token(TOKEN_LTEQCI, "<=?", pos);
10634 }
10635 else if (r.p(2) == "#") {
10636 r.seek_cur(3);
10637 return this.token(TOKEN_LTEQCS, "<=#", pos);
10638 }
10639 else {
10640 r.seek_cur(2);
10641 return this.token(TOKEN_LTEQ, "<=", pos);
10642 }
10643 }
10644 else if (c == "=" && r.p(1) == "~") {
10645 if (r.p(2) == "?") {
10646 r.seek_cur(3);
10647 return this.token(TOKEN_MATCHCI, "=~?", pos);
10648 }
10649 else if (r.p(2) == "#") {
10650 r.seek_cur(3);
10651 return this.token(TOKEN_MATCHCS, "=~#", pos);
10652 }
10653 else {
10654 r.seek_cur(2);
10655 return this.token(TOKEN_MATCH, "=~", pos);
10656 }
10657 }
10658 else if (c == "!" && r.p(1) == "~") {
10659 if (r.p(2) == "?") {
10660 r.seek_cur(3);
10661 return this.token(TOKEN_NOMATCHCI, "!~?", pos);
10662 }
10663 else if (r.p(2) == "#") {
10664 r.seek_cur(3);
10665 return this.token(TOKEN_NOMATCHCS, "!~#", pos);
10666 }
10667 else {
10668 r.seek_cur(2);
10669 return this.token(TOKEN_NOMATCH, "!~", pos);
10670 }
10671 }
10672 else if (c == ">") {
10673 if (r.p(1) == "?") {
10674 r.seek_cur(2);
10675 return this.token(TOKEN_GTCI, ">?", pos);
10676 }
10677 else if (r.p(1) == "#") {
10678 r.seek_cur(2);
10679 return this.token(TOKEN_GTCS, ">#", pos);
10680 }
10681 else {
10682 r.seek_cur(1);
10683 return this.token(TOKEN_GT, ">", pos);
10684 }
10685 }
10686 else if (c == "<") {
10687 if (r.p(1) == "?") {
10688 r.seek_cur(2);
10689 return this.token(TOKEN_LTCI, "<?", pos);
10690 }
10691 else if (r.p(1) == "#") {
10692 r.seek_cur(2);
10693 return this.token(TOKEN_LTCS, "<#", pos);
10694 }
10695 else {
10696 r.seek_cur(1);
10697 return this.token(TOKEN_LT, "<", pos);
10698 }
10699 }
10700 else if (c == "+") {
10701 r.seek_cur(1);
10702 return this.token(TOKEN_PLUS, "+", pos);
10703 }
10704 else if (c == "-") {
10705 if (r.p(1) == ">") {
10706 r.seek_cur(2);
10707 return this.token(TOKEN_ARROW, "->", pos);
10708 }
10709 else {
10710 r.seek_cur(1);
10711 return this.token(TOKEN_MINUS, "-", pos);
10712 }
10713 }
10714 else if (c == ".") {
10715 if (r.p(1) == "." && r.p(2) == ".") {
10716 r.seek_cur(3);
10717 return this.token(TOKEN_DOTDOTDOT, "...", pos);
10718 }
10719 else if (r.p(1) == ".") {
10720 r.seek_cur(2);
10721 return this.token(TOKEN_DOTDOT, "..", pos);
10722 // TODO check scriptversion?
10723 }
10724 else {
10725 r.seek_cur(1);
10726 return this.token(TOKEN_DOT, ".", pos);
10727 // TODO check scriptversion?
10728 }
10729 }
10730 else if (c == "*") {
10731 r.seek_cur(1);
10732 return this.token(TOKEN_STAR, "*", pos);
10733 }
10734 else if (c == "/") {
10735 r.seek_cur(1);
10736 return this.token(TOKEN_SLASH, "/", pos);
10737 }
10738 else if (c == "%") {
10739 r.seek_cur(1);
10740 return this.token(TOKEN_PERCENT, "%", pos);
10741 }
10742 else if (c == "!") {
10743 r.seek_cur(1);
10744 return this.token(TOKEN_NOT, "!", pos);
10745 }
10746 else if (c == "?") {
10747 r.seek_cur(1);
10748 return this.token(TOKEN_QUESTION, "?", pos);
10749 }
10750 else if (c == ":") {
10751 r.seek_cur(1);
10752 return this.token(TOKEN_COLON, ":", pos);
10753 }
10754 else if (c == "#") {
10755 if (r.p(1) == "{") {
10756 r.seek_cur(2);
10757 return this.token(TOKEN_LITCOPEN, "#{", pos);
10758 }
10759 else {
10760 r.seek_cur(1);
10761 return this.token(TOKEN_SHARP, "#", pos);
10762 }
10763 }
10764 else if (c == "(") {
10765 r.seek_cur(1);
10766 return this.token(TOKEN_POPEN, "(", pos);
10767 }
10768 else if (c == ")") {
10769 r.seek_cur(1);
10770 return this.token(TOKEN_PCLOSE, ")", pos);
10771 }
10772 else if (c == "[") {
10773 r.seek_cur(1);
10774 return this.token(TOKEN_SQOPEN, "[", pos);
10775 }
10776 else if (c == "]") {
10777 r.seek_cur(1);
10778 return this.token(TOKEN_SQCLOSE, "]", pos);
10779 }
10780 else if (c == "{") {
10781 r.seek_cur(1);
10782 return this.token(TOKEN_COPEN, "{", pos);
10783 }
10784 else if (c == "}") {
10785 r.seek_cur(1);
10786 return this.token(TOKEN_CCLOSE, "}", pos);
10787 }
10788 else if (c == ",") {
10789 r.seek_cur(1);
10790 return this.token(TOKEN_COMMA, ",", pos);
10791 }
10792 else if (c == "'") {
10793 r.seek_cur(1);
10794 return this.token(TOKEN_SQUOTE, "'", pos);
10795 }
10796 else if (c == "\"") {
10797 r.seek_cur(1);
10798 return this.token(TOKEN_DQUOTE, "\"", pos);
10799 }
10800 else if (c == "$") {
10801 var s = r.getn(1);
10802 s += r.read_word();
10803 return this.token(TOKEN_ENV, s, pos);
10804 }
10805 else if (c == "@") {
10806 // @<EOL> is treated as @"
10807 return this.token(TOKEN_REG, r.getn(2), pos);
10808 }
10809 else if (c == "&") {
10810 var s = "";
10811 if ((r.p(1) == "g" || r.p(1) == "l") && r.p(2) == ":") {
10812 var s = r.getn(3) + r.read_word();
10813 }
10814 else {
10815 var s = r.getn(1) + r.read_word();
10816 }
10817 return this.token(TOKEN_OPTION, s, pos);
10818 }
10819 else if (c == "=") {
10820 r.seek_cur(1);
10821 return this.token(TOKEN_EQ, "=", pos);
10822 }
10823 else if (c == "|") {
10824 r.seek_cur(1);
10825 return this.token(TOKEN_OR, "|", pos);
10826 }
10827 else if (c == ";") {
10828 r.seek_cur(1);
10829 return this.token(TOKEN_SEMICOLON, ";", pos);
10830 }
10831 else if (c == "`") {
10832 r.seek_cur(1);
10833 return this.token(TOKEN_BACKTICK, "`", pos);
10834 }
10835 else {
10836 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
10837 }
10838}
10839
10840ExprTokenizer.prototype.get_sstring = function() {
10841 this.reader.skip_white();
10842 var c = this.reader.p(0);
10843 if (c != "'") {
10844 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
10845 }
10846 this.reader.seek_cur(1);
10847 var s = "";
10848 while (TRUE) {
10849 var c = this.reader.p(0);
10850 if (c == "<EOF>" || c == "<EOL>") {
10851 throw Err("unexpected EOL", this.reader.getpos());
10852 }
10853 else if (c == "'") {
10854 this.reader.seek_cur(1);
10855 if (this.reader.p(0) == "'") {
10856 this.reader.seek_cur(1);
10857 s += "''";
10858 }
10859 else {
10860 break;
10861 }
10862 }
10863 else {
10864 this.reader.seek_cur(1);
10865 s += c;
10866 }
10867 }
10868 return s;
10869}
10870
10871ExprTokenizer.prototype.get_dstring = function() {
10872 this.reader.skip_white();
10873 var c = this.reader.p(0);
10874 if (c != "\"") {
10875 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
10876 }
10877 this.reader.seek_cur(1);
10878 var s = "";
10879 while (TRUE) {
10880 var c = this.reader.p(0);
10881 if (c == "<EOF>" || c == "<EOL>") {
10882 throw Err("unexpectd EOL", this.reader.getpos());
10883 }
10884 else if (c == "\"") {
10885 this.reader.seek_cur(1);
10886 break;
10887 }
10888 else if (c == "\\") {
10889 this.reader.seek_cur(1);
10890 s += c;
10891 var c = this.reader.p(0);
10892 if (c == "<EOF>" || c == "<EOL>") {
10893 throw Err("ExprTokenizer: unexpected EOL", this.reader.getpos());
10894 }
10895 this.reader.seek_cur(1);
10896 s += c;
10897 }
10898 else {
10899 this.reader.seek_cur(1);
10900 s += c;
10901 }
10902 }
10903 return s;
10904}
10905
10906ExprTokenizer.prototype.parse_dict_literal_key = function() {
10907 this.reader.skip_white();
10908 var c = this.reader.peek();
10909 if (!isalnum(c) && c != "_" && c != "-") {
10910 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
10911 }
10912 var node = Node(NODE_STRING);
10913 var s = c;
10914 this.reader.seek_cur(1);
10915 node.pos = this.reader.getpos();
10916 while (TRUE) {
10917 var c = this.reader.p(0);
10918 if (c == "<EOF>" || c == "<EOL>") {
10919 throw Err("unexpectd EOL", this.reader.getpos());
10920 }
10921 if (!isalnum(c) && c != "_" && c != "-") {
10922 break;
10923 }
10924 this.reader.seek_cur(1);
10925 s += c;
10926 }
10927 node.value = "'" + s + "'";
10928 return node;
10929}
10930
10931function ExprParser() { this.__init__.apply(this, arguments); }
10932ExprParser.prototype.__init__ = function(reader) {
10933 this.reader = reader;
10934 this.tokenizer = new ExprTokenizer(reader);
10935}
10936
10937ExprParser.prototype.parse = function() {
10938 return this.parse_expr1();
10939}
10940
10941// expr1: expr2 ? expr1 : expr1
10942ExprParser.prototype.parse_expr1 = function() {
10943 var left = this.parse_expr2();
10944 var pos = this.reader.tell();
10945 var token = this.tokenizer.get();
10946 if (token.type == TOKEN_QUESTION) {
10947 var node = Node(NODE_TERNARY);
10948 node.pos = token.pos;
10949 node.cond = left;
10950 node.left = this.parse_expr1();
10951 var token = this.tokenizer.get();
10952 if (token.type != TOKEN_COLON) {
10953 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10954 }
10955 node.right = this.parse_expr1();
10956 var left = node;
10957 }
10958 else {
10959 this.reader.seek_set(pos);
10960 }
10961 return left;
10962}
10963
10964// expr2: expr3 || expr3 ..
10965ExprParser.prototype.parse_expr2 = function() {
10966 var left = this.parse_expr3();
10967 while (TRUE) {
10968 var pos = this.reader.tell();
10969 var token = this.tokenizer.get();
10970 if (token.type == TOKEN_OROR) {
10971 var node = Node(NODE_OR);
10972 node.pos = token.pos;
10973 node.left = left;
10974 node.right = this.parse_expr3();
10975 var left = node;
10976 }
10977 else {
10978 this.reader.seek_set(pos);
10979 break;
10980 }
10981 }
10982 return left;
10983}
10984
10985// expr3: expr4 && expr4
10986ExprParser.prototype.parse_expr3 = function() {
10987 var left = this.parse_expr4();
10988 while (TRUE) {
10989 var pos = this.reader.tell();
10990 var token = this.tokenizer.get();
10991 if (token.type == TOKEN_ANDAND) {
10992 var node = Node(NODE_AND);
10993 node.pos = token.pos;
10994 node.left = left;
10995 node.right = this.parse_expr4();
10996 var left = node;
10997 }
10998 else {
10999 this.reader.seek_set(pos);
11000 break;
11001 }
11002 }
11003 return left;
11004}
11005
11006// expr4: expr5 == expr5
11007// expr5 != expr5
11008// expr5 > expr5
11009// expr5 >= expr5
11010// expr5 < expr5
11011// expr5 <= expr5
11012// expr5 =~ expr5
11013// expr5 !~ expr5
11014//
11015// expr5 ==? expr5
11016// expr5 ==# expr5
11017// etc.
11018//
11019// expr5 is expr5
11020// expr5 isnot expr5
11021ExprParser.prototype.parse_expr4 = function() {
11022 var left = this.parse_expr5();
11023 var pos = this.reader.tell();
11024 var token = this.tokenizer.get();
11025 if (token.type == TOKEN_EQEQ) {
11026 var node = Node(NODE_EQUAL);
11027 node.pos = token.pos;
11028 node.left = left;
11029 node.right = this.parse_expr5();
11030 var left = node;
11031 }
11032 else if (token.type == TOKEN_EQEQCI) {
11033 var node = Node(NODE_EQUALCI);
11034 node.pos = token.pos;
11035 node.left = left;
11036 node.right = this.parse_expr5();
11037 var left = node;
11038 }
11039 else if (token.type == TOKEN_EQEQCS) {
11040 var node = Node(NODE_EQUALCS);
11041 node.pos = token.pos;
11042 node.left = left;
11043 node.right = this.parse_expr5();
11044 var left = node;
11045 }
11046 else if (token.type == TOKEN_NEQ) {
11047 var node = Node(NODE_NEQUAL);
11048 node.pos = token.pos;
11049 node.left = left;
11050 node.right = this.parse_expr5();
11051 var left = node;
11052 }
11053 else if (token.type == TOKEN_NEQCI) {
11054 var node = Node(NODE_NEQUALCI);
11055 node.pos = token.pos;
11056 node.left = left;
11057 node.right = this.parse_expr5();
11058 var left = node;
11059 }
11060 else if (token.type == TOKEN_NEQCS) {
11061 var node = Node(NODE_NEQUALCS);
11062 node.pos = token.pos;
11063 node.left = left;
11064 node.right = this.parse_expr5();
11065 var left = node;
11066 }
11067 else if (token.type == TOKEN_GT) {
11068 var node = Node(NODE_GREATER);
11069 node.pos = token.pos;
11070 node.left = left;
11071 node.right = this.parse_expr5();
11072 var left = node;
11073 }
11074 else if (token.type == TOKEN_GTCI) {
11075 var node = Node(NODE_GREATERCI);
11076 node.pos = token.pos;
11077 node.left = left;
11078 node.right = this.parse_expr5();
11079 var left = node;
11080 }
11081 else if (token.type == TOKEN_GTCS) {
11082 var node = Node(NODE_GREATERCS);
11083 node.pos = token.pos;
11084 node.left = left;
11085 node.right = this.parse_expr5();
11086 var left = node;
11087 }
11088 else if (token.type == TOKEN_GTEQ) {
11089 var node = Node(NODE_GEQUAL);
11090 node.pos = token.pos;
11091 node.left = left;
11092 node.right = this.parse_expr5();
11093 var left = node;
11094 }
11095 else if (token.type == TOKEN_GTEQCI) {
11096 var node = Node(NODE_GEQUALCI);
11097 node.pos = token.pos;
11098 node.left = left;
11099 node.right = this.parse_expr5();
11100 var left = node;
11101 }
11102 else if (token.type == TOKEN_GTEQCS) {
11103 var node = Node(NODE_GEQUALCS);
11104 node.pos = token.pos;
11105 node.left = left;
11106 node.right = this.parse_expr5();
11107 var left = node;
11108 }
11109 else if (token.type == TOKEN_LT) {
11110 var node = Node(NODE_SMALLER);
11111 node.pos = token.pos;
11112 node.left = left;
11113 node.right = this.parse_expr5();
11114 var left = node;
11115 }
11116 else if (token.type == TOKEN_LTCI) {
11117 var node = Node(NODE_SMALLERCI);
11118 node.pos = token.pos;
11119 node.left = left;
11120 node.right = this.parse_expr5();
11121 var left = node;
11122 }
11123 else if (token.type == TOKEN_LTCS) {
11124 var node = Node(NODE_SMALLERCS);
11125 node.pos = token.pos;
11126 node.left = left;
11127 node.right = this.parse_expr5();
11128 var left = node;
11129 }
11130 else if (token.type == TOKEN_LTEQ) {
11131 var node = Node(NODE_SEQUAL);
11132 node.pos = token.pos;
11133 node.left = left;
11134 node.right = this.parse_expr5();
11135 var left = node;
11136 }
11137 else if (token.type == TOKEN_LTEQCI) {
11138 var node = Node(NODE_SEQUALCI);
11139 node.pos = token.pos;
11140 node.left = left;
11141 node.right = this.parse_expr5();
11142 var left = node;
11143 }
11144 else if (token.type == TOKEN_LTEQCS) {
11145 var node = Node(NODE_SEQUALCS);
11146 node.pos = token.pos;
11147 node.left = left;
11148 node.right = this.parse_expr5();
11149 var left = node;
11150 }
11151 else if (token.type == TOKEN_MATCH) {
11152 var node = Node(NODE_MATCH);
11153 node.pos = token.pos;
11154 node.left = left;
11155 node.right = this.parse_expr5();
11156 var left = node;
11157 }
11158 else if (token.type == TOKEN_MATCHCI) {
11159 var node = Node(NODE_MATCHCI);
11160 node.pos = token.pos;
11161 node.left = left;
11162 node.right = this.parse_expr5();
11163 var left = node;
11164 }
11165 else if (token.type == TOKEN_MATCHCS) {
11166 var node = Node(NODE_MATCHCS);
11167 node.pos = token.pos;
11168 node.left = left;
11169 node.right = this.parse_expr5();
11170 var left = node;
11171 }
11172 else if (token.type == TOKEN_NOMATCH) {
11173 var node = Node(NODE_NOMATCH);
11174 node.pos = token.pos;
11175 node.left = left;
11176 node.right = this.parse_expr5();
11177 var left = node;
11178 }
11179 else if (token.type == TOKEN_NOMATCHCI) {
11180 var node = Node(NODE_NOMATCHCI);
11181 node.pos = token.pos;
11182 node.left = left;
11183 node.right = this.parse_expr5();
11184 var left = node;
11185 }
11186 else if (token.type == TOKEN_NOMATCHCS) {
11187 var node = Node(NODE_NOMATCHCS);
11188 node.pos = token.pos;
11189 node.left = left;
11190 node.right = this.parse_expr5();
11191 var left = node;
11192 }
11193 else if (token.type == TOKEN_IS) {
11194 var node = Node(NODE_IS);
11195 node.pos = token.pos;
11196 node.left = left;
11197 node.right = this.parse_expr5();
11198 var left = node;
11199 }
11200 else if (token.type == TOKEN_ISCI) {
11201 var node = Node(NODE_ISCI);
11202 node.pos = token.pos;
11203 node.left = left;
11204 node.right = this.parse_expr5();
11205 var left = node;
11206 }
11207 else if (token.type == TOKEN_ISCS) {
11208 var node = Node(NODE_ISCS);
11209 node.pos = token.pos;
11210 node.left = left;
11211 node.right = this.parse_expr5();
11212 var left = node;
11213 }
11214 else if (token.type == TOKEN_ISNOT) {
11215 var node = Node(NODE_ISNOT);
11216 node.pos = token.pos;
11217 node.left = left;
11218 node.right = this.parse_expr5();
11219 var left = node;
11220 }
11221 else if (token.type == TOKEN_ISNOTCI) {
11222 var node = Node(NODE_ISNOTCI);
11223 node.pos = token.pos;
11224 node.left = left;
11225 node.right = this.parse_expr5();
11226 var left = node;
11227 }
11228 else if (token.type == TOKEN_ISNOTCS) {
11229 var node = Node(NODE_ISNOTCS);
11230 node.pos = token.pos;
11231 node.left = left;
11232 node.right = this.parse_expr5();
11233 var left = node;
11234 }
11235 else {
11236 this.reader.seek_set(pos);
11237 }
11238 return left;
11239}
11240
11241// expr5: expr6 + expr6 ..
11242// expr6 - expr6 ..
11243// expr6 . expr6 ..
11244// expr6 .. expr6 ..
11245ExprParser.prototype.parse_expr5 = function() {
11246 var left = this.parse_expr6();
11247 while (TRUE) {
11248 var pos = this.reader.tell();
11249 var token = this.tokenizer.get();
11250 if (token.type == TOKEN_PLUS) {
11251 var node = Node(NODE_ADD);
11252 node.pos = token.pos;
11253 node.left = left;
11254 node.right = this.parse_expr6();
11255 var left = node;
11256 }
11257 else if (token.type == TOKEN_MINUS) {
11258 var node = Node(NODE_SUBTRACT);
11259 node.pos = token.pos;
11260 node.left = left;
11261 node.right = this.parse_expr6();
11262 var left = node;
11263 }
11264 else if (token.type == TOKEN_DOTDOT) {
11265 // TODO check scriptversion?
11266 var node = Node(NODE_CONCAT);
11267 node.pos = token.pos;
11268 node.left = left;
11269 node.right = this.parse_expr6();
11270 var left = node;
11271 }
11272 else if (token.type == TOKEN_DOT) {
11273 // TODO check scriptversion?
11274 var node = Node(NODE_CONCAT);
11275 node.pos = token.pos;
11276 node.left = left;
11277 node.right = this.parse_expr6();
11278 var left = node;
11279 }
11280 else {
11281 this.reader.seek_set(pos);
11282 break;
11283 }
11284 }
11285 return left;
11286}
11287
11288// expr6: expr7 * expr7 ..
11289// expr7 / expr7 ..
11290// expr7 % expr7 ..
11291ExprParser.prototype.parse_expr6 = function() {
11292 var left = this.parse_expr7();
11293 while (TRUE) {
11294 var pos = this.reader.tell();
11295 var token = this.tokenizer.get();
11296 if (token.type == TOKEN_STAR) {
11297 var node = Node(NODE_MULTIPLY);
11298 node.pos = token.pos;
11299 node.left = left;
11300 node.right = this.parse_expr7();
11301 var left = node;
11302 }
11303 else if (token.type == TOKEN_SLASH) {
11304 var node = Node(NODE_DIVIDE);
11305 node.pos = token.pos;
11306 node.left = left;
11307 node.right = this.parse_expr7();
11308 var left = node;
11309 }
11310 else if (token.type == TOKEN_PERCENT) {
11311 var node = Node(NODE_REMAINDER);
11312 node.pos = token.pos;
11313 node.left = left;
11314 node.right = this.parse_expr7();
11315 var left = node;
11316 }
11317 else {
11318 this.reader.seek_set(pos);
11319 break;
11320 }
11321 }
11322 return left;
11323}
11324
11325// expr7: ! expr7
11326// - expr7
11327// + expr7
11328ExprParser.prototype.parse_expr7 = function() {
11329 var pos = this.reader.tell();
11330 var token = this.tokenizer.get();
11331 if (token.type == TOKEN_NOT) {
11332 var node = Node(NODE_NOT);
11333 node.pos = token.pos;
11334 node.left = this.parse_expr7();
11335 return node;
11336 }
11337 else if (token.type == TOKEN_MINUS) {
11338 var node = Node(NODE_MINUS);
11339 node.pos = token.pos;
11340 node.left = this.parse_expr7();
11341 return node;
11342 }
11343 else if (token.type == TOKEN_PLUS) {
11344 var node = Node(NODE_PLUS);
11345 node.pos = token.pos;
11346 node.left = this.parse_expr7();
11347 return node;
11348 }
11349 else {
11350 this.reader.seek_set(pos);
11351 var node = this.parse_expr8();
11352 return node;
11353 }
11354}
11355
11356// expr8: expr8[expr1]
11357// expr8[expr1 : expr1]
11358// expr8.name
11359// expr8->name(expr1, ...)
11360// expr8->s:user_func(expr1, ...)
11361// expr8->{lambda}(expr1, ...)
11362// expr8(expr1, ...)
11363ExprParser.prototype.parse_expr8 = function() {
11364 var left = this.parse_expr9();
11365 while (TRUE) {
11366 var pos = this.reader.tell();
11367 var c = this.reader.peek();
11368 var token = this.tokenizer.get();
11369 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
11370 var npos = token.pos;
11371 if (this.tokenizer.peek().type == TOKEN_COLON) {
11372 this.tokenizer.get();
11373 var node = Node(NODE_SLICE);
11374 node.pos = npos;
11375 node.left = left;
11376 node.rlist = [NIL, NIL];
11377 var token = this.tokenizer.peek();
11378 if (token.type != TOKEN_SQCLOSE) {
11379 node.rlist[1] = this.parse_expr1();
11380 }
11381 var token = this.tokenizer.get();
11382 if (token.type != TOKEN_SQCLOSE) {
11383 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11384 }
11385 var left = node;
11386 }
11387 else {
11388 var right = this.parse_expr1();
11389 if (this.tokenizer.peek().type == TOKEN_COLON) {
11390 this.tokenizer.get();
11391 var node = Node(NODE_SLICE);
11392 node.pos = npos;
11393 node.left = left;
11394 node.rlist = [right, NIL];
11395 var token = this.tokenizer.peek();
11396 if (token.type != TOKEN_SQCLOSE) {
11397 node.rlist[1] = this.parse_expr1();
11398 }
11399 var token = this.tokenizer.get();
11400 if (token.type != TOKEN_SQCLOSE) {
11401 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11402 }
11403 var left = node;
11404 }
11405 else {
11406 var node = Node(NODE_SUBSCRIPT);
11407 node.pos = npos;
11408 node.left = left;
11409 node.right = right;
11410 var token = this.tokenizer.get();
11411 if (token.type != TOKEN_SQCLOSE) {
11412 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11413 }
11414 var left = node;
11415 }
11416 }
11417 delete node;
11418 }
11419 else if (token.type == TOKEN_ARROW) {
11420 var funcname_or_lambda = this.parse_expr9();
11421 var token = this.tokenizer.get();
11422 if (token.type != TOKEN_POPEN) {
11423 throw Err("E107: Missing parentheses: lambda", token.pos);
11424 }
11425 var right = Node(NODE_CALL);
11426 right.pos = token.pos;
11427 right.left = funcname_or_lambda;
11428 right.rlist = this.parse_rlist();
11429 var node = Node(NODE_METHOD);
11430 node.pos = token.pos;
11431 node.left = left;
11432 node.right = right;
11433 var left = node;
11434 delete node;
11435 }
11436 else if (token.type == TOKEN_POPEN) {
11437 var node = Node(NODE_CALL);
11438 node.pos = token.pos;
11439 node.left = left;
11440 node.rlist = this.parse_rlist();
11441 var left = node;
11442 delete node;
11443 }
11444 else if (!iswhite(c) && token.type == TOKEN_DOT) {
11445 // TODO check scriptversion?
11446 var node = this.parse_dot(token, left);
11447 if (node === NIL) {
11448 this.reader.seek_set(pos);
11449 break;
11450 }
11451 var left = node;
11452 delete node;
11453 }
11454 else {
11455 this.reader.seek_set(pos);
11456 break;
11457 }
11458 }
11459 return left;
11460}
11461
11462ExprParser.prototype.parse_rlist = function() {
11463 var rlist = [];
11464 var token = this.tokenizer.peek();
11465 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
11466 this.tokenizer.get();
11467 }
11468 else {
11469 while (TRUE) {
11470 viml_add(rlist, this.parse_expr1());
11471 var token = this.tokenizer.get();
11472 if (token.type == TOKEN_COMMA) {
11473 // XXX: Vim allows foo(a, b, ). Lint should warn it.
11474 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
11475 this.tokenizer.get();
11476 break;
11477 }
11478 }
11479 else if (token.type == TOKEN_PCLOSE) {
11480 break;
11481 }
11482 else {
11483 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11484 }
11485 }
11486 }
11487 if (viml_len(rlist) > MAX_FUNC_ARGS) {
11488 // TODO: funcname E740: Too many arguments for function: %s
11489 throw Err("E740: Too many arguments for function", token.pos);
11490 }
11491 return rlist;
11492}
11493
11494// expr9: number
11495// "string"
11496// 'string'
11497// [expr1, ...]
11498// {expr1: expr1, ...}
11499// #{literal_key1: expr1, ...}
11500// {args -> expr1}
11501// &option
11502// (expr1)
11503// variable
11504// var{ria}ble
11505// $VAR
11506// @r
11507// function(expr1, ...)
11508// func{ti}on(expr1, ...)
11509ExprParser.prototype.parse_expr9 = function() {
11510 var pos = this.reader.tell();
11511 var token = this.tokenizer.get();
11512 var node = Node(-1);
11513 if (token.type == TOKEN_NUMBER) {
11514 var node = Node(NODE_NUMBER);
11515 node.pos = token.pos;
11516 node.value = token.value;
11517 }
11518 else if (token.type == TOKEN_BLOB) {
11519 var node = Node(NODE_BLOB);
11520 node.pos = token.pos;
11521 node.value = token.value;
11522 }
11523 else if (token.type == TOKEN_DQUOTE) {
11524 this.reader.seek_set(pos);
11525 var node = Node(NODE_STRING);
11526 node.pos = token.pos;
11527 node.value = "\"" + this.tokenizer.get_dstring() + "\"";
11528 }
11529 else if (token.type == TOKEN_SQUOTE) {
11530 this.reader.seek_set(pos);
11531 var node = Node(NODE_STRING);
11532 node.pos = token.pos;
11533 node.value = "'" + this.tokenizer.get_sstring() + "'";
11534 }
11535 else if (token.type == TOKEN_SQOPEN) {
11536 var node = Node(NODE_LIST);
11537 node.pos = token.pos;
11538 node.value = [];
11539 var token = this.tokenizer.peek();
11540 if (token.type == TOKEN_SQCLOSE) {
11541 this.tokenizer.get();
11542 }
11543 else {
11544 while (TRUE) {
11545 viml_add(node.value, this.parse_expr1());
11546 var token = this.tokenizer.peek();
11547 if (token.type == TOKEN_COMMA) {
11548 this.tokenizer.get();
11549 if (this.tokenizer.peek().type == TOKEN_SQCLOSE) {
11550 this.tokenizer.get();
11551 break;
11552 }
11553 }
11554 else if (token.type == TOKEN_SQCLOSE) {
11555 this.tokenizer.get();
11556 break;
11557 }
11558 else {
11559 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11560 }
11561 }
11562 }
11563 }
11564 else if (token.type == TOKEN_COPEN || token.type == TOKEN_LITCOPEN) {
11565 var is_litdict = token.type == TOKEN_LITCOPEN;
11566 var savepos = this.reader.tell();
11567 var nodepos = token.pos;
11568 var token = this.tokenizer.get();
11569 var lambda = token.type == TOKEN_ARROW;
11570 if (!lambda && !(token.type == TOKEN_SQUOTE || token.type == TOKEN_DQUOTE)) {
11571 // if the token type is stirng, we cannot peek next token and we can
11572 // assume it's not lambda.
11573 var token2 = this.tokenizer.peek();
11574 var lambda = token2.type == TOKEN_ARROW || token2.type == TOKEN_COMMA;
11575 }
11576 // fallback to dict or {expr} if true
11577 var fallback = FALSE;
11578 if (lambda) {
11579 // lambda {token,...} {->...} {token->...}
11580 var node = Node(NODE_LAMBDA);
11581 node.pos = nodepos;
11582 node.rlist = [];
11583 var named = {};
11584 while (TRUE) {
11585 if (token.type == TOKEN_ARROW) {
11586 break;
11587 }
11588 else if (token.type == TOKEN_IDENTIFIER) {
11589 if (!isargname(token.value)) {
11590 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
11591 }
11592 else if (viml_has_key(named, token.value)) {
11593 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
11594 }
11595 named[token.value] = 1;
11596 var varnode = Node(NODE_IDENTIFIER);
11597 varnode.pos = token.pos;
11598 varnode.value = token.value;
11599 // XXX: Vim doesn't skip white space before comma. {a ,b -> ...} => E475
11600 if (iswhite(this.reader.p(0)) && this.tokenizer.peek().type == TOKEN_COMMA) {
11601 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
11602 }
11603 var token = this.tokenizer.get();
11604 viml_add(node.rlist, varnode);
11605 if (token.type == TOKEN_COMMA) {
11606 // XXX: Vim allows last comma. {a, b, -> ...} => OK
11607 var token = this.tokenizer.peek();
11608 if (token.type == TOKEN_ARROW) {
11609 this.tokenizer.get();
11610 break;
11611 }
11612 }
11613 else if (token.type == TOKEN_ARROW) {
11614 break;
11615 }
11616 else {
11617 throw Err(viml_printf("unexpected token: %s, type: %d", token.value, token.type), token.pos);
11618 }
11619 }
11620 else if (token.type == TOKEN_DOTDOTDOT) {
11621 var varnode = Node(NODE_IDENTIFIER);
11622 varnode.pos = token.pos;
11623 varnode.value = token.value;
11624 viml_add(node.rlist, varnode);
11625 var token = this.tokenizer.peek();
11626 if (token.type == TOKEN_ARROW) {
11627 this.tokenizer.get();
11628 break;
11629 }
11630 else {
11631 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11632 }
11633 }
11634 else {
11635 var fallback = TRUE;
11636 break;
11637 }
11638 var token = this.tokenizer.get();
11639 }
11640 if (!fallback) {
11641 node.left = this.parse_expr1();
11642 var token = this.tokenizer.get();
11643 if (token.type != TOKEN_CCLOSE) {
11644 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11645 }
11646 return node;
11647 }
11648 }
11649 // dict
11650 var node = Node(NODE_DICT);
11651 node.pos = nodepos;
11652 node.value = [];
11653 this.reader.seek_set(savepos);
11654 var token = this.tokenizer.peek();
11655 if (token.type == TOKEN_CCLOSE) {
11656 this.tokenizer.get();
11657 return node;
11658 }
11659 while (1) {
11660 var key = is_litdict ? this.tokenizer.parse_dict_literal_key() : this.parse_expr1();
11661 var token = this.tokenizer.get();
11662 if (token.type == TOKEN_CCLOSE) {
11663 if (!viml_empty(node.value)) {
11664 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11665 }
11666 this.reader.seek_set(pos);
11667 var node = this.parse_identifier();
11668 break;
11669 }
11670 if (token.type != TOKEN_COLON) {
11671 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11672 }
11673 var val = this.parse_expr1();
11674 viml_add(node.value, [key, val]);
11675 var token = this.tokenizer.get();
11676 if (token.type == TOKEN_COMMA) {
11677 if (this.tokenizer.peek().type == TOKEN_CCLOSE) {
11678 this.tokenizer.get();
11679 break;
11680 }
11681 }
11682 else if (token.type == TOKEN_CCLOSE) {
11683 break;
11684 }
11685 else {
11686 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11687 }
11688 }
11689 return node;
11690 }
11691 else if (token.type == TOKEN_POPEN) {
11692 var node = this.parse_expr1();
11693 var token = this.tokenizer.get();
11694 if (token.type != TOKEN_PCLOSE) {
11695 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11696 }
11697 }
11698 else if (token.type == TOKEN_OPTION) {
11699 var node = Node(NODE_OPTION);
11700 node.pos = token.pos;
11701 node.value = token.value;
11702 }
11703 else if (token.type == TOKEN_IDENTIFIER) {
11704 this.reader.seek_set(pos);
11705 var node = this.parse_identifier();
11706 }
11707 else if (FALSE && (token.type == TOKEN_COLON || token.type == TOKEN_SHARP)) {
11708 // XXX: no parse error but invalid expression
11709 this.reader.seek_set(pos);
11710 var node = this.parse_identifier();
11711 }
11712 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
11713 this.reader.seek_set(pos);
11714 var node = this.parse_identifier();
11715 }
11716 else if (token.type == TOKEN_IS || token.type == TOKEN_ISCS || token.type == TOKEN_ISNOT || token.type == TOKEN_ISNOTCS) {
11717 this.reader.seek_set(pos);
11718 var node = this.parse_identifier();
11719 }
11720 else if (token.type == TOKEN_ENV) {
11721 var node = Node(NODE_ENV);
11722 node.pos = token.pos;
11723 node.value = token.value;
11724 }
11725 else if (token.type == TOKEN_REG) {
11726 var node = Node(NODE_REG);
11727 node.pos = token.pos;
11728 node.value = token.value;
11729 }
11730 else {
11731 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11732 }
11733 return node;
11734}
11735
11736// SUBSCRIPT or CONCAT
11737// dict "." [0-9A-Za-z_]+ => (subscript dict key)
11738// str "." expr6 => (concat str expr6)
11739ExprParser.prototype.parse_dot = function(token, left) {
11740 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) {
11741 return NIL;
11742 }
11743 if (!iswordc(this.reader.p(0))) {
11744 return NIL;
11745 }
11746 var pos = this.reader.getpos();
11747 var name = this.reader.read_word();
11748 if (isnamec(this.reader.p(0))) {
11749 // XXX: foo is str => ok, foo is obj => invalid expression
11750 // foo.s:bar or foo.bar#baz
11751 return NIL;
11752 }
11753 var node = Node(NODE_DOT);
11754 node.pos = token.pos;
11755 node.left = left;
11756 node.right = Node(NODE_IDENTIFIER);
11757 node.right.pos = pos;
11758 node.right.value = name;
11759 return node;
11760}
11761
11762// CONCAT
11763// str ".." expr6 => (concat str expr6)
11764ExprParser.prototype.parse_concat = function(token, left) {
11765 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) {
11766 return NIL;
11767 }
11768 if (!iswordc(this.reader.p(0))) {
11769 return NIL;
11770 }
11771 var pos = this.reader.getpos();
11772 var name = this.reader.read_word();
11773 if (isnamec(this.reader.p(0))) {
11774 // XXX: foo is str => ok, foo is obj => invalid expression
11775 // foo.s:bar or foo.bar#baz
11776 return NIL;
11777 }
11778 var node = Node(NODE_CONCAT);
11779 node.pos = token.pos;
11780 node.left = left;
11781 node.right = Node(NODE_IDENTIFIER);
11782 node.right.pos = pos;
11783 node.right.value = name;
11784 return node;
11785}
11786
11787ExprParser.prototype.parse_identifier = function() {
11788 this.reader.skip_white();
11789 var npos = this.reader.getpos();
11790 var curly_parts = this.parse_curly_parts();
11791 if (viml_len(curly_parts) == 1 && curly_parts[0].type == NODE_CURLYNAMEPART) {
11792 var node = Node(NODE_IDENTIFIER);
11793 node.pos = npos;
11794 node.value = curly_parts[0].value;
11795 return node;
11796 }
11797 else {
11798 var node = Node(NODE_CURLYNAME);
11799 node.pos = npos;
11800 node.value = curly_parts;
11801 return node;
11802 }
11803}
11804
11805ExprParser.prototype.parse_curly_parts = function() {
11806 var curly_parts = [];
11807 var c = this.reader.peek();
11808 var pos = this.reader.getpos();
11809 if (c == "<" && viml_equalci(this.reader.peekn(5), "<SID>")) {
11810 var name = this.reader.getn(5);
11811 var node = Node(NODE_CURLYNAMEPART);
11812 node.curly = FALSE;
11813 // Keep backword compatibility for the curly attribute
11814 node.pos = pos;
11815 node.value = name;
11816 viml_add(curly_parts, node);
11817 }
11818 while (TRUE) {
11819 var c = this.reader.peek();
11820 if (isnamec(c)) {
11821 var pos = this.reader.getpos();
11822 var name = this.reader.read_name();
11823 var node = Node(NODE_CURLYNAMEPART);
11824 node.curly = FALSE;
11825 // Keep backword compatibility for the curly attribute
11826 node.pos = pos;
11827 node.value = name;
11828 viml_add(curly_parts, node);
11829 }
11830 else if (c == "{") {
11831 this.reader.get();
11832 var pos = this.reader.getpos();
11833 var node = Node(NODE_CURLYNAMEEXPR);
11834 node.curly = TRUE;
11835 // Keep backword compatibility for the curly attribute
11836 node.pos = pos;
11837 node.value = this.parse_expr1();
11838 viml_add(curly_parts, node);
11839 this.reader.skip_white();
11840 var c = this.reader.p(0);
11841 if (c != "}") {
11842 throw Err(viml_printf("unexpected token: %s", c), this.reader.getpos());
11843 }
11844 this.reader.seek_cur(1);
11845 }
11846 else {
11847 break;
11848 }
11849 }
11850 return curly_parts;
11851}
11852
11853function LvalueParser() { ExprParser.apply(this, arguments); this.__init__.apply(this, arguments); }
11854LvalueParser.prototype = Object.create(ExprParser.prototype);
11855LvalueParser.prototype.parse = function() {
11856 return this.parse_lv8();
11857}
11858
11859// expr8: expr8[expr1]
11860// expr8[expr1 : expr1]
11861// expr8.name
11862LvalueParser.prototype.parse_lv8 = function() {
11863 var left = this.parse_lv9();
11864 while (TRUE) {
11865 var pos = this.reader.tell();
11866 var c = this.reader.peek();
11867 var token = this.tokenizer.get();
11868 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
11869 var npos = token.pos;
11870 var node = Node(-1);
11871 if (this.tokenizer.peek().type == TOKEN_COLON) {
11872 this.tokenizer.get();
11873 var node = Node(NODE_SLICE);
11874 node.pos = npos;
11875 node.left = left;
11876 node.rlist = [NIL, NIL];
11877 var token = this.tokenizer.peek();
11878 if (token.type != TOKEN_SQCLOSE) {
11879 node.rlist[1] = this.parse_expr1();
11880 }
11881 var token = this.tokenizer.get();
11882 if (token.type != TOKEN_SQCLOSE) {
11883 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11884 }
11885 }
11886 else {
11887 var right = this.parse_expr1();
11888 if (this.tokenizer.peek().type == TOKEN_COLON) {
11889 this.tokenizer.get();
11890 var node = Node(NODE_SLICE);
11891 node.pos = npos;
11892 node.left = left;
11893 node.rlist = [right, NIL];
11894 var token = this.tokenizer.peek();
11895 if (token.type != TOKEN_SQCLOSE) {
11896 node.rlist[1] = this.parse_expr1();
11897 }
11898 var token = this.tokenizer.get();
11899 if (token.type != TOKEN_SQCLOSE) {
11900 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11901 }
11902 }
11903 else {
11904 var node = Node(NODE_SUBSCRIPT);
11905 node.pos = npos;
11906 node.left = left;
11907 node.right = right;
11908 var token = this.tokenizer.get();
11909 if (token.type != TOKEN_SQCLOSE) {
11910 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11911 }
11912 }
11913 }
11914 var left = node;
11915 delete node;
11916 }
11917 else if (!iswhite(c) && token.type == TOKEN_DOT) {
11918 var node = this.parse_dot(token, left);
11919 if (node === NIL) {
11920 this.reader.seek_set(pos);
11921 break;
11922 }
11923 var left = node;
11924 delete node;
11925 }
11926 else {
11927 this.reader.seek_set(pos);
11928 break;
11929 }
11930 }
11931 return left;
11932}
11933
11934// expr9: &option
11935// variable
11936// var{ria}ble
11937// $VAR
11938// @r
11939LvalueParser.prototype.parse_lv9 = function() {
11940 var pos = this.reader.tell();
11941 var token = this.tokenizer.get();
11942 var node = Node(-1);
11943 if (token.type == TOKEN_COPEN) {
11944 this.reader.seek_set(pos);
11945 var node = this.parse_identifier();
11946 }
11947 else if (token.type == TOKEN_OPTION) {
11948 var node = Node(NODE_OPTION);
11949 node.pos = token.pos;
11950 node.value = token.value;
11951 }
11952 else if (token.type == TOKEN_IDENTIFIER) {
11953 this.reader.seek_set(pos);
11954 var node = this.parse_identifier();
11955 }
11956 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
11957 this.reader.seek_set(pos);
11958 var node = this.parse_identifier();
11959 }
11960 else if (token.type == TOKEN_ENV) {
11961 var node = Node(NODE_ENV);
11962 node.pos = token.pos;
11963 node.value = token.value;
11964 }
11965 else if (token.type == TOKEN_REG) {
11966 var node = Node(NODE_REG);
11967 node.pos = token.pos;
11968 node.pos = token.pos;
11969 node.value = token.value;
11970 }
11971 else {
11972 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
11973 }
11974 return node;
11975}
11976
11977function StringReader() { this.__init__.apply(this, arguments); }
11978StringReader.prototype.__init__ = function(lines) {
11979 this.buf = [];
11980 this.pos = [];
11981 var lnum = 0;
11982 var offset = 0;
11983 while (lnum < viml_len(lines)) {
11984 var col = 0;
11985 var __c7 = viml_split(lines[lnum], "\\zs");
11986 for (var __i7 = 0; __i7 < __c7.length; ++__i7) {
11987 var c = __c7[__i7];
11988 viml_add(this.buf, c);
11989 viml_add(this.pos, [lnum + 1, col + 1, offset]);
11990 col += viml_len(c);
11991 offset += viml_len(c);
11992 }
11993 while (lnum + 1 < viml_len(lines) && viml_eqregh(lines[lnum + 1], "^\\s*\\\\")) {
11994 var skip = TRUE;
11995 var col = 0;
11996 var __c8 = viml_split(lines[lnum + 1], "\\zs");
11997 for (var __i8 = 0; __i8 < __c8.length; ++__i8) {
11998 var c = __c8[__i8];
11999 if (skip) {
12000 if (c == "\\") {
12001 var skip = FALSE;
12002 }
12003 }
12004 else {
12005 viml_add(this.buf, c);
12006 viml_add(this.pos, [lnum + 2, col + 1, offset]);
12007 }
12008 col += viml_len(c);
12009 offset += viml_len(c);
12010 }
12011 lnum += 1;
12012 offset += 1;
12013 }
12014 viml_add(this.buf, "<EOL>");
12015 viml_add(this.pos, [lnum + 1, col + 1, offset]);
12016 lnum += 1;
12017 offset += 1;
12018 }
12019 // for <EOF>
12020 viml_add(this.pos, [lnum + 1, 0, offset]);
12021 this.i = 0;
12022}
12023
12024StringReader.prototype.eof = function() {
12025 return this.i >= viml_len(this.buf);
12026}
12027
12028StringReader.prototype.tell = function() {
12029 return this.i;
12030}
12031
12032StringReader.prototype.seek_set = function(i) {
12033 this.i = i;
12034}
12035
12036StringReader.prototype.seek_cur = function(i) {
12037 this.i = this.i + i;
12038}
12039
12040StringReader.prototype.seek_end = function(i) {
12041 this.i = viml_len(this.buf) + i;
12042}
12043
12044StringReader.prototype.p = function(i) {
12045 if (this.i >= viml_len(this.buf)) {
12046 return "<EOF>";
12047 }
12048 return this.buf[this.i + i];
12049}
12050
12051StringReader.prototype.peek = function() {
12052 if (this.i >= viml_len(this.buf)) {
12053 return "<EOF>";
12054 }
12055 return this.buf[this.i];
12056}
12057
12058StringReader.prototype.get = function() {
12059 if (this.i >= viml_len(this.buf)) {
12060 return "<EOF>";
12061 }
12062 this.i += 1;
12063 return this.buf[this.i - 1];
12064}
12065
12066StringReader.prototype.peekn = function(n) {
12067 var pos = this.tell();
12068 var r = this.getn(n);
12069 this.seek_set(pos);
12070 return r;
12071}
12072
12073StringReader.prototype.getn = function(n) {
12074 var r = "";
12075 var j = 0;
12076 while (this.i < viml_len(this.buf) && (n < 0 || j < n)) {
12077 var c = this.buf[this.i];
12078 if (c == "<EOL>") {
12079 break;
12080 }
12081 r += c;
12082 this.i += 1;
12083 j += 1;
12084 }
12085 return r;
12086}
12087
12088StringReader.prototype.peekline = function() {
12089 return this.peekn(-1);
12090}
12091
12092StringReader.prototype.readline = function() {
12093 var r = this.getn(-1);
12094 this.get();
12095 return r;
12096}
12097
12098StringReader.prototype.getstr = function(begin, end) {
12099 var r = "";
12100 var __c9 = viml_range(begin.i, end.i - 1);
12101 for (var __i9 = 0; __i9 < __c9.length; ++__i9) {
12102 var i = __c9[__i9];
12103 if (i >= viml_len(this.buf)) {
12104 break;
12105 }
12106 var c = this.buf[i];
12107 if (c == "<EOL>") {
12108 var c = "\n";
12109 }
12110 r += c;
12111 }
12112 return r;
12113}
12114
12115StringReader.prototype.getpos = function() {
12116 var __tmp = this.pos[this.i];
12117 var lnum = __tmp[0];
12118 var col = __tmp[1];
12119 var offset = __tmp[2];
12120 return {"i":this.i, "lnum":lnum, "col":col, "offset":offset};
12121}
12122
12123StringReader.prototype.setpos = function(pos) {
12124 this.i = pos.i;
12125}
12126
12127StringReader.prototype.read_alpha = function() {
12128 var r = "";
12129 while (isalpha(this.peekn(1))) {
12130 r += this.getn(1);
12131 }
12132 return r;
12133}
12134
12135StringReader.prototype.read_alnum = function() {
12136 var r = "";
12137 while (isalnum(this.peekn(1))) {
12138 r += this.getn(1);
12139 }
12140 return r;
12141}
12142
12143StringReader.prototype.read_digit = function() {
12144 var r = "";
12145 while (isdigit(this.peekn(1))) {
12146 r += this.getn(1);
12147 }
12148 return r;
12149}
12150
12151StringReader.prototype.read_odigit = function() {
12152 var r = "";
12153 while (isodigit(this.peekn(1))) {
12154 r += this.getn(1);
12155 }
12156 return r;
12157}
12158
12159StringReader.prototype.read_blob = function() {
12160 var r = "";
12161 while (1) {
12162 var s = this.peekn(2);
12163 if (viml_eqregh(s, "^[0-9A-Fa-f][0-9A-Fa-f]$")) {
12164 r += this.getn(2);
12165 }
12166 else if (viml_eqregh(s, "^\\.[0-9A-Fa-f]$")) {
12167 r += this.getn(1);
12168 }
12169 else if (viml_eqregh(s, "^[0-9A-Fa-f][^0-9A-Fa-f]$")) {
12170 throw Err("E973: Blob literal should have an even number of hex characters:" + s, this.getpos());
12171 }
12172 else {
12173 break;
12174 }
12175 }
12176 return r;
12177}
12178
12179StringReader.prototype.read_xdigit = function() {
12180 var r = "";
12181 while (isxdigit(this.peekn(1))) {
12182 r += this.getn(1);
12183 }
12184 return r;
12185}
12186
12187StringReader.prototype.read_bdigit = function() {
12188 var r = "";
12189 while (this.peekn(1) == "0" || this.peekn(1) == "1") {
12190 r += this.getn(1);
12191 }
12192 return r;
12193}
12194
12195StringReader.prototype.read_integer = function() {
12196 var r = "";
12197 var c = this.peekn(1);
12198 if (c == "-" || c == "+") {
12199 var r = this.getn(1);
12200 }
12201 return r + this.read_digit();
12202}
12203
12204StringReader.prototype.read_word = function() {
12205 var r = "";
12206 while (iswordc(this.peekn(1))) {
12207 r += this.getn(1);
12208 }
12209 return r;
12210}
12211
12212StringReader.prototype.read_white = function() {
12213 var r = "";
12214 while (iswhite(this.peekn(1))) {
12215 r += this.getn(1);
12216 }
12217 return r;
12218}
12219
12220StringReader.prototype.read_nonwhite = function() {
12221 var r = "";
12222 var ch = this.peekn(1);
12223 while (!iswhite(ch) && ch != "") {
12224 r += this.getn(1);
12225 var ch = this.peekn(1);
12226 }
12227 return r;
12228}
12229
12230StringReader.prototype.read_name = function() {
12231 var r = "";
12232 while (isnamec(this.peekn(1))) {
12233 r += this.getn(1);
12234 }
12235 return r;
12236}
12237
12238StringReader.prototype.skip_white = function() {
12239 while (iswhite(this.peekn(1))) {
12240 this.seek_cur(1);
12241 }
12242}
12243
12244StringReader.prototype.skip_white_and_colon = function() {
12245 while (TRUE) {
12246 var c = this.peekn(1);
12247 if (!iswhite(c) && c != ":") {
12248 break;
12249 }
12250 this.seek_cur(1);
12251 }
12252}
12253
12254function Compiler() { this.__init__.apply(this, arguments); }
12255Compiler.prototype.__init__ = function() {
12256 this.indent = [""];
12257 this.lines = [];
12258}
12259
12260Compiler.prototype.out = function() {
12261 var a000 = Array.prototype.slice.call(arguments, 0);
12262 if (viml_len(a000) == 1) {
12263 if (a000[0][0] == ")") {
12264 this.lines[this.lines.length - 1] += a000[0];
12265 }
12266 else {
12267 viml_add(this.lines, this.indent[0] + a000[0]);
12268 }
12269 }
12270 else {
12271 viml_add(this.lines, this.indent[0] + viml_printf.apply(null, a000));
12272 }
12273}
12274
12275Compiler.prototype.incindent = function(s) {
12276 viml_insert(this.indent, this.indent[0] + s);
12277}
12278
12279Compiler.prototype.decindent = function() {
12280 viml_remove(this.indent, 0);
12281}
12282
12283Compiler.prototype.compile = function(node) {
12284 if (node.type == NODE_TOPLEVEL) {
12285 return this.compile_toplevel(node);
12286 }
12287 else if (node.type == NODE_COMMENT) {
12288 this.compile_comment(node);
12289 return NIL;
12290 }
12291 else if (node.type == NODE_EXCMD) {
12292 this.compile_excmd(node);
12293 return NIL;
12294 }
12295 else if (node.type == NODE_FUNCTION) {
12296 this.compile_function(node);
12297 return NIL;
12298 }
12299 else if (node.type == NODE_DELFUNCTION) {
12300 this.compile_delfunction(node);
12301 return NIL;
12302 }
12303 else if (node.type == NODE_RETURN) {
12304 this.compile_return(node);
12305 return NIL;
12306 }
12307 else if (node.type == NODE_EXCALL) {
12308 this.compile_excall(node);
12309 return NIL;
12310 }
12311 else if (node.type == NODE_EVAL) {
12312 this.compile_eval(node);
12313 return NIL;
12314 }
12315 else if (node.type == NODE_LET) {
12316 this.compile_let(node);
12317 return NIL;
12318 }
12319 else if (node.type == NODE_CONST) {
12320 this.compile_const(node);
12321 return NIL;
12322 }
12323 else if (node.type == NODE_UNLET) {
12324 this.compile_unlet(node);
12325 return NIL;
12326 }
12327 else if (node.type == NODE_LOCKVAR) {
12328 this.compile_lockvar(node);
12329 return NIL;
12330 }
12331 else if (node.type == NODE_UNLOCKVAR) {
12332 this.compile_unlockvar(node);
12333 return NIL;
12334 }
12335 else if (node.type == NODE_IF) {
12336 this.compile_if(node);
12337 return NIL;
12338 }
12339 else if (node.type == NODE_WHILE) {
12340 this.compile_while(node);
12341 return NIL;
12342 }
12343 else if (node.type == NODE_FOR) {
12344 this.compile_for(node);
12345 return NIL;
12346 }
12347 else if (node.type == NODE_CONTINUE) {
12348 this.compile_continue(node);
12349 return NIL;
12350 }
12351 else if (node.type == NODE_BREAK) {
12352 this.compile_break(node);
12353 return NIL;
12354 }
12355 else if (node.type == NODE_TRY) {
12356 this.compile_try(node);
12357 return NIL;
12358 }
12359 else if (node.type == NODE_THROW) {
12360 this.compile_throw(node);
12361 return NIL;
12362 }
12363 else if (node.type == NODE_ECHO) {
12364 this.compile_echo(node);
12365 return NIL;
12366 }
12367 else if (node.type == NODE_ECHON) {
12368 this.compile_echon(node);
12369 return NIL;
12370 }
12371 else if (node.type == NODE_ECHOHL) {
12372 this.compile_echohl(node);
12373 return NIL;
12374 }
12375 else if (node.type == NODE_ECHOMSG) {
12376 this.compile_echomsg(node);
12377 return NIL;
12378 }
12379 else if (node.type == NODE_ECHOERR) {
12380 this.compile_echoerr(node);
12381 return NIL;
12382 }
12383 else if (node.type == NODE_EXECUTE) {
12384 this.compile_execute(node);
12385 return NIL;
12386 }
12387 else if (node.type == NODE_TERNARY) {
12388 return this.compile_ternary(node);
12389 }
12390 else if (node.type == NODE_OR) {
12391 return this.compile_or(node);
12392 }
12393 else if (node.type == NODE_AND) {
12394 return this.compile_and(node);
12395 }
12396 else if (node.type == NODE_EQUAL) {
12397 return this.compile_equal(node);
12398 }
12399 else if (node.type == NODE_EQUALCI) {
12400 return this.compile_equalci(node);
12401 }
12402 else if (node.type == NODE_EQUALCS) {
12403 return this.compile_equalcs(node);
12404 }
12405 else if (node.type == NODE_NEQUAL) {
12406 return this.compile_nequal(node);
12407 }
12408 else if (node.type == NODE_NEQUALCI) {
12409 return this.compile_nequalci(node);
12410 }
12411 else if (node.type == NODE_NEQUALCS) {
12412 return this.compile_nequalcs(node);
12413 }
12414 else if (node.type == NODE_GREATER) {
12415 return this.compile_greater(node);
12416 }
12417 else if (node.type == NODE_GREATERCI) {
12418 return this.compile_greaterci(node);
12419 }
12420 else if (node.type == NODE_GREATERCS) {
12421 return this.compile_greatercs(node);
12422 }
12423 else if (node.type == NODE_GEQUAL) {
12424 return this.compile_gequal(node);
12425 }
12426 else if (node.type == NODE_GEQUALCI) {
12427 return this.compile_gequalci(node);
12428 }
12429 else if (node.type == NODE_GEQUALCS) {
12430 return this.compile_gequalcs(node);
12431 }
12432 else if (node.type == NODE_SMALLER) {
12433 return this.compile_smaller(node);
12434 }
12435 else if (node.type == NODE_SMALLERCI) {
12436 return this.compile_smallerci(node);
12437 }
12438 else if (node.type == NODE_SMALLERCS) {
12439 return this.compile_smallercs(node);
12440 }
12441 else if (node.type == NODE_SEQUAL) {
12442 return this.compile_sequal(node);
12443 }
12444 else if (node.type == NODE_SEQUALCI) {
12445 return this.compile_sequalci(node);
12446 }
12447 else if (node.type == NODE_SEQUALCS) {
12448 return this.compile_sequalcs(node);
12449 }
12450 else if (node.type == NODE_MATCH) {
12451 return this.compile_match(node);
12452 }
12453 else if (node.type == NODE_MATCHCI) {
12454 return this.compile_matchci(node);
12455 }
12456 else if (node.type == NODE_MATCHCS) {
12457 return this.compile_matchcs(node);
12458 }
12459 else if (node.type == NODE_NOMATCH) {
12460 return this.compile_nomatch(node);
12461 }
12462 else if (node.type == NODE_NOMATCHCI) {
12463 return this.compile_nomatchci(node);
12464 }
12465 else if (node.type == NODE_NOMATCHCS) {
12466 return this.compile_nomatchcs(node);
12467 }
12468 else if (node.type == NODE_IS) {
12469 return this.compile_is(node);
12470 }
12471 else if (node.type == NODE_ISCI) {
12472 return this.compile_isci(node);
12473 }
12474 else if (node.type == NODE_ISCS) {
12475 return this.compile_iscs(node);
12476 }
12477 else if (node.type == NODE_ISNOT) {
12478 return this.compile_isnot(node);
12479 }
12480 else if (node.type == NODE_ISNOTCI) {
12481 return this.compile_isnotci(node);
12482 }
12483 else if (node.type == NODE_ISNOTCS) {
12484 return this.compile_isnotcs(node);
12485 }
12486 else if (node.type == NODE_ADD) {
12487 return this.compile_add(node);
12488 }
12489 else if (node.type == NODE_SUBTRACT) {
12490 return this.compile_subtract(node);
12491 }
12492 else if (node.type == NODE_CONCAT) {
12493 return this.compile_concat(node);
12494 }
12495 else if (node.type == NODE_MULTIPLY) {
12496 return this.compile_multiply(node);
12497 }
12498 else if (node.type == NODE_DIVIDE) {
12499 return this.compile_divide(node);
12500 }
12501 else if (node.type == NODE_REMAINDER) {
12502 return this.compile_remainder(node);
12503 }
12504 else if (node.type == NODE_NOT) {
12505 return this.compile_not(node);
12506 }
12507 else if (node.type == NODE_PLUS) {
12508 return this.compile_plus(node);
12509 }
12510 else if (node.type == NODE_MINUS) {
12511 return this.compile_minus(node);
12512 }
12513 else if (node.type == NODE_SUBSCRIPT) {
12514 return this.compile_subscript(node);
12515 }
12516 else if (node.type == NODE_SLICE) {
12517 return this.compile_slice(node);
12518 }
12519 else if (node.type == NODE_DOT) {
12520 return this.compile_dot(node);
12521 }
12522 else if (node.type == NODE_METHOD) {
12523 return this.compile_method(node);
12524 }
12525 else if (node.type == NODE_CALL) {
12526 return this.compile_call(node);
12527 }
12528 else if (node.type == NODE_NUMBER) {
12529 return this.compile_number(node);
12530 }
12531 else if (node.type == NODE_BLOB) {
12532 return this.compile_blob(node);
12533 }
12534 else if (node.type == NODE_STRING) {
12535 return this.compile_string(node);
12536 }
12537 else if (node.type == NODE_LIST) {
12538 return this.compile_list(node);
12539 }
12540 else if (node.type == NODE_DICT) {
12541 return this.compile_dict(node);
12542 }
12543 else if (node.type == NODE_OPTION) {
12544 return this.compile_option(node);
12545 }
12546 else if (node.type == NODE_IDENTIFIER) {
12547 return this.compile_identifier(node);
12548 }
12549 else if (node.type == NODE_CURLYNAME) {
12550 return this.compile_curlyname(node);
12551 }
12552 else if (node.type == NODE_ENV) {
12553 return this.compile_env(node);
12554 }
12555 else if (node.type == NODE_REG) {
12556 return this.compile_reg(node);
12557 }
12558 else if (node.type == NODE_CURLYNAMEPART) {
12559 return this.compile_curlynamepart(node);
12560 }
12561 else if (node.type == NODE_CURLYNAMEEXPR) {
12562 return this.compile_curlynameexpr(node);
12563 }
12564 else if (node.type == NODE_LAMBDA) {
12565 return this.compile_lambda(node);
12566 }
12567 else if (node.type == NODE_HEREDOC) {
12568 return this.compile_heredoc(node);
12569 }
12570 else {
12571 throw viml_printf("Compiler: unknown node: %s", viml_string(node));
12572 }
12573 return NIL;
12574}
12575
12576Compiler.prototype.compile_body = function(body) {
12577 var __c10 = body;
12578 for (var __i10 = 0; __i10 < __c10.length; ++__i10) {
12579 var node = __c10[__i10];
12580 this.compile(node);
12581 }
12582}
12583
12584Compiler.prototype.compile_toplevel = function(node) {
12585 this.compile_body(node.body);
12586 return this.lines;
12587}
12588
12589Compiler.prototype.compile_comment = function(node) {
12590 this.out(";%s", node.str);
12591}
12592
12593Compiler.prototype.compile_excmd = function(node) {
12594 this.out("(excmd \"%s\")", viml_escape(node.str, "\\\""));
12595}
12596
12597Compiler.prototype.compile_function = function(node) {
12598 var left = this.compile(node.left);
12599 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
12600 var default_args = node.default_args.map((function(vval) { return this.compile(vval); }).bind(this));
12601 if (!viml_empty(rlist)) {
12602 var remaining = FALSE;
12603 if (rlist[rlist.length - 1] == "...") {
12604 viml_remove(rlist, -1);
12605 var remaining = TRUE;
12606 }
12607 var __c11 = viml_range(viml_len(rlist));
12608 for (var __i11 = 0; __i11 < __c11.length; ++__i11) {
12609 var i = __c11[__i11];
12610 if (i < viml_len(rlist) - viml_len(default_args)) {
12611 left += viml_printf(" %s", rlist[i]);
12612 }
12613 else {
12614 left += viml_printf(" (%s %s)", rlist[i], default_args[i + viml_len(default_args) - viml_len(rlist)]);
12615 }
12616 }
12617 if (remaining) {
12618 left += " . ...";
12619 }
12620 }
12621 this.out("(function (%s)", left);
12622 this.incindent(" ");
12623 this.compile_body(node.body);
12624 this.out(")");
12625 this.decindent();
12626}
12627
12628Compiler.prototype.compile_delfunction = function(node) {
12629 this.out("(delfunction %s)", this.compile(node.left));
12630}
12631
12632Compiler.prototype.compile_return = function(node) {
12633 if (node.left === NIL) {
12634 this.out("(return)");
12635 }
12636 else {
12637 this.out("(return %s)", this.compile(node.left));
12638 }
12639}
12640
12641Compiler.prototype.compile_excall = function(node) {
12642 this.out("(call %s)", this.compile(node.left));
12643}
12644
12645Compiler.prototype.compile_eval = function(node) {
12646 this.out("(eval %s)", this.compile(node.left));
12647}
12648
12649Compiler.prototype.compile_let = function(node) {
12650 var left = "";
12651 if (node.left !== NIL) {
12652 var left = this.compile(node.left);
12653 }
12654 else {
12655 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
12656 if (node.rest !== NIL) {
12657 left += " . " + this.compile(node.rest);
12658 }
12659 var left = "(" + left + ")";
12660 }
12661 var right = this.compile(node.right);
12662 this.out("(let %s %s %s)", node.op, left, right);
12663}
12664
12665// TODO: merge with s:Compiler.compile_let() ?
12666Compiler.prototype.compile_const = function(node) {
12667 var left = "";
12668 if (node.left !== NIL) {
12669 var left = this.compile(node.left);
12670 }
12671 else {
12672 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
12673 if (node.rest !== NIL) {
12674 left += " . " + this.compile(node.rest);
12675 }
12676 var left = "(" + left + ")";
12677 }
12678 var right = this.compile(node.right);
12679 this.out("(const %s %s %s)", node.op, left, right);
12680}
12681
12682Compiler.prototype.compile_unlet = function(node) {
12683 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12684 this.out("(unlet %s)", viml_join(list, " "));
12685}
12686
12687Compiler.prototype.compile_lockvar = function(node) {
12688 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12689 if (node.depth === NIL) {
12690 this.out("(lockvar %s)", viml_join(list, " "));
12691 }
12692 else {
12693 this.out("(lockvar %s %s)", node.depth, viml_join(list, " "));
12694 }
12695}
12696
12697Compiler.prototype.compile_unlockvar = function(node) {
12698 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12699 if (node.depth === NIL) {
12700 this.out("(unlockvar %s)", viml_join(list, " "));
12701 }
12702 else {
12703 this.out("(unlockvar %s %s)", node.depth, viml_join(list, " "));
12704 }
12705}
12706
12707Compiler.prototype.compile_if = function(node) {
12708 this.out("(if %s", this.compile(node.cond));
12709 this.incindent(" ");
12710 this.compile_body(node.body);
12711 this.decindent();
12712 var __c12 = node.elseif;
12713 for (var __i12 = 0; __i12 < __c12.length; ++__i12) {
12714 var enode = __c12[__i12];
12715 this.out(" elseif %s", this.compile(enode.cond));
12716 this.incindent(" ");
12717 this.compile_body(enode.body);
12718 this.decindent();
12719 }
12720 if (node._else !== NIL) {
12721 this.out(" else");
12722 this.incindent(" ");
12723 this.compile_body(node._else.body);
12724 this.decindent();
12725 }
12726 this.incindent(" ");
12727 this.out(")");
12728 this.decindent();
12729}
12730
12731Compiler.prototype.compile_while = function(node) {
12732 this.out("(while %s", this.compile(node.cond));
12733 this.incindent(" ");
12734 this.compile_body(node.body);
12735 this.out(")");
12736 this.decindent();
12737}
12738
12739Compiler.prototype.compile_for = function(node) {
12740 var left = "";
12741 if (node.left !== NIL) {
12742 var left = this.compile(node.left);
12743 }
12744 else {
12745 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
12746 if (node.rest !== NIL) {
12747 left += " . " + this.compile(node.rest);
12748 }
12749 var left = "(" + left + ")";
12750 }
12751 var right = this.compile(node.right);
12752 this.out("(for %s %s", left, right);
12753 this.incindent(" ");
12754 this.compile_body(node.body);
12755 this.out(")");
12756 this.decindent();
12757}
12758
12759Compiler.prototype.compile_continue = function(node) {
12760 this.out("(continue)");
12761}
12762
12763Compiler.prototype.compile_break = function(node) {
12764 this.out("(break)");
12765}
12766
12767Compiler.prototype.compile_try = function(node) {
12768 this.out("(try");
12769 this.incindent(" ");
12770 this.compile_body(node.body);
12771 var __c13 = node.catch;
12772 for (var __i13 = 0; __i13 < __c13.length; ++__i13) {
12773 var cnode = __c13[__i13];
12774 if (cnode.pattern !== NIL) {
12775 this.decindent();
12776 this.out(" catch /%s/", cnode.pattern);
12777 this.incindent(" ");
12778 this.compile_body(cnode.body);
12779 }
12780 else {
12781 this.decindent();
12782 this.out(" catch");
12783 this.incindent(" ");
12784 this.compile_body(cnode.body);
12785 }
12786 }
12787 if (node._finally !== NIL) {
12788 this.decindent();
12789 this.out(" finally");
12790 this.incindent(" ");
12791 this.compile_body(node._finally.body);
12792 }
12793 this.out(")");
12794 this.decindent();
12795}
12796
12797Compiler.prototype.compile_throw = function(node) {
12798 this.out("(throw %s)", this.compile(node.left));
12799}
12800
12801Compiler.prototype.compile_echo = function(node) {
12802 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12803 this.out("(echo %s)", viml_join(list, " "));
12804}
12805
12806Compiler.prototype.compile_echon = function(node) {
12807 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12808 this.out("(echon %s)", viml_join(list, " "));
12809}
12810
12811Compiler.prototype.compile_echohl = function(node) {
12812 this.out("(echohl \"%s\")", viml_escape(node.str, "\\\""));
12813}
12814
12815Compiler.prototype.compile_echomsg = function(node) {
12816 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12817 this.out("(echomsg %s)", viml_join(list, " "));
12818}
12819
12820Compiler.prototype.compile_echoerr = function(node) {
12821 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12822 this.out("(echoerr %s)", viml_join(list, " "));
12823}
12824
12825Compiler.prototype.compile_execute = function(node) {
12826 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
12827 this.out("(execute %s)", viml_join(list, " "));
12828}
12829
12830Compiler.prototype.compile_ternary = function(node) {
12831 return viml_printf("(?: %s %s %s)", this.compile(node.cond), this.compile(node.left), this.compile(node.right));
12832}
12833
12834Compiler.prototype.compile_or = function(node) {
12835 return viml_printf("(|| %s %s)", this.compile(node.left), this.compile(node.right));
12836}
12837
12838Compiler.prototype.compile_and = function(node) {
12839 return viml_printf("(&& %s %s)", this.compile(node.left), this.compile(node.right));
12840}
12841
12842Compiler.prototype.compile_equal = function(node) {
12843 return viml_printf("(== %s %s)", this.compile(node.left), this.compile(node.right));
12844}
12845
12846Compiler.prototype.compile_equalci = function(node) {
12847 return viml_printf("(==? %s %s)", this.compile(node.left), this.compile(node.right));
12848}
12849
12850Compiler.prototype.compile_equalcs = function(node) {
12851 return viml_printf("(==# %s %s)", this.compile(node.left), this.compile(node.right));
12852}
12853
12854Compiler.prototype.compile_nequal = function(node) {
12855 return viml_printf("(!= %s %s)", this.compile(node.left), this.compile(node.right));
12856}
12857
12858Compiler.prototype.compile_nequalci = function(node) {
12859 return viml_printf("(!=? %s %s)", this.compile(node.left), this.compile(node.right));
12860}
12861
12862Compiler.prototype.compile_nequalcs = function(node) {
12863 return viml_printf("(!=# %s %s)", this.compile(node.left), this.compile(node.right));
12864}
12865
12866Compiler.prototype.compile_greater = function(node) {
12867 return viml_printf("(> %s %s)", this.compile(node.left), this.compile(node.right));
12868}
12869
12870Compiler.prototype.compile_greaterci = function(node) {
12871 return viml_printf("(>? %s %s)", this.compile(node.left), this.compile(node.right));
12872}
12873
12874Compiler.prototype.compile_greatercs = function(node) {
12875 return viml_printf("(># %s %s)", this.compile(node.left), this.compile(node.right));
12876}
12877
12878Compiler.prototype.compile_gequal = function(node) {
12879 return viml_printf("(>= %s %s)", this.compile(node.left), this.compile(node.right));
12880}
12881
12882Compiler.prototype.compile_gequalci = function(node) {
12883 return viml_printf("(>=? %s %s)", this.compile(node.left), this.compile(node.right));
12884}
12885
12886Compiler.prototype.compile_gequalcs = function(node) {
12887 return viml_printf("(>=# %s %s)", this.compile(node.left), this.compile(node.right));
12888}
12889
12890Compiler.prototype.compile_smaller = function(node) {
12891 return viml_printf("(< %s %s)", this.compile(node.left), this.compile(node.right));
12892}
12893
12894Compiler.prototype.compile_smallerci = function(node) {
12895 return viml_printf("(<? %s %s)", this.compile(node.left), this.compile(node.right));
12896}
12897
12898Compiler.prototype.compile_smallercs = function(node) {
12899 return viml_printf("(<# %s %s)", this.compile(node.left), this.compile(node.right));
12900}
12901
12902Compiler.prototype.compile_sequal = function(node) {
12903 return viml_printf("(<= %s %s)", this.compile(node.left), this.compile(node.right));
12904}
12905
12906Compiler.prototype.compile_sequalci = function(node) {
12907 return viml_printf("(<=? %s %s)", this.compile(node.left), this.compile(node.right));
12908}
12909
12910Compiler.prototype.compile_sequalcs = function(node) {
12911 return viml_printf("(<=# %s %s)", this.compile(node.left), this.compile(node.right));
12912}
12913
12914Compiler.prototype.compile_match = function(node) {
12915 return viml_printf("(=~ %s %s)", this.compile(node.left), this.compile(node.right));
12916}
12917
12918Compiler.prototype.compile_matchci = function(node) {
12919 return viml_printf("(=~? %s %s)", this.compile(node.left), this.compile(node.right));
12920}
12921
12922Compiler.prototype.compile_matchcs = function(node) {
12923 return viml_printf("(=~# %s %s)", this.compile(node.left), this.compile(node.right));
12924}
12925
12926Compiler.prototype.compile_nomatch = function(node) {
12927 return viml_printf("(!~ %s %s)", this.compile(node.left), this.compile(node.right));
12928}
12929
12930Compiler.prototype.compile_nomatchci = function(node) {
12931 return viml_printf("(!~? %s %s)", this.compile(node.left), this.compile(node.right));
12932}
12933
12934Compiler.prototype.compile_nomatchcs = function(node) {
12935 return viml_printf("(!~# %s %s)", this.compile(node.left), this.compile(node.right));
12936}
12937
12938Compiler.prototype.compile_is = function(node) {
12939 return viml_printf("(is %s %s)", this.compile(node.left), this.compile(node.right));
12940}
12941
12942Compiler.prototype.compile_isci = function(node) {
12943 return viml_printf("(is? %s %s)", this.compile(node.left), this.compile(node.right));
12944}
12945
12946Compiler.prototype.compile_iscs = function(node) {
12947 return viml_printf("(is# %s %s)", this.compile(node.left), this.compile(node.right));
12948}
12949
12950Compiler.prototype.compile_isnot = function(node) {
12951 return viml_printf("(isnot %s %s)", this.compile(node.left), this.compile(node.right));
12952}
12953
12954Compiler.prototype.compile_isnotci = function(node) {
12955 return viml_printf("(isnot? %s %s)", this.compile(node.left), this.compile(node.right));
12956}
12957
12958Compiler.prototype.compile_isnotcs = function(node) {
12959 return viml_printf("(isnot# %s %s)", this.compile(node.left), this.compile(node.right));
12960}
12961
12962Compiler.prototype.compile_add = function(node) {
12963 return viml_printf("(+ %s %s)", this.compile(node.left), this.compile(node.right));
12964}
12965
12966Compiler.prototype.compile_subtract = function(node) {
12967 return viml_printf("(- %s %s)", this.compile(node.left), this.compile(node.right));
12968}
12969
12970Compiler.prototype.compile_concat = function(node) {
12971 return viml_printf("(concat %s %s)", this.compile(node.left), this.compile(node.right));
12972}
12973
12974Compiler.prototype.compile_multiply = function(node) {
12975 return viml_printf("(* %s %s)", this.compile(node.left), this.compile(node.right));
12976}
12977
12978Compiler.prototype.compile_divide = function(node) {
12979 return viml_printf("(/ %s %s)", this.compile(node.left), this.compile(node.right));
12980}
12981
12982Compiler.prototype.compile_remainder = function(node) {
12983 return viml_printf("(%% %s %s)", this.compile(node.left), this.compile(node.right));
12984}
12985
12986Compiler.prototype.compile_not = function(node) {
12987 return viml_printf("(! %s)", this.compile(node.left));
12988}
12989
12990Compiler.prototype.compile_plus = function(node) {
12991 return viml_printf("(+ %s)", this.compile(node.left));
12992}
12993
12994Compiler.prototype.compile_minus = function(node) {
12995 return viml_printf("(- %s)", this.compile(node.left));
12996}
12997
12998Compiler.prototype.compile_subscript = function(node) {
12999 return viml_printf("(subscript %s %s)", this.compile(node.left), this.compile(node.right));
13000}
13001
13002Compiler.prototype.compile_slice = function(node) {
13003 var r0 = node.rlist[0] === NIL ? "nil" : this.compile(node.rlist[0]);
13004 var r1 = node.rlist[1] === NIL ? "nil" : this.compile(node.rlist[1]);
13005 return viml_printf("(slice %s %s %s)", this.compile(node.left), r0, r1);
13006}
13007
13008Compiler.prototype.compile_dot = function(node) {
13009 return viml_printf("(dot %s %s)", this.compile(node.left), this.compile(node.right));
13010}
13011
13012Compiler.prototype.compile_method = function(node) {
13013 return viml_printf("(method %s %s)", this.compile(node.left), this.compile(node.right));
13014}
13015
13016Compiler.prototype.compile_call = function(node) {
13017 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
13018 if (viml_empty(rlist)) {
13019 return viml_printf("(%s)", this.compile(node.left));
13020 }
13021 else {
13022 return viml_printf("(%s %s)", this.compile(node.left), viml_join(rlist, " "));
13023 }
13024}
13025
13026Compiler.prototype.compile_number = function(node) {
13027 return node.value;
13028}
13029
13030Compiler.prototype.compile_blob = function(node) {
13031 return node.value;
13032}
13033
13034Compiler.prototype.compile_string = function(node) {
13035 return node.value;
13036}
13037
13038Compiler.prototype.compile_list = function(node) {
13039 var value = node.value.map((function(vval) { return this.compile(vval); }).bind(this));
13040 if (viml_empty(value)) {
13041 return "(list)";
13042 }
13043 else {
13044 return viml_printf("(list %s)", viml_join(value, " "));
13045 }
13046}
13047
13048Compiler.prototype.compile_dict = function(node) {
13049 var value = node.value.map((function(vval) { return "(" + this.compile(vval[0]) + " " + this.compile(vval[1]) + ")"; }).bind(this));
13050 if (viml_empty(value)) {
13051 return "(dict)";
13052 }
13053 else {
13054 return viml_printf("(dict %s)", viml_join(value, " "));
13055 }
13056}
13057
13058Compiler.prototype.compile_option = function(node) {
13059 return node.value;
13060}
13061
13062Compiler.prototype.compile_identifier = function(node) {
13063 return node.value;
13064}
13065
13066Compiler.prototype.compile_curlyname = function(node) {
13067 return viml_join(node.value.map((function(vval) { return this.compile(vval); }).bind(this)), "");
13068}
13069
13070Compiler.prototype.compile_env = function(node) {
13071 return node.value;
13072}
13073
13074Compiler.prototype.compile_reg = function(node) {
13075 return node.value;
13076}
13077
13078Compiler.prototype.compile_curlynamepart = function(node) {
13079 return node.value;
13080}
13081
13082Compiler.prototype.compile_curlynameexpr = function(node) {
13083 return "{" + this.compile(node.value) + "}";
13084}
13085
13086Compiler.prototype.escape_string = function(str) {
13087 var m = {"\n":"\\n", "\t":"\\t", "\r":"\\r"};
13088 var out = "\"";
13089 var __c14 = viml_range(viml_len(str));
13090 for (var __i14 = 0; __i14 < __c14.length; ++__i14) {
13091 var i = __c14[__i14];
13092 var c = str[i];
13093 if (viml_has_key(m, c)) {
13094 out += m[c];
13095 }
13096 else {
13097 out += c;
13098 }
13099 }
13100 out += "\"";
13101 return out;
13102}
13103
13104Compiler.prototype.compile_lambda = function(node) {
13105 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
13106 return viml_printf("(lambda (%s) %s)", viml_join(rlist, " "), this.compile(node.left));
13107}
13108
13109Compiler.prototype.compile_heredoc = function(node) {
13110 if (viml_empty(node.rlist)) {
13111 var rlist = "(list)";
13112 }
13113 else {
13114 var rlist = "(list " + viml_join(node.rlist.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
13115 }
13116 if (viml_empty(node.body)) {
13117 var body = "(list)";
13118 }
13119 else {
13120 var body = "(list " + viml_join(node.body.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
13121 }
13122 var op = this.escape_string(node.op);
13123 return viml_printf("(heredoc %s %s %s)", rlist, op, body);
13124}
13125
13126// TODO: under construction
13127function RegexpParser() { this.__init__.apply(this, arguments); }
13128RegexpParser.prototype.RE_VERY_NOMAGIC = 1;
13129RegexpParser.prototype.RE_NOMAGIC = 2;
13130RegexpParser.prototype.RE_MAGIC = 3;
13131RegexpParser.prototype.RE_VERY_MAGIC = 4;
13132RegexpParser.prototype.__init__ = function(reader, cmd, delim) {
13133 this.reader = reader;
13134 this.cmd = cmd;
13135 this.delim = delim;
13136 this.reg_magic = this.RE_MAGIC;
13137}
13138
13139RegexpParser.prototype.isend = function(c) {
13140 return c == "<EOF>" || c == "<EOL>" || c == this.delim;
13141}
13142
13143RegexpParser.prototype.parse_regexp = function() {
13144 var prevtoken = "";
13145 var ntoken = "";
13146 var ret = [];
13147 if (this.reader.peekn(4) == "\\%#=") {
13148 var epos = this.reader.getpos();
13149 var token = this.reader.getn(5);
13150 if (token != "\\%#=0" && token != "\\%#=1" && token != "\\%#=2") {
13151 throw Err("E864: \\%#= can only be followed by 0, 1, or 2", epos);
13152 }
13153 viml_add(ret, token);
13154 }
13155 while (!this.isend(this.reader.peek())) {
13156 var prevtoken = ntoken;
13157 var __tmp = this.get_token();
13158 var token = __tmp[0];
13159 var ntoken = __tmp[1];
13160 if (ntoken == "\\m") {
13161 this.reg_magic = this.RE_MAGIC;
13162 }
13163 else if (ntoken == "\\M") {
13164 this.reg_magic = this.RE_NOMAGIC;
13165 }
13166 else if (ntoken == "\\v") {
13167 this.reg_magic = this.RE_VERY_MAGIC;
13168 }
13169 else if (ntoken == "\\V") {
13170 this.reg_magic = this.RE_VERY_NOMAGIC;
13171 }
13172 else if (ntoken == "\\*") {
13173 // '*' is not magic as the very first character.
13174 if (prevtoken == "" || prevtoken == "\\^" || prevtoken == "\\&" || prevtoken == "\\|" || prevtoken == "\\(") {
13175 var ntoken = "*";
13176 }
13177 }
13178 else if (ntoken == "\\^") {
13179 // '^' is only magic as the very first character.
13180 if (this.reg_magic != this.RE_VERY_MAGIC && prevtoken != "" && prevtoken != "\\&" && prevtoken != "\\|" && prevtoken != "\\n" && prevtoken != "\\(" && prevtoken != "\\%(") {
13181 var ntoken = "^";
13182 }
13183 }
13184 else if (ntoken == "\\$") {
13185 // '$' is only magic as the very last character
13186 var pos = this.reader.tell();
13187 if (this.reg_magic != this.RE_VERY_MAGIC) {
13188 while (!this.isend(this.reader.peek())) {
13189 var __tmp = this.get_token();
13190 var t = __tmp[0];
13191 var n = __tmp[1];
13192 // XXX: Vim doesn't check \v and \V?
13193 if (n == "\\c" || n == "\\C" || n == "\\m" || n == "\\M" || n == "\\Z") {
13194 continue;
13195 }
13196 if (n != "\\|" && n != "\\&" && n != "\\n" && n != "\\)") {
13197 var ntoken = "$";
13198 }
13199 break;
13200 }
13201 }
13202 this.reader.seek_set(pos);
13203 }
13204 else if (ntoken == "\\?") {
13205 // '?' is literal in '?' command.
13206 if (this.cmd == "?") {
13207 var ntoken = "?";
13208 }
13209 }
13210 viml_add(ret, ntoken);
13211 }
13212 return ret;
13213}
13214
13215// @return [actual_token, normalized_token]
13216RegexpParser.prototype.get_token = function() {
13217 if (this.reg_magic == this.RE_VERY_MAGIC) {
13218 return this.get_token_very_magic();
13219 }
13220 else if (this.reg_magic == this.RE_MAGIC) {
13221 return this.get_token_magic();
13222 }
13223 else if (this.reg_magic == this.RE_NOMAGIC) {
13224 return this.get_token_nomagic();
13225 }
13226 else if (this.reg_magic == this.RE_VERY_NOMAGIC) {
13227 return this.get_token_very_nomagic();
13228 }
13229}
13230
13231RegexpParser.prototype.get_token_very_magic = function() {
13232 if (this.isend(this.reader.peek())) {
13233 return ["<END>", "<END>"];
13234 }
13235 var c = this.reader.get();
13236 if (c == "\\") {
13237 return this.get_token_backslash_common();
13238 }
13239 else if (c == "*") {
13240 return ["*", "\\*"];
13241 }
13242 else if (c == "+") {
13243 return ["+", "\\+"];
13244 }
13245 else if (c == "=") {
13246 return ["=", "\\="];
13247 }
13248 else if (c == "?") {
13249 return ["?", "\\?"];
13250 }
13251 else if (c == "{") {
13252 return this.get_token_brace("{");
13253 }
13254 else if (c == "@") {
13255 return this.get_token_at("@");
13256 }
13257 else if (c == "^") {
13258 return ["^", "\\^"];
13259 }
13260 else if (c == "$") {
13261 return ["$", "\\$"];
13262 }
13263 else if (c == ".") {
13264 return [".", "\\."];
13265 }
13266 else if (c == "<") {
13267 return ["<", "\\<"];
13268 }
13269 else if (c == ">") {
13270 return [">", "\\>"];
13271 }
13272 else if (c == "%") {
13273 return this.get_token_percent("%");
13274 }
13275 else if (c == "[") {
13276 return this.get_token_sq("[");
13277 }
13278 else if (c == "~") {
13279 return ["~", "\\~"];
13280 }
13281 else if (c == "|") {
13282 return ["|", "\\|"];
13283 }
13284 else if (c == "&") {
13285 return ["&", "\\&"];
13286 }
13287 else if (c == "(") {
13288 return ["(", "\\("];
13289 }
13290 else if (c == ")") {
13291 return [")", "\\)"];
13292 }
13293 return [c, c];
13294}
13295
13296RegexpParser.prototype.get_token_magic = function() {
13297 if (this.isend(this.reader.peek())) {
13298 return ["<END>", "<END>"];
13299 }
13300 var c = this.reader.get();
13301 if (c == "\\") {
13302 var pos = this.reader.tell();
13303 var c = this.reader.get();
13304 if (c == "+") {
13305 return ["\\+", "\\+"];
13306 }
13307 else if (c == "=") {
13308 return ["\\=", "\\="];
13309 }
13310 else if (c == "?") {
13311 return ["\\?", "\\?"];
13312 }
13313 else if (c == "{") {
13314 return this.get_token_brace("\\{");
13315 }
13316 else if (c == "@") {
13317 return this.get_token_at("\\@");
13318 }
13319 else if (c == "<") {
13320 return ["\\<", "\\<"];
13321 }
13322 else if (c == ">") {
13323 return ["\\>", "\\>"];
13324 }
13325 else if (c == "%") {
13326 return this.get_token_percent("\\%");
13327 }
13328 else if (c == "|") {
13329 return ["\\|", "\\|"];
13330 }
13331 else if (c == "&") {
13332 return ["\\&", "\\&"];
13333 }
13334 else if (c == "(") {
13335 return ["\\(", "\\("];
13336 }
13337 else if (c == ")") {
13338 return ["\\)", "\\)"];
13339 }
13340 this.reader.seek_set(pos);
13341 return this.get_token_backslash_common();
13342 }
13343 else if (c == "*") {
13344 return ["*", "\\*"];
13345 }
13346 else if (c == "^") {
13347 return ["^", "\\^"];
13348 }
13349 else if (c == "$") {
13350 return ["$", "\\$"];
13351 }
13352 else if (c == ".") {
13353 return [".", "\\."];
13354 }
13355 else if (c == "[") {
13356 return this.get_token_sq("[");
13357 }
13358 else if (c == "~") {
13359 return ["~", "\\~"];
13360 }
13361 return [c, c];
13362}
13363
13364RegexpParser.prototype.get_token_nomagic = function() {
13365 if (this.isend(this.reader.peek())) {
13366 return ["<END>", "<END>"];
13367 }
13368 var c = this.reader.get();
13369 if (c == "\\") {
13370 var pos = this.reader.tell();
13371 var c = this.reader.get();
13372 if (c == "*") {
13373 return ["\\*", "\\*"];
13374 }
13375 else if (c == "+") {
13376 return ["\\+", "\\+"];
13377 }
13378 else if (c == "=") {
13379 return ["\\=", "\\="];
13380 }
13381 else if (c == "?") {
13382 return ["\\?", "\\?"];
13383 }
13384 else if (c == "{") {
13385 return this.get_token_brace("\\{");
13386 }
13387 else if (c == "@") {
13388 return this.get_token_at("\\@");
13389 }
13390 else if (c == ".") {
13391 return ["\\.", "\\."];
13392 }
13393 else if (c == "<") {
13394 return ["\\<", "\\<"];
13395 }
13396 else if (c == ">") {
13397 return ["\\>", "\\>"];
13398 }
13399 else if (c == "%") {
13400 return this.get_token_percent("\\%");
13401 }
13402 else if (c == "~") {
13403 return ["\\~", "\\^"];
13404 }
13405 else if (c == "[") {
13406 return this.get_token_sq("\\[");
13407 }
13408 else if (c == "|") {
13409 return ["\\|", "\\|"];
13410 }
13411 else if (c == "&") {
13412 return ["\\&", "\\&"];
13413 }
13414 else if (c == "(") {
13415 return ["\\(", "\\("];
13416 }
13417 else if (c == ")") {
13418 return ["\\)", "\\)"];
13419 }
13420 this.reader.seek_set(pos);
13421 return this.get_token_backslash_common();
13422 }
13423 else if (c == "^") {
13424 return ["^", "\\^"];
13425 }
13426 else if (c == "$") {
13427 return ["$", "\\$"];
13428 }
13429 return [c, c];
13430}
13431
13432RegexpParser.prototype.get_token_very_nomagic = function() {
13433 if (this.isend(this.reader.peek())) {
13434 return ["<END>", "<END>"];
13435 }
13436 var c = this.reader.get();
13437 if (c == "\\") {
13438 var pos = this.reader.tell();
13439 var c = this.reader.get();
13440 if (c == "*") {
13441 return ["\\*", "\\*"];
13442 }
13443 else if (c == "+") {
13444 return ["\\+", "\\+"];
13445 }
13446 else if (c == "=") {
13447 return ["\\=", "\\="];
13448 }
13449 else if (c == "?") {
13450 return ["\\?", "\\?"];
13451 }
13452 else if (c == "{") {
13453 return this.get_token_brace("\\{");
13454 }
13455 else if (c == "@") {
13456 return this.get_token_at("\\@");
13457 }
13458 else if (c == "^") {
13459 return ["\\^", "\\^"];
13460 }
13461 else if (c == "$") {
13462 return ["\\$", "\\$"];
13463 }
13464 else if (c == "<") {
13465 return ["\\<", "\\<"];
13466 }
13467 else if (c == ">") {
13468 return ["\\>", "\\>"];
13469 }
13470 else if (c == "%") {
13471 return this.get_token_percent("\\%");
13472 }
13473 else if (c == "~") {
13474 return ["\\~", "\\~"];
13475 }
13476 else if (c == "[") {
13477 return this.get_token_sq("\\[");
13478 }
13479 else if (c == "|") {
13480 return ["\\|", "\\|"];
13481 }
13482 else if (c == "&") {
13483 return ["\\&", "\\&"];
13484 }
13485 else if (c == "(") {
13486 return ["\\(", "\\("];
13487 }
13488 else if (c == ")") {
13489 return ["\\)", "\\)"];
13490 }
13491 this.reader.seek_set(pos);
13492 return this.get_token_backslash_common();
13493 }
13494 return [c, c];
13495}
13496
13497RegexpParser.prototype.get_token_backslash_common = function() {
13498 var cclass = "iIkKfFpPsSdDxXoOwWhHaAlLuU";
13499 var c = this.reader.get();
13500 if (c == "\\") {
13501 return ["\\\\", "\\\\"];
13502 }
13503 else if (viml_stridx(cclass, c) != -1) {
13504 return ["\\" + c, "\\" + c];
13505 }
13506 else if (c == "_") {
13507 var epos = this.reader.getpos();
13508 var c = this.reader.get();
13509 if (viml_stridx(cclass, c) != -1) {
13510 return ["\\_" + c, "\\_ . c"];
13511 }
13512 else if (c == "^") {
13513 return ["\\_^", "\\_^"];
13514 }
13515 else if (c == "$") {
13516 return ["\\_$", "\\_$"];
13517 }
13518 else if (c == ".") {
13519 return ["\\_.", "\\_."];
13520 }
13521 else if (c == "[") {
13522 return this.get_token_sq("\\_[");
13523 }
13524 throw Err("E63: invalid use of \\_", epos);
13525 }
13526 else if (viml_stridx("etrb", c) != -1) {
13527 return ["\\" + c, "\\" + c];
13528 }
13529 else if (viml_stridx("123456789", c) != -1) {
13530 return ["\\" + c, "\\" + c];
13531 }
13532 else if (c == "z") {
13533 var epos = this.reader.getpos();
13534 var c = this.reader.get();
13535 if (viml_stridx("123456789", c) != -1) {
13536 return ["\\z" + c, "\\z" + c];
13537 }
13538 else if (c == "s") {
13539 return ["\\zs", "\\zs"];
13540 }
13541 else if (c == "e") {
13542 return ["\\ze", "\\ze"];
13543 }
13544 else if (c == "(") {
13545 return ["\\z(", "\\z("];
13546 }
13547 throw Err("E68: Invalid character after \\z", epos);
13548 }
13549 else if (viml_stridx("cCmMvVZ", c) != -1) {
13550 return ["\\" + c, "\\" + c];
13551 }
13552 else if (c == "%") {
13553 var epos = this.reader.getpos();
13554 var c = this.reader.get();
13555 if (c == "d") {
13556 var r = this.getdecchrs();
13557 if (r != "") {
13558 return ["\\%d" + r, "\\%d" + r];
13559 }
13560 }
13561 else if (c == "o") {
13562 var r = this.getoctchrs();
13563 if (r != "") {
13564 return ["\\%o" + r, "\\%o" + r];
13565 }
13566 }
13567 else if (c == "x") {
13568 var r = this.gethexchrs(2);
13569 if (r != "") {
13570 return ["\\%x" + r, "\\%x" + r];
13571 }
13572 }
13573 else if (c == "u") {
13574 var r = this.gethexchrs(4);
13575 if (r != "") {
13576 return ["\\%u" + r, "\\%u" + r];
13577 }
13578 }
13579 else if (c == "U") {
13580 var r = this.gethexchrs(8);
13581 if (r != "") {
13582 return ["\\%U" + r, "\\%U" + r];
13583 }
13584 }
13585 throw Err("E678: Invalid character after \\%[dxouU]", epos);
13586 }
13587 return ["\\" + c, c];
13588}
13589
13590// \{}
13591RegexpParser.prototype.get_token_brace = function(pre) {
13592 var r = "";
13593 var minus = "";
13594 var comma = "";
13595 var n = "";
13596 var m = "";
13597 if (this.reader.p(0) == "-") {
13598 var minus = this.reader.get();
13599 r += minus;
13600 }
13601 if (isdigit(this.reader.p(0))) {
13602 var n = this.reader.read_digit();
13603 r += n;
13604 }
13605 if (this.reader.p(0) == ",") {
13606 var comma = this.rader.get();
13607 r += comma;
13608 }
13609 if (isdigit(this.reader.p(0))) {
13610 var m = this.reader.read_digit();
13611 r += m;
13612 }
13613 if (this.reader.p(0) == "\\") {
13614 r += this.reader.get();
13615 }
13616 if (this.reader.p(0) != "}") {
13617 throw Err("E554: Syntax error in \\{...}", this.reader.getpos());
13618 }
13619 this.reader.get();
13620 return [pre + r, "\\{" + minus + n + comma + m + "}"];
13621}
13622
13623// \[]
13624RegexpParser.prototype.get_token_sq = function(pre) {
13625 var start = this.reader.tell();
13626 var r = "";
13627 // Complement of range
13628 if (this.reader.p(0) == "^") {
13629 r += this.reader.get();
13630 }
13631 // At the start ']' and '-' mean the literal character.
13632 if (this.reader.p(0) == "]" || this.reader.p(0) == "-") {
13633 r += this.reader.get();
13634 }
13635 while (TRUE) {
13636 var startc = 0;
13637 var c = this.reader.p(0);
13638 if (this.isend(c)) {
13639 // If there is no matching ']', we assume the '[' is a normal character.
13640 this.reader.seek_set(start);
13641 return [pre, "["];
13642 }
13643 else if (c == "]") {
13644 this.reader.seek_cur(1);
13645 return [pre + r + "]", "\\[" + r + "]"];
13646 }
13647 else if (c == "[") {
13648 var e = this.get_token_sq_char_class();
13649 if (e == "") {
13650 var e = this.get_token_sq_equi_class();
13651 if (e == "") {
13652 var e = this.get_token_sq_coll_element();
13653 if (e == "") {
13654 var __tmp = this.get_token_sq_c();
13655 var e = __tmp[0];
13656 var startc = __tmp[1];
13657 }
13658 }
13659 }
13660 r += e;
13661 }
13662 else {
13663 var __tmp = this.get_token_sq_c();
13664 var e = __tmp[0];
13665 var startc = __tmp[1];
13666 r += e;
13667 }
13668 if (startc != 0 && this.reader.p(0) == "-" && !this.isend(this.reader.p(1)) && !(this.reader.p(1) == "\\" && this.reader.p(2) == "n")) {
13669 this.reader.seek_cur(1);
13670 r += "-";
13671 var c = this.reader.p(0);
13672 if (c == "[") {
13673 var e = this.get_token_sq_coll_element();
13674 if (e != "") {
13675 var endc = viml_char2nr(e[2]);
13676 }
13677 else {
13678 var __tmp = this.get_token_sq_c();
13679 var e = __tmp[0];
13680 var endc = __tmp[1];
13681 }
13682 r += e;
13683 }
13684 else {
13685 var __tmp = this.get_token_sq_c();
13686 var e = __tmp[0];
13687 var endc = __tmp[1];
13688 r += e;
13689 }
13690 if (startc > endc || endc > startc + 256) {
13691 throw Err("E16: Invalid range", this.reader.getpos());
13692 }
13693 }
13694 }
13695}
13696
13697// [c]
13698RegexpParser.prototype.get_token_sq_c = function() {
13699 var c = this.reader.p(0);
13700 if (c == "\\") {
13701 this.reader.seek_cur(1);
13702 var c = this.reader.p(0);
13703 if (c == "n") {
13704 this.reader.seek_cur(1);
13705 return ["\\n", 0];
13706 }
13707 else if (c == "r") {
13708 this.reader.seek_cur(1);
13709 return ["\\r", 13];
13710 }
13711 else if (c == "t") {
13712 this.reader.seek_cur(1);
13713 return ["\\t", 9];
13714 }
13715 else if (c == "e") {
13716 this.reader.seek_cur(1);
13717 return ["\\e", 27];
13718 }
13719 else if (c == "b") {
13720 this.reader.seek_cur(1);
13721 return ["\\b", 8];
13722 }
13723 else if (viml_stridx("]^-\\", c) != -1) {
13724 this.reader.seek_cur(1);
13725 return ["\\" + c, viml_char2nr(c)];
13726 }
13727 else if (viml_stridx("doxuU", c) != -1) {
13728 var __tmp = this.get_token_sq_coll_char();
13729 var c = __tmp[0];
13730 var n = __tmp[1];
13731 return [c, n];
13732 }
13733 else {
13734 return ["\\", viml_char2nr("\\")];
13735 }
13736 }
13737 else if (c == "-") {
13738 this.reader.seek_cur(1);
13739 return ["-", viml_char2nr("-")];
13740 }
13741 else {
13742 this.reader.seek_cur(1);
13743 return [c, viml_char2nr(c)];
13744 }
13745}
13746
13747// [\d123]
13748RegexpParser.prototype.get_token_sq_coll_char = function() {
13749 var pos = this.reader.tell();
13750 var c = this.reader.get();
13751 if (c == "d") {
13752 var r = this.getdecchrs();
13753 var n = viml_str2nr(r, 10);
13754 }
13755 else if (c == "o") {
13756 var r = this.getoctchrs();
13757 var n = viml_str2nr(r, 8);
13758 }
13759 else if (c == "x") {
13760 var r = this.gethexchrs(2);
13761 var n = viml_str2nr(r, 16);
13762 }
13763 else if (c == "u") {
13764 var r = this.gethexchrs(4);
13765 var n = viml_str2nr(r, 16);
13766 }
13767 else if (c == "U") {
13768 var r = this.gethexchrs(8);
13769 var n = viml_str2nr(r, 16);
13770 }
13771 else {
13772 var r = "";
13773 }
13774 if (r == "") {
13775 this.reader.seek_set(pos);
13776 return "\\";
13777 }
13778 return ["\\" + c + r, n];
13779}
13780
13781// [[.a.]]
13782RegexpParser.prototype.get_token_sq_coll_element = function() {
13783 if (this.reader.p(0) == "[" && this.reader.p(1) == "." && !this.isend(this.reader.p(2)) && this.reader.p(3) == "." && this.reader.p(4) == "]") {
13784 return this.reader.getn(5);
13785 }
13786 return "";
13787}
13788
13789// [[=a=]]
13790RegexpParser.prototype.get_token_sq_equi_class = function() {
13791 if (this.reader.p(0) == "[" && this.reader.p(1) == "=" && !this.isend(this.reader.p(2)) && this.reader.p(3) == "=" && this.reader.p(4) == "]") {
13792 return this.reader.getn(5);
13793 }
13794 return "";
13795}
13796
13797// [[:alpha:]]
13798RegexpParser.prototype.get_token_sq_char_class = function() {
13799 var class_names = ["alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "xdigit", "tab", "return", "backspace", "escape"];
13800 var pos = this.reader.tell();
13801 if (this.reader.p(0) == "[" && this.reader.p(1) == ":") {
13802 this.reader.seek_cur(2);
13803 var r = this.reader.read_alpha();
13804 if (this.reader.p(0) == ":" && this.reader.p(1) == "]") {
13805 this.reader.seek_cur(2);
13806 var __c15 = class_names;
13807 for (var __i15 = 0; __i15 < __c15.length; ++__i15) {
13808 var name = __c15[__i15];
13809 if (r == name) {
13810 return "[:" + name + ":]";
13811 }
13812 }
13813 }
13814 }
13815 this.reader.seek_set(pos);
13816 return "";
13817}
13818
13819// \@...
13820RegexpParser.prototype.get_token_at = function(pre) {
13821 var epos = this.reader.getpos();
13822 var c = this.reader.get();
13823 if (c == ">") {
13824 return [pre + ">", "\\@>"];
13825 }
13826 else if (c == "=") {
13827 return [pre + "=", "\\@="];
13828 }
13829 else if (c == "!") {
13830 return [pre + "!", "\\@!"];
13831 }
13832 else if (c == "<") {
13833 var c = this.reader.get();
13834 if (c == "=") {
13835 return [pre + "<=", "\\@<="];
13836 }
13837 else if (c == "!") {
13838 return [pre + "<!", "\\@<!"];
13839 }
13840 }
13841 throw Err("E64: @ follows nothing", epos);
13842}
13843
13844// \%...
13845RegexpParser.prototype.get_token_percent = function(pre) {
13846 var c = this.reader.get();
13847 if (c == "^") {
13848 return [pre + "^", "\\%^"];
13849 }
13850 else if (c == "$") {
13851 return [pre + "$", "\\%$"];
13852 }
13853 else if (c == "V") {
13854 return [pre + "V", "\\%V"];
13855 }
13856 else if (c == "#") {
13857 return [pre + "#", "\\%#"];
13858 }
13859 else if (c == "[") {
13860 return this.get_token_percent_sq(pre + "[");
13861 }
13862 else if (c == "(") {
13863 return [pre + "(", "\\%("];
13864 }
13865 else {
13866 return this.get_token_mlcv(pre);
13867 }
13868}
13869
13870// \%[]
13871RegexpParser.prototype.get_token_percent_sq = function(pre) {
13872 var r = "";
13873 while (TRUE) {
13874 var c = this.reader.peek();
13875 if (this.isend(c)) {
13876 throw Err("E69: Missing ] after \\%[", this.reader.getpos());
13877 }
13878 else if (c == "]") {
13879 if (r == "") {
13880 throw Err("E70: Empty \\%[", this.reader.getpos());
13881 }
13882 this.reader.seek_cur(1);
13883 break;
13884 }
13885 this.reader.seek_cur(1);
13886 r += c;
13887 }
13888 return [pre + r + "]", "\\%[" + r + "]"];
13889}
13890
13891// \%'m \%l \%c \%v
13892RegexpParser.prototype.get_token_mlvc = function(pre) {
13893 var r = "";
13894 var cmp = "";
13895 if (this.reader.p(0) == "<" || this.reader.p(0) == ">") {
13896 var cmp = this.reader.get();
13897 r += cmp;
13898 }
13899 if (this.reader.p(0) == "'") {
13900 r += this.reader.get();
13901 var c = this.reader.p(0);
13902 if (this.isend(c)) {
13903 // FIXME: Should be error? Vim allow this.
13904 var c = "";
13905 }
13906 else {
13907 var c = this.reader.get();
13908 }
13909 return [pre + r + c, "\\%" + cmp + "'" + c];
13910 }
13911 else if (isdigit(this.reader.p(0))) {
13912 var d = this.reader.read_digit();
13913 r += d;
13914 var c = this.reader.p(0);
13915 if (c == "l") {
13916 this.reader.get();
13917 return [pre + r + "l", "\\%" + cmp + d + "l"];
13918 }
13919 else if (c == "c") {
13920 this.reader.get();
13921 return [pre + r + "c", "\\%" + cmp + d + "c"];
13922 }
13923 else if (c == "v") {
13924 this.reader.get();
13925 return [pre + r + "v", "\\%" + cmp + d + "v"];
13926 }
13927 }
13928 throw Err("E71: Invalid character after %", this.reader.getpos());
13929}
13930
13931RegexpParser.prototype.getdecchrs = function() {
13932 return this.reader.read_digit();
13933}
13934
13935RegexpParser.prototype.getoctchrs = function() {
13936 return this.reader.read_odigit();
13937}
13938
13939RegexpParser.prototype.gethexchrs = function(n) {
13940 var r = "";
13941 var __c16 = viml_range(n);
13942 for (var __i16 = 0; __i16 < __c16.length; ++__i16) {
13943 var i = __c16[__i16];
13944 var c = this.reader.peek();
13945 if (!isxdigit(c)) {
13946 break;
13947 }
13948 r += this.reader.get();
13949 }
13950 return r;
13951}
13952
13953if (__webpack_require__.c[__webpack_require__.s] === module) {
13954 main();
13955}
13956else {
13957 module.exports = {
13958 VimLParser: VimLParser,
13959 StringReader: StringReader,
13960 Compiler: Compiler
13961 };
13962}
13963
13964/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(54)(module)))
13965
13966/***/ }),
13967
13968/***/ 54:
13969/***/ (function(module, exports) {
13970
13971module.exports = function(module) {
13972 if (!module.webpackPolyfill) {
13973 module.deprecate = function() {};
13974 module.paths = [];
13975 // module.parent = undefined by default
13976 if (!module.children) module.children = [];
13977 Object.defineProperty(module, "loaded", {
13978 enumerable: true,
13979 get: function() {
13980 return module.l;
13981 }
13982 });
13983 Object.defineProperty(module, "id", {
13984 enumerable: true,
13985 get: function() {
13986 return module.i;
13987 }
13988 });
13989 module.webpackPolyfill = 1;
13990 }
13991 return module;
13992};
13993
13994
13995/***/ }),
13996
13997/***/ 55:
13998/***/ (function(module, exports, __webpack_require__) {
13999
14000"use strict";
14001
14002Object.defineProperty(exports, "__esModule", { value: true });
14003exports.errorLinePattern = /[^:]+:\s*(.+?):\s*line\s*([0-9]+)\s*col\s*([0-9]+)/;
14004exports.commentPattern = /^[ \t]*("|')/;
14005exports.keywordPattern = /[\w#&$<>.:]/;
14006exports.builtinFunctionPattern = /^((<SID>|\b(v|g|b|s|l|a):)?[\w#&]+)[ \t]*\([^)]*\)/;
14007exports.wordPrePattern = /^.*?(((<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+)|(<SID>|<SID|<SI|<S|<|\b(v|g|b|s|l|a):))$/;
14008exports.wordNextPattern = /^((SID>|ID>|D>|>|<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+|(:[\w#&$.]+)).*?(\r\n|\r|\n)?$/;
14009exports.colorschemePattern = /\bcolorscheme[ \t]+\w*$/;
14010exports.mapCommandPattern = /^([ \t]*(\[ \t]*)?)\w*map[ \t]+/;
14011exports.highlightLinkPattern = /^[ \t]*(hi|highlight)[ \t]+link([ \t]+[^ \t]+)*[ \t]*$/;
14012exports.highlightPattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]*$/;
14013exports.highlightValuePattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]+([^ \t=]+)=[^ \t=]*$/;
14014exports.autocmdPattern = /^[ \t]*(au|autocmd)!?[ \t]+([^ \t,]+,)*[^ \t,]*$/;
14015exports.builtinVariablePattern = [
14016 /\bv:\w*$/,
14017];
14018exports.optionPattern = [
14019 /(^|[ \t]+)&\w*$/,
14020 /(^|[ \t]+)set(l|local|g|global)?[ \t]+\w+$/,
14021];
14022exports.notFunctionPattern = [
14023 /^[ \t]*\\$/,
14024 /^[ \t]*\w+$/,
14025 /^[ \t]*"/,
14026 /(let|set|colorscheme)[ \t][^ \t]*$/,
14027 /[^([,\\ \t\w#>]\w*$/,
14028 /^[ \t]*(hi|highlight)([ \t]+link)?([ \t]+[^ \t]+)*[ \t]*$/,
14029 exports.autocmdPattern,
14030];
14031exports.commandPattern = [
14032 /(^|[ \t]):\w+$/,
14033 /^[ \t]*\w+$/,
14034 /:?silent!?[ \t]\w+/,
14035];
14036exports.featurePattern = [
14037 /\bhas\([ \t]*["']\w*/,
14038];
14039exports.expandPattern = [
14040 /\bexpand\(['"]<\w*$/,
14041 /\bexpand\([ \t]*['"]\w*$/,
14042];
14043exports.notIdentifierPattern = [
14044 exports.commentPattern,
14045 /("|'):\w*$/,
14046 /^[ \t]*\\$/,
14047 /^[ \t]*call[ \t]+[^ \t()]*$/,
14048 /('|"|#|&|\$|<)\w*$/,
14049];
14050
14051
14052/***/ }),
14053
14054/***/ 6:
14055/***/ (function(module, exports, __webpack_require__) {
14056
14057"use strict";
14058/* --------------------------------------------------------------------------------------------
14059 * Copyright (c) Microsoft Corporation. All rights reserved.
14060 * Licensed under the MIT License. See License.txt in the project root for license information.
14061 * ------------------------------------------------------------------------------------------ */
14062
14063Object.defineProperty(exports, "__esModule", { value: true });
14064const is = __webpack_require__(5);
14065/**
14066 * Predefined error codes.
14067 */
14068var ErrorCodes;
14069(function (ErrorCodes) {
14070 // Defined by JSON RPC
14071 ErrorCodes.ParseError = -32700;
14072 ErrorCodes.InvalidRequest = -32600;
14073 ErrorCodes.MethodNotFound = -32601;
14074 ErrorCodes.InvalidParams = -32602;
14075 ErrorCodes.InternalError = -32603;
14076 ErrorCodes.serverErrorStart = -32099;
14077 ErrorCodes.serverErrorEnd = -32000;
14078 ErrorCodes.ServerNotInitialized = -32002;
14079 ErrorCodes.UnknownErrorCode = -32001;
14080 // Defined by the protocol.
14081 ErrorCodes.RequestCancelled = -32800;
14082 ErrorCodes.ContentModified = -32801;
14083 // Defined by VSCode library.
14084 ErrorCodes.MessageWriteError = 1;
14085 ErrorCodes.MessageReadError = 2;
14086})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
14087/**
14088 * An error object return in a response in case a request
14089 * has failed.
14090 */
14091class ResponseError extends Error {
14092 constructor(code, message, data) {
14093 super(message);
14094 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
14095 this.data = data;
14096 Object.setPrototypeOf(this, ResponseError.prototype);
14097 }
14098 toJson() {
14099 return {
14100 code: this.code,
14101 message: this.message,
14102 data: this.data,
14103 };
14104 }
14105}
14106exports.ResponseError = ResponseError;
14107/**
14108 * An abstract implementation of a MessageType.
14109 */
14110class AbstractMessageType {
14111 constructor(_method, _numberOfParams) {
14112 this._method = _method;
14113 this._numberOfParams = _numberOfParams;
14114 }
14115 get method() {
14116 return this._method;
14117 }
14118 get numberOfParams() {
14119 return this._numberOfParams;
14120 }
14121}
14122exports.AbstractMessageType = AbstractMessageType;
14123/**
14124 * Classes to type request response pairs
14125 *
14126 * The type parameter RO will be removed in the next major version
14127 * of the JSON RPC library since it is a LSP concept and doesn't
14128 * belong here. For now it is tagged as default never.
14129 */
14130class RequestType0 extends AbstractMessageType {
14131 constructor(method) {
14132 super(method, 0);
14133 }
14134}
14135exports.RequestType0 = RequestType0;
14136class RequestType extends AbstractMessageType {
14137 constructor(method) {
14138 super(method, 1);
14139 }
14140}
14141exports.RequestType = RequestType;
14142class RequestType1 extends AbstractMessageType {
14143 constructor(method) {
14144 super(method, 1);
14145 }
14146}
14147exports.RequestType1 = RequestType1;
14148class RequestType2 extends AbstractMessageType {
14149 constructor(method) {
14150 super(method, 2);
14151 }
14152}
14153exports.RequestType2 = RequestType2;
14154class RequestType3 extends AbstractMessageType {
14155 constructor(method) {
14156 super(method, 3);
14157 }
14158}
14159exports.RequestType3 = RequestType3;
14160class RequestType4 extends AbstractMessageType {
14161 constructor(method) {
14162 super(method, 4);
14163 }
14164}
14165exports.RequestType4 = RequestType4;
14166class RequestType5 extends AbstractMessageType {
14167 constructor(method) {
14168 super(method, 5);
14169 }
14170}
14171exports.RequestType5 = RequestType5;
14172class RequestType6 extends AbstractMessageType {
14173 constructor(method) {
14174 super(method, 6);
14175 }
14176}
14177exports.RequestType6 = RequestType6;
14178class RequestType7 extends AbstractMessageType {
14179 constructor(method) {
14180 super(method, 7);
14181 }
14182}
14183exports.RequestType7 = RequestType7;
14184class RequestType8 extends AbstractMessageType {
14185 constructor(method) {
14186 super(method, 8);
14187 }
14188}
14189exports.RequestType8 = RequestType8;
14190class RequestType9 extends AbstractMessageType {
14191 constructor(method) {
14192 super(method, 9);
14193 }
14194}
14195exports.RequestType9 = RequestType9;
14196/**
14197 * The type parameter RO will be removed in the next major version
14198 * of the JSON RPC library since it is a LSP concept and doesn't
14199 * belong here. For now it is tagged as default never.
14200 */
14201class NotificationType extends AbstractMessageType {
14202 constructor(method) {
14203 super(method, 1);
14204 this._ = undefined;
14205 }
14206}
14207exports.NotificationType = NotificationType;
14208class NotificationType0 extends AbstractMessageType {
14209 constructor(method) {
14210 super(method, 0);
14211 }
14212}
14213exports.NotificationType0 = NotificationType0;
14214class NotificationType1 extends AbstractMessageType {
14215 constructor(method) {
14216 super(method, 1);
14217 }
14218}
14219exports.NotificationType1 = NotificationType1;
14220class NotificationType2 extends AbstractMessageType {
14221 constructor(method) {
14222 super(method, 2);
14223 }
14224}
14225exports.NotificationType2 = NotificationType2;
14226class NotificationType3 extends AbstractMessageType {
14227 constructor(method) {
14228 super(method, 3);
14229 }
14230}
14231exports.NotificationType3 = NotificationType3;
14232class NotificationType4 extends AbstractMessageType {
14233 constructor(method) {
14234 super(method, 4);
14235 }
14236}
14237exports.NotificationType4 = NotificationType4;
14238class NotificationType5 extends AbstractMessageType {
14239 constructor(method) {
14240 super(method, 5);
14241 }
14242}
14243exports.NotificationType5 = NotificationType5;
14244class NotificationType6 extends AbstractMessageType {
14245 constructor(method) {
14246 super(method, 6);
14247 }
14248}
14249exports.NotificationType6 = NotificationType6;
14250class NotificationType7 extends AbstractMessageType {
14251 constructor(method) {
14252 super(method, 7);
14253 }
14254}
14255exports.NotificationType7 = NotificationType7;
14256class NotificationType8 extends AbstractMessageType {
14257 constructor(method) {
14258 super(method, 8);
14259 }
14260}
14261exports.NotificationType8 = NotificationType8;
14262class NotificationType9 extends AbstractMessageType {
14263 constructor(method) {
14264 super(method, 9);
14265 }
14266}
14267exports.NotificationType9 = NotificationType9;
14268/**
14269 * Tests if the given message is a request message
14270 */
14271function isRequestMessage(message) {
14272 let candidate = message;
14273 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
14274}
14275exports.isRequestMessage = isRequestMessage;
14276/**
14277 * Tests if the given message is a notification message
14278 */
14279function isNotificationMessage(message) {
14280 let candidate = message;
14281 return candidate && is.string(candidate.method) && message.id === void 0;
14282}
14283exports.isNotificationMessage = isNotificationMessage;
14284/**
14285 * Tests if the given message is a response message
14286 */
14287function isResponseMessage(message) {
14288 let candidate = message;
14289 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
14290}
14291exports.isResponseMessage = isResponseMessage;
14292
14293
14294/***/ }),
14295
14296/***/ 7:
14297/***/ (function(module, exports, __webpack_require__) {
14298
14299"use strict";
14300/* --------------------------------------------------------------------------------------------
14301 * Copyright (c) Microsoft Corporation. All rights reserved.
14302 * Licensed under the MIT License. See License.txt in the project root for license information.
14303 * ------------------------------------------------------------------------------------------ */
14304
14305Object.defineProperty(exports, "__esModule", { value: true });
14306const events_1 = __webpack_require__(8);
14307const Is = __webpack_require__(5);
14308let DefaultSize = 8192;
14309let CR = Buffer.from('\r', 'ascii')[0];
14310let LF = Buffer.from('\n', 'ascii')[0];
14311let CRLF = '\r\n';
14312class MessageBuffer {
14313 constructor(encoding = 'utf8') {
14314 this.encoding = encoding;
14315 this.index = 0;
14316 this.buffer = Buffer.allocUnsafe(DefaultSize);
14317 }
14318 append(chunk) {
14319 var toAppend = chunk;
14320 if (typeof (chunk) === 'string') {
14321 var str = chunk;
14322 var bufferLen = Buffer.byteLength(str, this.encoding);
14323 toAppend = Buffer.allocUnsafe(bufferLen);
14324 toAppend.write(str, 0, bufferLen, this.encoding);
14325 }
14326 if (this.buffer.length - this.index >= toAppend.length) {
14327 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
14328 }
14329 else {
14330 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
14331 if (this.index === 0) {
14332 this.buffer = Buffer.allocUnsafe(newSize);
14333 toAppend.copy(this.buffer, 0, 0, toAppend.length);
14334 }
14335 else {
14336 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
14337 }
14338 }
14339 this.index += toAppend.length;
14340 }
14341 tryReadHeaders() {
14342 let result = undefined;
14343 let current = 0;
14344 while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {
14345 current++;
14346 }
14347 // No header / body separator found (e.g CRLFCRLF)
14348 if (current + 3 >= this.index) {
14349 return result;
14350 }
14351 result = Object.create(null);
14352 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
14353 headers.forEach((header) => {
14354 let index = header.indexOf(':');
14355 if (index === -1) {
14356 throw new Error('Message header must separate key and value using :');
14357 }
14358 let key = header.substr(0, index);
14359 let value = header.substr(index + 1).trim();
14360 result[key] = value;
14361 });
14362 let nextStart = current + 4;
14363 this.buffer = this.buffer.slice(nextStart);
14364 this.index = this.index - nextStart;
14365 return result;
14366 }
14367 tryReadContent(length) {
14368 if (this.index < length) {
14369 return null;
14370 }
14371 let result = this.buffer.toString(this.encoding, 0, length);
14372 let nextStart = length;
14373 this.buffer.copy(this.buffer, 0, nextStart);
14374 this.index = this.index - nextStart;
14375 return result;
14376 }
14377 get numberOfBytes() {
14378 return this.index;
14379 }
14380}
14381var MessageReader;
14382(function (MessageReader) {
14383 function is(value) {
14384 let candidate = value;
14385 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
14386 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
14387 }
14388 MessageReader.is = is;
14389})(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
14390class AbstractMessageReader {
14391 constructor() {
14392 this.errorEmitter = new events_1.Emitter();
14393 this.closeEmitter = new events_1.Emitter();
14394 this.partialMessageEmitter = new events_1.Emitter();
14395 }
14396 dispose() {
14397 this.errorEmitter.dispose();
14398 this.closeEmitter.dispose();
14399 }
14400 get onError() {
14401 return this.errorEmitter.event;
14402 }
14403 fireError(error) {
14404 this.errorEmitter.fire(this.asError(error));
14405 }
14406 get onClose() {
14407 return this.closeEmitter.event;
14408 }
14409 fireClose() {
14410 this.closeEmitter.fire(undefined);
14411 }
14412 get onPartialMessage() {
14413 return this.partialMessageEmitter.event;
14414 }
14415 firePartialMessage(info) {
14416 this.partialMessageEmitter.fire(info);
14417 }
14418 asError(error) {
14419 if (error instanceof Error) {
14420 return error;
14421 }
14422 else {
14423 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
14424 }
14425 }
14426}
14427exports.AbstractMessageReader = AbstractMessageReader;
14428class StreamMessageReader extends AbstractMessageReader {
14429 constructor(readable, encoding = 'utf8') {
14430 super();
14431 this.readable = readable;
14432 this.buffer = new MessageBuffer(encoding);
14433 this._partialMessageTimeout = 10000;
14434 }
14435 set partialMessageTimeout(timeout) {
14436 this._partialMessageTimeout = timeout;
14437 }
14438 get partialMessageTimeout() {
14439 return this._partialMessageTimeout;
14440 }
14441 listen(callback) {
14442 this.nextMessageLength = -1;
14443 this.messageToken = 0;
14444 this.partialMessageTimer = undefined;
14445 this.callback = callback;
14446 this.readable.on('data', (data) => {
14447 this.onData(data);
14448 });
14449 this.readable.on('error', (error) => this.fireError(error));
14450 this.readable.on('close', () => this.fireClose());
14451 }
14452 onData(data) {
14453 this.buffer.append(data);
14454 while (true) {
14455 if (this.nextMessageLength === -1) {
14456 let headers = this.buffer.tryReadHeaders();
14457 if (!headers) {
14458 return;
14459 }
14460 let contentLength = headers['Content-Length'];
14461 if (!contentLength) {
14462 throw new Error('Header must provide a Content-Length property.');
14463 }
14464 let length = parseInt(contentLength);
14465 if (isNaN(length)) {
14466 throw new Error('Content-Length value must be a number.');
14467 }
14468 this.nextMessageLength = length;
14469 // Take the encoding form the header. For compatibility
14470 // treat both utf-8 and utf8 as node utf8
14471 }
14472 var msg = this.buffer.tryReadContent(this.nextMessageLength);
14473 if (msg === null) {
14474 /** We haven't received the full message yet. */
14475 this.setPartialMessageTimer();
14476 return;
14477 }
14478 this.clearPartialMessageTimer();
14479 this.nextMessageLength = -1;
14480 this.messageToken++;
14481 var json = JSON.parse(msg);
14482 this.callback(json);
14483 }
14484 }
14485 clearPartialMessageTimer() {
14486 if (this.partialMessageTimer) {
14487 clearTimeout(this.partialMessageTimer);
14488 this.partialMessageTimer = undefined;
14489 }
14490 }
14491 setPartialMessageTimer() {
14492 this.clearPartialMessageTimer();
14493 if (this._partialMessageTimeout <= 0) {
14494 return;
14495 }
14496 this.partialMessageTimer = setTimeout((token, timeout) => {
14497 this.partialMessageTimer = undefined;
14498 if (token === this.messageToken) {
14499 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
14500 this.setPartialMessageTimer();
14501 }
14502 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
14503 }
14504}
14505exports.StreamMessageReader = StreamMessageReader;
14506class IPCMessageReader extends AbstractMessageReader {
14507 constructor(process) {
14508 super();
14509 this.process = process;
14510 let eventEmitter = this.process;
14511 eventEmitter.on('error', (error) => this.fireError(error));
14512 eventEmitter.on('close', () => this.fireClose());
14513 }
14514 listen(callback) {
14515 this.process.on('message', callback);
14516 }
14517}
14518exports.IPCMessageReader = IPCMessageReader;
14519class SocketMessageReader extends StreamMessageReader {
14520 constructor(socket, encoding = 'utf-8') {
14521 super(socket, encoding);
14522 }
14523}
14524exports.SocketMessageReader = SocketMessageReader;
14525
14526
14527/***/ }),
14528
14529/***/ 8:
14530/***/ (function(module, exports, __webpack_require__) {
14531
14532"use strict";
14533/* --------------------------------------------------------------------------------------------
14534 * Copyright (c) Microsoft Corporation. All rights reserved.
14535 * Licensed under the MIT License. See License.txt in the project root for license information.
14536 * ------------------------------------------------------------------------------------------ */
14537
14538Object.defineProperty(exports, "__esModule", { value: true });
14539var Disposable;
14540(function (Disposable) {
14541 function create(func) {
14542 return {
14543 dispose: func
14544 };
14545 }
14546 Disposable.create = create;
14547})(Disposable = exports.Disposable || (exports.Disposable = {}));
14548var Event;
14549(function (Event) {
14550 const _disposable = { dispose() { } };
14551 Event.None = function () { return _disposable; };
14552})(Event = exports.Event || (exports.Event = {}));
14553class CallbackList {
14554 add(callback, context = null, bucket) {
14555 if (!this._callbacks) {
14556 this._callbacks = [];
14557 this._contexts = [];
14558 }
14559 this._callbacks.push(callback);
14560 this._contexts.push(context);
14561 if (Array.isArray(bucket)) {
14562 bucket.push({ dispose: () => this.remove(callback, context) });
14563 }
14564 }
14565 remove(callback, context = null) {
14566 if (!this._callbacks) {
14567 return;
14568 }
14569 var foundCallbackWithDifferentContext = false;
14570 for (var i = 0, len = this._callbacks.length; i < len; i++) {
14571 if (this._callbacks[i] === callback) {
14572 if (this._contexts[i] === context) {
14573 // callback & context match => remove it
14574 this._callbacks.splice(i, 1);
14575 this._contexts.splice(i, 1);
14576 return;
14577 }
14578 else {
14579 foundCallbackWithDifferentContext = true;
14580 }
14581 }
14582 }
14583 if (foundCallbackWithDifferentContext) {
14584 throw new Error('When adding a listener with a context, you should remove it with the same context');
14585 }
14586 }
14587 invoke(...args) {
14588 if (!this._callbacks) {
14589 return [];
14590 }
14591 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
14592 for (var i = 0, len = callbacks.length; i < len; i++) {
14593 try {
14594 ret.push(callbacks[i].apply(contexts[i], args));
14595 }
14596 catch (e) {
14597 // eslint-disable-next-line no-console
14598 console.error(e);
14599 }
14600 }
14601 return ret;
14602 }
14603 isEmpty() {
14604 return !this._callbacks || this._callbacks.length === 0;
14605 }
14606 dispose() {
14607 this._callbacks = undefined;
14608 this._contexts = undefined;
14609 }
14610}
14611class Emitter {
14612 constructor(_options) {
14613 this._options = _options;
14614 }
14615 /**
14616 * For the public to allow to subscribe
14617 * to events from this Emitter
14618 */
14619 get event() {
14620 if (!this._event) {
14621 this._event = (listener, thisArgs, disposables) => {
14622 if (!this._callbacks) {
14623 this._callbacks = new CallbackList();
14624 }
14625 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
14626 this._options.onFirstListenerAdd(this);
14627 }
14628 this._callbacks.add(listener, thisArgs);
14629 let result;
14630 result = {
14631 dispose: () => {
14632 this._callbacks.remove(listener, thisArgs);
14633 result.dispose = Emitter._noop;
14634 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
14635 this._options.onLastListenerRemove(this);
14636 }
14637 }
14638 };
14639 if (Array.isArray(disposables)) {
14640 disposables.push(result);
14641 }
14642 return result;
14643 };
14644 }
14645 return this._event;
14646 }
14647 /**
14648 * To be kept private to fire an event to
14649 * subscribers
14650 */
14651 fire(event) {
14652 if (this._callbacks) {
14653 this._callbacks.invoke.call(this._callbacks, event);
14654 }
14655 }
14656 dispose() {
14657 if (this._callbacks) {
14658 this._callbacks.dispose();
14659 this._callbacks = undefined;
14660 }
14661 }
14662}
14663exports.Emitter = Emitter;
14664Emitter._noop = function () { };
14665
14666
14667/***/ }),
14668
14669/***/ 9:
14670/***/ (function(module, exports, __webpack_require__) {
14671
14672"use strict";
14673/* --------------------------------------------------------------------------------------------
14674 * Copyright (c) Microsoft Corporation. All rights reserved.
14675 * Licensed under the MIT License. See License.txt in the project root for license information.
14676 * ------------------------------------------------------------------------------------------ */
14677
14678Object.defineProperty(exports, "__esModule", { value: true });
14679const events_1 = __webpack_require__(8);
14680const Is = __webpack_require__(5);
14681let ContentLength = 'Content-Length: ';
14682let CRLF = '\r\n';
14683var MessageWriter;
14684(function (MessageWriter) {
14685 function is(value) {
14686 let candidate = value;
14687 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
14688 Is.func(candidate.onError) && Is.func(candidate.write);
14689 }
14690 MessageWriter.is = is;
14691})(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
14692class AbstractMessageWriter {
14693 constructor() {
14694 this.errorEmitter = new events_1.Emitter();
14695 this.closeEmitter = new events_1.Emitter();
14696 }
14697 dispose() {
14698 this.errorEmitter.dispose();
14699 this.closeEmitter.dispose();
14700 }
14701 get onError() {
14702 return this.errorEmitter.event;
14703 }
14704 fireError(error, message, count) {
14705 this.errorEmitter.fire([this.asError(error), message, count]);
14706 }
14707 get onClose() {
14708 return this.closeEmitter.event;
14709 }
14710 fireClose() {
14711 this.closeEmitter.fire(undefined);
14712 }
14713 asError(error) {
14714 if (error instanceof Error) {
14715 return error;
14716 }
14717 else {
14718 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
14719 }
14720 }
14721}
14722exports.AbstractMessageWriter = AbstractMessageWriter;
14723class StreamMessageWriter extends AbstractMessageWriter {
14724 constructor(writable, encoding = 'utf8') {
14725 super();
14726 this.writable = writable;
14727 this.encoding = encoding;
14728 this.errorCount = 0;
14729 this.writable.on('error', (error) => this.fireError(error));
14730 this.writable.on('close', () => this.fireClose());
14731 }
14732 write(msg) {
14733 let json = JSON.stringify(msg);
14734 let contentLength = Buffer.byteLength(json, this.encoding);
14735 let headers = [
14736 ContentLength, contentLength.toString(), CRLF,
14737 CRLF
14738 ];
14739 try {
14740 // Header must be written in ASCII encoding
14741 this.writable.write(headers.join(''), 'ascii');
14742 // Now write the content. This can be written in any encoding
14743 this.writable.write(json, this.encoding);
14744 this.errorCount = 0;
14745 }
14746 catch (error) {
14747 this.errorCount++;
14748 this.fireError(error, msg, this.errorCount);
14749 }
14750 }
14751}
14752exports.StreamMessageWriter = StreamMessageWriter;
14753class IPCMessageWriter extends AbstractMessageWriter {
14754 constructor(process) {
14755 super();
14756 this.process = process;
14757 this.errorCount = 0;
14758 this.queue = [];
14759 this.sending = false;
14760 let eventEmitter = this.process;
14761 eventEmitter.on('error', (error) => this.fireError(error));
14762 eventEmitter.on('close', () => this.fireClose);
14763 }
14764 write(msg) {
14765 if (!this.sending && this.queue.length === 0) {
14766 // See https://github.com/nodejs/node/issues/7657
14767 this.doWriteMessage(msg);
14768 }
14769 else {
14770 this.queue.push(msg);
14771 }
14772 }
14773 doWriteMessage(msg) {
14774 try {
14775 if (this.process.send) {
14776 this.sending = true;
14777 this.process.send(msg, undefined, undefined, (error) => {
14778 this.sending = false;
14779 if (error) {
14780 this.errorCount++;
14781 this.fireError(error, msg, this.errorCount);
14782 }
14783 else {
14784 this.errorCount = 0;
14785 }
14786 if (this.queue.length > 0) {
14787 this.doWriteMessage(this.queue.shift());
14788 }
14789 });
14790 }
14791 }
14792 catch (error) {
14793 this.errorCount++;
14794 this.fireError(error, msg, this.errorCount);
14795 }
14796 }
14797}
14798exports.IPCMessageWriter = IPCMessageWriter;
14799class SocketMessageWriter extends AbstractMessageWriter {
14800 constructor(socket, encoding = 'utf8') {
14801 super();
14802 this.socket = socket;
14803 this.queue = [];
14804 this.sending = false;
14805 this.encoding = encoding;
14806 this.errorCount = 0;
14807 this.socket.on('error', (error) => this.fireError(error));
14808 this.socket.on('close', () => this.fireClose());
14809 }
14810 dispose() {
14811 super.dispose();
14812 this.socket.destroy();
14813 }
14814 write(msg) {
14815 if (!this.sending && this.queue.length === 0) {
14816 // See https://github.com/nodejs/node/issues/7657
14817 this.doWriteMessage(msg);
14818 }
14819 else {
14820 this.queue.push(msg);
14821 }
14822 }
14823 doWriteMessage(msg) {
14824 let json = JSON.stringify(msg);
14825 let contentLength = Buffer.byteLength(json, this.encoding);
14826 let headers = [
14827 ContentLength, contentLength.toString(), CRLF,
14828 CRLF
14829 ];
14830 try {
14831 // Header must be written in ASCII encoding
14832 this.sending = true;
14833 this.socket.write(headers.join(''), 'ascii', (error) => {
14834 if (error) {
14835 this.handleError(error, msg);
14836 }
14837 try {
14838 // Now write the content. This can be written in any encoding
14839 this.socket.write(json, this.encoding, (error) => {
14840 this.sending = false;
14841 if (error) {
14842 this.handleError(error, msg);
14843 }
14844 else {
14845 this.errorCount = 0;
14846 }
14847 if (this.queue.length > 0) {
14848 this.doWriteMessage(this.queue.shift());
14849 }
14850 });
14851 }
14852 catch (error) {
14853 this.handleError(error, msg);
14854 }
14855 });
14856 }
14857 catch (error) {
14858 this.handleError(error, msg);
14859 }
14860 }
14861 handleError(error, msg) {
14862 this.errorCount++;
14863 this.fireError(error, msg, this.errorCount);
14864 }
14865}
14866exports.SocketMessageWriter = SocketMessageWriter;
14867
14868
14869/***/ })
14870
14871/******/ })));
\No newline at end of file